protected void btnUpdate_click(object sender, EventArgs e) { try { bool status = false; string CL = ""; string SL = ""; string AL = ""; string ML = ""; string LWP = ""; string OCODE = ((SessionUser)Session["SessionUser"]).OCode; var row = objLeave_BLL.GetAllLeaveType(OCODE).ToList(); if (row.Count > 0) { foreach (var item in row) { if (item.LEV_TYPE == "AL") { AL = item.LEV_DAYS.ToString(); } else if (item.LEV_TYPE == "CL") { CL = item.LEV_DAYS.ToString(); } else if (item.LEV_TYPE == "SL") { SL = item.LEV_DAYS.ToString(); } else if (item.LEV_TYPE == "ML") { ML = item.LEV_DAYS.ToString(); } } } if (txtEid_TRNS.Text == "") { status = false; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Input E-ID')", true); } else if (drpLeaveType.SelectedItem.ToString() == "--Select--") { status = false; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Select Leave Type')", true); } else if (txtbxFromDate.Text == "") { status = false; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Input From Date')", true); } else if (txtbxToDate.Text == "") { status = false; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Input To Date')", true); } else if (drpLeaveType.SelectedItem.ToString() == "CL") { status = true; Int32 totalActualLeave = TotalLeave(); Int32 totalLeave = totalActualLeave - Convert.ToInt16(hidTotalLeave.Value); if (totalLeave + Convert.ToInt32(txtbxTotalDay.Text) > Convert.ToInt32(CL)) { status = false; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Check Total CL Leave!')", true); } } else if (drpLeaveType.SelectedItem.ToString() == "SL") { status = true; Int32 totalActualLeave = TotalLeave(); Int32 totalLeave = totalActualLeave - Convert.ToInt16(hidTotalLeave.Value); if (Convert.ToInt32(txtbxTotalDay.Text) + totalLeave > Convert.ToInt32(SL)) { status = false; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Check Total SL Leave!')", true); } } else if (drpLeaveType.SelectedItem.ToString() == "AL") { Int32 totalActualLeave = TotalLeave(); Int32 totalLeave = totalActualLeave - Convert.ToInt16(hidTotalLeave.Value); status = true; if (Convert.ToInt32(txtbxTotalDay.Text) + totalLeave > Convert.ToInt32(AL)) { status = false; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Check Total AL Leave!')", true); } } else if (drpLeaveType.SelectedItem.ToString() == "ML") { status = true; Int32 totalActualLeave = TotalLeave(); Int32 totalLeave = totalActualLeave - Convert.ToInt16(hidTotalLeave.Value); if (totalLeave + Convert.ToInt32(txtbxTotalDay.Text) > Convert.ToInt32(ML)) { status = false; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Check Total ML Leave!')", true); } } else if (drpLeaveType.SelectedItem.ToString() == "LWP") { status = true; } if (status) { if (DeleteExistinLeaveDetailsByCodeId()) { if (txtbxToDate.Text != "") { if (!IsExist()) { //string OCODE1 = ((SessionUser)Session["SessionUser"]).OCode; DateTime DateTimeFrom = Convert.ToDateTime(txtbxFromDate.Text); DateTime DateTo = Convert.ToDateTime(txtbxToDate.Text); List <HRM_LeaveApply> leaveApplyesDates = new List <HRM_LeaveApply>(); for (int i = 0; i < Convert.ToInt16(txtbxTotalDay.Text); i++) { //check employee present List <HRM_ATTENDANCE> lstHRM_ATTENDANCE = aAttendance_BLL.GetAttendanceInfo_DateWise(DateTimeFrom.AddDays(i)).Where(x => x.EID == txtEid_TRNS.Text && x.Status == "P").ToList(); if (lstHRM_ATTENDANCE.Count > 0) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('This Employee Already Exist in Attendance!')", true); return; } HRM_LeaveApply leaveApplyObj = new HRM_LeaveApply(); leaveApplyObj.LeaveCode = hidLeaveCode.Value.ToString(); leaveApplyObj.LeaveDates = DateTimeFrom.AddDays(i); leaveApplyObj.LeaveAppliedDate = Convert.ToDateTime(hidAppliedDate.Value); leaveApplyObj.LeaveToDate = Convert.ToDateTime(txtbxToDate.Text); leaveApplyObj.Eid = txtEid_TRNS.Text; leaveApplyObj.LeaveTypeId = Convert.ToInt16(drpLeaveType.SelectedValue.ToString()); leaveApplyObj.LeaveCurrentYear = Convert.ToDateTime(txtbxFromDate.Text).Year; leaveApplyObj.LeaveResion = txtbxResion.Text.Trim(); leaveApplyObj.ReprotingBossHRM = drpApprovedHR.SelectedValue.ToString(); leaveApplyObj.ReprotingBoss1 = drpdwnApproveSupervisor.SelectedValue.ToString(); leaveApplyObj.ReprotingBoss2 = drpApprovedAdmin.SelectedValue.ToString(); leaveApplyObj.LeaveStatusHRM = true; leaveApplyObj.ReprotingBoss1ApproveStatus = true; leaveApplyObj.ReportingBoss2ApporveStatus = true; leaveApplyObj.EDIT_USER = ((SessionUser)Session["SessionUser"]).UserId; leaveApplyObj.EDIT_DATE = DateTime.Now; leaveApplyObj.OCODE = ((SessionUser)Session["SessionUser"]).OCode; leaveApplyesDates.Add(leaveApplyObj); } //int checkResult = objLeave_BLL.CheckAttendance(leaveApplyesDates); //if (checkResult == 0) //{ int result = objLeave_BLL.InsertLeaveApply(leaveApplyesDates); if (result == 1) { int Attendanceresult = objLeave_BLL.DeleteAttendanceByLeaveDate(leaveApplyesDates); if (Attendanceresult == 1) { ClaerAllController(); string employeeID = Convert.ToString(txtEid_TRNS.Text); GetLeaveDetailsByEID(employeeID); ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Updated Successfully!')", true); } } //} //else //{ // ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('This Employee Already Exist in Attendance!')", true); //} } else { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('This Date Already Exist for Leave !')", true); } } } } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true); } }
protected void btnSave_click(object sender, EventArgs e) { try { bool status = false; if (txtEid_TRNS.Text == "") { status = false; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Input E-ID!')", true); } else if (drpLeaveType.SelectedItem.ToString() == "--Select--") { status = false; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Select Leave Type!')", true); } else if (txtbxFromDate.Text == "") { status = false; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Input From Date!')", true); } else if (txtbxToDate.Text == "") { status = false; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Input To Date!')", true); } else if (drpLeaveType.SelectedItem.ToString() == "CL") { status = true; if (Convert.ToInt32(lblCloE.Text) + Convert.ToInt32(txtbxTotalDay.Text) > Convert.ToInt32(lblCl.Text)) { status = false; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Check Total CL Leave!')", true); } } else if (drpLeaveType.SelectedItem.ToString() == "SL") { status = true; if (Convert.ToInt32(lblSLE.Text) + Convert.ToInt32(txtbxTotalDay.Text) > Convert.ToInt32(lblSl.Text)) { status = false; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Check Total SL Leave!')", true); } } else if (drpLeaveType.SelectedItem.ToString() == "AL") { status = true; if (Convert.ToInt32(lblALE.Text) + Convert.ToInt32(txtbxTotalDay.Text) > Convert.ToInt32(lblAL.Text)) { status = false; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Check Total AL Leave!')", true); } } else if (drpLeaveType.SelectedItem.ToString() == "ML") { status = true; if (Convert.ToInt32(lblMLE.Text) + Convert.ToInt32(txtbxTotalDay.Text) > Convert.ToInt32(lblML.Text)) { status = false; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Check Total ML Leave!')", true); } } else if (drpLeaveType.SelectedItem.ToString() == "LWP") { status = true; } if (status) { if (!IsExist()) { string OCODE = ((SessionUser)Session["SessionUser"]).OCode; int count = objLeave_BLL.GetLastRowNumber(OCODE); int total = count + 1; string Code = "LC" + total; DateTime DateTimeFrom = Convert.ToDateTime(txtbxFromDate.Text); DateTime DateTo = Convert.ToDateTime(txtbxToDate.Text); List <HRM_LeaveApply> leaveApplyesDates = new List <HRM_LeaveApply>(); for (int i = 0; i < Convert.ToInt16(txtbxTotalDay.Text); i++) { //check employee present List <HRM_ATTENDANCE> lstHRM_ATTENDANCE = aAttendance_BLL.GetAttendanceInfo_DateWise(DateTimeFrom.AddDays(i)).Where(x => x.EID == txtEid_TRNS.Text).ToList(); if (lstHRM_ATTENDANCE.Count > 0) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('This Employee Already Exist in Attendance!')", true); return; } HRM_LeaveApply leaveApplyObj = new HRM_LeaveApply(); leaveApplyObj.LeaveCode = Code; leaveApplyObj.EDIT_USER = ((SessionUser)Session["SessionUser"]).UserId; leaveApplyObj.EDIT_DATE = DateTime.Now; leaveApplyObj.OCODE = ((SessionUser)Session["SessionUser"]).OCode; leaveApplyObj.LeaveDates = DateTimeFrom.AddDays(i); leaveApplyObj.LeaveAppliedDate = Convert.ToDateTime(txtbxFromDate.Text); leaveApplyObj.LeaveToDate = Convert.ToDateTime(txtbxToDate.Text); leaveApplyObj.Eid = txtEid_TRNS.Text; leaveApplyObj.LeaveTypeId = Convert.ToInt16(drpLeaveType.SelectedValue.ToString()); leaveApplyObj.LeaveCurrentYear = Convert.ToDateTime(txtbxFromDate.Text).Year; leaveApplyObj.LeaveResion = txtbxResion.Text.Trim(); leaveApplyObj.ReprotingBossHRM = drpApprovedHR.SelectedValue.ToString(); leaveApplyObj.ReprotingBoss1 = drpdwnApproveSupervisor.SelectedValue.ToString(); leaveApplyObj.ReprotingBoss2 = drpApprovedAdmin.SelectedValue.ToString(); leaveApplyObj.LeaveStatusHRM = true; leaveApplyObj.ReprotingBoss1ApproveStatus = true; leaveApplyObj.ReportingBoss2ApporveStatus = true; leaveApplyObj.EDIT_DATE = DateTime.Now; leaveApplyObj.EDIT_USER = ((SessionUser)Session["SessionUser"]).UserId; leaveApplyesDates.Add(leaveApplyObj); } int result = objLeave_BLL.InsertLeaveApply(leaveApplyesDates); if (result == 1) { int Attendanceresult = objLeave_BLL.DeleteAttendanceByLeaveDate(leaveApplyesDates); if (Attendanceresult == 1) { ClaerAllController(); string employeeID = Convert.ToString(txtEid_TRNS.Text); getLeaveEnjoyedInfoById(employeeID); ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Saved Successfully')", true); } } } else { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('This Date Already Exist for Leave!')", true); } } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true); } }
//private void BindGridEmployeeTermination() //{ // try // { // string OCODE = ((SessionUser)Session["SessionUser"]).OCode; // using (ERPSSLHBEntities context = new ERPSSLHBEntities()) // { // if (context.HRM_JOB_TERMINATE.Count() > 0) // { // var query = (from ter in context.HRM_JOB_TERMINATE // where ter.OCODE == OCODE // select ter).OrderByDescending(ter => ter.TERMINATE_ID); // GridViewEMP_TR.DataSource = query; // GridViewEMP_TR.DataBind(); // } // else // { // var obj = new List<HRM_JOB_TERMINATE>(); // obj.Add(new HRM_JOB_TERMINATE()); // // Bind the DataTable which contain a blank row to the GridView // GridViewEMP_TR.DataSource = obj; // GridViewEMP_TR.DataBind(); // int columnsCount = GridViewEMP_TR.Columns.Count; // GridViewEMP_TR.Rows[0].Cells.Clear();// clear all the cells in the row // GridViewEMP_TR.Rows[0].Cells.Add(new TableCell()); //add a new blank cell // GridViewEMP_TR.Rows[0].Cells[0].ColumnSpan = columnsCount; //set the column span to the new added cell // GridViewEMP_TR.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center; // GridViewEMP_TR.Rows[0].Cells[0].ForeColor = System.Drawing.Color.Red; // GridViewEMP_TR.Rows[0].Cells[0].Font.Bold = true; // //set No Results found to the new added cell // // GridViewEMP_TR.Rows[0].Cells[0].Text = "NO RECORDS FOUND!"; // } // } // } // catch (Exception) // { // throw; // } //} protected void btnJobTermntSubmit_Click(object sender, EventArgs e) { try { HRM_JOB_TERMINATE obj = new HRM_JOB_TERMINATE(); List <HRM_JOB_TERMINATE> jobterminates = new List <HRM_JOB_TERMINATE>(); string OCODE = ((SessionUser)Session["SessionUser"]).OCode; if (drpstatus.SelectedItem.ToString() != "------- Select --------") { List <HRM_ATTENDANCE> lstHRM_ATTENDANCE = aAttendance_BLL.GetAttendanceInfo_DateWise(Convert.ToDateTime(txtTerminateDate.Text)).Where(x => x.EID == txtEid_TR.Text && x.Status == "P").ToList(); if (lstHRM_ATTENDANCE.Count == 0) { string eid = obj.EID = txtEid_TR.Text; obj.TERMINATE_DATE = Convert.ToDateTime(txtTerminateDate.Text); obj.REMARKS = txtRemarks_TRM.Text; obj.EDIT_USER = ((SessionUser)Session["SessionUser"]).UserId; obj.EDIT_DATE = DateTime.Now; obj.OCODE = ((SessionUser)Session["SessionUser"]).OCode; obj.Termination_Status = true; if (drpstatus.SelectedItem.ToString() == "Resignation") { obj.Status = "Resignation"; } else if (drpstatus.SelectedItem.ToString() == "Termination") { obj.Status = "Termination"; } else if (drpstatus.SelectedItem.ToString() == "Retirement") { obj.Status = "Retirement"; } else if (drpstatus.SelectedItem.ToString() == "Dismissal") { obj.Status = "Dismissal"; } else if (drpstatus.SelectedItem.ToString() == "Died") { obj.Status = "Died"; } else if (drpstatus.SelectedItem.ToString() == "Dis-Continution") { obj.Status = "Dis-Continution"; } else if (drpstatus.SelectedItem.ToString() == "Others") { obj.Status = "Others"; } //-------------------------------- HRM_PersonalInformations objEmpUpdate = context.HRM_PersonalInformations.First(x => x.EID == obj.EID); if (drpstatus.SelectedItem.ToString() == "Termination") { objEmpUpdate.EMP_TERMIN_STATUS = true; } else if (drpstatus.SelectedItem.ToString() == "Retirement") { objEmpUpdate.EMP_Retired_Status = true; } else if (drpstatus.SelectedItem.ToString() == "Resignation") { objEmpUpdate.EMP_Resignation_Status = true; } else if (drpstatus.SelectedItem.ToString() == "Dismissal") { objEmpUpdate.EMP_Dismissal_Status = true; } else if (drpstatus.SelectedItem.ToString() == "Died") { objEmpUpdate.EMP_Died_Status = true; } else if (drpstatus.SelectedItem.ToString() == "Dis-Continution") { objEmpUpdate.EMP_Dis_Continution_Status = true; } else if (drpstatus.SelectedItem.ToString() == "Others") { objEmpUpdate.EMP_Other = true; } objEmpUpdate.Seperation_Date = Convert.ToDateTime(txtTerminateDate.Text); if (btnJobTermntSubmit.Text == "Submit") { int count = (from terminat in context.HRM_JOB_TERMINATE where terminat.TERMINATE_DATE == obj.TERMINATE_DATE && terminat.EID == obj.EID select terminat.TERMINATE_DATE).Count(); if (count > 0) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Separation Date Already Exists!')", true); return; } context.HRM_JOB_TERMINATE.AddObject(obj); context.SaveChanges(); } else { int terminationid = Convert.ToInt32(hidTerminationid.Value); string employeeid = hidEid.Value; var result = objEmp_BLL.GetEmployeeDetailsID(employeeid, OCODE).ToList(); if (result.Count > 0) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Active Employee separated information can not be update!')", true); return; } HRM_JOB_TERMINATE objHRM_JOB_TERMINATE = context.HRM_JOB_TERMINATE.First(x => x.TERMINATE_ID == terminationid && x.EID == employeeid); objHRM_JOB_TERMINATE.TERMINATE_DATE = obj.TERMINATE_DATE; objHRM_JOB_TERMINATE.Status = obj.Status; objHRM_JOB_TERMINATE.REMARKS = obj.REMARKS; context.SaveChanges(); } #region Commented Code //aAttendance_BLL.Delete_Attendance_ByEID_Date(txtEid_TR.Text, Convert.ToDateTime(txtTerminateDate.Text)); //DateTime CurrentDate = DateTime.Now; //DateTime SeparationDate = Convert.ToDateTime(txtTerminateDate.Text); //List<HRM_ATTENDANCE> attendences = (from att in context.HRM_ATTENDANCE // where att.EID == eid && (att.Attendance_Date >= SeparationDate && att.Attendance_Date <= CurrentDate) // select att).ToList(); //if (attendences.Count > 0) //{ // foreach (HRM_ATTENDANCE aitem in attendences) // { // HRM_ATTENDANCE _att = context.HRM_ATTENDANCE.First(a => a.EID == aitem.EID && a.Attendance_Date == aitem.Attendance_Date); // context.HRM_ATTENDANCE.DeleteObject(_att); // context.SaveChanges(); // } //} //lblTrMessage.Text = "Record Added successfully!"; //lblTrMessage.ForeColor = System.Drawing.Color.Green; #endregion ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Record Added successfully')", true); jobterminates.Add(obj); GetEmployee_Separation_Details(txtEid_TR.Text, OCODE); ClearAll(); } else { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('This Employee is present in this day!')", true); } } else { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Select Status!')", true); } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true); } }