public ActionResult Delete(decimal id) { try { EmployeeSalary.Delete(id); ViewBag.Message = "Employee Salary Deleted Successfully"; return(RedirectToAction("Index")); } catch (Exception ex) { return(View()); } }
public string Delete(int Id) { try { string ResultData; int Result = EmployeeSalary.Delete(Id); if (Result > 0) { ResultData = "Record delete successfully."; } else { ResultData = "Something was wrong !!"; } return(ResultData); } catch (Exception ex) { throw ex; } }
protected void btnSave_Click(object sender, EventArgs e) { try { CustomList <HRM_Emp> EmpList = (CustomList <HRM_Emp>)HttpContext.Current.Session["View_EmpList"]; CustomList <HRM_Emp> SaveableEmpList = EmpList.FindAll(f => f.IsChecked == true); CustomList <EmployeeSalaryTemp> StructureTempEmpSalary = (CustomList <EmployeeSalaryTemp>)Session["SalaryInfoEntry_grdSalaryEntryList"]; CustomList <EmployeeSalaryTemp> TempEmpSalary = new CustomList <EmployeeSalaryTemp>(); foreach (HRM_Emp H in SaveableEmpList) { foreach (EmployeeSalaryTemp S in StructureTempEmpSalary) { EmployeeSalaryTemp ST = new EmployeeSalaryTemp(); ST.EmpKey = H.EmpKey; ST.SalaryHeadKey = S.SalaryHeadKey; ST.SalaryRuleCode = S.SalaryRuleCode; ST.IsFixed = S.IsFixed; ST.Amount = S.Amount; ST.AddedBy = CurrentUserSession.UserCode; ST.DateAdded = DateTime.Now; TempEmpSalary.Add(ST); } } CustomList <EmployeeSalary> InsertSalaryList = new CustomList <EmployeeSalary>(); CustomList <EmployeeSalary> DeleteSalaryList = new CustomList <EmployeeSalary>(); if (chkApproved.Checked) { TempEmpSalary.ForEach(s => s.DateApproved = DateTime.Now); TempEmpSalary.ForEach(s => s.ApprovedBy = CurrentUserSession.UserCode); foreach (EmployeeSalaryTemp t in TempEmpSalary) { EmployeeSalary newObjInsert = new EmployeeSalary(); newObjInsert.EmpKey = t.EmpKey; newObjInsert.SalaryRuleCode = t.SalaryRuleCode; newObjInsert.SalaryHeadKey = t.SalaryHeadKey; newObjInsert.IsFixed = t.IsFixed; newObjInsert.Amount = t.Amount; InsertSalaryList.Add(newObjInsert); EmployeeSalary newObjDelete = new EmployeeSalary(); newObjDelete.SalaryHeadKey = t.SalaryHeadKey; newObjDelete.EmpKey = t.EmpKey; newObjDelete.Delete(); DeleteSalaryList.Add(newObjDelete); } } if (!CheckUserAuthentication(TempEmpSalary, DeleteSalaryList, InsertSalaryList)) { return; } manager.SaveSalaryInfo(ref TempEmpSalary, ref DeleteSalaryList, ref InsertSalaryList); //txtSalaryRuleID.Text = manager.SalaryRuleCode; this.SuccessMessage = (StaticInfo.SavedSuccessfullyMsg); } catch (SqlException ex) { this.ErrorMessage = (ExceptionHelper.getSqlExceptionMessage(ex)); } catch (Exception ex) { this.ErrorMessage = (ExceptionHelper.getExceptionMessage(ex)); } }
public void SaveEmployeeInfo(ArrayList empInfo, string mode = "insert") { ConnectionManager conManager = new ConnectionManager(ConnectionName.HR); Boolean blnTranStarted = false; try { conManager.BeginTransaction(); blnTranStarted = true; #region save parent var genInfo = (CustomList <HRM_Emp>)empInfo[0]; ReSetSPName(genInfo); long empKey = genInfo[0].EmpKey; if (mode == "insert") { empKey = Convert.ToInt32(conManager.InsertData(blnTranStarted, genInfo)); } else { conManager.SaveDataCollectionThroughCollection(blnTranStarted, genInfo); } genInfo.AcceptChanges(); #endregion var addr = (CustomList <HRM_EmpAddr>)empInfo[1]; addr.ForEach(x => x.EmpKey = empKey); ReSetSPName(addr); conManager.SaveDataCollectionThroughCollection(blnTranStarted, addr); addr.AcceptChanges(); var EmergencyContact = (CustomList <EmployeeEmergencyInfo>)empInfo[2]; EmergencyContact.ForEach(x => x.EmpKey = empKey); ReSetSPName(EmergencyContact); conManager.SaveDataCollectionThroughCollection(blnTranStarted, EmergencyContact); EmergencyContact.AcceptChanges(); var JobResponsibility = (CustomList <JobResponsibility>)empInfo[3]; JobResponsibility.ForEach(x => x.EmpKey = empKey); ReSetSPName(JobResponsibility); conManager.SaveDataCollectionThroughCollection(blnTranStarted, JobResponsibility); JobResponsibility.AcceptChanges(); var edu = (CustomList <HRM_EmpEdu>)empInfo[4]; edu.ForEach(x => x.EmpKey = empKey); ReSetSPName(edu); conManager.SaveDataCollectionThroughCollection(blnTranStarted, edu); edu.AcceptChanges(); var dip = (CustomList <HRM_EmpEduDip>)empInfo[5]; dip.ForEach(x => x.EmpKey = empKey); ReSetSPName(dip); conManager.SaveDataCollectionThroughCollection(blnTranStarted, dip); dip.AcceptChanges(); var hist = (CustomList <HRM_EmpEmployment>)empInfo[6]; hist.ForEach(x => x.EmpKey = empKey); ReSetSPName(hist); conManager.SaveDataCollectionThroughCollection(blnTranStarted, hist); hist.AcceptChanges(); var file = (CustomList <HRM_EmpFileAttach>)empInfo[7]; file.ForEach(x => x.EmpKey = empKey); ReSetSPName(file); conManager.SaveDataCollectionThroughCollection(blnTranStarted, file); file.AcceptChanges(); CustomList <EmployeeHKInfo> deletedHKInfoList = new CustomList <EmployeeHKInfo>(); EmployeeHKInfo newHKInfo = new EmployeeHKInfo(); newHKInfo.EmpKey = empKey; newHKInfo.Delete(); deletedHKInfoList.Add(newHKInfo); deletedHKInfoList.DeleteSpName = "spDeleteEmployeeHKInfo"; var OfficalInfo = (CustomList <EmployeeHKInfo>)empInfo[8]; OfficalInfo.ForEach(x => x.EmpKey = empKey); ReSetSPName(OfficalInfo); conManager.SaveDataCollectionThroughCollection(blnTranStarted, deletedHKInfoList, OfficalInfo); OfficalInfo.AcceptChanges(); //Delete from Employee Salary CustomList <EmployeeSalary> deletedSalaryList = new CustomList <EmployeeSalary>(); EmployeeSalary eS = new EmployeeSalary(); eS.EmpKey = empKey; eS.Delete(); deletedSalaryList.Add(eS); deletedSalaryList.DeleteSpName = "spDeleteRoleEmployeeSalary"; var EmpSalary = (CustomList <EmployeeSalaryTemp>)empInfo[9]; EmpSalary.ForEach(x => x.EmpKey = empKey); ReSetSPName(EmpSalary); conManager.SaveDataCollectionThroughCollection(blnTranStarted, deletedSalaryList, EmpSalary); EmpSalary.AcceptChanges(); deletedSalaryList.AcceptChanges(); var EmpLanguage = (CustomList <LanguageInfo>)empInfo[10]; EmpLanguage.ForEach(x => x.EmpKey = empKey); ReSetSPName(EmpLanguage); conManager.SaveDataCollectionThroughCollection(blnTranStarted, EmpLanguage); EmpLanguage.AcceptChanges(); var EmpFamilyDet = (CustomList <HRM_EmpFamDet>)empInfo[11]; EmpFamilyDet.ForEach(x => x.EmpKey = empKey); ReSetSPName(EmpFamilyDet); conManager.SaveDataCollectionThroughCollection(blnTranStarted, EmpFamilyDet); EmpFamilyDet.AcceptChanges(); var MedicalAllowance = (CustomList <MedicalReinSetup>)empInfo[12]; MedicalAllowance.ForEach(x => x.EmpKey = empKey); ReSetSPName(MedicalAllowance); conManager.SaveDataCollectionThroughCollection(blnTranStarted, MedicalAllowance); MedicalAllowance.AcceptChanges(); conManager.CommitTransaction(); blnTranStarted = false; conManager.Dispose(); } catch (Exception Ex) { conManager.RollBack(); throw Ex; } finally { if (conManager.IsNotNull()) { conManager.Dispose(); } } }