public int Update(GovernmentFunds GovernmentFund) { try { using (var db = new HCMEntities()) { GovernmentFunds GovernmentFundObj = db.GovernmentFunds.SingleOrDefault(x => x.GovernmentFundID.Equals(GovernmentFund.GovernmentFundID)); GovernmentFundObj.EmployeeCodeID = GovernmentFund.EmployeeCodeID; GovernmentFundObj.GovernmentFundTypeID = GovernmentFund.GovernmentFundTypeID; GovernmentFundObj.GovernmentDeductionTypeID = GovernmentFund.GovernmentDeductionTypeID; GovernmentFundObj.MonthlyDeductionAmount = GovernmentFund.MonthlyDeductionAmount; GovernmentFundObj.TotalDeductionAmount = GovernmentFund.TotalDeductionAmount; GovernmentFundObj.LoanNo = GovernmentFund.LoanNo; GovernmentFundObj.LoanDate = GovernmentFund.LoanDate; GovernmentFundObj.DeductionStartDate = GovernmentFund.DeductionStartDate; GovernmentFundObj.ContractNo = GovernmentFund.ContractNo; //GovernmentFundObj.ContractDate = GovernmentFund.ContractDate; GovernmentFundObj.KSACityID = GovernmentFund.KSACityID; GovernmentFundObj.SponserToName = GovernmentFund.SponserToName; GovernmentFundObj.SponserToIDNo = GovernmentFund.SponserToIDNo; GovernmentFundObj.LastUpdatedDate = GovernmentFund.LastUpdatedDate; GovernmentFundObj.LastUpdatedBy = GovernmentFund.LastUpdatedBy; GovernmentFundObj.BankIPAN = GovernmentFund.BankIPAN; return(db.SaveChanges()); } } catch { throw; } }
public int Delete(int GovernmentFundID, int UserIdentity) { try { using (var db = new HCMEntities()) { GovernmentFunds GovernmentFundsObj = db.GovernmentFunds.SingleOrDefault(x => x.GovernmentFundID.Equals(GovernmentFundID)); db.GovernmentFunds.Remove(GovernmentFundsObj); return(db.SaveChanges(UserIdentity)); } } catch { throw; } }
public int Deactivate(GovernmentFunds GovernmentFund) { try { using (var db = new HCMEntities()) { GovernmentFunds GovernmentFundObj = db.GovernmentFunds.SingleOrDefault(x => x.GovernmentFundID.Equals(GovernmentFund.GovernmentFundID)); GovernmentFundObj.LetterDate = GovernmentFund.LetterDate; GovernmentFundObj.LetterNo = GovernmentFund.LetterNo; GovernmentFundObj.Notes = GovernmentFund.Notes; GovernmentFundObj.DeactiveDate = GovernmentFund.DeactiveDate; GovernmentFundObj.IsActive = GovernmentFund.IsActive; GovernmentFundObj.LastUpdatedDate = GovernmentFund.LastUpdatedDate; GovernmentFundObj.LastUpdatedBy = GovernmentFund.LastUpdatedBy; GovernmentFundObj.GovernmentFundDeactiveReasonID = GovernmentFund.GovernmentFundDeactiveReasonID; return(db.SaveChanges()); } } catch { throw; } }
public int Insert(GovernmentFunds GovernmentFund) { try { using (var db = new HCMEntities()) { db.GovernmentFunds.Add(GovernmentFund); db.SaveChanges(); return(GovernmentFund.GovernmentFundID); } } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } }