using System;
using System.Data;
using System.Globalization;
using System.Resources;
using System.Threading;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
/****************************************************************************************************************************
* Project Name    : TimeCheck                                         Started Date  : 12-Aug-2007
* Module          : Shift Pattern                                     Last Modified : 10-Aug-2007
* Programmer      : Janakaraj.P
* Current Storage : \\Angler56\Projects\Inprogress\SCREEN1206\code\Time_AttendanceApp
* BackUp          :
****************************************************************************************************************************/
public partial class Masters_TA_UI_Master_ShiftPatternAdd : Base.BasePage
{
    #region VariableDeclaration
    ResourceManager rm;
    CultureInfo ci;
    string strflag = "";
    DataSet ds_Shift = new DataSet();
    int Count, intCompanyId;
    ShiftPatternEventData objShiftpattern = new ShiftPatternEventData();
    ShiftEvenData objShift = new ShiftEvenData();
    Cls_CheckUser objCheckUser = new Cls_CheckUser();
    DataSet ds_Checkuser = new DataSet();
    cls_Common objCommon = new cls_Common();
    string gstrUserGroupName = string.Empty;
    #endregion
    #region PageLoad
    protected override void Page_Load(object sender, EventArgs e)
    {
        // session checking
        base.Page_Load(sender, e);
        //get the culture info to set the language
        string source_Language;
        source_Language = Convert.ToString(Session["Session_ActiveLanguage"]);
        rm = new ResourceManager(source_Language, System.Reflection.Assembly.Load("App_GlobalResources"));
        ci = Thread.CurrentThread.CurrentCulture;
        site.SiteMapProvider = Convert.ToString(Session["SiteMapProvider"]);
        LoadStrings(ci);
        gstrUserGroupName = Convert.ToString(Session["UserGroupName"]);
        string strSetAlert = "";
        strSetAlert = strSetAlert + "<script language='javascript'>";
        strSetAlert = strSetAlert + "MaxLengthh('" + rm.GetString("Alert_MaximumLengthis", ci) + "');";
        strSetAlert = strSetAlert + "SetAlertMessages('" + rm.GetString("Alert_ClickGobuttontoGenerateDays") + "','" + rm.GetString("ReqField_SelectDay") + "','" + rm.GetString("Alert_ConfirmSave") + "','" + rm.GetString("Alert_Select_Company") + "','" + rm.GetString("PatternName_Enter") + "');";
        strSetAlert = strSetAlert + "</script>";
        Page.RegisterStartupScript("SetAlertMessages", strSetAlert);
        // set user rights
        UserRights();
        if (!Page.IsPostBack)
        {
            ddlCompany.Focus();
            CompanyBinding();
            objCommon.menu("ShiftMaster", "20");
        }
        GenerateHtmlTable();
    }
    #endregion
    #region UserDefinedFunctions
    //Getting Information from resource file and display it in label
    private void LoadStrings(CultureInfo ci)
    {
        lblCompany.Text = rm.GetString("EntranceMaster_Company", ci);
        lbl_IndicatesMandatoryFields.Text = rm.GetString("IndicatesMandatoryFields", ci);
        lbl_PatternName.Text = rm.GetString("ShiftPattern_PatternName", ci);
        lbl_NumberOfDays.Text = rm.GetString("ShiftPattern_NumberOfDays", ci);
        RequiredFieldValidator1.ErrorMessage = rm.GetString("PatternName_Enter", ci);
        RequiredFieldValidator3.ErrorMessage = rm.GetString("Alert_Select_Company", ci);
        RequiredFieldValidator2.ErrorMessage = rm.GetString("Validator_SelectNumberOfDays", ci);
        lbl_HeaderShiftPattern.Text = rm.GetString("Masters_ShiftPattern", ci);
        butSelect.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Go", ci);
        btn_Add.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Save", ci);
        btn_Cancel.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Back", ci);
        ddl_NoDays.Items[0].Text = rm.GetString("Select", ci);
        ddlCompany.Items[0].Text = rm.GetString("Select", ci);
    }
    private void UserRights()
    {
        ds_Checkuser = objCheckUser.checkRights(20, Convert.ToInt32(Session["userGroup_Id"]), "addPrv");
        if (ds_Checkuser.Tables[0].Rows.Count == 0)
        {
            Response.Redirect("MasterLandingPage.aspx");
        }
        else
        {
            //   
        }
    }
    private void CompanyBinding()
    {
        DataSet dsCompany = new DataSet();
        dsCompany = objShift.SelectCompanyWithApprovalSettings(gstrUserGroupName, Convert.ToString(Session["LevelRights"]), 0, "P");
        if (dsCompany != null)
        {
            if (dsCompany.Tables[0].Rows.Count > 0)
            {
                ddlCompany.DataSource = dsCompany;
                ddlCompany.DataTextField = "CompanyName";
                ddlCompany.DataValueField = "CompanyId";
                ddlCompany.DataBind();
            }
        }
        foreach (ListItem item in ddlCompany.Items)
        {
            item.Attributes.Add("title", item.Text);
        }
    }
    private void GenerateHtmlTable()
    {
        try
        {
            int numrows;
            int numcells;
            int i;
            int j;
            int count = 1;
            // Generate rows and cells
            numrows = Convert.ToInt16(ddl_NoDays.SelectedValue);
            if (numrows != 0)
            {
                Table1.Style.Add("border", "1px solid #c5dffc;");
            }
            if (numrows == 0)
            {
                Table1.Style.Add("height", "0px");
                Table1.Style.Add("border", "none");
            }
            else if (numrows == 1 || numrows == 2)
            {
                Table1.Style.Add("height", "80px");
            }
            else if (numrows == 3 || numrows == 4)
            {
                Table1.Style.Add("height", "120px");
            }
            else if (numrows == 5 || numrows == 6)
            {
                Table1.Style.Add("height", "160px");
            }
            else if (numrows == 7 || numrows == 8)
            {
                Table1.Style.Add("height", "200px");
            }
            else if (numrows == 9 || numrows == 10)
            {
                Table1.Style.Add("height", "210px");
            }
            else
            {
                Table1.Style.Add("height", "207px");
                Table1.Style.Add("border", "1px solid #c5dffc;");
            }
            numcells = 4;
            if (numrows >= 3)
                if ((numrows % 3) == 0)
                    numrows = numrows / 3;
                else
                    numrows = numrows + 1;
            else
                numrows = 1;
            //Generate Rows and Cols based on the selected value
            for (j = 1; j <= numrows; j++)
            {
                for (i = 1; i <= numcells; i++)
                {
                    if (count <= Convert.ToInt16(ddl_NoDays.SelectedValue))
                    {
                        HtmlGenericControl div = new HtmlGenericControl("div");
                        div.Attributes.Add("class", "col-md-2");
                        div.Style.Add("padding-top", "10px");
                        if (count < 10)
                        {
                            div.Controls.Add(new LiteralControl(rm.GetString("ShiftPattern_Day", ci) + " " + count));
                        }
                        else
                        {
                            div.Controls.Add(new LiteralControl(rm.GetString("ShiftPattern_Day", ci) + " " + count));
                        }
                        Table1.Controls.Add(div);
                        HtmlGenericControl div1 = new HtmlGenericControl("div");
                        div1.Attributes.Add("class", "col-md-3");
                        div1.Style.Add("padding-top", "10px");
                        div1.Style.Add("padding-left", "14px");
                        div1.Style.Add("padding-right", "14px");
                        DropDownList ddl_SPattern = new DropDownList();
                        ddl_SPattern.ID = "ddl_Pattern" + count;
                        ddl_SPattern.CssClass = "form-control select2";
                        ddl_SPattern.DataSource = FillDropDown();
                        ddl_SPattern.Attributes.Add("onchange", "CheckShift(this," + count + "," + Convert.ToInt16(ddl_NoDays.SelectedValue) + ");");
                        ddl_SPattern.DataTextField = "Shift_ShortName";
                        ddl_SPattern.DataValueField = "Shift_Id";
                        ddl_SPattern.DataBind();
                        ListItem liSelect = new ListItem();
                        liSelect.Text = rm.GetString("Select", ci);
                        liSelect.Value = "-Select-";
                        ddl_SPattern.Items.Insert(0, liSelect);
                        //ddl_SPattern.Items.Insert(0, "-Select-");
                        ListItem liOff = new ListItem();
                        liOff.Text = rm.GetString("lbl_Off", ci);
                        liOff.Value = "Off";
                        ddl_SPattern.Items.Insert(ddl_SPattern.Items.Count, liOff);
                        //ddl_SPattern.Items.Insert(ddl_SPattern.Items.Count, "Off");
                        foreach (ListItem item in ddl_SPattern.Items)
                        {
                            item.Attributes.Add("title", item.Text);
                        }
                        div1.Controls.Add(ddl_SPattern);
                        Table1.Controls.Add(div1);
                        Table1.Controls.Add(new LiteralControl("<div class='col-md-1'></div>"));
                        count = count + 1;
                        ddl_SPattern.Items[ddl_SPattern.Items.Count - 1].Value = "-1";
                    }
                }
            }
        }
        catch (Exception ex)
        {
            Response.Write(Convert.ToString(ex.Message));
        }
    }
    private DataSet FillDropDown()
    {
        //Fills the dropdowns with Shift Name        
        try
        {
            string usergroupname = string.Empty;
            //ds_Shift = objShiftpattern.SelectShift(usergroupname, Convert.ToString(Session["LevelRights"])); // previous one used jan-15-09  
            ds_Shift = objShiftpattern.SelectShiftForShiftPattern(Convert.ToInt32(ddlCompany.SelectedValue));
            foreach (DataRow drRow in ds_Shift.Tables[0].Rows)
            {
                switch (Convert.ToString(drRow["Shift_ShortName"]))
                {
                    case "No Shift":
                        drRow["Shift_ShortName"] = rm.GetString("Caption_NoShift", ci);
                        break;
                }
            }
        }
        catch
        {
            //
        }
        return ds_Shift;
    }
    private void InsertShiftPattern()
    {
        try
        {
            // 1- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 1)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"));
                    if (d1.SelectedItem.Text != "-Select")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), 0, 0, 0,
                                                             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Convert.ToInt32(Session["EmpAutoID"]));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "');", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
            // 2- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 2)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    DropDownList d2 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    d2 = (DropDownList)Table1.FindControl("ddl_Pattern2");
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"));
                    if (d1.SelectedItem.Text != "-Select-" && d2.SelectedItem.Text != "-Select-")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), Convert.ToInt16(d2.SelectedValue), 0, 0,
                                                              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Convert.ToInt32(Session["EmpAutoID"]));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "');", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
            // 3- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 3)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    DropDownList d2 = new DropDownList();
                    DropDownList d3 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    d2 = (DropDownList)Table1.FindControl("ddl_Pattern2");
                    d3 = (DropDownList)Table1.FindControl("ddl_Pattern3");
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"));
                    if (d1.SelectedItem.Text != "-Select-" && d2.SelectedItem.Text != "-Select-" && d3.SelectedItem.Text != "-Select-")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), Convert.ToInt16(d2.SelectedValue), Convert.ToInt16(d3.SelectedValue), 0,
                                                              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Convert.ToInt32(Session["EmpAutoID"]));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "');", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
            // 4- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 4)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    DropDownList d2 = new DropDownList();
                    DropDownList d3 = new DropDownList();
                    DropDownList d4 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    d2 = (DropDownList)Table1.FindControl("ddl_Pattern2");
                    d3 = (DropDownList)Table1.FindControl("ddl_Pattern3");
                    d4 = (DropDownList)Table1.FindControl("ddl_Pattern4");
                    string test = d2.SelectedItem.Text;
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"));
                    if (d1.SelectedItem.Text != "-Select-" && d2.SelectedItem.Text != "-Select-" && d3.SelectedItem.Text != "-Select-" && d4.SelectedItem.Text != "-Select-")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), Convert.ToInt16(d2.SelectedValue), Convert.ToInt16(d3.SelectedValue), Convert.ToInt16(d4.SelectedValue),
                                                              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Convert.ToInt32(Session["EmpAutoID"]));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "');", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
            // 5- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 5)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    DropDownList d2 = new DropDownList();
                    DropDownList d3 = new DropDownList();
                    DropDownList d4 = new DropDownList();
                    DropDownList d5 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    d2 = (DropDownList)Table1.FindControl("ddl_Pattern2");
                    d3 = (DropDownList)Table1.FindControl("ddl_Pattern3");
                    d4 = (DropDownList)Table1.FindControl("ddl_Pattern4");
                    d5 = (DropDownList)Table1.FindControl("ddl_Pattern5");
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"));
                    if (d1.SelectedItem.Text != "-Select-" && d2.SelectedItem.Text != "-Select-" && d3.SelectedItem.Text != "-Select-" && d4.SelectedItem.Text != "-Select-" && d5.SelectedItem.Text != "-Select-")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), Convert.ToInt16(d2.SelectedValue), Convert.ToInt16(d3.SelectedValue), Convert.ToInt16(d4.SelectedValue),
                                                              Convert.ToInt16(d5.SelectedValue), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Convert.ToInt32(Session["EmpAutoID"]));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "');", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
            // 6- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 6)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    DropDownList d2 = new DropDownList();
                    DropDownList d3 = new DropDownList();
                    DropDownList d4 = new DropDownList();
                    DropDownList d5 = new DropDownList();
                    DropDownList d6 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    d2 = (DropDownList)Table1.FindControl("ddl_Pattern2");
                    d3 = (DropDownList)Table1.FindControl("ddl_Pattern3");
                    d4 = (DropDownList)Table1.FindControl("ddl_Pattern4");
                    d5 = (DropDownList)Table1.FindControl("ddl_Pattern5");
                    d6 = (DropDownList)Table1.FindControl("ddl_Pattern6");
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"));
                    if (d1.SelectedItem.Text != "-Select-" && d2.SelectedItem.Text != "-Select-" && d3.SelectedItem.Text != "-Select-" && d4.SelectedItem.Text != "-Select-" && d5.SelectedItem.Text != "-Select-" && d6.SelectedItem.Text != "-Select-")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), Convert.ToInt16(d2.SelectedValue), Convert.ToInt16(d3.SelectedValue), Convert.ToInt16(d4.SelectedValue),
                                                              Convert.ToInt16(d5.SelectedValue), Convert.ToInt16(d6.SelectedValue), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Convert.ToInt32(Session["EmpAutoID"]));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "');", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
            // 7- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 7)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    DropDownList d2 = new DropDownList();
                    DropDownList d3 = new DropDownList();
                    DropDownList d4 = new DropDownList();
                    DropDownList d5 = new DropDownList();
                    DropDownList d6 = new DropDownList();
                    DropDownList d7 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    d2 = (DropDownList)Table1.FindControl("ddl_Pattern2");
                    d3 = (DropDownList)Table1.FindControl("ddl_Pattern3");
                    d4 = (DropDownList)Table1.FindControl("ddl_Pattern4");
                    d5 = (DropDownList)Table1.FindControl("ddl_Pattern5");
                    d6 = (DropDownList)Table1.FindControl("ddl_Pattern6");
                    d7 = (DropDownList)Table1.FindControl("ddl_Pattern7");
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"));
                    if (d1.SelectedItem.Text != "-Select-" && d2.SelectedItem.Text != "-Select-" && d3.SelectedItem.Text != "-Select-" && d4.SelectedItem.Text != "-Select-" && d5.SelectedItem.Text != "-Select-" && d6.SelectedItem.Text != "-Select-" && d7.SelectedItem.Text != "-Select-")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), Convert.ToInt16(d2.SelectedValue), Convert.ToInt16(d3.SelectedValue), Convert.ToInt16(d4.SelectedValue),
                                                              Convert.ToInt16(d5.SelectedValue), Convert.ToInt16(d6.SelectedValue), Convert.ToInt16(d7.SelectedValue), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Convert.ToInt32(Session["EmpAutoID"]));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "');", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
            // 8- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 8)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    DropDownList d2 = new DropDownList();
                    DropDownList d3 = new DropDownList();
                    DropDownList d4 = new DropDownList();
                    DropDownList d5 = new DropDownList();
                    DropDownList d6 = new DropDownList();
                    DropDownList d7 = new DropDownList();
                    DropDownList d8 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    d2 = (DropDownList)Table1.FindControl("ddl_Pattern2");
                    d3 = (DropDownList)Table1.FindControl("ddl_Pattern3");
                    d4 = (DropDownList)Table1.FindControl("ddl_Pattern4");
                    d5 = (DropDownList)Table1.FindControl("ddl_Pattern5");
                    d6 = (DropDownList)Table1.FindControl("ddl_Pattern6");
                    d7 = (DropDownList)Table1.FindControl("ddl_Pattern7");
                    d8 = (DropDownList)Table1.FindControl("ddl_Pattern8");
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim());
                    if (d1.SelectedItem.Text != "-Select-" && d2.SelectedItem.Text != "-Select-" && d3.SelectedItem.Text != "-Select-" && d4.SelectedItem.Text != "-Select-" && d5.SelectedItem.Text != "-Select-" && d6.SelectedItem.Text != "-Select-" && d7.SelectedItem.Text != "-Select-" && d8.SelectedItem.Text != "-Select-")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), Convert.ToInt16(d2.SelectedValue), Convert.ToInt16(d3.SelectedValue), Convert.ToInt16(d4.SelectedValue),
                                                              Convert.ToInt16(d5.SelectedValue), Convert.ToInt16(d6.SelectedValue), Convert.ToInt16(d7.SelectedValue), Convert.ToInt16(d8.SelectedValue), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Convert.ToInt32(Session["EmpAutoID"]));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "');", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
            // 9- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 9)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    DropDownList d2 = new DropDownList();
                    DropDownList d3 = new DropDownList();
                    DropDownList d4 = new DropDownList();
                    DropDownList d5 = new DropDownList();
                    DropDownList d6 = new DropDownList();
                    DropDownList d7 = new DropDownList();
                    DropDownList d8 = new DropDownList();
                    DropDownList d9 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    d2 = (DropDownList)Table1.FindControl("ddl_Pattern2");
                    d3 = (DropDownList)Table1.FindControl("ddl_Pattern3");
                    d4 = (DropDownList)Table1.FindControl("ddl_Pattern4");
                    d5 = (DropDownList)Table1.FindControl("ddl_Pattern5");
                    d6 = (DropDownList)Table1.FindControl("ddl_Pattern6");
                    d7 = (DropDownList)Table1.FindControl("ddl_Pattern7");
                    d8 = (DropDownList)Table1.FindControl("ddl_Pattern8");
                    d9 = (DropDownList)Table1.FindControl("ddl_Pattern9");
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"));
                    if (d1.SelectedItem.Text != "-Select-" && d2.SelectedItem.Text != "-Select-" && d3.SelectedItem.Text != "-Select-" && d4.SelectedItem.Text != "-Select-" && d5.SelectedItem.Text != "-Select-" && d6.SelectedItem.Text != "-Select-" && d7.SelectedItem.Text != "-Select-" && d8.SelectedItem.Text != "-Select-" && d9.SelectedItem.Text != "-Select")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), Convert.ToInt16(d2.SelectedValue), Convert.ToInt16(d3.SelectedValue), Convert.ToInt16(d4.SelectedValue),
                                                              Convert.ToInt16(d5.SelectedValue), Convert.ToInt16(d6.SelectedValue), Convert.ToInt16(d7.SelectedValue), Convert.ToInt16(d8.SelectedValue), Convert.ToInt16(d9.SelectedValue), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Convert.ToInt32(Session["EmpAutoID"]));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "');", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
            // 10- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 10)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    DropDownList d2 = new DropDownList();
                    DropDownList d3 = new DropDownList();
                    DropDownList d4 = new DropDownList();
                    DropDownList d5 = new DropDownList();
                    DropDownList d6 = new DropDownList();
                    DropDownList d7 = new DropDownList();
                    DropDownList d8 = new DropDownList();
                    DropDownList d9 = new DropDownList();
                    DropDownList d10 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    d2 = (DropDownList)Table1.FindControl("ddl_Pattern2");
                    d3 = (DropDownList)Table1.FindControl("ddl_Pattern3");
                    d4 = (DropDownList)Table1.FindControl("ddl_Pattern4");
                    d5 = (DropDownList)Table1.FindControl("ddl_Pattern5");
                    d6 = (DropDownList)Table1.FindControl("ddl_Pattern6");
                    d7 = (DropDownList)Table1.FindControl("ddl_Pattern7");
                    d8 = (DropDownList)Table1.FindControl("ddl_Pattern8");
                    d9 = (DropDownList)Table1.FindControl("ddl_Pattern9");
                    d10 = (DropDownList)Table1.FindControl("ddl_Pattern10");
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"));
                    if (d1.SelectedItem.Text != "-Select-" && d2.SelectedItem.Text != "-Select-" && d3.SelectedItem.Text != "-Select-" && d4.SelectedItem.Text != "-Select-" && d5.SelectedItem.Text != "-Select-" && d6.SelectedItem.Text != "-Select-" && d7.SelectedItem.Text != "-Select-" && d8.SelectedItem.Text != "-Select-" && d9.SelectedItem.Text != "-Select" && d10.SelectedItem.Text != "-Select-")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), Convert.ToInt16(d2.SelectedValue), Convert.ToInt16(d3.SelectedValue), Convert.ToInt16(d4.SelectedValue),
                                                              Convert.ToInt16(d5.SelectedValue), Convert.ToInt16(d6.SelectedValue), Convert.ToInt16(d7.SelectedValue), Convert.ToInt16(d8.SelectedValue), Convert.ToInt16(d9.SelectedValue),
                                                              Convert.ToInt16(d10.SelectedValue), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Convert.ToInt32(Session["EmpAutoID"]));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "');", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
            // 11- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 11)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    DropDownList d2 = new DropDownList();
                    DropDownList d3 = new DropDownList();
                    DropDownList d4 = new DropDownList();
                    DropDownList d5 = new DropDownList();
                    DropDownList d6 = new DropDownList();
                    DropDownList d7 = new DropDownList();
                    DropDownList d8 = new DropDownList();
                    DropDownList d9 = new DropDownList();
                    DropDownList d10 = new DropDownList();
                    DropDownList d11 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    d2 = (DropDownList)Table1.FindControl("ddl_Pattern2");
                    d3 = (DropDownList)Table1.FindControl("ddl_Pattern3");
                    d4 = (DropDownList)Table1.FindControl("ddl_Pattern4");
                    d5 = (DropDownList)Table1.FindControl("ddl_Pattern5");
                    d6 = (DropDownList)Table1.FindControl("ddl_Pattern6");
                    d7 = (DropDownList)Table1.FindControl("ddl_Pattern7");
                    d8 = (DropDownList)Table1.FindControl("ddl_Pattern8");
                    d9 = (DropDownList)Table1.FindControl("ddl_Pattern9");
                    d10 = (DropDownList)Table1.FindControl("ddl_Pattern10");
                    d11 = (DropDownList)Table1.FindControl("ddl_Pattern11");
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"));
                    if (d1.SelectedItem.Text != "-Select-" && d2.SelectedItem.Text != "-Select-" && d3.SelectedItem.Text != "-Select-" && d4.SelectedItem.Text != "-Select-" && d5.SelectedItem.Text != "-Select-" && d6.SelectedItem.Text != "-Select-" && d7.SelectedItem.Text != "-Select-" && d8.SelectedItem.Text != "-Select-" && d9.SelectedItem.Text != "-Select" && d10.SelectedItem.Text != "-Select-" && d11.SelectedItem.Text != "-Select")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), Convert.ToInt16(d2.SelectedValue), Convert.ToInt16(d3.SelectedValue), Convert.ToInt16(d4.SelectedValue),
                                                              Convert.ToInt16(d5.SelectedValue), Convert.ToInt16(d6.SelectedValue), Convert.ToInt16(d7.SelectedValue), Convert.ToInt16(d8.SelectedValue), Convert.ToInt16(d9.SelectedValue),
                                                              Convert.ToInt16(d10.SelectedValue), Convert.ToInt16(d11.SelectedValue), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Convert.ToInt32(Session["EmpAutoID"]));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "');", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
            // 12- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 12)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    DropDownList d2 = new DropDownList();
                    DropDownList d3 = new DropDownList();
                    DropDownList d4 = new DropDownList();
                    DropDownList d5 = new DropDownList();
                    DropDownList d6 = new DropDownList();
                    DropDownList d7 = new DropDownList();
                    DropDownList d8 = new DropDownList();
                    DropDownList d9 = new DropDownList();
                    DropDownList d10 = new DropDownList();
                    DropDownList d11 = new DropDownList();
                    DropDownList d12 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    d2 = (DropDownList)Table1.FindControl("ddl_Pattern2");
                    d3 = (DropDownList)Table1.FindControl("ddl_Pattern3");
                    d4 = (DropDownList)Table1.FindControl("ddl_Pattern4");
                    d5 = (DropDownList)Table1.FindControl("ddl_Pattern5");
                    d6 = (DropDownList)Table1.FindControl("ddl_Pattern6");
                    d7 = (DropDownList)Table1.FindControl("ddl_Pattern7");
                    d8 = (DropDownList)Table1.FindControl("ddl_Pattern8");
                    d9 = (DropDownList)Table1.FindControl("ddl_Pattern9");
                    d10 = (DropDownList)Table1.FindControl("ddl_Pattern10");
                    d11 = (DropDownList)Table1.FindControl("ddl_Pattern11");
                    d12 = (DropDownList)Table1.FindControl("ddl_Pattern12");
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"));
                    if (d1.SelectedItem.Text != "-Select-" && d2.SelectedItem.Text != "-Select-" && d3.SelectedItem.Text != "-Select-" && d4.SelectedItem.Text != "-Select-" && d5.SelectedItem.Text != "-Select-" && d6.SelectedItem.Text != "-Select-" && d7.SelectedItem.Text != "-Select-" && d8.SelectedItem.Text != "-Select-" && d9.SelectedItem.Text != "-Select" && d10.SelectedItem.Text != "-Select-" && d11.SelectedItem.Text != "-Select" && d12.SelectedItem.Text != "-Select-")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), Convert.ToInt16(d2.SelectedValue), Convert.ToInt16(d3.SelectedValue), Convert.ToInt16(d4.SelectedValue),
                                                              Convert.ToInt16(d5.SelectedValue), Convert.ToInt16(d6.SelectedValue), Convert.ToInt16(d7.SelectedValue), Convert.ToInt16(d8.SelectedValue), Convert.ToInt16(d9.SelectedValue),
                                                              Convert.ToInt16(d10.SelectedValue), Convert.ToInt16(d11.SelectedValue), Convert.ToInt16(d12.SelectedValue), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Convert.ToInt32(Session["EmpAutoID"]));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "');", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
            // 13- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 13)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    DropDownList d2 = new DropDownList();
                    DropDownList d3 = new DropDownList();
                    DropDownList d4 = new DropDownList();
                    DropDownList d5 = new DropDownList();
                    DropDownList d6 = new DropDownList();
                    DropDownList d7 = new DropDownList();
                    DropDownList d8 = new DropDownList();
                    DropDownList d9 = new DropDownList();
                    DropDownList d10 = new DropDownList();
                    DropDownList d11 = new DropDownList();
                    DropDownList d12 = new DropDownList();
                    DropDownList d13 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    d2 = (DropDownList)Table1.FindControl("ddl_Pattern2");
                    d3 = (DropDownList)Table1.FindControl("ddl_Pattern3");
                    d4 = (DropDownList)Table1.FindControl("ddl_Pattern4");
                    d5 = (DropDownList)Table1.FindControl("ddl_Pattern5");
                    d6 = (DropDownList)Table1.FindControl("ddl_Pattern6");
                    d7 = (DropDownList)Table1.FindControl("ddl_Pattern7");
                    d8 = (DropDownList)Table1.FindControl("ddl_Pattern8");
                    d9 = (DropDownList)Table1.FindControl("ddl_Pattern9");
                    d10 = (DropDownList)Table1.FindControl("ddl_Pattern10");
                    d11 = (DropDownList)Table1.FindControl("ddl_Pattern11");
                    d12 = (DropDownList)Table1.FindControl("ddl_Pattern12");
                    d13 = (DropDownList)Table1.FindControl("ddl_Pattern13");
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"));
                    if (d1.SelectedItem.Text != "-Select-" && d2.SelectedItem.Text != "-Select-" && d3.SelectedItem.Text != "-Select-" && d4.SelectedItem.Text != "-Select-" && d5.SelectedItem.Text != "-Select-" && d6.SelectedItem.Text != "-Select-" && d7.SelectedItem.Text != "-Select-" && d8.SelectedItem.Text != "-Select-" && d9.SelectedItem.Text != "-Select" && d10.SelectedItem.Text != "-Select-" && d11.SelectedItem.Text != "-Select" && d12.SelectedItem.Text != "-Select-" && d13.SelectedItem.Text != "-Select-")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), Convert.ToInt16(d2.SelectedValue), Convert.ToInt16(d3.SelectedValue), Convert.ToInt16(d4.SelectedValue),
                                                              Convert.ToInt16(d5.SelectedValue), Convert.ToInt16(d6.SelectedValue), Convert.ToInt16(d7.SelectedValue), Convert.ToInt16(d8.SelectedValue), Convert.ToInt16(d9.SelectedValue),
                                                              Convert.ToInt16(d10.SelectedValue), Convert.ToInt16(d11.SelectedValue), Convert.ToInt16(d12.SelectedValue), Convert.ToInt16(d13.SelectedValue), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Convert.ToInt32(Session["EmpAutoID"]));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "');", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
            // 14- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 14)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    DropDownList d2 = new DropDownList();
                    DropDownList d3 = new DropDownList();
                    DropDownList d4 = new DropDownList();
                    DropDownList d5 = new DropDownList();
                    DropDownList d6 = new DropDownList();
                    DropDownList d7 = new DropDownList();
                    DropDownList d8 = new DropDownList();
                    DropDownList d9 = new DropDownList();
                    DropDownList d10 = new DropDownList();
                    DropDownList d11 = new DropDownList();
                    DropDownList d12 = new DropDownList();
                    DropDownList d13 = new DropDownList();
                    DropDownList d14 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    d2 = (DropDownList)Table1.FindControl("ddl_Pattern2");
                    d3 = (DropDownList)Table1.FindControl("ddl_Pattern3");
                    d4 = (DropDownList)Table1.FindControl("ddl_Pattern4");
                    d5 = (DropDownList)Table1.FindControl("ddl_Pattern5");
                    d6 = (DropDownList)Table1.FindControl("ddl_Pattern6");
                    d7 = (DropDownList)Table1.FindControl("ddl_Pattern7");
                    d8 = (DropDownList)Table1.FindControl("ddl_Pattern8");
                    d9 = (DropDownList)Table1.FindControl("ddl_Pattern9");
                    d10 = (DropDownList)Table1.FindControl("ddl_Pattern10");
                    d11 = (DropDownList)Table1.FindControl("ddl_Pattern11");
                    d12 = (DropDownList)Table1.FindControl("ddl_Pattern12");
                    d13 = (DropDownList)Table1.FindControl("ddl_Pattern13");
                    d14 = (DropDownList)Table1.FindControl("ddl_Pattern14");
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"));
                    if (d1.SelectedItem.Text != "-Select-" && d2.SelectedItem.Text != "-Select-" && d3.SelectedItem.Text != "-Select-" && d4.SelectedItem.Text != "-Select-" && d5.SelectedItem.Text != "-Select-" && d6.SelectedItem.Text != "-Select-" && d7.SelectedItem.Text != "-Select-" && d8.SelectedItem.Text != "-Select-" && d9.SelectedItem.Text != "-Select" && d10.SelectedItem.Text != "-Select-" && d11.SelectedItem.Text != "-Select" && d12.SelectedItem.Text != "-Select-" && d13.SelectedItem.Text != "-Select-" && d14.SelectedItem.Text != "-Select-")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), Convert.ToInt16(d2.SelectedValue), Convert.ToInt16(d3.SelectedValue), Convert.ToInt16(d4.SelectedValue),
                                                              Convert.ToInt16(d5.SelectedValue), Convert.ToInt16(d6.SelectedValue), Convert.ToInt16(d7.SelectedValue), Convert.ToInt16(d8.SelectedValue), Convert.ToInt16(d9.SelectedValue),
                                                              Convert.ToInt16(d10.SelectedValue), Convert.ToInt16(d11.SelectedValue), Convert.ToInt16(d12.SelectedValue), Convert.ToInt16(d13.SelectedValue), Convert.ToInt16(d14.SelectedValue),
                                                              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Convert.ToInt32(Session["EmpAutoID"]));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "');", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
            // 15- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 15)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    DropDownList d2 = new DropDownList();
                    DropDownList d3 = new DropDownList();
                    DropDownList d4 = new DropDownList();
                    DropDownList d5 = new DropDownList();
                    DropDownList d6 = new DropDownList();
                    DropDownList d7 = new DropDownList();
                    DropDownList d8 = new DropDownList();
                    DropDownList d9 = new DropDownList();
                    DropDownList d10 = new DropDownList();
                    DropDownList d11 = new DropDownList();
                    DropDownList d12 = new DropDownList();
                    DropDownList d13 = new DropDownList();
                    DropDownList d14 = new DropDownList();
                    DropDownList d15 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    d2 = (DropDownList)Table1.FindControl("ddl_Pattern2");
                    d3 = (DropDownList)Table1.FindControl("ddl_Pattern3");
                    d4 = (DropDownList)Table1.FindControl("ddl_Pattern4");
                    d5 = (DropDownList)Table1.FindControl("ddl_Pattern5");
                    d6 = (DropDownList)Table1.FindControl("ddl_Pattern6");
                    d7 = (DropDownList)Table1.FindControl("ddl_Pattern7");
                    d8 = (DropDownList)Table1.FindControl("ddl_Pattern8");
                    d9 = (DropDownList)Table1.FindControl("ddl_Pattern9");
                    d10 = (DropDownList)Table1.FindControl("ddl_Pattern10");
                    d11 = (DropDownList)Table1.FindControl("ddl_Pattern11");
                    d12 = (DropDownList)Table1.FindControl("ddl_Pattern12");
                    d13 = (DropDownList)Table1.FindControl("ddl_Pattern13");
                    d14 = (DropDownList)Table1.FindControl("ddl_Pattern14");
                    d15 = (DropDownList)Table1.FindControl("ddl_Pattern15");
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"));
                    if (d1.SelectedItem.Text != "-Select-" && d2.SelectedItem.Text != "-Select-" && d3.SelectedItem.Text != "-Select-" && d4.SelectedItem.Text != "-Select-" && d5.SelectedItem.Text != "-Select-" && d6.SelectedItem.Text != "-Select-" && d7.SelectedItem.Text != "-Select-" && d8.SelectedItem.Text != "-Select-" && d9.SelectedItem.Text != "-Select" && d10.SelectedItem.Text != "-Select-" && d11.SelectedItem.Text != "-Select" && d12.SelectedItem.Text != "-Select-" && d13.SelectedItem.Text != "-Select-" && d14.SelectedItem.Text != "-Select-" && d15.SelectedItem.Text != "-Select-")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), Convert.ToInt16(d2.SelectedValue), Convert.ToInt16(d3.SelectedValue), Convert.ToInt16(d4.SelectedValue),
                                                              Convert.ToInt16(d5.SelectedValue), Convert.ToInt16(d6.SelectedValue), Convert.ToInt16(d7.SelectedValue), Convert.ToInt16(d8.SelectedValue), Convert.ToInt16(d9.SelectedValue),
                                                              Convert.ToInt16(d10.SelectedValue), Convert.ToInt16(d11.SelectedValue), Convert.ToInt16(d12.SelectedValue), Convert.ToInt16(d13.SelectedValue), Convert.ToInt16(d14.SelectedValue),
                                                              Convert.ToInt16(d15.SelectedValue), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Convert.ToInt32(Session["EmpAutoID"]));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "');", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
            // 16- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 16)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    DropDownList d2 = new DropDownList();
                    DropDownList d3 = new DropDownList();
                    DropDownList d4 = new DropDownList();
                    DropDownList d5 = new DropDownList();
                    DropDownList d6 = new DropDownList();
                    DropDownList d7 = new DropDownList();
                    DropDownList d8 = new DropDownList();
                    DropDownList d9 = new DropDownList();
                    DropDownList d10 = new DropDownList();
                    DropDownList d11 = new DropDownList();
                    DropDownList d12 = new DropDownList();
                    DropDownList d13 = new DropDownList();
                    DropDownList d14 = new DropDownList();
                    DropDownList d15 = new DropDownList();
                    DropDownList d16 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    d2 = (DropDownList)Table1.FindControl("ddl_Pattern2");
                    d3 = (DropDownList)Table1.FindControl("ddl_Pattern3");
                    d4 = (DropDownList)Table1.FindControl("ddl_Pattern4");
                    d5 = (DropDownList)Table1.FindControl("ddl_Pattern5");
                    d6 = (DropDownList)Table1.FindControl("ddl_Pattern6");
                    d7 = (DropDownList)Table1.FindControl("ddl_Pattern7");
                    d8 = (DropDownList)Table1.FindControl("ddl_Pattern8");
                    d9 = (DropDownList)Table1.FindControl("ddl_Pattern9");
                    d10 = (DropDownList)Table1.FindControl("ddl_Pattern10");
                    d11 = (DropDownList)Table1.FindControl("ddl_Pattern11");
                    d12 = (DropDownList)Table1.FindControl("ddl_Pattern12");
                    d13 = (DropDownList)Table1.FindControl("ddl_Pattern13");
                    d14 = (DropDownList)Table1.FindControl("ddl_Pattern14");
                    d15 = (DropDownList)Table1.FindControl("ddl_Pattern15");
                    d16 = (DropDownList)Table1.FindControl("ddl_Pattern16");
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"));
                    if (d1.SelectedItem.Text != "-Select-" && d2.SelectedItem.Text != "-Select-" && d3.SelectedItem.Text != "-Select-" && d4.SelectedItem.Text != "-Select-" && d5.SelectedItem.Text != "-Select-" && d6.SelectedItem.Text != "-Select-" && d7.SelectedItem.Text != "-Select-" && d8.SelectedItem.Text != "-Select-" && d9.SelectedItem.Text != "-Select" && d10.SelectedItem.Text != "-Select-" && d11.SelectedItem.Text != "-Select" && d12.SelectedItem.Text != "-Select-" && d13.SelectedItem.Text != "-Select-" && d14.SelectedItem.Text != "-Select-" && d15.SelectedItem.Text != "-Select-" && d16.SelectedItem.Text != "-Select-")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), Convert.ToInt16(d2.SelectedValue), Convert.ToInt16(d3.SelectedValue), Convert.ToInt16(d4.SelectedValue),
                                                              Convert.ToInt16(d5.SelectedValue), Convert.ToInt16(d6.SelectedValue), Convert.ToInt16(d7.SelectedValue), Convert.ToInt16(d8.SelectedValue), Convert.ToInt16(d9.SelectedValue),
                                                              Convert.ToInt16(d10.SelectedValue), Convert.ToInt16(d11.SelectedValue), Convert.ToInt16(d12.SelectedValue), Convert.ToInt16(d13.SelectedValue), Convert.ToInt16(d14.SelectedValue),
                                                              Convert.ToInt16(d15.SelectedValue), Convert.ToInt16(d16.SelectedValue), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Convert.ToInt32(Session["EmpAutoID"]));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "');", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
            // 17- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 17)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    DropDownList d2 = new DropDownList();
                    DropDownList d3 = new DropDownList();
                    DropDownList d4 = new DropDownList();
                    DropDownList d5 = new DropDownList();
                    DropDownList d6 = new DropDownList();
                    DropDownList d7 = new DropDownList();
                    DropDownList d8 = new DropDownList();
                    DropDownList d9 = new DropDownList();
                    DropDownList d10 = new DropDownList();
                    DropDownList d11 = new DropDownList();
                    DropDownList d12 = new DropDownList();
                    DropDownList d13 = new DropDownList();
                    DropDownList d14 = new DropDownList();
                    DropDownList d15 = new DropDownList();
                    DropDownList d16 = new DropDownList();
                    DropDownList d17 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    d2 = (DropDownList)Table1.FindControl("ddl_Pattern2");
                    d3 = (DropDownList)Table1.FindControl("ddl_Pattern3");
                    d4 = (DropDownList)Table1.FindControl("ddl_Pattern4");
                    d5 = (DropDownList)Table1.FindControl("ddl_Pattern5");
                    d6 = (DropDownList)Table1.FindControl("ddl_Pattern6");
                    d7 = (DropDownList)Table1.FindControl("ddl_Pattern7");
                    d8 = (DropDownList)Table1.FindControl("ddl_Pattern8");
                    d9 = (DropDownList)Table1.FindControl("ddl_Pattern9");
                    d10 = (DropDownList)Table1.FindControl("ddl_Pattern10");
                    d11 = (DropDownList)Table1.FindControl("ddl_Pattern11");
                    d12 = (DropDownList)Table1.FindControl("ddl_Pattern12");
                    d13 = (DropDownList)Table1.FindControl("ddl_Pattern13");
                    d14 = (DropDownList)Table1.FindControl("ddl_Pattern14");
                    d15 = (DropDownList)Table1.FindControl("ddl_Pattern15");
                    d16 = (DropDownList)Table1.FindControl("ddl_Pattern16");
                    d17 = (DropDownList)Table1.FindControl("ddl_Pattern17");
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"));
                    if (d1.SelectedItem.Text != "-Select-" && d2.SelectedItem.Text != "-Select-" && d3.SelectedItem.Text != "-Select-" && d4.SelectedItem.Text != "-Select-" && d5.SelectedItem.Text != "-Select-" && d6.SelectedItem.Text != "-Select-" && d7.SelectedItem.Text != "-Select-" && d8.SelectedItem.Text != "-Select-" && d9.SelectedItem.Text != "-Select" && d10.SelectedItem.Text != "-Select-" && d11.SelectedItem.Text != "-Select" && d12.SelectedItem.Text != "-Select-" && d13.SelectedItem.Text != "-Select-" && d14.SelectedItem.Text != "-Select-" && d15.SelectedItem.Text != "-Select-" && d16.SelectedItem.Text != "-Select-" && d17.SelectedItem.Text != "-Select-")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), Convert.ToInt16(d2.SelectedValue), Convert.ToInt16(d3.SelectedValue), Convert.ToInt16(d4.SelectedValue),
                                                              Convert.ToInt16(d5.SelectedValue), Convert.ToInt16(d6.SelectedValue), Convert.ToInt16(d7.SelectedValue), Convert.ToInt16(d8.SelectedValue), Convert.ToInt16(d9.SelectedValue),
                                                              Convert.ToInt16(d10.SelectedValue), Convert.ToInt16(d11.SelectedValue), Convert.ToInt16(d12.SelectedValue), Convert.ToInt16(d13.SelectedValue), Convert.ToInt16(d14.SelectedValue),
                                                              Convert.ToInt16(d15.SelectedValue), Convert.ToInt16(d16.SelectedValue), Convert.ToInt16(d17.SelectedValue), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Convert.ToInt32(Session["EmpAutoID"]));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "');", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
            // 18- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 18)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    DropDownList d2 = new DropDownList();
                    DropDownList d3 = new DropDownList();
                    DropDownList d4 = new DropDownList();
                    DropDownList d5 = new DropDownList();
                    DropDownList d6 = new DropDownList();
                    DropDownList d7 = new DropDownList();
                    DropDownList d8 = new DropDownList();
                    DropDownList d9 = new DropDownList();
                    DropDownList d10 = new DropDownList();
                    DropDownList d11 = new DropDownList();
                    DropDownList d12 = new DropDownList();
                    DropDownList d13 = new DropDownList();
                    DropDownList d14 = new DropDownList();
                    DropDownList d15 = new DropDownList();
                    DropDownList d16 = new DropDownList();
                    DropDownList d17 = new DropDownList();
                    DropDownList d18 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    d2 = (DropDownList)Table1.FindControl("ddl_Pattern2");
                    d3 = (DropDownList)Table1.FindControl("ddl_Pattern3");
                    d4 = (DropDownList)Table1.FindControl("ddl_Pattern4");
                    d5 = (DropDownList)Table1.FindControl("ddl_Pattern5");
                    d6 = (DropDownList)Table1.FindControl("ddl_Pattern6");
                    d7 = (DropDownList)Table1.FindControl("ddl_Pattern7");
                    d8 = (DropDownList)Table1.FindControl("ddl_Pattern8");
                    d9 = (DropDownList)Table1.FindControl("ddl_Pattern9");
                    d10 = (DropDownList)Table1.FindControl("ddl_Pattern10");
                    d11 = (DropDownList)Table1.FindControl("ddl_Pattern11");
                    d12 = (DropDownList)Table1.FindControl("ddl_Pattern12");
                    d13 = (DropDownList)Table1.FindControl("ddl_Pattern13");
                    d14 = (DropDownList)Table1.FindControl("ddl_Pattern14");
                    d15 = (DropDownList)Table1.FindControl("ddl_Pattern15");
                    d16 = (DropDownList)Table1.FindControl("ddl_Pattern16");
                    d17 = (DropDownList)Table1.FindControl("ddl_Pattern17");
                    d18 = (DropDownList)Table1.FindControl("ddl_Pattern18");
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"));
                    if (d1.SelectedItem.Text != "-Select-" && d2.SelectedItem.Text != "-Select-" && d3.SelectedItem.Text != "-Select-" && d4.SelectedItem.Text != "-Select-" && d5.SelectedItem.Text != "-Select-" && d6.SelectedItem.Text != "-Select-" && d7.SelectedItem.Text != "-Select-" && d8.SelectedItem.Text != "-Select-" && d9.SelectedItem.Text != "-Select" && d10.SelectedItem.Text != "-Select-" && d11.SelectedItem.Text != "-Select" && d12.SelectedItem.Text != "-Select-" && d13.SelectedItem.Text != "-Select-" && d14.SelectedItem.Text != "-Select-" && d15.SelectedItem.Text != "-Select-" && d16.SelectedItem.Text != "-Select-" && d17.SelectedItem.Text != "-Select-" && d18.SelectedItem.Text != "-Select-")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), Convert.ToInt16(d2.SelectedValue), Convert.ToInt16(d3.SelectedValue), Convert.ToInt16(d4.SelectedValue),
                                                              Convert.ToInt16(d5.SelectedValue), Convert.ToInt16(d6.SelectedValue), Convert.ToInt16(d7.SelectedValue), Convert.ToInt16(d8.SelectedValue), Convert.ToInt16(d9.SelectedValue),
                                                              Convert.ToInt16(d10.SelectedValue), Convert.ToInt16(d11.SelectedValue), Convert.ToInt16(d12.SelectedValue), Convert.ToInt16(d13.SelectedValue), Convert.ToInt16(d14.SelectedValue),
                                                              Convert.ToInt16(d15.SelectedValue), Convert.ToInt16(d16.SelectedValue), Convert.ToInt16(d17.SelectedValue), Convert.ToInt16(d18.SelectedValue), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Convert.ToInt32(Session["EmpAutoID"]));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "');", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
            // 19- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 19)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    DropDownList d2 = new DropDownList();
                    DropDownList d3 = new DropDownList();
                    DropDownList d4 = new DropDownList();
                    DropDownList d5 = new DropDownList();
                    DropDownList d6 = new DropDownList();
                    DropDownList d7 = new DropDownList();
                    DropDownList d8 = new DropDownList();
                    DropDownList d9 = new DropDownList();
                    DropDownList d10 = new DropDownList();
                    DropDownList d11 = new DropDownList();
                    DropDownList d12 = new DropDownList();
                    DropDownList d13 = new DropDownList();
                    DropDownList d14 = new DropDownList();
                    DropDownList d15 = new DropDownList();
                    DropDownList d16 = new DropDownList();
                    DropDownList d17 = new DropDownList();
                    DropDownList d18 = new DropDownList();
                    DropDownList d19 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    d2 = (DropDownList)Table1.FindControl("ddl_Pattern2");
                    d3 = (DropDownList)Table1.FindControl("ddl_Pattern3");
                    d4 = (DropDownList)Table1.FindControl("ddl_Pattern4");
                    d5 = (DropDownList)Table1.FindControl("ddl_Pattern5");
                    d6 = (DropDownList)Table1.FindControl("ddl_Pattern6");
                    d7 = (DropDownList)Table1.FindControl("ddl_Pattern7");
                    d8 = (DropDownList)Table1.FindControl("ddl_Pattern8");
                    d9 = (DropDownList)Table1.FindControl("ddl_Pattern9");
                    d10 = (DropDownList)Table1.FindControl("ddl_Pattern10");
                    d11 = (DropDownList)Table1.FindControl("ddl_Pattern11");
                    d12 = (DropDownList)Table1.FindControl("ddl_Pattern12");
                    d13 = (DropDownList)Table1.FindControl("ddl_Pattern13");
                    d14 = (DropDownList)Table1.FindControl("ddl_Pattern14");
                    d15 = (DropDownList)Table1.FindControl("ddl_Pattern15");
                    d16 = (DropDownList)Table1.FindControl("ddl_Pattern16");
                    d17 = (DropDownList)Table1.FindControl("ddl_Pattern17");
                    d18 = (DropDownList)Table1.FindControl("ddl_Pattern18");
                    d19 = (DropDownList)Table1.FindControl("ddl_Pattern19");
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"));
                    if (d1.SelectedItem.Text != "-Select-" && d2.SelectedItem.Text != "-Select-" && d3.SelectedItem.Text != "-Select-" && d4.SelectedItem.Text != "-Select-" && d5.SelectedItem.Text != "-Select-" && d6.SelectedItem.Text != "-Select-" && d7.SelectedItem.Text != "-Select-" && d8.SelectedItem.Text != "-Select-" && d9.SelectedItem.Text != "-Select" && d10.SelectedItem.Text != "-Select-" && d11.SelectedItem.Text != "-Select" && d12.SelectedItem.Text != "-Select-" && d13.SelectedItem.Text != "-Select-" && d14.SelectedItem.Text != "-Select-" && d15.SelectedItem.Text != "-Select-" && d16.SelectedItem.Text != "-Select-" && d17.SelectedItem.Text != "-Select-" && d18.SelectedItem.Text != "-Select-" && d19.SelectedItem.Text != "-Select-")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), Convert.ToInt16(d2.SelectedValue), Convert.ToInt16(d3.SelectedValue), Convert.ToInt16(d4.SelectedValue),
                                                              Convert.ToInt16(d5.SelectedValue), Convert.ToInt16(d6.SelectedValue), Convert.ToInt16(d7.SelectedValue), Convert.ToInt16(d8.SelectedValue), Convert.ToInt16(d9.SelectedValue),
                                                              Convert.ToInt16(d10.SelectedValue), Convert.ToInt16(d11.SelectedValue), Convert.ToInt16(d12.SelectedValue), Convert.ToInt16(d13.SelectedValue), Convert.ToInt16(d14.SelectedValue),
                                                              Convert.ToInt16(d15.SelectedValue), Convert.ToInt16(d16.SelectedValue), Convert.ToInt16(d17.SelectedValue), Convert.ToInt16(d18.SelectedValue), Convert.ToInt16(d19.SelectedValue),
                                                              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Convert.ToInt32(Session["EmpAutoID"]));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "');", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
            //20- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 20)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    DropDownList d2 = new DropDownList();
                    DropDownList d3 = new DropDownList();
                    DropDownList d4 = new DropDownList();
                    DropDownList d5 = new DropDownList();
                    DropDownList d6 = new DropDownList();
                    DropDownList d7 = new DropDownList();
                    DropDownList d8 = new DropDownList();
                    DropDownList d9 = new DropDownList();
                    DropDownList d10 = new DropDownList();
                    DropDownList d11 = new DropDownList();
                    DropDownList d12 = new DropDownList();
                    DropDownList d13 = new DropDownList();
                    DropDownList d14 = new DropDownList();
                    DropDownList d15 = new DropDownList();
                    DropDownList d16 = new DropDownList();
                    DropDownList d17 = new DropDownList();
                    DropDownList d18 = new DropDownList();
                    DropDownList d19 = new DropDownList();
                    DropDownList d20 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    d2 = (DropDownList)Table1.FindControl("ddl_Pattern2");
                    d3 = (DropDownList)Table1.FindControl("ddl_Pattern3");
                    d4 = (DropDownList)Table1.FindControl("ddl_Pattern4");
                    d5 = (DropDownList)Table1.FindControl("ddl_Pattern5");
                    d6 = (DropDownList)Table1.FindControl("ddl_Pattern6");
                    d7 = (DropDownList)Table1.FindControl("ddl_Pattern7");
                    d8 = (DropDownList)Table1.FindControl("ddl_Pattern8");
                    d9 = (DropDownList)Table1.FindControl("ddl_Pattern9");
                    d10 = (DropDownList)Table1.FindControl("ddl_Pattern10");
                    d11 = (DropDownList)Table1.FindControl("ddl_Pattern11");
                    d12 = (DropDownList)Table1.FindControl("ddl_Pattern12");
                    d13 = (DropDownList)Table1.FindControl("ddl_Pattern13");
                    d14 = (DropDownList)Table1.FindControl("ddl_Pattern14");
                    d15 = (DropDownList)Table1.FindControl("ddl_Pattern15");
                    d16 = (DropDownList)Table1.FindControl("ddl_Pattern16");
                    d17 = (DropDownList)Table1.FindControl("ddl_Pattern17");
                    d18 = (DropDownList)Table1.FindControl("ddl_Pattern18");
                    d19 = (DropDownList)Table1.FindControl("ddl_Pattern19");
                    d20 = (DropDownList)Table1.FindControl("ddl_Pattern20");
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"));
                    if (d1.SelectedItem.Text != "-Select-" && d2.SelectedItem.Text != "-Select-" && d3.SelectedItem.Text != "-Select-" && d4.SelectedItem.Text != "-Select-" && d5.SelectedItem.Text != "-Select-" && d6.SelectedItem.Text != "-Select-" && d7.SelectedItem.Text != "-Select-" && d8.SelectedItem.Text != "-Select-" && d9.SelectedItem.Text != "-Select" && d10.SelectedItem.Text != "-Select-" && d11.SelectedItem.Text != "-Select" && d12.SelectedItem.Text != "-Select-" && d13.SelectedItem.Text != "-Select-" && d14.SelectedItem.Text != "-Select-" && d15.SelectedItem.Text != "-Select-" && d16.SelectedItem.Text != "-Select-" && d17.SelectedItem.Text != "-Select-" && d18.SelectedItem.Text != "-Select-" && d19.SelectedItem.Text != "-Select-" && d20.SelectedItem.Text != "-Select-")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), Convert.ToInt16(d2.SelectedValue), Convert.ToInt16(d3.SelectedValue), Convert.ToInt16(d4.SelectedValue),
                                                              Convert.ToInt16(d5.SelectedValue), Convert.ToInt16(d6.SelectedValue), Convert.ToInt16(d7.SelectedValue), Convert.ToInt16(d8.SelectedValue), Convert.ToInt16(d9.SelectedValue),
                                                              Convert.ToInt16(d10.SelectedValue), Convert.ToInt16(d11.SelectedValue), Convert.ToInt16(d12.SelectedValue), Convert.ToInt16(d13.SelectedValue), Convert.ToInt16(d14.SelectedValue),
                                                              Convert.ToInt16(d15.SelectedValue), Convert.ToInt16(d16.SelectedValue), Convert.ToInt16(d17.SelectedValue), Convert.ToInt16(d18.SelectedValue), Convert.ToInt16(d19.SelectedValue),
                                                              Convert.ToInt16(d20.SelectedValue), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Convert.ToInt32(Session["EmpAutoID"]));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "');", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
            //21- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 21)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    DropDownList d2 = new DropDownList();
                    DropDownList d3 = new DropDownList();
                    DropDownList d4 = new DropDownList();
                    DropDownList d5 = new DropDownList();
                    DropDownList d6 = new DropDownList();
                    DropDownList d7 = new DropDownList();
                    DropDownList d8 = new DropDownList();
                    DropDownList d9 = new DropDownList();
                    DropDownList d10 = new DropDownList();
                    DropDownList d11 = new DropDownList();
                    DropDownList d12 = new DropDownList();
                    DropDownList d13 = new DropDownList();
                    DropDownList d14 = new DropDownList();
                    DropDownList d15 = new DropDownList();
                    DropDownList d16 = new DropDownList();
                    DropDownList d17 = new DropDownList();
                    DropDownList d18 = new DropDownList();
                    DropDownList d19 = new DropDownList();
                    DropDownList d20 = new DropDownList();
                    DropDownList d21 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    d2 = (DropDownList)Table1.FindControl("ddl_Pattern2");
                    d3 = (DropDownList)Table1.FindControl("ddl_Pattern3");
                    d4 = (DropDownList)Table1.FindControl("ddl_Pattern4");
                    d5 = (DropDownList)Table1.FindControl("ddl_Pattern5");
                    d6 = (DropDownList)Table1.FindControl("ddl_Pattern6");
                    d7 = (DropDownList)Table1.FindControl("ddl_Pattern7");
                    d8 = (DropDownList)Table1.FindControl("ddl_Pattern8");
                    d9 = (DropDownList)Table1.FindControl("ddl_Pattern9");
                    d10 = (DropDownList)Table1.FindControl("ddl_Pattern10");
                    d11 = (DropDownList)Table1.FindControl("ddl_Pattern11");
                    d12 = (DropDownList)Table1.FindControl("ddl_Pattern12");
                    d13 = (DropDownList)Table1.FindControl("ddl_Pattern13");
                    d14 = (DropDownList)Table1.FindControl("ddl_Pattern14");
                    d15 = (DropDownList)Table1.FindControl("ddl_Pattern15");
                    d16 = (DropDownList)Table1.FindControl("ddl_Pattern16");
                    d17 = (DropDownList)Table1.FindControl("ddl_Pattern17");
                    d18 = (DropDownList)Table1.FindControl("ddl_Pattern18");
                    d19 = (DropDownList)Table1.FindControl("ddl_Pattern19");
                    d20 = (DropDownList)Table1.FindControl("ddl_Pattern20");
                    d21 = (DropDownList)Table1.FindControl("ddl_Pattern21");
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"));
                    if (d1.SelectedItem.Text != "-Select-" && d2.SelectedItem.Text != "-Select-" && d3.SelectedItem.Text != "-Select-" && d4.SelectedItem.Text != "-Select-" && d5.SelectedItem.Text != "-Select-" && d6.SelectedItem.Text != "-Select-" && d7.SelectedItem.Text != "-Select-" && d8.SelectedItem.Text != "-Select-" && d9.SelectedItem.Text != "-Select" && d10.SelectedItem.Text != "-Select-" && d11.SelectedItem.Text != "-Select" && d12.SelectedItem.Text != "-Select-" && d13.SelectedItem.Text != "-Select-" && d14.SelectedItem.Text != "-Select-" && d15.SelectedItem.Text != "-Select-" && d16.SelectedItem.Text != "-Select-" && d17.SelectedItem.Text != "-Select-" && d18.SelectedItem.Text != "-Select-" && d19.SelectedItem.Text != "-Select-" && d20.SelectedItem.Text != "-Select-" && d21.SelectedItem.Text != "-Select-")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), Convert.ToInt16(d2.SelectedValue), Convert.ToInt16(d3.SelectedValue), Convert.ToInt16(d4.SelectedValue),
                                                              Convert.ToInt16(d5.SelectedValue), Convert.ToInt16(d6.SelectedValue), Convert.ToInt16(d7.SelectedValue), Convert.ToInt16(d8.SelectedValue), Convert.ToInt16(d9.SelectedValue),
                                                              Convert.ToInt16(d10.SelectedValue), Convert.ToInt16(d11.SelectedValue), Convert.ToInt16(d12.SelectedValue), Convert.ToInt16(d13.SelectedValue), Convert.ToInt16(d14.SelectedValue),
                                                              Convert.ToInt16(d15.SelectedValue), Convert.ToInt16(d16.SelectedValue), Convert.ToInt16(d17.SelectedValue), Convert.ToInt16(d18.SelectedValue), Convert.ToInt16(d19.SelectedValue),
                                                              Convert.ToInt16(d20.SelectedValue), Convert.ToInt16(d21.SelectedValue), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Convert.ToInt32(Session["EmpAutoID"]));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "');", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
            //22- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 22)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    DropDownList d2 = new DropDownList();
                    DropDownList d3 = new DropDownList();
                    DropDownList d4 = new DropDownList();
                    DropDownList d5 = new DropDownList();
                    DropDownList d6 = new DropDownList();
                    DropDownList d7 = new DropDownList();
                    DropDownList d8 = new DropDownList();
                    DropDownList d9 = new DropDownList();
                    DropDownList d10 = new DropDownList();
                    DropDownList d11 = new DropDownList();
                    DropDownList d12 = new DropDownList();
                    DropDownList d13 = new DropDownList();
                    DropDownList d14 = new DropDownList();
                    DropDownList d15 = new DropDownList();
                    DropDownList d16 = new DropDownList();
                    DropDownList d17 = new DropDownList();
                    DropDownList d18 = new DropDownList();
                    DropDownList d19 = new DropDownList();
                    DropDownList d20 = new DropDownList();
                    DropDownList d21 = new DropDownList();
                    DropDownList d22 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    d2 = (DropDownList)Table1.FindControl("ddl_Pattern2");
                    d3 = (DropDownList)Table1.FindControl("ddl_Pattern3");
                    d4 = (DropDownList)Table1.FindControl("ddl_Pattern4");
                    d5 = (DropDownList)Table1.FindControl("ddl_Pattern5");
                    d6 = (DropDownList)Table1.FindControl("ddl_Pattern6");
                    d7 = (DropDownList)Table1.FindControl("ddl_Pattern7");
                    d8 = (DropDownList)Table1.FindControl("ddl_Pattern8");
                    d9 = (DropDownList)Table1.FindControl("ddl_Pattern9");
                    d10 = (DropDownList)Table1.FindControl("ddl_Pattern10");
                    d11 = (DropDownList)Table1.FindControl("ddl_Pattern11");
                    d12 = (DropDownList)Table1.FindControl("ddl_Pattern12");
                    d13 = (DropDownList)Table1.FindControl("ddl_Pattern13");
                    d14 = (DropDownList)Table1.FindControl("ddl_Pattern14");
                    d15 = (DropDownList)Table1.FindControl("ddl_Pattern15");
                    d16 = (DropDownList)Table1.FindControl("ddl_Pattern16");
                    d17 = (DropDownList)Table1.FindControl("ddl_Pattern17");
                    d18 = (DropDownList)Table1.FindControl("ddl_Pattern18");
                    d19 = (DropDownList)Table1.FindControl("ddl_Pattern19");
                    d20 = (DropDownList)Table1.FindControl("ddl_Pattern20");
                    d21 = (DropDownList)Table1.FindControl("ddl_Pattern21");
                    d22 = (DropDownList)Table1.FindControl("ddl_Pattern22");
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"));
                    if (d1.SelectedItem.Text != "-Select-" && d2.SelectedItem.Text != "-Select-" && d3.SelectedItem.Text != "-Select-" && d4.SelectedItem.Text != "-Select-" && d5.SelectedItem.Text != "-Select-" && d6.SelectedItem.Text != "-Select-" && d7.SelectedItem.Text != "-Select-" && d8.SelectedItem.Text != "-Select-" && d9.SelectedItem.Text != "-Select" && d10.SelectedItem.Text != "-Select-" && d11.SelectedItem.Text != "-Select" && d12.SelectedItem.Text != "-Select-" && d13.SelectedItem.Text != "-Select-" && d14.SelectedItem.Text != "-Select-" && d15.SelectedItem.Text != "-Select-" && d16.SelectedItem.Text != "-Select-" && d17.SelectedItem.Text != "-Select-" && d18.SelectedItem.Text != "-Select-" && d19.SelectedItem.Text != "-Select-" && d20.SelectedItem.Text != "-Select-" && d21.SelectedItem.Text != "-Select-" && d22.SelectedItem.Text != "-Select-")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), Convert.ToInt16(d2.SelectedValue), Convert.ToInt16(d3.SelectedValue), Convert.ToInt16(d4.SelectedValue),
                                                              Convert.ToInt16(d5.SelectedValue), Convert.ToInt16(d6.SelectedValue), Convert.ToInt16(d7.SelectedValue), Convert.ToInt16(d8.SelectedValue), Convert.ToInt16(d9.SelectedValue),
                                                              Convert.ToInt16(d10.SelectedValue), Convert.ToInt16(d11.SelectedValue), Convert.ToInt16(d12.SelectedValue), Convert.ToInt16(d13.SelectedValue), Convert.ToInt16(d14.SelectedValue),
                                                              Convert.ToInt16(d15.SelectedValue), Convert.ToInt16(d16.SelectedValue), Convert.ToInt16(d17.SelectedValue), Convert.ToInt16(d18.SelectedValue), Convert.ToInt16(d19.SelectedValue),
                                                              Convert.ToInt16(d20.SelectedValue), Convert.ToInt16(d21.SelectedValue), Convert.ToInt16(d22.SelectedValue), 0, 0, 0, 0, 0, 0, 0, 0, 0, Convert.ToInt32(Session["EmpAutoID"]));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "');", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
            //23- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 23)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    DropDownList d2 = new DropDownList();
                    DropDownList d3 = new DropDownList();
                    DropDownList d4 = new DropDownList();
                    DropDownList d5 = new DropDownList();
                    DropDownList d6 = new DropDownList();
                    DropDownList d7 = new DropDownList();
                    DropDownList d8 = new DropDownList();
                    DropDownList d9 = new DropDownList();
                    DropDownList d10 = new DropDownList();
                    DropDownList d11 = new DropDownList();
                    DropDownList d12 = new DropDownList();
                    DropDownList d13 = new DropDownList();
                    DropDownList d14 = new DropDownList();
                    DropDownList d15 = new DropDownList();
                    DropDownList d16 = new DropDownList();
                    DropDownList d17 = new DropDownList();
                    DropDownList d18 = new DropDownList();
                    DropDownList d19 = new DropDownList();
                    DropDownList d20 = new DropDownList();
                    DropDownList d21 = new DropDownList();
                    DropDownList d22 = new DropDownList();
                    DropDownList d23 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    d2 = (DropDownList)Table1.FindControl("ddl_Pattern2");
                    d3 = (DropDownList)Table1.FindControl("ddl_Pattern3");
                    d4 = (DropDownList)Table1.FindControl("ddl_Pattern4");
                    d5 = (DropDownList)Table1.FindControl("ddl_Pattern5");
                    d6 = (DropDownList)Table1.FindControl("ddl_Pattern6");
                    d7 = (DropDownList)Table1.FindControl("ddl_Pattern7");
                    d8 = (DropDownList)Table1.FindControl("ddl_Pattern8");
                    d9 = (DropDownList)Table1.FindControl("ddl_Pattern9");
                    d10 = (DropDownList)Table1.FindControl("ddl_Pattern10");
                    d11 = (DropDownList)Table1.FindControl("ddl_Pattern11");
                    d12 = (DropDownList)Table1.FindControl("ddl_Pattern12");
                    d13 = (DropDownList)Table1.FindControl("ddl_Pattern13");
                    d14 = (DropDownList)Table1.FindControl("ddl_Pattern14");
                    d15 = (DropDownList)Table1.FindControl("ddl_Pattern15");
                    d16 = (DropDownList)Table1.FindControl("ddl_Pattern16");
                    d17 = (DropDownList)Table1.FindControl("ddl_Pattern17");
                    d18 = (DropDownList)Table1.FindControl("ddl_Pattern18");
                    d19 = (DropDownList)Table1.FindControl("ddl_Pattern19");
                    d20 = (DropDownList)Table1.FindControl("ddl_Pattern20");
                    d21 = (DropDownList)Table1.FindControl("ddl_Pattern21");
                    d22 = (DropDownList)Table1.FindControl("ddl_Pattern22");
                    d23 = (DropDownList)Table1.FindControl("ddl_Pattern23");
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"));
                    if (d1.SelectedItem.Text != "-Select-" && d2.SelectedItem.Text != "-Select-" && d3.SelectedItem.Text != "-Select-" && d4.SelectedItem.Text != "-Select-" && d5.SelectedItem.Text != "-Select-" && d6.SelectedItem.Text != "-Select-" && d7.SelectedItem.Text != "-Select-" && d8.SelectedItem.Text != "-Select-" && d9.SelectedItem.Text != "-Select" && d10.SelectedItem.Text != "-Select-" && d11.SelectedItem.Text != "-Select" && d12.SelectedItem.Text != "-Select-" && d13.SelectedItem.Text != "-Select-" && d14.SelectedItem.Text != "-Select-" && d15.SelectedItem.Text != "-Select-" && d16.SelectedItem.Text != "-Select-" && d17.SelectedItem.Text != "-Select-" && d18.SelectedItem.Text != "-Select-" && d19.SelectedItem.Text != "-Select-" && d20.SelectedItem.Text != "-Select-" && d21.SelectedItem.Text != "-Select-" && d22.SelectedItem.Text != "-Select-" && d23.SelectedItem.Text != "-Select-")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), Convert.ToInt16(d2.SelectedValue), Convert.ToInt16(d3.SelectedValue), Convert.ToInt16(d4.SelectedValue),
                                                              Convert.ToInt16(d5.SelectedValue), Convert.ToInt16(d6.SelectedValue), Convert.ToInt16(d7.SelectedValue), Convert.ToInt16(d8.SelectedValue), Convert.ToInt16(d9.SelectedValue),
                                                              Convert.ToInt16(d10.SelectedValue), Convert.ToInt16(d11.SelectedValue), Convert.ToInt16(d12.SelectedValue), Convert.ToInt16(d13.SelectedValue), Convert.ToInt16(d14.SelectedValue),
                                                              Convert.ToInt16(d15.SelectedValue), Convert.ToInt16(d16.SelectedValue), Convert.ToInt16(d17.SelectedValue), Convert.ToInt16(d18.SelectedValue), Convert.ToInt16(d19.SelectedValue),
                                                              Convert.ToInt16(d20.SelectedValue), Convert.ToInt16(d21.SelectedValue), Convert.ToInt16(d22.SelectedValue), Convert.ToInt16(d23.SelectedValue), 0, 0, 0, 0, 0, 0, 0, 0, Convert.ToInt32(Session["EmpAutoID"]));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "');", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
            //24- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 24)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    DropDownList d2 = new DropDownList();
                    DropDownList d3 = new DropDownList();
                    DropDownList d4 = new DropDownList();
                    DropDownList d5 = new DropDownList();
                    DropDownList d6 = new DropDownList();
                    DropDownList d7 = new DropDownList();
                    DropDownList d8 = new DropDownList();
                    DropDownList d9 = new DropDownList();
                    DropDownList d10 = new DropDownList();
                    DropDownList d11 = new DropDownList();
                    DropDownList d12 = new DropDownList();
                    DropDownList d13 = new DropDownList();
                    DropDownList d14 = new DropDownList();
                    DropDownList d15 = new DropDownList();
                    DropDownList d16 = new DropDownList();
                    DropDownList d17 = new DropDownList();
                    DropDownList d18 = new DropDownList();
                    DropDownList d19 = new DropDownList();
                    DropDownList d20 = new DropDownList();
                    DropDownList d21 = new DropDownList();
                    DropDownList d22 = new DropDownList();
                    DropDownList d23 = new DropDownList();
                    DropDownList d24 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    d2 = (DropDownList)Table1.FindControl("ddl_Pattern2");
                    d3 = (DropDownList)Table1.FindControl("ddl_Pattern3");
                    d4 = (DropDownList)Table1.FindControl("ddl_Pattern4");
                    d5 = (DropDownList)Table1.FindControl("ddl_Pattern5");
                    d6 = (DropDownList)Table1.FindControl("ddl_Pattern6");
                    d7 = (DropDownList)Table1.FindControl("ddl_Pattern7");
                    d8 = (DropDownList)Table1.FindControl("ddl_Pattern8");
                    d9 = (DropDownList)Table1.FindControl("ddl_Pattern9");
                    d10 = (DropDownList)Table1.FindControl("ddl_Pattern10");
                    d11 = (DropDownList)Table1.FindControl("ddl_Pattern11");
                    d12 = (DropDownList)Table1.FindControl("ddl_Pattern12");
                    d13 = (DropDownList)Table1.FindControl("ddl_Pattern13");
                    d14 = (DropDownList)Table1.FindControl("ddl_Pattern14");
                    d15 = (DropDownList)Table1.FindControl("ddl_Pattern15");
                    d16 = (DropDownList)Table1.FindControl("ddl_Pattern16");
                    d17 = (DropDownList)Table1.FindControl("ddl_Pattern17");
                    d18 = (DropDownList)Table1.FindControl("ddl_Pattern18");
                    d19 = (DropDownList)Table1.FindControl("ddl_Pattern19");
                    d20 = (DropDownList)Table1.FindControl("ddl_Pattern20");
                    d21 = (DropDownList)Table1.FindControl("ddl_Pattern21");
                    d22 = (DropDownList)Table1.FindControl("ddl_Pattern22");
                    d23 = (DropDownList)Table1.FindControl("ddl_Pattern23");
                    d24 = (DropDownList)Table1.FindControl("ddl_Pattern24");
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"));
                    if (d1.SelectedItem.Text != "-Select-" && d2.SelectedItem.Text != "-Select-" && d3.SelectedItem.Text != "-Select-" && d4.SelectedItem.Text != "-Select-" && d5.SelectedItem.Text != "-Select-" && d6.SelectedItem.Text != "-Select-" && d7.SelectedItem.Text != "-Select-" && d8.SelectedItem.Text != "-Select-" && d9.SelectedItem.Text != "-Select" && d10.SelectedItem.Text != "-Select-" && d11.SelectedItem.Text != "-Select" && d12.SelectedItem.Text != "-Select-" && d13.SelectedItem.Text != "-Select-" && d14.SelectedItem.Text != "-Select-" && d15.SelectedItem.Text != "-Select-" && d16.SelectedItem.Text != "-Select-" && d17.SelectedItem.Text != "-Select-" && d18.SelectedItem.Text != "-Select-" && d19.SelectedItem.Text != "-Select-" && d20.SelectedItem.Text != "-Select-" && d21.SelectedItem.Text != "-Select-" && d22.SelectedItem.Text != "-Select-" && d23.SelectedItem.Text != "-Select-" && d24.SelectedItem.Text != "-Select-")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), Convert.ToInt16(d2.SelectedValue), Convert.ToInt16(d3.SelectedValue), Convert.ToInt16(d4.SelectedValue),
                                                              Convert.ToInt16(d5.SelectedValue), Convert.ToInt16(d6.SelectedValue), Convert.ToInt16(d7.SelectedValue), Convert.ToInt16(d8.SelectedValue), Convert.ToInt16(d9.SelectedValue),
                                                              Convert.ToInt16(d10.SelectedValue), Convert.ToInt16(d11.SelectedValue), Convert.ToInt16(d12.SelectedValue), Convert.ToInt16(d13.SelectedValue), Convert.ToInt16(d14.SelectedValue),
                                                              Convert.ToInt16(d15.SelectedValue), Convert.ToInt16(d16.SelectedValue), Convert.ToInt16(d17.SelectedValue), Convert.ToInt16(d18.SelectedValue), Convert.ToInt16(d19.SelectedValue),
                                                              Convert.ToInt16(d20.SelectedValue), Convert.ToInt16(d21.SelectedValue), Convert.ToInt16(d22.SelectedValue), Convert.ToInt16(d23.SelectedValue), Convert.ToInt16(d24.SelectedValue), 0, 0, 0, 0, 0, 0, 0, Convert.ToInt32(Session["EmpAutoID"]));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "');", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
            //25- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 25)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    DropDownList d2 = new DropDownList();
                    DropDownList d3 = new DropDownList();
                    DropDownList d4 = new DropDownList();
                    DropDownList d5 = new DropDownList();
                    DropDownList d6 = new DropDownList();
                    DropDownList d7 = new DropDownList();
                    DropDownList d8 = new DropDownList();
                    DropDownList d9 = new DropDownList();
                    DropDownList d10 = new DropDownList();
                    DropDownList d11 = new DropDownList();
                    DropDownList d12 = new DropDownList();
                    DropDownList d13 = new DropDownList();
                    DropDownList d14 = new DropDownList();
                    DropDownList d15 = new DropDownList();
                    DropDownList d16 = new DropDownList();
                    DropDownList d17 = new DropDownList();
                    DropDownList d18 = new DropDownList();
                    DropDownList d19 = new DropDownList();
                    DropDownList d20 = new DropDownList();
                    DropDownList d21 = new DropDownList();
                    DropDownList d22 = new DropDownList();
                    DropDownList d23 = new DropDownList();
                    DropDownList d24 = new DropDownList();
                    DropDownList d25 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    d2 = (DropDownList)Table1.FindControl("ddl_Pattern2");
                    d3 = (DropDownList)Table1.FindControl("ddl_Pattern3");
                    d4 = (DropDownList)Table1.FindControl("ddl_Pattern4");
                    d5 = (DropDownList)Table1.FindControl("ddl_Pattern5");
                    d6 = (DropDownList)Table1.FindControl("ddl_Pattern6");
                    d7 = (DropDownList)Table1.FindControl("ddl_Pattern7");
                    d8 = (DropDownList)Table1.FindControl("ddl_Pattern8");
                    d9 = (DropDownList)Table1.FindControl("ddl_Pattern9");
                    d10 = (DropDownList)Table1.FindControl("ddl_Pattern10");
                    d11 = (DropDownList)Table1.FindControl("ddl_Pattern11");
                    d12 = (DropDownList)Table1.FindControl("ddl_Pattern12");
                    d13 = (DropDownList)Table1.FindControl("ddl_Pattern13");
                    d14 = (DropDownList)Table1.FindControl("ddl_Pattern14");
                    d15 = (DropDownList)Table1.FindControl("ddl_Pattern15");
                    d16 = (DropDownList)Table1.FindControl("ddl_Pattern16");
                    d17 = (DropDownList)Table1.FindControl("ddl_Pattern17");
                    d18 = (DropDownList)Table1.FindControl("ddl_Pattern18");
                    d19 = (DropDownList)Table1.FindControl("ddl_Pattern19");
                    d20 = (DropDownList)Table1.FindControl("ddl_Pattern20");
                    d21 = (DropDownList)Table1.FindControl("ddl_Pattern21");
                    d22 = (DropDownList)Table1.FindControl("ddl_Pattern22");
                    d23 = (DropDownList)Table1.FindControl("ddl_Pattern23");
                    d24 = (DropDownList)Table1.FindControl("ddl_Pattern24");
                    d25 = (DropDownList)Table1.FindControl("ddl_Pattern25");
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"));
                    if (d1.SelectedItem.Text != "-Select-" && d2.SelectedItem.Text != "-Select-" && d3.SelectedItem.Text != "-Select-" && d4.SelectedItem.Text != "-Select-" && d5.SelectedItem.Text != "-Select-" && d6.SelectedItem.Text != "-Select-" && d7.SelectedItem.Text != "-Select-" && d8.SelectedItem.Text != "-Select-" && d9.SelectedItem.Text != "-Select" && d10.SelectedItem.Text != "-Select-" && d11.SelectedItem.Text != "-Select" && d12.SelectedItem.Text != "-Select-" && d13.SelectedItem.Text != "-Select-" && d14.SelectedItem.Text != "-Select-" && d15.SelectedItem.Text != "-Select-" && d16.SelectedItem.Text != "-Select-" && d17.SelectedItem.Text != "-Select-" && d18.SelectedItem.Text != "-Select-" && d19.SelectedItem.Text != "-Select-" && d20.SelectedItem.Text != "-Select-" && d21.SelectedItem.Text != "-Select-" && d22.SelectedItem.Text != "-Select-" && d23.SelectedItem.Text != "-Select-" && d24.SelectedItem.Text != "-Select-" && d25.SelectedItem.Text != "-Select-")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), Convert.ToInt16(d2.SelectedValue), Convert.ToInt16(d3.SelectedValue), Convert.ToInt16(d4.SelectedValue),
                                                              Convert.ToInt16(d5.SelectedValue), Convert.ToInt16(d6.SelectedValue), Convert.ToInt16(d7.SelectedValue), Convert.ToInt16(d8.SelectedValue), Convert.ToInt16(d9.SelectedValue),
                                                              Convert.ToInt16(d10.SelectedValue), Convert.ToInt16(d11.SelectedValue), Convert.ToInt16(d12.SelectedValue), Convert.ToInt16(d13.SelectedValue), Convert.ToInt16(d14.SelectedValue),
                                                              Convert.ToInt16(d15.SelectedValue), Convert.ToInt16(d16.SelectedValue), Convert.ToInt16(d17.SelectedValue), Convert.ToInt16(d18.SelectedValue), Convert.ToInt16(d19.SelectedValue),
                                                              Convert.ToInt16(d20.SelectedValue), Convert.ToInt16(d21.SelectedValue), Convert.ToInt16(d22.SelectedValue), Convert.ToInt16(d23.SelectedValue), Convert.ToInt16(d24.SelectedValue),
                                                              Convert.ToInt16(d25.SelectedValue), 0, 0, 0, 0, 0, 0, Convert.ToInt32(Session["EmpAutoID"]));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "');", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
            //26- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 26)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    DropDownList d2 = new DropDownList();
                    DropDownList d3 = new DropDownList();
                    DropDownList d4 = new DropDownList();
                    DropDownList d5 = new DropDownList();
                    DropDownList d6 = new DropDownList();
                    DropDownList d7 = new DropDownList();
                    DropDownList d8 = new DropDownList();
                    DropDownList d9 = new DropDownList();
                    DropDownList d10 = new DropDownList();
                    DropDownList d11 = new DropDownList();
                    DropDownList d12 = new DropDownList();
                    DropDownList d13 = new DropDownList();
                    DropDownList d14 = new DropDownList();
                    DropDownList d15 = new DropDownList();
                    DropDownList d16 = new DropDownList();
                    DropDownList d17 = new DropDownList();
                    DropDownList d18 = new DropDownList();
                    DropDownList d19 = new DropDownList();
                    DropDownList d20 = new DropDownList();
                    DropDownList d21 = new DropDownList();
                    DropDownList d22 = new DropDownList();
                    DropDownList d23 = new DropDownList();
                    DropDownList d24 = new DropDownList();
                    DropDownList d25 = new DropDownList();
                    DropDownList d26 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    d2 = (DropDownList)Table1.FindControl("ddl_Pattern2");
                    d3 = (DropDownList)Table1.FindControl("ddl_Pattern3");
                    d4 = (DropDownList)Table1.FindControl("ddl_Pattern4");
                    d5 = (DropDownList)Table1.FindControl("ddl_Pattern5");
                    d6 = (DropDownList)Table1.FindControl("ddl_Pattern6");
                    d7 = (DropDownList)Table1.FindControl("ddl_Pattern7");
                    d8 = (DropDownList)Table1.FindControl("ddl_Pattern8");
                    d9 = (DropDownList)Table1.FindControl("ddl_Pattern9");
                    d10 = (DropDownList)Table1.FindControl("ddl_Pattern10");
                    d11 = (DropDownList)Table1.FindControl("ddl_Pattern11");
                    d12 = (DropDownList)Table1.FindControl("ddl_Pattern12");
                    d13 = (DropDownList)Table1.FindControl("ddl_Pattern13");
                    d14 = (DropDownList)Table1.FindControl("ddl_Pattern14");
                    d15 = (DropDownList)Table1.FindControl("ddl_Pattern15");
                    d16 = (DropDownList)Table1.FindControl("ddl_Pattern16");
                    d17 = (DropDownList)Table1.FindControl("ddl_Pattern17");
                    d18 = (DropDownList)Table1.FindControl("ddl_Pattern18");
                    d19 = (DropDownList)Table1.FindControl("ddl_Pattern19");
                    d20 = (DropDownList)Table1.FindControl("ddl_Pattern20");
                    d21 = (DropDownList)Table1.FindControl("ddl_Pattern21");
                    d22 = (DropDownList)Table1.FindControl("ddl_Pattern22");
                    d23 = (DropDownList)Table1.FindControl("ddl_Pattern23");
                    d24 = (DropDownList)Table1.FindControl("ddl_Pattern24");
                    d25 = (DropDownList)Table1.FindControl("ddl_Pattern25");
                    d26 = (DropDownList)Table1.FindControl("ddl_Pattern26");
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"));
                    if (d1.SelectedItem.Text != "-Select-" && d2.SelectedItem.Text != "-Select-" && d3.SelectedItem.Text != "-Select-" && d4.SelectedItem.Text != "-Select-" && d5.SelectedItem.Text != "-Select-" && d6.SelectedItem.Text != "-Select-" && d7.SelectedItem.Text != "-Select-" && d8.SelectedItem.Text != "-Select-" && d9.SelectedItem.Text != "-Select" && d10.SelectedItem.Text != "-Select-" && d11.SelectedItem.Text != "-Select" && d12.SelectedItem.Text != "-Select-" && d13.SelectedItem.Text != "-Select-" && d14.SelectedItem.Text != "-Select-" && d15.SelectedItem.Text != "-Select-" && d16.SelectedItem.Text != "-Select-" && d17.SelectedItem.Text != "-Select-" && d18.SelectedItem.Text != "-Select-" && d19.SelectedItem.Text != "-Select-" && d20.SelectedItem.Text != "-Select-" && d21.SelectedItem.Text != "-Select-" && d22.SelectedItem.Text != "-Select-" && d23.SelectedItem.Text != "-Select-" && d24.SelectedItem.Text != "-Select-" && d25.SelectedItem.Text != "-Select-" && d26.SelectedItem.Text != "-Select-")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), Convert.ToInt16(d2.SelectedValue), Convert.ToInt16(d3.SelectedValue), Convert.ToInt16(d4.SelectedValue),
                                                              Convert.ToInt16(d5.SelectedValue), Convert.ToInt16(d6.SelectedValue), Convert.ToInt16(d7.SelectedValue), Convert.ToInt16(d8.SelectedValue), Convert.ToInt16(d9.SelectedValue),
                                                              Convert.ToInt16(d10.SelectedValue), Convert.ToInt16(d11.SelectedValue), Convert.ToInt16(d12.SelectedValue), Convert.ToInt16(d13.SelectedValue), Convert.ToInt16(d14.SelectedValue),
                                                              Convert.ToInt16(d15.SelectedValue), Convert.ToInt16(d16.SelectedValue), Convert.ToInt16(d17.SelectedValue), Convert.ToInt16(d18.SelectedValue), Convert.ToInt16(d19.SelectedValue),
                                                              Convert.ToInt16(d20.SelectedValue), Convert.ToInt16(d21.SelectedValue), Convert.ToInt16(d22.SelectedValue), Convert.ToInt16(d23.SelectedValue), Convert.ToInt16(d24.SelectedValue),
                                                              Convert.ToInt16(d25.SelectedValue), Convert.ToInt16(d26.SelectedValue), 0, 0, 0, 0, 0, Convert.ToInt32(Session["EmpAutoID"]));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "');", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
            //27- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 27)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    DropDownList d2 = new DropDownList();
                    DropDownList d3 = new DropDownList();
                    DropDownList d4 = new DropDownList();
                    DropDownList d5 = new DropDownList();
                    DropDownList d6 = new DropDownList();
                    DropDownList d7 = new DropDownList();
                    DropDownList d8 = new DropDownList();
                    DropDownList d9 = new DropDownList();
                    DropDownList d10 = new DropDownList();
                    DropDownList d11 = new DropDownList();
                    DropDownList d12 = new DropDownList();
                    DropDownList d13 = new DropDownList();
                    DropDownList d14 = new DropDownList();
                    DropDownList d15 = new DropDownList();
                    DropDownList d16 = new DropDownList();
                    DropDownList d17 = new DropDownList();
                    DropDownList d18 = new DropDownList();
                    DropDownList d19 = new DropDownList();
                    DropDownList d20 = new DropDownList();
                    DropDownList d21 = new DropDownList();
                    DropDownList d22 = new DropDownList();
                    DropDownList d23 = new DropDownList();
                    DropDownList d24 = new DropDownList();
                    DropDownList d25 = new DropDownList();
                    DropDownList d26 = new DropDownList();
                    DropDownList d27 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    d2 = (DropDownList)Table1.FindControl("ddl_Pattern2");
                    d3 = (DropDownList)Table1.FindControl("ddl_Pattern3");
                    d4 = (DropDownList)Table1.FindControl("ddl_Pattern4");
                    d5 = (DropDownList)Table1.FindControl("ddl_Pattern5");
                    d6 = (DropDownList)Table1.FindControl("ddl_Pattern6");
                    d7 = (DropDownList)Table1.FindControl("ddl_Pattern7");
                    d8 = (DropDownList)Table1.FindControl("ddl_Pattern8");
                    d9 = (DropDownList)Table1.FindControl("ddl_Pattern9");
                    d10 = (DropDownList)Table1.FindControl("ddl_Pattern10");
                    d11 = (DropDownList)Table1.FindControl("ddl_Pattern11");
                    d12 = (DropDownList)Table1.FindControl("ddl_Pattern12");
                    d13 = (DropDownList)Table1.FindControl("ddl_Pattern13");
                    d14 = (DropDownList)Table1.FindControl("ddl_Pattern14");
                    d15 = (DropDownList)Table1.FindControl("ddl_Pattern15");
                    d16 = (DropDownList)Table1.FindControl("ddl_Pattern16");
                    d17 = (DropDownList)Table1.FindControl("ddl_Pattern17");
                    d18 = (DropDownList)Table1.FindControl("ddl_Pattern18");
                    d19 = (DropDownList)Table1.FindControl("ddl_Pattern19");
                    d20 = (DropDownList)Table1.FindControl("ddl_Pattern20");
                    d21 = (DropDownList)Table1.FindControl("ddl_Pattern21");
                    d22 = (DropDownList)Table1.FindControl("ddl_Pattern22");
                    d23 = (DropDownList)Table1.FindControl("ddl_Pattern23");
                    d24 = (DropDownList)Table1.FindControl("ddl_Pattern24");
                    d25 = (DropDownList)Table1.FindControl("ddl_Pattern25");
                    d26 = (DropDownList)Table1.FindControl("ddl_Pattern26");
                    d27 = (DropDownList)Table1.FindControl("ddl_Pattern27");
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"));
                    if (d1.SelectedItem.Text != "-Select-" && d2.SelectedItem.Text != "-Select-" && d3.SelectedItem.Text != "-Select-" && d4.SelectedItem.Text != "-Select-" && d5.SelectedItem.Text != "-Select-" && d6.SelectedItem.Text != "-Select-" && d7.SelectedItem.Text != "-Select-" && d8.SelectedItem.Text != "-Select-" && d9.SelectedItem.Text != "-Select" && d10.SelectedItem.Text != "-Select-" && d11.SelectedItem.Text != "-Select" && d12.SelectedItem.Text != "-Select-" && d13.SelectedItem.Text != "-Select-" && d14.SelectedItem.Text != "-Select-" && d15.SelectedItem.Text != "-Select-" && d16.SelectedItem.Text != "-Select-" && d17.SelectedItem.Text != "-Select-" && d18.SelectedItem.Text != "-Select-" && d19.SelectedItem.Text != "-Select-" && d20.SelectedItem.Text != "-Select-" && d21.SelectedItem.Text != "-Select-" && d22.SelectedItem.Text != "-Select-" && d23.SelectedItem.Text != "-Select-" && d24.SelectedItem.Text != "-Select-" && d25.SelectedItem.Text != "-Select-" && d26.SelectedItem.Text != "-Select-" && d27.SelectedItem.Text != "-Select-")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), Convert.ToInt16(d2.SelectedValue), Convert.ToInt16(d3.SelectedValue), Convert.ToInt16(d4.SelectedValue),
                                                              Convert.ToInt16(d5.SelectedValue), Convert.ToInt16(d6.SelectedValue), Convert.ToInt16(d7.SelectedValue), Convert.ToInt16(d8.SelectedValue), Convert.ToInt16(d9.SelectedValue),
                                                              Convert.ToInt16(d10.SelectedValue), Convert.ToInt16(d11.SelectedValue), Convert.ToInt16(d12.SelectedValue), Convert.ToInt16(d13.SelectedValue), Convert.ToInt16(d14.SelectedValue),
                                                              Convert.ToInt16(d15.SelectedValue), Convert.ToInt16(d16.SelectedValue), Convert.ToInt16(d17.SelectedValue), Convert.ToInt16(d18.SelectedValue), Convert.ToInt16(d19.SelectedValue),
                                                              Convert.ToInt16(d20.SelectedValue), Convert.ToInt16(d21.SelectedValue), Convert.ToInt16(d22.SelectedValue), Convert.ToInt16(d23.SelectedValue), Convert.ToInt16(d24.SelectedValue),
                                                              Convert.ToInt16(d25.SelectedValue), Convert.ToInt16(d26.SelectedValue), Convert.ToInt16(d27.SelectedValue), 0, 0, 0, 0, Convert.ToInt32(Session["EmpAutoID"]));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "');", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
            //28- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 28)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    DropDownList d2 = new DropDownList();
                    DropDownList d3 = new DropDownList();
                    DropDownList d4 = new DropDownList();
                    DropDownList d5 = new DropDownList();
                    DropDownList d6 = new DropDownList();
                    DropDownList d7 = new DropDownList();
                    DropDownList d8 = new DropDownList();
                    DropDownList d9 = new DropDownList();
                    DropDownList d10 = new DropDownList();
                    DropDownList d11 = new DropDownList();
                    DropDownList d12 = new DropDownList();
                    DropDownList d13 = new DropDownList();
                    DropDownList d14 = new DropDownList();
                    DropDownList d15 = new DropDownList();
                    DropDownList d16 = new DropDownList();
                    DropDownList d17 = new DropDownList();
                    DropDownList d18 = new DropDownList();
                    DropDownList d19 = new DropDownList();
                    DropDownList d20 = new DropDownList();
                    DropDownList d21 = new DropDownList();
                    DropDownList d22 = new DropDownList();
                    DropDownList d23 = new DropDownList();
                    DropDownList d24 = new DropDownList();
                    DropDownList d25 = new DropDownList();
                    DropDownList d26 = new DropDownList();
                    DropDownList d27 = new DropDownList();
                    DropDownList d28 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    d2 = (DropDownList)Table1.FindControl("ddl_Pattern2");
                    d3 = (DropDownList)Table1.FindControl("ddl_Pattern3");
                    d4 = (DropDownList)Table1.FindControl("ddl_Pattern4");
                    d5 = (DropDownList)Table1.FindControl("ddl_Pattern5");
                    d6 = (DropDownList)Table1.FindControl("ddl_Pattern6");
                    d7 = (DropDownList)Table1.FindControl("ddl_Pattern7");
                    d8 = (DropDownList)Table1.FindControl("ddl_Pattern8");
                    d9 = (DropDownList)Table1.FindControl("ddl_Pattern9");
                    d10 = (DropDownList)Table1.FindControl("ddl_Pattern10");
                    d11 = (DropDownList)Table1.FindControl("ddl_Pattern11");
                    d12 = (DropDownList)Table1.FindControl("ddl_Pattern12");
                    d13 = (DropDownList)Table1.FindControl("ddl_Pattern13");
                    d14 = (DropDownList)Table1.FindControl("ddl_Pattern14");
                    d15 = (DropDownList)Table1.FindControl("ddl_Pattern15");
                    d16 = (DropDownList)Table1.FindControl("ddl_Pattern16");
                    d17 = (DropDownList)Table1.FindControl("ddl_Pattern17");
                    d18 = (DropDownList)Table1.FindControl("ddl_Pattern18");
                    d19 = (DropDownList)Table1.FindControl("ddl_Pattern19");
                    d20 = (DropDownList)Table1.FindControl("ddl_Pattern20");
                    d21 = (DropDownList)Table1.FindControl("ddl_Pattern21");
                    d22 = (DropDownList)Table1.FindControl("ddl_Pattern22");
                    d23 = (DropDownList)Table1.FindControl("ddl_Pattern23");
                    d24 = (DropDownList)Table1.FindControl("ddl_Pattern24");
                    d25 = (DropDownList)Table1.FindControl("ddl_Pattern25");
                    d26 = (DropDownList)Table1.FindControl("ddl_Pattern26");
                    d27 = (DropDownList)Table1.FindControl("ddl_Pattern27");
                    d28 = (DropDownList)Table1.FindControl("ddl_Pattern28");
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"));
                    if (d1.SelectedItem.Text != "-Select-" && d2.SelectedItem.Text != "-Select-" && d3.SelectedItem.Text != "-Select-" && d4.SelectedItem.Text != "-Select-" && d5.SelectedItem.Text != "-Select-" && d6.SelectedItem.Text != "-Select-" && d7.SelectedItem.Text != "-Select-" && d8.SelectedItem.Text != "-Select-" && d9.SelectedItem.Text != "-Select" && d10.SelectedItem.Text != "-Select-" && d11.SelectedItem.Text != "-Select" && d12.SelectedItem.Text != "-Select-" && d13.SelectedItem.Text != "-Select-" && d14.SelectedItem.Text != "-Select-" && d15.SelectedItem.Text != "-Select-" && d16.SelectedItem.Text != "-Select-" && d17.SelectedItem.Text != "-Select-" && d18.SelectedItem.Text != "-Select-" && d19.SelectedItem.Text != "-Select-" && d20.SelectedItem.Text != "-Select-" && d21.SelectedItem.Text != "-Select-" && d22.SelectedItem.Text != "-Select-" && d23.SelectedItem.Text != "-Select-" && d24.SelectedItem.Text != "-Select-" && d25.SelectedItem.Text != "-Select-" && d26.SelectedItem.Text != "-Select-" && d27.SelectedItem.Text != "-Select-" && d28.SelectedItem.Text != "-Select-")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), Convert.ToInt16(d2.SelectedValue), Convert.ToInt16(d3.SelectedValue), Convert.ToInt16(d4.SelectedValue),
                                                              Convert.ToInt16(d5.SelectedValue), Convert.ToInt16(d6.SelectedValue), Convert.ToInt16(d7.SelectedValue), Convert.ToInt16(d8.SelectedValue), Convert.ToInt16(d9.SelectedValue),
                                                              Convert.ToInt16(d10.SelectedValue), Convert.ToInt16(d11.SelectedValue), Convert.ToInt16(d12.SelectedValue), Convert.ToInt16(d13.SelectedValue), Convert.ToInt16(d14.SelectedValue),
                                                              Convert.ToInt16(d15.SelectedValue), Convert.ToInt16(d16.SelectedValue), Convert.ToInt16(d17.SelectedValue), Convert.ToInt16(d18.SelectedValue), Convert.ToInt16(d19.SelectedValue),
                                                              Convert.ToInt16(d20.SelectedValue), Convert.ToInt16(d21.SelectedValue), Convert.ToInt16(d22.SelectedValue), Convert.ToInt16(d23.SelectedValue), Convert.ToInt16(d24.SelectedValue),
                                                              Convert.ToInt16(d25.SelectedValue), Convert.ToInt16(d26.SelectedValue), Convert.ToInt16(d27.SelectedValue), Convert.ToInt16(d28.SelectedValue), 0, 0, 0, Convert.ToInt32(Session["EmpAutoID"]));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "');", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
            //29- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 29)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    DropDownList d2 = new DropDownList();
                    DropDownList d3 = new DropDownList();
                    DropDownList d4 = new DropDownList();
                    DropDownList d5 = new DropDownList();
                    DropDownList d6 = new DropDownList();
                    DropDownList d7 = new DropDownList();
                    DropDownList d8 = new DropDownList();
                    DropDownList d9 = new DropDownList();
                    DropDownList d10 = new DropDownList();
                    DropDownList d11 = new DropDownList();
                    DropDownList d12 = new DropDownList();
                    DropDownList d13 = new DropDownList();
                    DropDownList d14 = new DropDownList();
                    DropDownList d15 = new DropDownList();
                    DropDownList d16 = new DropDownList();
                    DropDownList d17 = new DropDownList();
                    DropDownList d18 = new DropDownList();
                    DropDownList d19 = new DropDownList();
                    DropDownList d20 = new DropDownList();
                    DropDownList d21 = new DropDownList();
                    DropDownList d22 = new DropDownList();
                    DropDownList d23 = new DropDownList();
                    DropDownList d24 = new DropDownList();
                    DropDownList d25 = new DropDownList();
                    DropDownList d26 = new DropDownList();
                    DropDownList d27 = new DropDownList();
                    DropDownList d28 = new DropDownList();
                    DropDownList d29 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    d2 = (DropDownList)Table1.FindControl("ddl_Pattern2");
                    d3 = (DropDownList)Table1.FindControl("ddl_Pattern3");
                    d4 = (DropDownList)Table1.FindControl("ddl_Pattern4");
                    d5 = (DropDownList)Table1.FindControl("ddl_Pattern5");
                    d6 = (DropDownList)Table1.FindControl("ddl_Pattern6");
                    d7 = (DropDownList)Table1.FindControl("ddl_Pattern7");
                    d8 = (DropDownList)Table1.FindControl("ddl_Pattern8");
                    d9 = (DropDownList)Table1.FindControl("ddl_Pattern9");
                    d10 = (DropDownList)Table1.FindControl("ddl_Pattern10");
                    d11 = (DropDownList)Table1.FindControl("ddl_Pattern11");
                    d12 = (DropDownList)Table1.FindControl("ddl_Pattern12");
                    d13 = (DropDownList)Table1.FindControl("ddl_Pattern13");
                    d14 = (DropDownList)Table1.FindControl("ddl_Pattern14");
                    d15 = (DropDownList)Table1.FindControl("ddl_Pattern15");
                    d16 = (DropDownList)Table1.FindControl("ddl_Pattern16");
                    d17 = (DropDownList)Table1.FindControl("ddl_Pattern17");
                    d18 = (DropDownList)Table1.FindControl("ddl_Pattern18");
                    d19 = (DropDownList)Table1.FindControl("ddl_Pattern19");
                    d20 = (DropDownList)Table1.FindControl("ddl_Pattern20");
                    d21 = (DropDownList)Table1.FindControl("ddl_Pattern21");
                    d22 = (DropDownList)Table1.FindControl("ddl_Pattern22");
                    d23 = (DropDownList)Table1.FindControl("ddl_Pattern23");
                    d24 = (DropDownList)Table1.FindControl("ddl_Pattern24");
                    d25 = (DropDownList)Table1.FindControl("ddl_Pattern25");
                    d26 = (DropDownList)Table1.FindControl("ddl_Pattern26");
                    d27 = (DropDownList)Table1.FindControl("ddl_Pattern27");
                    d28 = (DropDownList)Table1.FindControl("ddl_Pattern28");
                    d29 = (DropDownList)Table1.FindControl("ddl_Pattern29");
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"));
                    if (d1.SelectedItem.Text != "-Select-" && d2.SelectedItem.Text != "-Select-" && d3.SelectedItem.Text != "-Select-" && d4.SelectedItem.Text != "-Select-" && d5.SelectedItem.Text != "-Select-" && d6.SelectedItem.Text != "-Select-" && d7.SelectedItem.Text != "-Select-" && d8.SelectedItem.Text != "-Select-" && d9.SelectedItem.Text != "-Select" && d10.SelectedItem.Text != "-Select-" && d11.SelectedItem.Text != "-Select" && d12.SelectedItem.Text != "-Select-" && d13.SelectedItem.Text != "-Select-" && d14.SelectedItem.Text != "-Select-" && d15.SelectedItem.Text != "-Select-" && d16.SelectedItem.Text != "-Select-" && d17.SelectedItem.Text != "-Select-" && d18.SelectedItem.Text != "-Select-" && d19.SelectedItem.Text != "-Select-" && d20.SelectedItem.Text != "-Select-" && d21.SelectedItem.Text != "-Select-" && d22.SelectedItem.Text != "-Select-" && d23.SelectedItem.Text != "-Select-" && d24.SelectedItem.Text != "-Select-" && d25.SelectedItem.Text != "-Select-" && d26.SelectedItem.Text != "-Select-" && d27.SelectedItem.Text != "-Select-" && d28.SelectedItem.Text != "-Select-" && d29.SelectedItem.Text != "-Select-")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), Convert.ToInt16(d2.SelectedValue), Convert.ToInt16(d3.SelectedValue), Convert.ToInt16(d4.SelectedValue),
                                                              Convert.ToInt16(d5.SelectedValue), Convert.ToInt16(d6.SelectedValue), Convert.ToInt16(d7.SelectedValue), Convert.ToInt16(d8.SelectedValue), Convert.ToInt16(d9.SelectedValue),
                                                              Convert.ToInt16(d10.SelectedValue), Convert.ToInt16(d11.SelectedValue), Convert.ToInt16(d12.SelectedValue), Convert.ToInt16(d13.SelectedValue), Convert.ToInt16(d14.SelectedValue),
                                                              Convert.ToInt16(d15.SelectedValue), Convert.ToInt16(d16.SelectedValue), Convert.ToInt16(d17.SelectedValue), Convert.ToInt16(d18.SelectedValue), Convert.ToInt16(d19.SelectedValue),
                                                              Convert.ToInt16(d20.SelectedValue), Convert.ToInt16(d21.SelectedValue), Convert.ToInt16(d22.SelectedValue), Convert.ToInt16(d23.SelectedValue), Convert.ToInt16(d24.SelectedValue),
                                                              Convert.ToInt16(d25.SelectedValue), Convert.ToInt16(d26.SelectedValue), Convert.ToInt16(d27.SelectedValue), Convert.ToInt16(d28.SelectedValue), Convert.ToInt16(d29.SelectedValue), 0, 0, Convert.ToInt32(Session["EmpAutoID"]));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "');", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
            //30- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 30)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    DropDownList d2 = new DropDownList();
                    DropDownList d3 = new DropDownList();
                    DropDownList d4 = new DropDownList();
                    DropDownList d5 = new DropDownList();
                    DropDownList d6 = new DropDownList();
                    DropDownList d7 = new DropDownList();
                    DropDownList d8 = new DropDownList();
                    DropDownList d9 = new DropDownList();
                    DropDownList d10 = new DropDownList();
                    DropDownList d11 = new DropDownList();
                    DropDownList d12 = new DropDownList();
                    DropDownList d13 = new DropDownList();
                    DropDownList d14 = new DropDownList();
                    DropDownList d15 = new DropDownList();
                    DropDownList d16 = new DropDownList();
                    DropDownList d17 = new DropDownList();
                    DropDownList d18 = new DropDownList();
                    DropDownList d19 = new DropDownList();
                    DropDownList d20 = new DropDownList();
                    DropDownList d21 = new DropDownList();
                    DropDownList d22 = new DropDownList();
                    DropDownList d23 = new DropDownList();
                    DropDownList d24 = new DropDownList();
                    DropDownList d25 = new DropDownList();
                    DropDownList d26 = new DropDownList();
                    DropDownList d27 = new DropDownList();
                    DropDownList d28 = new DropDownList();
                    DropDownList d29 = new DropDownList();
                    DropDownList d30 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    d2 = (DropDownList)Table1.FindControl("ddl_Pattern2");
                    d3 = (DropDownList)Table1.FindControl("ddl_Pattern3");
                    d4 = (DropDownList)Table1.FindControl("ddl_Pattern4");
                    d5 = (DropDownList)Table1.FindControl("ddl_Pattern5");
                    d6 = (DropDownList)Table1.FindControl("ddl_Pattern6");
                    d7 = (DropDownList)Table1.FindControl("ddl_Pattern7");
                    d8 = (DropDownList)Table1.FindControl("ddl_Pattern8");
                    d9 = (DropDownList)Table1.FindControl("ddl_Pattern9");
                    d10 = (DropDownList)Table1.FindControl("ddl_Pattern10");
                    d11 = (DropDownList)Table1.FindControl("ddl_Pattern11");
                    d12 = (DropDownList)Table1.FindControl("ddl_Pattern12");
                    d13 = (DropDownList)Table1.FindControl("ddl_Pattern13");
                    d14 = (DropDownList)Table1.FindControl("ddl_Pattern14");
                    d15 = (DropDownList)Table1.FindControl("ddl_Pattern15");
                    d16 = (DropDownList)Table1.FindControl("ddl_Pattern16");
                    d17 = (DropDownList)Table1.FindControl("ddl_Pattern17");
                    d18 = (DropDownList)Table1.FindControl("ddl_Pattern18");
                    d19 = (DropDownList)Table1.FindControl("ddl_Pattern19");
                    d20 = (DropDownList)Table1.FindControl("ddl_Pattern20");
                    d21 = (DropDownList)Table1.FindControl("ddl_Pattern21");
                    d22 = (DropDownList)Table1.FindControl("ddl_Pattern22");
                    d23 = (DropDownList)Table1.FindControl("ddl_Pattern23");
                    d24 = (DropDownList)Table1.FindControl("ddl_Pattern24");
                    d25 = (DropDownList)Table1.FindControl("ddl_Pattern25");
                    d26 = (DropDownList)Table1.FindControl("ddl_Pattern26");
                    d27 = (DropDownList)Table1.FindControl("ddl_Pattern27");
                    d28 = (DropDownList)Table1.FindControl("ddl_Pattern28");
                    d29 = (DropDownList)Table1.FindControl("ddl_Pattern29");
                    d30 = (DropDownList)Table1.FindControl("ddl_Pattern30");
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"));
                    if (d1.SelectedItem.Text != "-Select-" && d2.SelectedItem.Text != "-Select-" && d3.SelectedItem.Text != "-Select-" && d4.SelectedItem.Text != "-Select-" && d5.SelectedItem.Text != "-Select-" && d6.SelectedItem.Text != "-Select-" && d7.SelectedItem.Text != "-Select-" && d8.SelectedItem.Text != "-Select-" && d9.SelectedItem.Text != "-Select" && d10.SelectedItem.Text != "-Select-" && d11.SelectedItem.Text != "-Select" && d12.SelectedItem.Text != "-Select-" && d13.SelectedItem.Text != "-Select-" && d14.SelectedItem.Text != "-Select-" && d15.SelectedItem.Text != "-Select-" && d16.SelectedItem.Text != "-Select-" && d17.SelectedItem.Text != "-Select-" && d18.SelectedItem.Text != "-Select-" && d19.SelectedItem.Text != "-Select-" && d20.SelectedItem.Text != "-Select-" && d21.SelectedItem.Text != "-Select-" && d22.SelectedItem.Text != "-Select-" && d23.SelectedItem.Text != "-Select-" && d24.SelectedItem.Text != "-Select-" && d25.SelectedItem.Text != "-Select-" && d26.SelectedItem.Text != "-Select-" && d27.SelectedItem.Text != "-Select-" && d28.SelectedItem.Text != "-Select-" && d29.SelectedItem.Text != "-Select-" && d30.SelectedItem.Text != "-Select-")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), Convert.ToInt16(d2.SelectedValue), Convert.ToInt16(d3.SelectedValue), Convert.ToInt16(d4.SelectedValue),
                                                              Convert.ToInt16(d5.SelectedValue), Convert.ToInt16(d6.SelectedValue), Convert.ToInt16(d7.SelectedValue), Convert.ToInt16(d8.SelectedValue), Convert.ToInt16(d9.SelectedValue),
                                                              Convert.ToInt16(d10.SelectedValue), Convert.ToInt16(d11.SelectedValue), Convert.ToInt16(d12.SelectedValue), Convert.ToInt16(d13.SelectedValue), Convert.ToInt16(d14.SelectedValue),
                                                              Convert.ToInt16(d15.SelectedValue), Convert.ToInt16(d16.SelectedValue), Convert.ToInt16(d17.SelectedValue), Convert.ToInt16(d18.SelectedValue), Convert.ToInt16(d19.SelectedValue),
                                                              Convert.ToInt16(d20.SelectedValue), Convert.ToInt16(d21.SelectedValue), Convert.ToInt16(d22.SelectedValue), Convert.ToInt16(d23.SelectedValue), Convert.ToInt16(d24.SelectedValue),
                                                              Convert.ToInt16(d25.SelectedValue), Convert.ToInt16(d26.SelectedValue), Convert.ToInt16(d27.SelectedValue), Convert.ToInt16(d28.SelectedValue), Convert.ToInt16(d29.SelectedValue),
                                                              Convert.ToInt16(d30.SelectedValue), 0, Convert.ToInt32(Session["EmpAutoID"]));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "');", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
            //31- day pattern
            if (Convert.ToInt16(ddl_NoDays.SelectedValue) == 31)
            {
                try
                {
                    DropDownList d1 = new DropDownList();
                    DropDownList d2 = new DropDownList();
                    DropDownList d3 = new DropDownList();
                    DropDownList d4 = new DropDownList();
                    DropDownList d5 = new DropDownList();
                    DropDownList d6 = new DropDownList();
                    DropDownList d7 = new DropDownList();
                    DropDownList d8 = new DropDownList();
                    DropDownList d9 = new DropDownList();
                    DropDownList d10 = new DropDownList();
                    DropDownList d11 = new DropDownList();
                    DropDownList d12 = new DropDownList();
                    DropDownList d13 = new DropDownList();
                    DropDownList d14 = new DropDownList();
                    DropDownList d15 = new DropDownList();
                    DropDownList d16 = new DropDownList();
                    DropDownList d17 = new DropDownList();
                    DropDownList d18 = new DropDownList();
                    DropDownList d19 = new DropDownList();
                    DropDownList d20 = new DropDownList();
                    DropDownList d21 = new DropDownList();
                    DropDownList d22 = new DropDownList();
                    DropDownList d23 = new DropDownList();
                    DropDownList d24 = new DropDownList();
                    DropDownList d25 = new DropDownList();
                    DropDownList d26 = new DropDownList();
                    DropDownList d27 = new DropDownList();
                    DropDownList d28 = new DropDownList();
                    DropDownList d29 = new DropDownList();
                    DropDownList d30 = new DropDownList();
                    DropDownList d31 = new DropDownList();
                    d1 = (DropDownList)Table1.FindControl("ddl_Pattern1");
                    d2 = (DropDownList)Table1.FindControl("ddl_Pattern2");
                    d3 = (DropDownList)Table1.FindControl("ddl_Pattern3");
                    d4 = (DropDownList)Table1.FindControl("ddl_Pattern4");
                    d5 = (DropDownList)Table1.FindControl("ddl_Pattern5");
                    d6 = (DropDownList)Table1.FindControl("ddl_Pattern6");
                    d7 = (DropDownList)Table1.FindControl("ddl_Pattern7");
                    d8 = (DropDownList)Table1.FindControl("ddl_Pattern8");
                    d9 = (DropDownList)Table1.FindControl("ddl_Pattern9");
                    d10 = (DropDownList)Table1.FindControl("ddl_Pattern10");
                    d11 = (DropDownList)Table1.FindControl("ddl_Pattern11");
                    d12 = (DropDownList)Table1.FindControl("ddl_Pattern12");
                    d13 = (DropDownList)Table1.FindControl("ddl_Pattern13");
                    d14 = (DropDownList)Table1.FindControl("ddl_Pattern14");
                    d15 = (DropDownList)Table1.FindControl("ddl_Pattern15");
                    d16 = (DropDownList)Table1.FindControl("ddl_Pattern16");
                    d17 = (DropDownList)Table1.FindControl("ddl_Pattern17");
                    d18 = (DropDownList)Table1.FindControl("ddl_Pattern18");
                    d19 = (DropDownList)Table1.FindControl("ddl_Pattern19");
                    d20 = (DropDownList)Table1.FindControl("ddl_Pattern20");
                    d21 = (DropDownList)Table1.FindControl("ddl_Pattern21");
                    d22 = (DropDownList)Table1.FindControl("ddl_Pattern22");
                    d23 = (DropDownList)Table1.FindControl("ddl_Pattern23");
                    d24 = (DropDownList)Table1.FindControl("ddl_Pattern24");
                    d25 = (DropDownList)Table1.FindControl("ddl_Pattern25");
                    d26 = (DropDownList)Table1.FindControl("ddl_Pattern26");
                    d27 = (DropDownList)Table1.FindControl("ddl_Pattern27");
                    d28 = (DropDownList)Table1.FindControl("ddl_Pattern28");
                    d29 = (DropDownList)Table1.FindControl("ddl_Pattern29");
                    d30 = (DropDownList)Table1.FindControl("ddl_Pattern30");
                    d31 = (DropDownList)Table1.FindControl("ddl_Pattern31");
                    Count = objShiftpattern.CheckShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"));
                    if (d1.SelectedItem.Text != "-Select-" && d2.SelectedItem.Text != "-Select-" && d3.SelectedItem.Text != "-Select-" && d4.SelectedItem.Text != "-Select-" && d5.SelectedItem.Text != "-Select-" && d6.SelectedItem.Text != "-Select-" && d7.SelectedItem.Text != "-Select-" && d8.SelectedItem.Text != "-Select-" && d9.SelectedItem.Text != "-Select" && d10.SelectedItem.Text != "-Select-" && d11.SelectedItem.Text != "-Select" && d12.SelectedItem.Text != "-Select-" && d13.SelectedItem.Text != "-Select-" && d14.SelectedItem.Text != "-Select-" && d15.SelectedItem.Text != "-Select-" && d16.SelectedItem.Text != "-Select-" && d17.SelectedItem.Text != "-Select-" && d18.SelectedItem.Text != "-Select-" && d19.SelectedItem.Text != "-Select-" && d20.SelectedItem.Text != "-Select-" && d21.SelectedItem.Text != "-Select-" && d22.SelectedItem.Text != "-Select-" && d23.SelectedItem.Text != "-Select-" && d24.SelectedItem.Text != "-Select-" && d25.SelectedItem.Text != "-Select-" && d26.SelectedItem.Text != "-Select-" && d27.SelectedItem.Text != "-Select-" && d28.SelectedItem.Text != "-Select-" && d29.SelectedItem.Text != "-Select-" && d30.SelectedItem.Text != "-Select-" && d31.SelectedItem.Text != "-Select-")
                    {
                        if (Count == 0)
                        {
                            objShiftpattern.InserShiftPattern(intCompanyId, txt_PatternName.Text.Trim().Replace("'", "''"), Convert.ToInt16(ddl_NoDays.SelectedValue), Convert.ToInt16(d1.SelectedValue), Convert.ToInt16(d2.SelectedValue), Convert.ToInt16(d3.SelectedValue), Convert.ToInt16(d4.SelectedValue),
                                                              Convert.ToInt16(d5.SelectedValue), Convert.ToInt16(d6.SelectedValue), Convert.ToInt16(d7.SelectedValue), Convert.ToInt16(d8.SelectedValue), Convert.ToInt16(d9.SelectedValue),
                                                              Convert.ToInt16(d10.SelectedValue), Convert.ToInt16(d11.SelectedValue), Convert.ToInt16(d12.SelectedValue), Convert.ToInt16(d13.SelectedValue), Convert.ToInt16(d14.SelectedValue),
                                                              Convert.ToInt16(d15.SelectedValue), Convert.ToInt16(d16.SelectedValue), Convert.ToInt16(d17.SelectedValue), Convert.ToInt16(d18.SelectedValue), Convert.ToInt16(d19.SelectedValue),
                                                              Convert.ToInt16(d20.SelectedValue), Convert.ToInt16(d21.SelectedValue), Convert.ToInt16(d22.SelectedValue), Convert.ToInt16(d23.SelectedValue), Convert.ToInt16(d24.SelectedValue),
                                                              Convert.ToInt16(d25.SelectedValue), Convert.ToInt16(d26.SelectedValue), Convert.ToInt16(d27.SelectedValue), Convert.ToInt16(d28.SelectedValue), Convert.ToInt16(d29.SelectedValue),
                                                              Convert.ToInt16(d30.SelectedValue), Convert.ToInt16(d31.SelectedValue), Convert.ToInt32(Session["EmpAutoID"]));
                            string strScript = "";
                            strScript = strScript + "<script language='javascript'>";
                            strScript = strScript + "alert('" + rm.GetString("Alert_ShiftPatternsavedsuccessfully", ci) + "');";
                            strScript = strScript + "location.replace('../Masters/TA_UI_Master_ShiftPattern.aspx');";
                            strScript = strScript + "</script>";
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", strScript, false);
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Masters_ShiftPattern_Name_Already_Exits", ci) + "');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Selectallthedropdowns", ci) + "')'", true);
                        strflag = "true";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(Convert.ToString(ex));
                }
            }
        }
        catch
        {
            //
        }
    }
    #endregion
    #region ButtonEvents
    protected void btn_Add_Click(object sender, EventArgs e)
    {
        if (ddlCompany.SelectedValue != "0")
        {
            intCompanyId = Convert.ToInt32(ddlCompany.SelectedValue);
        }
        else
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Select_Company", ci) + "');", true);
            return;
        }
        InsertShiftPattern();
        if (Count == 0 && strflag != "true")
        {
            string strScript = "";
            strScript = strScript + "<script language='javascript'>";
            strScript = strScript + "alert('" + rm.GetString("Alert_ShiftPatternsavedsuccessfully", ci) + "');";
            strScript = strScript + "location.replace('TA_UI_Master_ShiftPattern.aspx');";
            strScript = strScript + "</script>";
            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", strScript, false);
        }
    }
    protected void ddl_NoDays_SelectedIndexChanged(object sender, EventArgs e)
    {
    }
    protected void btn_Cancel_Click(object sender, EventArgs e)
    {
        Response.Redirect("../Masters/TA_UI_Master_ShiftPattern.aspx");
    }
    protected void butSelect_Click(object sender, EventArgs e)
    {
    }
    #endregion
    protected void ddlCompany_DataBound(object sender, EventArgs e)
    {
        DropDownList ddl = sender as DropDownList;
        if (ddl != null)
        {
            foreach (ListItem li in ddl.Items)
            {
                li.Attributes["title"] = li.Text;
            }
        }
    }
}
