private void btnAdd_Click(object sender, EventArgs e) { CollectionManager oManager = new CollectionManager(); CollectionUnit oUnit = new CollectionUnit(); oManager.ConnectionString = this.ConnectionString; oManager.Open(); oUnit.DocNum = this.LoanNumber; oUnit.RefNo = txtReferenceNo.Text; oUnit.ScheduleNo = this.ScheduledNo; oUnit.Remarks = txtRemarks.Text; oUnit.TotalPayment = Convert.ToDouble(txtAmount.Text); oUnit.DateCreated = System.DateTime.Now; oUnit.DateModified = System.DateTime.Now; oUnit.CreatedBy = this.ActiveUserID; oUnit.ModifiedBy = this.ActiveUserID; oManager.AddCollection(oUnit); oManager.Close(); this.Close(); }
public void UpdateCollection(CollectionUnit oUnit) { SqlCommand oCommand = new SqlCommand(); oCommand.Connection = this.Connection; oCommand.CommandText = "UPDATE LOAN2 SET ScheduledNo=@ScheduleNo, RefNo=@RefNo, Remarks=@Remarks, TotalBalance=@TotalBalance, TotalPayment=@TotalPayment, DateCreated=@DateCreated, CreatedBy=@CreatedBy, DateModified=@DateModified, ModifiedBy=@ModifiedBy WHERE DocNum=@DocNum"; oCommand.Parameters.Add(new SqlParameter("@DocNum", oUnit.DocNum)); oCommand.Parameters.Add(new SqlParameter("@ScheduleNo", oUnit.ScheduleNo)); oCommand.Parameters.Add(new SqlParameter("@RefNo", oUnit.RefNo)); oCommand.Parameters.Add(new SqlParameter("@Remarks", oUnit.Remarks)); oCommand.Parameters.Add(new SqlParameter("@TotalBalance", oUnit.TotalBalance)); oCommand.Parameters.Add(new SqlParameter("@TotalPayment", oUnit.TotalPayment)); oCommand.Parameters.Add(new SqlParameter("@DateCreated", oUnit.DateCreated)); oCommand.Parameters.Add(new SqlParameter("@CreatedBy", oUnit.CreatedBy)); oCommand.Parameters.Add(new SqlParameter("@DateModified", oUnit.DateModified)); oCommand.Parameters.Add(new SqlParameter("@ModifiedBy", oUnit.ModifiedBy)); oCommand.ExecuteNonQuery(); }
public void AddCollection(CollectionUnit oUnit) { SqlCommand oCommand = new SqlCommand(); oCommand.Connection = this.Connection; oCommand.CommandText = "INSERT LOAN2 (DocNum, ScheduledNo, RefNo, Remarks, TotalBalance, TotalPayment, DateCreated, CreatedBy, DateModified, ModifiedBy) VALUES (@DocNum, @ScheduleNo, @RefNo, @Remarks, @TotalBalance, @TotalPayment, @DateCreated, @CreatedBy, @DateModified, @ModifiedBy)"; oCommand.Parameters.Add(new SqlParameter("@DocNum", oUnit.DocNum)); oCommand.Parameters.Add(new SqlParameter("@ScheduleNo", oUnit.ScheduleNo)); oCommand.Parameters.Add(new SqlParameter("@RefNo", oUnit.RefNo)); oCommand.Parameters.Add(new SqlParameter("@Remarks", oUnit.Remarks)); oCommand.Parameters.Add(new SqlParameter("@TotalBalance", oUnit.TotalBalance)); oCommand.Parameters.Add(new SqlParameter("@TotalPayment", oUnit.TotalPayment)); oCommand.Parameters.Add(new SqlParameter("@DateCreated", oUnit.DateCreated)); oCommand.Parameters.Add(new SqlParameter("@CreatedBy", oUnit.CreatedBy)); oCommand.Parameters.Add(new SqlParameter("@DateModified", oUnit.DateModified)); oCommand.Parameters.Add(new SqlParameter("@ModifiedBy", oUnit.ModifiedBy)); oCommand.ExecuteNonQuery(); }