Exemplo n.º 1
0
        protected void btn_Confirm_Clcik(object sender, EventArgs e)
        {
            try
            {
                UserDAL               userDAl        = new UserDAL();
                Attendance_BLL        _attendancebll = new Attendance_BLL();
                List <HRM_ATTENDANCE> attendances    = new List <HRM_ATTENDANCE>();

                //string[] plussign = txtbxOtHour.Text.Split('+');
                //string[] Minsign = txtbxOtHour.Text.Split('-');

                //string psign = plussign[0].ToString();
                //string misign = Minsign[0].ToString();


                //string plussign = txtbxOtHour.Text.ToString();
                //string[] values = plussign.Split('+');
                //string psign = values[1].ToString();

                //string Minsign = txtbxOtHour.Text.ToString();
                //string[] values1 = Minsign.Split('-');
                //string misign = values1[1].ToString();


                //string sign = txtbxOtHour.Text.ToString();
                string sign = txtbxOtHour.Text.Substring(0, 1);
                if (sign == "+" || sign == "-")
                {
                    //CheckBox headerChkBox = ((CheckBox)grdview.HeaderRow.FindControl("headerLevelCheckBox"));
                    //if (headerChkBox.Checked == true)
                    //{
                    //    foreach (GridViewRow gvRow in grdview.Rows)
                    //    {

                    //        HRM_ATTENDANCE _attendance = new HRM_ATTENDANCE();
                    //        CheckBox rowChkBox = ((CheckBox)gvRow.FindControl("rowLevelCheckBox"));

                    //        Label lblEID = ((Label)gvRow.FindControl("lblEID"));

                    //        TextBox txtbx = ((TextBox)gvRow.FindControl("txtbx"));


                    //        _attendance.EID = lblEID.Text;
                    //        _attendance.Remarks = txtbxremark.Text;
                    //        _attendance.Attendance_Date = Convert.ToDateTime(txtDate.Text);
                    //        attendances.Add(_attendance);
                    //    }
                    //}

                    //else
                    //{
                    foreach (GridViewRow gvRow in grdview.Rows)
                    {
                        CheckBox rowChkBox = ((CheckBox)gvRow.FindControl("rowLevelCheckBox"));

                        HRM_ATTENDANCE _attendance = new HRM_ATTENDANCE();

                        if (rowChkBox.Checked == true)
                        {
                            Label   lblEID = ((Label)gvRow.FindControl("lblEID"));
                            TextBox txtbx  = ((TextBox)gvRow.FindControl("txtbx"));


                            _attendance.EID             = lblEID.Text;
                            _attendance.Attendance_Date = Convert.ToDateTime(txtDate.Text);
                            _attendance.Remarks         = txtbxremark.Text;
                            attendances.Add(_attendance);
                        }
                    }

                    //}
                    string OThour    = Convert.ToString(txtbxOtHour.Text.Trim());
                    Guid   UserID    = ((SessionUser)Session["SessionUser"]).UserId;
                    string apprvedBy = userDAl.getEIDbyUserGuidID(UserID);
                    int    result    = _attendancebll.ManualOTUpdate(attendances, apprvedBy, OThour);
                    if (result == 1)
                    {
                        ClearUI();
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Update Successfully.')", true);
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Use + or - Sign Before Number')", true);
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true);
            }
        }