public void addPayment(Payment p)
 {
     entities.Payments.Add(p);
     entities.SaveChanges();
 }
 public void updatePayment(Payment p)
 {
     entities.Payments.Attach(p);
     entities.Entry(p).State = EntityState.Modified;
     entities.SaveChanges();
 }
Пример #3
0
 private void bSave_Click(object sender, EventArgs e)
 {
     ContractRepository crep = new ContractRepository();
     Contract contract = crep.getContract(contractId);
     PaymentRepository repository = new PaymentRepository();
     PersianDateFormatter pdf = new PersianDateFormatter();
     Payment payment = new Payment();
     payment.ContractId = contractId;
     payment.AmountOfPayment = Convert.ToInt32(tPayment.Text);
     payment.DateOfPayment = pdf.convert(tPaymentDate.Text);
     DateModel dm = pdf.getSplittedDateIntegers(payment.DateOfPayment.Value);
     payment.Year = dm.Year;
     payment.Month = dm.Month;
     payment.Day = dm.Day;
     contract.Payment += payment.AmountOfPayment;
     repository.addPayment(payment);
     crep.updateContract(contract);
 }