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>(); if (ckIndividualPunishment.Checked) //individual process { if (txtbxEID.Text == "") { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Enter E-ID!')", true); return; } if (txtDate.Text == "") { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Select Attendance Date!')", true); return; } HRM_ATTENDANCE _attendance = new HRM_ATTENDANCE(); _attendance.EID = txtbxEID.Text; _attendance.Attendance_Date = Convert.ToDateTime(txtDate.Text); _attendance.Remarks = txtbxremark.Text; _attendance.Edit_User = ((SessionUser)Session["SessionUser"]).UserId; _attendance.Edit_Date = DateTime.Now; _attendance.OCode = ((SessionUser)Session["SessionUser"]).OCode; attendances.Add(_attendance); if (attendances.Count > 0) { List <HRM_EMPLOYEES_VIEWER> lstEmpAttendnace = _attendancebll.GetEmployeesByEidForAttendance(txtbxEID.Text, Convert.ToDateTime(txtDate.Text), Convert.ToDateTime(txtDate.Text)); //check attendance data if (lstEmpAttendnace.Count > 0) { Guid UserID = ((SessionUser)Session["SessionUser"]).UserId; string PunishedBy = userDAl.getEIDbyUserGuidID(UserID); int result = _attendancebll.AttendanceAdjustment(attendances, PunishedBy); if (result == 1) { // insert/update leave/holiday attendnace status process by selected eid aAttendance_RPT_Bll.Insert_Update_AbsentLeaveStatus_ByDate_EID(attendances, Convert.ToDateTime(txtDate.Text), Convert.ToDateTime(txtDate.Text)); ClearUI(); ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Attendance Punishment Successfull')", true); } } else { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('No Attendance Data Found!')", true); } } else { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('No Employee selected in the list!')", true); } } 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; _attendance.Edit_User = ((SessionUser)Session["SessionUser"]).UserId; _attendance.Edit_Date = DateTime.Now; _attendance.OCode = ((SessionUser)Session["SessionUser"]).OCode; attendances.Add(_attendance); } } if (attendances.Count > 0) { Guid UserID = ((SessionUser)Session["SessionUser"]).UserId; string PunishedBy = userDAl.getEIDbyUserGuidID(UserID); int result = _attendancebll.AttendanceAdjustment(attendances, PunishedBy); if (result == 1) { // insert/update leave/holiday attendnace status process by selected eid aAttendance_RPT_Bll.Insert_Update_AbsentLeaveStatus_ByDate_EID(attendances, Convert.ToDateTime(txtDate.Text), Convert.ToDateTime(txtDate.Text)); ClearUI(); ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Attendance Punishment Successfull')", true); } } else { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('No Employee selected in the list!')", true); } } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true); } }