public int AddNewPaymentPlan(PaymentPlan plan) { string query = "INSERT INTO payment_plan(invoice_no, contract_date, customer_id, device_model, serial_no, invoice_amount, down_payment, schedule, notes, installment_no, installment_amount, first_installment_due_date) VALUES('" + plan.invoice_no + "','" + utils.DateTimeToSQLDateString(plan.contract_date) + "'," + plan.customer_id + ",'" + plan.device_model + "','" + plan.serial_no + "'," + plan.invoice_amount + "," + plan.down_payment + ",'" + plan.schedule + "','" + plan.notes + "'," + plan.installment_no + "," + plan.installment_amount + ",'" + utils.DateTimeToSQLDateString(plan.first_installment_due_date) + "');" + "select last_insert_id();"; try { conn.Open(); MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = query; int isInserted = Convert.ToInt32(cmd.ExecuteScalar()); conn.Close(); if (isInserted > 0) { DuePaymentMonthModel dm = new DuePaymentMonthModel(); dm.createDuePaymentMonthRow(isInserted, confirmPaymentPlan(plan)); } return(isInserted); } catch (Exception ex) { throw ex; } finally { conn.Close(); } }
public List <DueListItem> confirmPaymentPlan(PaymentPlan plan) { return(utils.DueAmountList(plan.invoice_amount, plan.down_payment, plan.installment_no, plan.installment_amount, plan.first_installment_due_date, plan.schedule)); }