private void SaveButton_Click(object sender, EventArgs e) { if (!this.ValidateChildren()) { ClientHelper.ShowRequiredMessage("Check Number, Amount"); } else { CheckColumnModel model = new CheckColumnModel() { CheckNumber = CheckNumberTextbox.Text, Amount = decimal.Parse(AmountTextbox.Text), Bank = BankTextbox.Text, Branch = BranchTextbox.Text, CheckDate = CheckDatePicker.Value, ClearingDate = ClearingDatePicker.Value, IsDeleted = false }; CheckAdded(sender, new CheckAddedEventArgs() { CheckModel = model }); this.Close(); } }
public void UpdateCheck(CheckColumnModel model) { try { using (this.unitOfWork) { var item = FetchCheckById(model.Id); if (item != null) { item.CheckNumber = model.CheckNumber; item.Bank = model.Bank; item.Branch = model.Branch; item.Amount = model.Amount; item.CheckDate = model.CheckDate; item.ClearingDate = model.ClearingDate; item.IsDeleted = model.IsDeleted; } this.actionLogController.AddToLog("Updated Check", UserInfo.UserId); this.unitOfWork.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public void InsertCheck(CheckColumnModel model) { try { using (this.unitOfWork) { Check item = new Check() { CheckNumber = model.CheckNumber, Bank = model.Bank, Branch = model.Branch, Amount = model.Amount, CheckDate = model.CheckDate, ClearingDate = model.ClearingDate, IsDeleted = model.IsDeleted, }; this.unitOfWork.Context.AddToCheck(item); this.actionLogController.AddToLog("Added new Check", UserInfo.UserId); this.unitOfWork.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public List <CheckColumnModel> FetchPaymentChecks(int paymentId) { try { var payments = (from p in db.PaymentDetail where p.Id == paymentId select p).FirstOrDefault(); List <CheckColumnModel> result = new List <CheckColumnModel>(); if (payments.Check.Any()) { foreach (Check c in payments.Check) { CheckColumnModel model = new CheckColumnModel() { Id = c.Id, Amount = c.Amount.HasValue ? c.Amount.Value : 0, Bank = c.Bank, Branch = c.Branch, CheckDate = c.CheckDate.HasValue ? c.CheckDate.Value : DateTime.Today, ClearingDate = c.ClearingDate.HasValue ? c.ClearingDate.Value : DateTime.Today, CheckNumber = c.CheckNumber, IsDeleted = c.IsDeleted.HasValue ? c.IsDeleted.Value : false }; result.Add(model); } } return(result); } catch (Exception ex) { throw ex; } }