public void UpdatePaymentPlan(string AppID) { SqlCommand cmd = new SqlCommand(); SqlCommand cmd2; SqlConnection conn = new SqlConnection(Utility.connectionString); byte cmtype = 3; cmd.CommandText = "delete tblBLPaymentPlan where accountid=" + AppID + ""; cmd.Connection = conn; cmd.CommandType = CommandType.Text; SqlTransaction tran = null; try { conn.Open(); tran = conn.BeginTransaction(); cmd.Transaction = tran; cmd.ExecuteNonQuery(); int i = 0; foreach (HtmlTableRow row in this.TABLE1.Rows) { string labelstring = "lblMonth"; string newlbl = labelstring + i.ToString(); Control ctrl = null; if (i > 1) { if (row.Cells.Count > 0) ctrl = row.Cells[1].Controls[0]; } if (ctrl != null) { if (i > 1) { #region obsolete //datarow.AccountID = accountid; //datarow.MonthName = ((Label)row.Cells[0].Controls[0]).Text; //datarow.MonthIndex = Convert.ToByte(i - 1); //datarow.Repayment = Utility.ConvertToDouble(((TextBox)row.Cells[4].Controls[0]).Text).ToString(); //datarow.AmountOutstanding = Utility.ConvertToDouble(((TextBox)row.Cells[5].Controls[0]).Text).ToString(); //datarow.Ir = Utility.ConvertToDecimal(((TextBox)row.Cells[2].Controls[0]).Text); //datarow.BalanceBF = Utility.ConvertToDecimal(((TextBox)row.Cells[1].Controls[0]).Text); //datarow.Loan_Interest = Utility.ConvertToDecimal(((TextBox)row.Cells[3].Controls[0]).Text); //datarow.RType = cmtype; #endregion LoanDSTableAdapters.PaymentPlanTableAdapter plan = new LoanDSTableAdapters.PaymentPlanTableAdapter(); plan.InsertPaymentPlan(Convert.ToDateTime(((Label)row.Cells[0].Controls[0]).Text), Convert.ToDecimal(Utility.ConvertToDecimal(((TextBox)row.Cells[1].Controls[0]).Text)), Utility.ConvertToDecimal(((TextBox)row.Cells[2].Controls[0]).Text), Utility.ConvertToDecimal(((TextBox)row.Cells[2].Controls[0]).Text), Convert.ToDecimal ("0"), Utility.ConvertToDecimal(((TextBox)row.Cells[3].Controls[0]).Text), Utility.ConvertToDecimal(((TextBox)row.Cells[5].Controls[0]).Text), MySessionManager.AppID, Convert.ToInt32(((Label)row.Cells[0].Controls[0]).Text) ); } } i++; } } catch (Exception ex) { tran.Rollback(); } finally { conn.Close(); } }
public void UpdatePaymentPlan(string AppID) { SqlCommand cmd = new SqlCommand(); SqlCommand cmd2; SqlConnection conn = new SqlConnection(Utility.connectionString); byte cmtype = 3; cmd.CommandText = "delete tblBLPaymentPlan where accountid=" + AppID + ""; cmd.Connection = conn; cmd.CommandType = CommandType.Text; SqlTransaction tran = null; try { conn.Open(); tran = conn.BeginTransaction(); cmd.Transaction = tran; cmd.ExecuteNonQuery(); int i = 0; foreach (HtmlTableRow row in this.TABLE1.Rows) { string labelstring = "lblMonth"; string newlbl = labelstring + i.ToString(); Control ctrl = null; if (i > 1) { if (row.Cells.Count > 0) { ctrl = row.Cells[1].Controls[0]; } } if (ctrl != null) { if (i > 1) { #region obsolete //datarow.AccountID = accountid; //datarow.MonthName = ((Label)row.Cells[0].Controls[0]).Text; //datarow.MonthIndex = Convert.ToByte(i - 1); //datarow.Repayment = Utility.ConvertToDouble(((TextBox)row.Cells[4].Controls[0]).Text).ToString(); //datarow.AmountOutstanding = Utility.ConvertToDouble(((TextBox)row.Cells[5].Controls[0]).Text).ToString(); //datarow.Ir = Utility.ConvertToDecimal(((TextBox)row.Cells[2].Controls[0]).Text); //datarow.BalanceBF = Utility.ConvertToDecimal(((TextBox)row.Cells[1].Controls[0]).Text); //datarow.Loan_Interest = Utility.ConvertToDecimal(((TextBox)row.Cells[3].Controls[0]).Text); //datarow.RType = cmtype; #endregion LoanDSTableAdapters.PaymentPlanTableAdapter plan = new LoanDSTableAdapters.PaymentPlanTableAdapter(); plan.InsertPaymentPlan(Convert.ToDateTime(((Label)row.Cells[0].Controls[0]).Text), Convert.ToDecimal(Utility.ConvertToDecimal(((TextBox)row.Cells[1].Controls[0]).Text)), Utility.ConvertToDecimal(((TextBox)row.Cells[2].Controls[0]).Text), Utility.ConvertToDecimal(((TextBox)row.Cells[2].Controls[0]).Text), Convert.ToDecimal("0"), Utility.ConvertToDecimal(((TextBox)row.Cells[3].Controls[0]).Text), Utility.ConvertToDecimal(((TextBox)row.Cells[5].Controls[0]).Text), MySessionManager.AppID, Convert.ToInt32(((Label)row.Cells[0].Controls[0]).Text) ); } } i++; } } catch (Exception ex) { tran.Rollback(); } finally { conn.Close(); } }
public void AddPaymentPlan() { LoanDSTableAdapters.PaymentPlanTableAdapter plan = new LoanDSTableAdapters.PaymentPlanTableAdapter(); LoanDS.PaymentPlanDataTable tbl = new LoanDS.PaymentPlanDataTable(); LoanDS.PaymentPlanRow datarow; long AppID = MySessionManager.AppID; int i = 0; DeletePaymentPlan(); foreach (HtmlTableRow row in this.TABLE1.Rows) { string labelstring = "lblMonth"; string newlbl = labelstring + i.ToString(); Control ctrl = null; if (i > 1) { if (row.Cells.Count > 0) ctrl = row.Cells[1].Controls[0]; } if (ctrl != null) { if (i > 1) { datarow = tbl.NewPaymentPlanRow(); datarow.datApplicationID = MySessionManager .AppID; datarow.datMonth = Convert.ToDateTime(((Label)row.Cells[0].Controls[0]).Text); datarow.datMonthIndex = Convert.ToInt32(i - 1); datarow.datMonthlyPayment = Utility.ConvertToDecimal(((TextBox)row.Cells[5].Controls[0]).Text); datarow.datOutstanding = Utility.ConvertToDecimal(((TextBox)row.Cells[6].Controls[0]).Text); datarow.datInterest1 = Utility.ConvertToDecimal(((TextBox)row.Cells[3].Controls[0]).Text); datarow.datBalanceBF = Utility.ConvertToDecimal(((TextBox)row.Cells[1].Controls[0]).Text); datarow.datPrincipalComponent = Utility.ConvertToDecimal(((TextBox)row.Cells[5].Controls[0]).Text) - Utility.ConvertToDecimal(((TextBox)row.Cells[3].Controls[0]).Text); tbl.Rows.Add(datarow); plan.InsertPaymentPlan( Convert.ToDateTime(datarow.datMonth), Convert.ToDecimal(datarow.datBalanceBF), Convert.ToDecimal(datarow.datInterest1), Convert.ToDecimal(datarow.datMonthlyPayment), Convert.ToDecimal("0.0"), Convert.ToDecimal(datarow.datPrincipalComponent.ToString()), Convert.ToDecimal(datarow.datOutstanding.ToString()), MySessionManager.AppID, Convert.ToInt32(datarow.datMonthIndex.ToString())); } } i++; } }
public void AddPaymentPlan() { LoanDSTableAdapters.PaymentPlanTableAdapter plan = new LoanDSTableAdapters.PaymentPlanTableAdapter(); LoanDS.PaymentPlanDataTable tbl = new LoanDS.PaymentPlanDataTable(); LoanDS.PaymentPlanRow datarow; long AppID = MySessionManager.AppID; int i = 0; DeletePaymentPlan(); foreach (HtmlTableRow row in this.TABLE1.Rows) { string labelstring = "lblMonth"; string newlbl = labelstring + i.ToString(); Control ctrl = null; if (i > 1) { if (row.Cells.Count > 0) { ctrl = row.Cells[1].Controls[0]; } } if (ctrl != null) { if (i > 1) { datarow = tbl.NewPaymentPlanRow(); datarow.datApplicationID = MySessionManager.AppID; datarow.datMonth = Convert.ToDateTime(((Label)row.Cells[0].Controls[0]).Text); datarow.datMonthIndex = Convert.ToInt32(i - 1); datarow.datMonthlyPayment = Utility.ConvertToDecimal(((TextBox)row.Cells[5].Controls[0]).Text); datarow.datOutstanding = Utility.ConvertToDecimal(((TextBox)row.Cells[6].Controls[0]).Text); datarow.datInterest1 = Utility.ConvertToDecimal(((TextBox)row.Cells[3].Controls[0]).Text); datarow.datBalanceBF = Utility.ConvertToDecimal(((TextBox)row.Cells[1].Controls[0]).Text); datarow.datPrincipalComponent = Utility.ConvertToDecimal(((TextBox)row.Cells[5].Controls[0]).Text) - Utility.ConvertToDecimal(((TextBox)row.Cells[3].Controls[0]).Text); tbl.Rows.Add(datarow); plan.InsertPaymentPlan(Convert.ToDateTime(datarow.datMonth), Convert.ToDecimal(datarow.datBalanceBF), Convert.ToDecimal(datarow.datInterest1), Convert.ToDecimal(datarow.datMonthlyPayment), Convert.ToDecimal("0.0"), Convert.ToDecimal(datarow.datPrincipalComponent.ToString()), Convert.ToDecimal(datarow.datOutstanding.ToString()), MySessionManager.AppID, Convert.ToInt32(datarow.datMonthIndex.ToString())); } } i++; } }