using System; using System.Collections; using System.Configuration; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq;  using System.Globalization;   public partial class TimeAlocate : System.Web.UI.Page {     public static string ATMSConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ATMSABILEConnectionString"];     private SqlConnection conn = null;     DBConnection con = new DBConnection();     DataTable dt;     public DateTime startDate = DateTime.Now.AddMonths(-2);     public DateTime endDate = DateTime.Now;      protected void Page_Load(object sender, EventArgs e)     {         foreach (RepeaterItem rptgrt in grtWeekOff.Items)         {             if (rptgrt.ItemType == ListItemType.Item || rptgrt.ItemType == ListItemType.AlternatingItem)             {                 LinkButton lbtEdit = (LinkButton)rptgrt.FindControl("lbtnShow");                 ToolkitScriptManager1.RegisterPostBackControl(lbtEdit);             }         }         pnlInValid.Visible = false;          var controlName = Request.Params.Get("__EVENTTARGET");         var argument = Request.Params.Get("__EVENTARGUMENT");         if (controlName == "Panel1" && argument == "Click")         {             InsertReqTime();         }           if (!IsPostBack)         {             //200014  200009 200012             Session["EmpCode"] = "200008";             BindPage();             bindDDAllEmp();                               }             }      private void BindPage()     {         string qry = "select CASE WHEN st.WeekOffC ='1' THEN 'W/OFF' Else isnull(sl.InD+' - '+sl.OutD ,'AUTO' ) END as ShiftGroupC, UPPER(SUBSTRING(datename(dw,st.DateD), 1, 3)) As dayNam,st.EmpNameC,st.EmpCodeC,st.DeptCodeC, st.DateD,st.WeekOffC, CASE WHEN dly.TimeInN ='' THEN '00:00' Else LEFT(dly.TimeInN, 5) END as TIn , CASE WHEN dly.TimeOutN ='' THEN '00:00' Else LEFT(dly.TimeOutN, 5) END as TOut, wr.TimeAlocateId, wr.Hin,wr.[Min],wr.Hout,wr.Mout,wr.Reason,wr.Remark1, isnull(wr.Status1,'None') as Status1 from ShiftTable st inner join ShiftGroupInfo sgi  on sgi.ShiftGroupCodeC=st.ShiftGroupC left join ShiftLite sl on sgi.ShiftCodeC=sl.CodeC inner join Daily dly on st.EmpCodeC =dly.EmpCodeC left join TimeAlocated wr on wr.DateD in (SELECT DateD FROM TimeAlocated WHERE wr.EmpCodeC= st.EmpCodeC and DateD=st.DateD and wr.History='0')";         if (txtDate.Text.Trim() != "" && txtDate.Text.Trim() != "")         {             dt = con.GetData(qry + "where st.EmpCodeC in (select EmpCodeC from ShiftTable WHERE CONVERT(datetime,st.DateD,105) BETWEEN CONVERT(datetime,'" + txtDate.Text.Trim() + "',105) AND CONVERT(datetime,'" + txtToDate.Text.Trim() + "',105)) and st.DateD=dly.ClockDateD  order by st.DateD");                 }         else         {             dt = con.GetData(qry + "where st.EmpCodeC in (select EmpCodeC from ShiftTable WHERE CONVERT(datetime,st.DateD,105) BETWEEN CONVERT(datetime,'" + startDate + "',105) AND CONVERT(datetime,'" + endDate + "',105)) and st.DateD=dly.ClockDateD  order by st.DateD");         }         //Session["EmpCode"] = "200008";         //Session["multiple"] = "0";         //con.parameters("@DateD", DBConnection.Type.eDateTime, Convert.ToDateTime(DateTime.Now.AddMonths(50)));         //string qry = "sp_TimeAlocateSelect";         //dt = con.ExecuteDataTable(qry);         ViewState["vsEmpCode"] = dt;         repeaterBind();             }      private void bindDDAllEmp()     {         string qry = "select DeptCodeC,DeptNameC from Department";         dt = con.GetData(qry);          ddAllDep.DataSource = dt;         ddAllDep.DataTextField = "DeptNameC";         ddAllDep.DataValueField = "DeptCodeC";         ddAllDep.DataBind();         ddAllDep.Items.Insert(0, new ListItem("--DEP SRCH--", "0"));             }            protected void btnAllDate_Click(object sender, EventArgs e)     {          string qry = "select CASE WHEN st.WeekOffC ='1' THEN 'W/OFF' Else isnull(sl.InD+' - '+sl.OutD ,'AUTO' ) END as ShiftGroupC, UPPER(SUBSTRING(datename(dw,st.DateD), 1, 3)) As dayNam,st.EmpNameC,st.EmpCodeC,st.DeptCodeC, st.DateD,st.WeekOffC, CASE WHEN dly.TimeInN ='' THEN '00:00' Else LEFT(dly.TimeInN, 5) END as TIn , CASE WHEN dly.TimeOutN ='' THEN '00:00' Else LEFT(dly.TimeOutN, 5) END as TOut, wr.TimeAlocateId, wr.Hin,wr.[Min],wr.Hout,wr.Mout,wr.Reason,wr.Remark1, isnull(wr.Status1,'None') as Status1 from ShiftTable st inner join ShiftGroupInfo sgi  on sgi.ShiftGroupCodeC=st.ShiftGroupC left join ShiftLite sl on sgi.ShiftCodeC=sl.CodeC inner join Daily dly on st.EmpCodeC =dly.EmpCodeC left join TimeAlocated wr on wr.DateD in (SELECT DateD FROM TimeAlocated WHERE wr.EmpCodeC= st.EmpCodeC and DateD=st.DateD and wr.History='0')";         dt = con.GetData(qry + "where st.EmpCodeC in (select EmpCodeC from ShiftTable WHERE CONVERT(datetime,st.DateD,105) BETWEEN CONVERT(datetime,'" + txtDate.Text.Trim() + "',105) AND CONVERT(datetime,'" + txtToDate.Text.Trim() + "',105)) and st.DateD=dly.ClockDateD  order by st.DateD");         //con.parameters("@FromDateD", DBConnection.Type.eDateTime, Convert.ToDateTime(txtFromDate.Text.Trim()));         //string qry = "sp_TimeAlocateSelect";        //dt = con.ExecuteDataTable(qry);         ViewState["vsEmpCode"] = dt;          repeaterBind();      }           protected void cbGroupEmployee1_CheckedChanged(object sender, EventArgs e)     {         int count = 0;         foreach (RepeaterItem item in grtWeekOff.Items)         {             CheckBox cbMultiple = item.FindControl("cbGroupEmployee1") as CheckBox;             if (cbMultiple.Checked == true)             {                  count += 1;             }              if (count > 1)             {                 pnlMulCB.Visible = true;              }             else             {                  pnlMulCB.Visible = false;                 rbMultiple.Checked = false;                 rbSingle.Checked = false;              }          }      }        private void repeaterBind()     {         if (ViewState["vsEmpCode"] != null)         {             DataTable dt = (DataTable)ViewState["vsEmpCode"];             PagedDataSource objPagedDataSource = new PagedDataSource();             DataView objDataView = new DataView(dt);             objPagedDataSource.DataSource = objDataView;             objPagedDataSource.AllowPaging = true;             objPagedDataSource.PageSize = 30;          //Set the Page Size, Means the number os records you want to dispay in a page             objPagedDataSource.CurrentPageIndex = GetCurrentPageNumber;             //if (objPagedDataSource.Count > 0)             //{             grtWeekOff.DataSource = objPagedDataSource;             grtWeekOff.DataBind();             lblCOunt.Text = dt.Rows.Count.ToString();             //}              if (GetCurrentPageNumber == 0)             {                  lnkPrevious.Enabled = false;                 lnkPrevious.CssClass = "bttn1 prev1";             }             else             {                 lnkPrevious.Enabled = true;                 lnkPrevious.CssClass = "bttn prev";             }              //Showing              int Pageno = (GetCurrentPageNumber + 1) * objPagedDataSource.PageSize;               if (Pageno > (Convert.ToInt32(lblCOunt.Text)))             {                 Pageno = Convert.ToInt32(lblCOunt.Text);              }              lbltotalcount.Text = Convert.ToString((GetCurrentPageNumber) * objPagedDataSource.PageSize) + "-" + Convert.ToString(Pageno);              // Enable/Disable Next link Button              if (objPagedDataSource.Count + 1 > objPagedDataSource.PageSize)             {                 lnkNext.Enabled = true;                 lnkNext.CssClass = "bttn next";              }             else             {                 lnkNext.Enabled = false;                 lnkNext.CssClass = "bttn1 next1";             }              //Repeater1.DataSource = dt;             //Repeater1.DataBind();           }     }      protected void lnkPrevious_Click(object sender, EventArgs e)     {         GetCurrentPageNumber -= 1;         repeaterBind();     }     protected void lnkNext_Click(object sender, EventArgs e)     {         GetCurrentPageNumber += 1;         repeaterBind();      }      //<summary>     //Property to get and set the current page number and Page Number is stored in ViewState     //</summary>     private int m_GetCurrentPageNumber = 0;     private int GetCurrentPageNumber     {         get         {             if (ViewState["CurrentPage"] != null)             {                 return Convert.ToInt32(ViewState["CurrentPage"]);             }             else             {                 return m_GetCurrentPageNumber;             }         }         set         {             ViewState["CurrentPage"] = value;         }     }       protected void rep_ServiceStatus_ItemDataBound(object sender, RepeaterItemEventArgs e)     {              if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)         {             Panel tr = (Panel)e.Item.FindControl("Panel1");             Panel Panel2 = (Panel)e.Item.FindControl("Panel2");//Where TD1 is the ID of the Table Cell             Panel Panel3 = (Panel)e.Item.FindControl("Panel3");             Panel Panel4 = (Panel)e.Item.FindControl("Panel4");             Panel Panel5 = (Panel)e.Item.FindControl("Panel5");             Panel Panel6 = (Panel)e.Item.FindControl("Panel6");             Panel Panel7 = (Panel)e.Item.FindControl("Panel7");             Label lId = (Label)e.Item.FindControl("lblId");             Label lWeekOff = (Label)e.Item.FindControl("lblWeekOff");             Panel Panel13 = (Panel)e.Item.FindControl("Panel13");             Panel Panel12 = (Panel)e.Item.FindControl("Panel12");              System.Web.UI.HtmlControls.HtmlSelect dReqIn1 = (System.Web.UI.HtmlControls.HtmlSelect)e.Item.FindControl("ddRegIn1");             System.Web.UI.HtmlControls.HtmlSelect dReqIn2 = (System.Web.UI.HtmlControls.HtmlSelect)e.Item.FindControl("ddTIn2");             System.Web.UI.HtmlControls.HtmlSelect dReqOut1 = (System.Web.UI.HtmlControls.HtmlSelect)e.Item.FindControl("ddTOut1");             System.Web.UI.HtmlControls.HtmlSelect dReqOut2 = (System.Web.UI.HtmlControls.HtmlSelect)e.Item.FindControl("ddTOut2");             Label lHin = (Label)e.Item.FindControl("lblHin");             Label lMin = (Label)e.Item.FindControl("lblMin");             Label lHout = (Label)e.Item.FindControl("lblHout");             Label lMout = (Label)e.Item.FindControl("lblMout");                          if (lWeekOff.Text.Trim() == "1")             {                 //tr.Attributes.Add("style", "background-color:#FF8D8D;");                  tr.Attributes.Add("class", "weekoff");                 Panel2.Attributes.Add("class", "weekoff");                 Panel3.Attributes.Add("class", "weekoff");                 Panel4.Attributes.Add("class", "weekoff");                 Panel5.Attributes.Add("class", "weekoff");                  Panel6.Attributes.Add("class", "weekoff");                 Panel7.Attributes.Add("class", "weekoff");                 Panel12.Attributes.Add("class", "weekoff");                 Panel13.Attributes.Add("class", "weekoff");             }             else             {                 // tr.Attributes.Add("style", "background-color: #f5f5f5;");                 tr.BackColor = System.Drawing.Color.Empty;             }              if (lHin.Text != "")             {                 dReqIn1.Value = lHin.Text;                 dReqIn2.Value = lMin.Text;                 dReqOut1.Value = lHout.Text;                 dReqOut2.Value = lMout.Text;             }                    }           CellMerge();             }      void CellMerge()     {         int ColSpan = 1; //RowSpan 갯수 설정          for (int i = grtWeekOff.Items.Count - 1; i > 0; i--)         {             Label lblcell01 = (Label)grtWeekOff.Items[i].FindControl("lblId");             Label lblcell01_1 = (Label)grtWeekOff.Items[i - 1].FindControl("lblId");             LinkButton lnkbtnHR = (LinkButton)grtWeekOff.Items[i - 1].FindControl("linkEdit");              if (lblcell01.Text == lblcell01_1.Text)             {                 ColSpan++;                 HtmlTableCell td1 = (HtmlTableCell)grtWeekOff.Items[i].FindControl("Td1");                 HtmlTableCell td01 = (HtmlTableCell)grtWeekOff.Items[i - 1].FindControl("Td1");                 td01.RowSpan = ColSpan;                 td1.Visible = false;             }             else             {                 ColSpan = 1;             }         }     }      protected void butnSearch_Click(object sender, EventArgs e)     {         if (txtSearch.Text != "")         {             DataTable dt = (DataTable)ViewState["vsEmpCode"];             var result = from a in dt.AsEnumerable()                          select new                          {                              ShiftGroupC = a.Field<string>("ShiftGroupC"),                              dayNam = a.Field<string>("dayNam"),                              EmpCodeC = a.Field<string>("EmpCodeC"),                              EmpNameC = a.Field<string>("EmpNameC"),                                                          DateD = a.Field<DateTime>("DateD"),                              Hout = a.Field<string>("Hout"),                              Mout = a.Field<string>("Mout"),                              Hin = a.Field<string>("Hin"),                              Min = a.Field<string>("Min"),                              TIn = a.Field<string>("TIn"),                              TOut = a.Field<string>("TOut"),                              TimeAlocateId = a.Field<int?>("TimeAlocateId"),                              DeptCodeC = a.Field<string>("DeptCodeC"),                              Reason = a.Field<string>("Reason"),                              WeekOffC = a.Field<string>("WeekOffC"),                                                        };              if (!string.IsNullOrEmpty(txtSearch.Text))             {                 result = result.Where(a => a.EmpCodeC.Contains(txtSearch.Text) || a.EmpNameC.Contains(txtSearch.Text) || a.dayNam.Contains(txtSearch.Text) || a.DateD.ToString().Contains(txtSearch.Text));             }                          grtWeekOff.DataSource = result.ToList();             grtWeekOff.DataBind();             pnlMulCB.Visible = false;             rbMultiple.Checked = false;             rbSingle.Checked = false;          }         else         {             repeaterBind();         }      }        protected void ddAllDep_SelectedIndexChanged(object sender, EventArgs e)     {         if (ddAllDep.SelectedIndex > 0)         {             DataTable dt = (DataTable)ViewState["vsEmpCode"];             var result = from a in dt.AsEnumerable()                          select new                          {                              ShiftGroupC = a.Field<string>("ShiftGroupC"),                              dayNam = a.Field<string>("dayNam"),                              EmpCodeC = a.Field<string>("EmpCodeC"),                              EmpNameC = a.Field<string>("EmpNameC"),                              DateD = a.Field<DateTime>("DateD"),                              Hout = a.Field<string>("Hout"),                              Mout = a.Field<string>("Mout"),                              Hin = a.Field<string>("Hin"),                              Min = a.Field<string>("Min"),                              TIn = a.Field<string>("TIn"),                              TOut = a.Field<string>("TOut"),                              TimeAlocateId = a.Field<int?>("TimeAlocateId"),                              DeptCodeC = a.Field<string>("DeptCodeC"),                              Reason = a.Field<string>("Reason"),                              WeekOffC = a.Field<string>("WeekOffC"),                          };              result = result.Where(a => a.DeptCodeC.Contains(ddAllDep.SelectedItem.Value));             grtWeekOff.DataSource = result.ToList();             grtWeekOff.DataBind();                        CellMerge();             lnkNext.Enabled = false;             lnkPrevious.Enabled = false;                    }         else         {             repeaterBind();         }             }      protected void rbSingle_CheckedChanged(object sender, EventArgs e)     {         repRowSet();         Page.ClientScript.RegisterStartupScript(this.GetType(), "MyScript",        "javascript:document.getElementById('lightB').style.display='block';document.getElementById('fadeB').style.display='block';", true);      }      private void repRowSet()     {         DataTable dtlightRep = new DataTable();         DataRow dr = null;          dtlightRep.Columns.Add(new DataColumn("day", typeof(string)));         dtlightRep.Columns.Add(new DataColumn("EmpCodeC", typeof(string)));         dtlightRep.Columns.Add(new DataColumn("EmpNameC", typeof(string)));         dtlightRep.Columns.Add(new DataColumn("ShiftGroupC", typeof(string)));         dtlightRep.Columns.Add(new DataColumn("Tin", typeof(string)));         dtlightRep.Columns.Add(new DataColumn("Tout", typeof(string)));                 foreach (RepeaterItem item in grtWeekOff.Items)         {             Label lday = item.FindControl("lblday") as Label;             Label lEmpCodeC = item.FindControl("lblEmpCodeC") as Label;                 Label lEmpNameC = item.FindControl("lblEmpNameC") as Label;                        Label lShiftGroupC = item.FindControl("lblShiftGroupC") as Label;             Label lTin = item.FindControl("lblTin") as Label;             Label lTout = item.FindControl("lblTout") as Label;             CheckBox cbGroup = item.FindControl("cbGroupEmployee1") as CheckBox;              if (cbGroup.Checked == true)             {                 dr = dtlightRep.NewRow();                 dr["day"] = lday.Text;                 dr["EmpCodeC"] = lEmpCodeC.Text;                 dr["EmpNameC"] = lEmpNameC.Text;                 dr["ShiftGroupC"] = lShiftGroupC.Text;                 dr["Tin"] = lTin.Text;                 dr["Tout"] = lTout.Text;                 dtlightRep.Rows.Add(dr);             }         }          ViewState["vsRepLight"] = dtlightRep;         grdEmp.DataSource = dtlightRep;         grdEmp.DataBind();      }               private void InsertReqTime()     {      string EmpCode = Session["EmpCode"].ToString();             con.parameters("@EmpCodeC", DBConnection.Type.eVarchar, "");             con.parameters("@DateD", DBConnection.Type.eDateTime, Convert.ToDateTime(null));             con.parameters("@Hin", DBConnection.Type.eVarchar, "");             con.parameters("@Min", DBConnection.Type.eVarchar, "");             con.parameters("@Hout", DBConnection.Type.eVarchar, "");             con.parameters("@Mout", DBConnection.Type.eVarchar, "");                     con.parameters("@Reason", DBConnection.Type.eVarchar, "");             con.parameters("@Level1_id", DBConnection.Type.eVarchar, "");              con.parameters1("@EmpCodeC", DBConnection.Type.eVarchar, "");             con.parameters1("@DateD", DBConnection.Type.eDateTime, Convert.ToDateTime(null));             con.parameters1("@Hin", DBConnection.Type.eVarchar, "");             con.parameters1("@Min", DBConnection.Type.eVarchar, "");             con.parameters1("@Hout", DBConnection.Type.eVarchar, "");             con.parameters1("@Mout", DBConnection.Type.eVarchar, "");                        int update = 0;             getHR();             DataTable dtLevel1 = (DataTable)ViewState["HR"];             getPosition();             DataTable dtApprove = (DataTable)ViewState["vsApprove"];                            if (rbSingle.Checked == false)                 {                     foreach (RepeaterItem item in grtWeekOff.Items)                     {                          Label lEmpCodeC = item.FindControl("lblEmpCodeC") as Label;                         Label lDateD = item.FindControl("lblDate") as Label;                         Label lShift = item.FindControl("lblShiftGroupC") as Label;                          System.Web.UI.HtmlControls.HtmlSelect dReqIn1 = item.FindControl("ddRegIn1") as System.Web.UI.HtmlControls.HtmlSelect;                         System.Web.UI.HtmlControls.HtmlSelect dTIn2 = item.FindControl("ddTIn2") as System.Web.UI.HtmlControls.HtmlSelect;                         System.Web.UI.HtmlControls.HtmlSelect dTOut1 = item.FindControl("ddTOut1") as System.Web.UI.HtmlControls.HtmlSelect;                         System.Web.UI.HtmlControls.HtmlSelect dTOut2 = item.FindControl("ddTOut2") as System.Web.UI.HtmlControls.HtmlSelect;                         TextBox tReason = item.FindControl("txtReason") as TextBox;                         Label lReason = item.FindControl("lblReason") as Label;                         CheckBox cGroupEmployee1 = item.FindControl("cbGroupEmployee1") as CheckBox;                          if (cGroupEmployee1.Checked == true)                         {                             update = 1;                               if (dtApprove.Rows.Count != 1)                           {                                                        con.parametersFor("@EmpCodeC", lEmpCodeC.Text.Trim());                             con.parametersFor("@DateD", Convert.ToDateTime(lDateD.Text));                             con.parametersFor("@Hin", dReqIn1.Value);                             con.parametersFor("@Min", dTIn2.Value);                             con.parametersFor("@Hout", dTOut1.Value);                             con.parametersFor("@Mout", dTOut2.Value);                             con.parametersFor("@Reason", tReason.Text.Trim());                             con.parametersFor("@Level1_id", dtLevel1.Rows[0]["Level1_id"].ToString());                             con.ExecProcedure("sp_TimeAlocate");                                }                               else                               {                                   timeAlocate(lEmpCodeC.Text.Trim(), lDateD.Text.Trim(), ddRegIn1.Value, ddTIn2.Value, ddTOut1.Value, ddTOut2.Value);                                                           }                         }                     }                  }                 else                 {                      foreach (RepeaterItem item in grtWeekOff.Items)                     {                         Label lEmpCodeC = item.FindControl("lblEmpCodeC") as Label;                         Label lDateD = item.FindControl("lblDate") as Label;                         Label lShift = item.FindControl("lblShiftGroupC") as Label;                         CheckBox cGroupEmployee1 = item.FindControl("cbGroupEmployee1") as CheckBox;                          if (cGroupEmployee1.Checked == true)                         {                             update = 1;                               if (dtApprove.Rows.Count != 1)                           {                                                         con.parametersFor("@EmpCodeC", lEmpCodeC.Text.Trim());                             con.parametersFor("@DateD", Convert.ToDateTime(lDateD.Text));                             con.parametersFor("@Hin", ddRegIn1.Value);                             con.parametersFor("@Min", ddTIn2.Value);                             con.parametersFor("@Hout", ddTOut1.Value);                             con.parametersFor("@Mout", ddTOut2.Value);                             con.parametersFor("@Reason", txtlightReason.Text.Trim());                             con.parametersFor("@Level1_id", dtLevel1.Rows[0]["Level1_id"].ToString());                             con.ExecProcedure("sp_TimeAlocate");                                }                                else                               {                                   timeAlocate(lEmpCodeC.Text.Trim(),lDateD.Text.Trim(),ddRegIn1.Value,ddTIn2.Value,ddTOut1.Value,ddTOut2.Value);                                                           }                         }                      }                             }                      if (update == 1)         {             lblVAlidate.Text = "Successfully Submited!!!";             pnlInValid.Visible = true;         }         else             {             lblVAlidate.Text = "Please choose Employee!!";             pnlInValid.Visible = true;              }          BindPage();          }      private void timeAlocate(string emp, string dte, string Hin, string Min, string Hout, string Mout)     {                      con.parametersFor1("@EmpCodeC", emp);             con.parametersFor1("@DateD", Convert.ToDateTime(dte));             con.parametersFor1("@Hin", Hin);             con.parametersFor1("@Min", Min);             con.parametersFor1("@Hout", Hout);             con.parametersFor1("@Mout", Mout);             con.ExecProcedure1("sp_TimeChange");                     }      private void getPosition()     {          findlevel();           DataTable dtView = (DataTable)ViewState["vsStatusView"];          string StatusView = dtView.Rows[0]["RoleC"].ToString();          if (dtView.Rows.Count > 0)          {              string qryView = "select Approve from URRoleMaster where RoleC='" + StatusView + "' and MenuC ='Vendor'";              dtView = con.GetData(qryView);                         ViewState["vsApprove"] = dtView;          }      }      private void findlevel()     {         string EmpCode = Session["EmpCode"].ToString();         string qryView = "select RoleC from URPosition where EmpCodeC ='" + EmpCode + "'";         dt = con.GetData(qryView);         if (dt.Rows.Count > 0)         {              ViewState["vsStatusView"] = dt;         }     }      protected void imgbtnlightClose_Click(object sender, EventArgs e)     {          Page.ClientScript.RegisterStartupScript(this.GetType(), "MyScript",         "javascript:document.getElementById('lightB').style.display='none';document.getElementById('fadeB').style.display='none';", true);          pnlMulCB.Visible = false;         rbMultiple.Checked = false;         rbSingle.Checked = false;         repeaterBind();       }      protected void grtEmp_PageIndexChanging(object sender, GridViewPageEventArgs e)     {         repeaterBind();         grdEmp.PageIndex = e.NewPageIndex;         grdEmp.DataBind();          Page.ClientScript.RegisterStartupScript(this.GetType(), "MyScript",       "javascript:document.getElementById('lightB').style.display='block';document.getElementById('fadeB').style.display='block';", true);      }      private void bindgrtEmp()     {         DataTable dt = (DataTable)ViewState["vsRepLight"];         grdEmp.DataSource = dt;         grdEmp.DataBind();     }      protected void linklightEdit1_Click(object sender, EventArgs e)     {         InsertReqTime();         Page.ClientScript.RegisterStartupScript(this.GetType(), "MyScript",         "javascript:document.getElementById('lightB').style.display='none';document.getElementById('fadeB').style.display='none';", true);          pnlMulCB.Visible = false;         rbMultiple.Checked = false;         rbSingle.Checked = false;     }     private void getHR()     {         string EmpCode = Session["EmpCode"].ToString();         string qry = "select Level1_id from URPosition where EmpCodeC='" + EmpCode + "'";         dt = con.GetData(qry);         ViewState["HR"] = dt;     }      protected void linkEdit_click(object sender, EventArgs e)     {          //conn = new SqlConnection(ATMSConnectionString);         string EmpCode = Session["EmpCode"].ToString();          LinkButton btn = (LinkButton)sender;         RepeaterItem ritem = (RepeaterItem)btn.NamingContainer;         Label lDateD = (Label)ritem.FindControl("lblDate");         Label lEmpCodeC = (Label)ritem.FindControl("lblEmpCodeC");          con.parameters("@EmpCodeC", DBConnection.Type.eVarchar, lEmpCodeC.Text);         con.parameters("@DateD", DBConnection.Type.eDateTime, Convert.ToDateTime(lDateD.Text.Trim()));         string qry = "sp_TimeAlocateReqHsty";         dt = con.ExecuteDataTable(qry);         ViewState["vsHistory"] = dt;           DataTable dtPres = new DataTable();         string qryPres = "sp_TimeAlocateReqHstyPres";         dtPres = con.ExecuteDataTable(qryPres);         ViewState["vsHistoryPres"] = dtPres;         bindLightGrt();      }      private void bindLightGrt()     {         DataTable dt = (DataTable)ViewState["vsHistory"];         grtHistory.DataSource = dt;         grtHistory.DataBind();          DataTable dtPres = (DataTable)ViewState["vsHistoryPres"];         grtHstyPres.DataSource = dtPres;         grtHstyPres.DataBind();          Page.ClientScript.RegisterStartupScript(this.GetType(), "MyScript",                     "javascript:document.getElementById('lightA').style.display='block';document.getElementById('fadeA').style.display='block';", true);       } }