bool Insert() { objCustomersPayment = new CustomersPayment(); objCustomersPayment.BeginTransaction(); objCustomersPayment.CustomerID = int.Parse(ddlCustomer.SelectedValue); objCustomersPayment.Payment = Convert.ToDouble(txtPayment.Text.Trim()); objCustomersPayment.PaymentDateM = Convert.ToDateTime(txtPaymentDateM.Text.Trim(), culture); objCustomersPayment.PaymentDateH = txtPaymentDateH.Text.Trim(); objCustomersPayment.Insert(); objCustomer = objCustomer.Single(p => p.CustomerID == int.Parse(ddlCustomer.SelectedValue)); objCustomer.Balance -= Convert.ToDouble(txtPayment.Text.Trim()); objCustomer.Update(p => p.CustomerID == objCustomer.CustomerID); objCustomer.EndTransaction(); return(true); }
bool Delete(int CustomerPaymentID) { try { objCustomersPayment.BeginTransaction(); objCustomersPayment = objCustomersPayment.Single(z => z.CustomerPaymentID == CustomerPaymentID); objCustomer = objCustomer.Single(p => p.CustomerID == objCustomersPayment.CustomerID); objCustomer.Balance += objCustomersPayment.Payment; objCustomer.Update(p => p.CustomerID == objCustomer.CustomerID); objCustomersPayment.Delete(p => p.CustomerPaymentID == objCustomersPayment.CustomerPaymentID); objCustomersPayment.EndTransaction(); } catch (Exception ex) { return(false); } return(true); }