public void UpdateBill(BillItem Item) { using (var db = Connection.CreateConnection()) { db.Open(); var sql = "dbo.spUpdateBill"; var cmd = new SqlCommand(sql, db); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@TotalAmount", Item.Bill_TotalAmount)); cmd.Parameters.Add(new SqlParameter("@Discount", Item.Bill_Discount)); cmd.Parameters.Add(new SqlParameter("@FinalAmount", Item.Bill_FinalAmount)); cmd.Parameters.Add(new SqlParameter("@PayMade", Item.Bill_PaymentMade)); cmd.Parameters.Add(new SqlParameter("@Balance", Item.Bill_Balance)); cmd.Parameters.Add(new SqlParameter("@Semester", Item.Bill_Semester)); cmd.Parameters.Add(new SqlParameter("@SchoolYear", Item.Bill_SchoolYear)); cmd.Parameters.Add(new SqlParameter("@DueDate", Item.Bill_DueDate)); cmd.Parameters.Add(new SqlParameter("@DatePaid", Item.Bill_DatePaid)); cmd.Parameters.Add(new SqlParameter("@Status", Item.Bill_Status)); cmd.Parameters.Add(new SqlParameter("@BillId", Item.Bill_Id)); cmd.ExecuteNonQuery(); db.Close(); } }
public void LoadJoinOldPartialPaymentsFromDb(int stdId) { paymentCollect = new List <PaymentItem>(); partialCollect = new List <PartialPaymentItem>(); billCollect = new List <BillItem>(); paymentCollect.Clear(); partialCollect.Clear(); billCollect.Clear(); using (var db = Connection.CreateConnection()) { db.Open(); var sql = "dbo.spJoinPartialPaymentsOld"; var cmd = new SqlCommand(sql, db); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@StdId", stdId)); var reader = cmd.ExecuteReader(); if (!reader.HasRows) { return; } while (reader.Read()) { var item = new PaymentItem(); var item2 = new PartialPaymentItem(); var item3 = new BillItem(); item.Payment_Id = Int32.Parse(reader["Payment_Id"].ToString()); item.Payment_PartPay_Id = Int32.Parse(reader["Payment_PartPay_Id"].ToString()); item.Payment_Bill_Id = Int32.Parse(reader["Payment_Bill_Id"].ToString()); item.Payment_Std_Id = Int32.Parse(reader["Payment_Std_Id"].ToString()); item.Payment_Number = Int32.Parse(reader["Payment_Number"].ToString()); item.Payment_Paid = Decimal.Parse(reader["Payment_Paid"].ToString()); item.Payment_DatePaid = reader["Payment_DatePaid"].ToString(); item.Payment_Deleted = reader["Payment_Deleted"].ToString(); item2.PartPay_Id = Int32.Parse(reader["PartPay_Id"].ToString()); item2.PartPay_Bill_Id = Int32.Parse(reader["PartPay_Bill_Id"].ToString()); item2.PartPay_Std_Id = Int32.Parse(reader["PartPay_Std_Id"].ToString()); item2.PartPay_Partition = reader["PartPay_Partition"].ToString(); item2.PartPay_Amount = Decimal.Parse(reader["PartPay_Amount"].ToString()); item2.PartPay_Balance = Decimal.Parse(reader["PartPay_Balance"].ToString()); item2.PartPay_DueDate = reader["PartPay_DueDate"].ToString(); item2.PartPay_DatePaid = reader["PartPay_DatePaid"].ToString(); item2.PartPay_PaymentMade = Decimal.Parse(reader["PartPay_PaymentMade"].ToString()); item2.PartPay_Status = reader["PartPay_Status"].ToString(); item2.PartPay_Deleted = reader["PartPay_Deleted"].ToString(); item3.Bill_Id = Int32.Parse(reader["Bill_Id"].ToString()); paymentCollect.Add(item); partialCollect.Add(item2); billCollect.Add(item3); } db.Close(); } }
public void SaveBill(BillItem billItem) { using (var db = Connection.CreateConnection()) { db.Open(); var sql = "dbo.spInsertBill"; var cmd = new SqlCommand(sql, db); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@BillStdId", billItem.Bill_Std_Id)); cmd.Parameters.Add(new SqlParameter("@BillDescription", billItem.Bill_Description)); cmd.Parameters.Add(new SqlParameter("@BillTotalAmount", billItem.Bill_TotalAmount)); cmd.Parameters.Add(new SqlParameter("@BillFinalAmount", billItem.Bill_FinalAmount)); cmd.Parameters.Add(new SqlParameter("@BillDiscount", billItem.Bill_Discount)); cmd.Parameters.Add(new SqlParameter("@BillStatus", billItem.Bill_Status)); cmd.Parameters.Add(new SqlParameter("@BillPaymentMade", billItem.Bill_PaymentMade)); cmd.Parameters.Add(new SqlParameter("@BillDatePaid", billItem.Bill_DatePaid)); cmd.Parameters.Add(new SqlParameter("@BillBalance", billItem.Bill_Balance)); cmd.Parameters.Add(new SqlParameter("@BillSemester", billItem.Bill_Semester)); cmd.Parameters.Add(new SqlParameter("@BillSchoolYear", billItem.Bill_SchoolYear)); cmd.Parameters.Add(new SqlParameter("@BillDueDate", billItem.Bill_DueDate)); cmd.Parameters.Add(new SqlParameter("@BillIsOld", billItem.Bill_IsOld)); cmd.Parameters.Add(new SqlParameter("@BillDeleted", billItem.Bill_Deleted)); myReturnedID = int.Parse(cmd.ExecuteScalar().ToString()); db.Close(); } }
public void LoadBillWithStdIdFromDb(int stdId) { billCollect = new List <BillItem>(); billCollect.Clear(); using (var db = Connection.CreateConnection()) { db.Open(); var sql = "dbo.spLoadBillWithStdId"; var cmd = new SqlCommand(sql, db); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@StdId", stdId)); var reader = cmd.ExecuteReader(); if (!reader.HasRows) { return; } while (reader.Read()) { var item = new BillItem(); item.Bill_Id = Int32.Parse(reader["Bill_Id"].ToString()); item.Bill_Std_Id = Int32.Parse(reader["Bill_Std_Id"].ToString()); item.Bill_Description = reader["Bill_Description"].ToString(); item.Bill_TotalAmount = Decimal.Parse(reader["Bill_TotalAmount"].ToString()); item.Bill_Discount = Int32.Parse(reader["Bill_Discount"].ToString()); item.Bill_FinalAmount = Decimal.Parse(reader["Bill_FinalAmount"].ToString()); item.Bill_Status = reader["Bill_Status"].ToString(); item.Bill_PaymentMade = Decimal.Parse(reader["Bill_PaymentMade"].ToString()); item.Bill_DatePaid = reader["Bill_DatePaid"].ToString(); item.Bill_Balance = Decimal.Parse(reader["Bill_Balance"].ToString()); item.Bill_Semester = reader["Bill_Semester"].ToString(); item.Bill_SchoolYear = reader["Bill_SchoolYear"].ToString(); item.Bill_DueDate = reader["Bill_DueDate"].ToString(); item.Bill_IsOld = reader["Bill_IsOld"].ToString(); item.Bill_Deleted = reader["Bill_Deleted"].ToString(); billCollect.Add(item); LoginUser.stdLogStudentBillId = item.Bill_Id.ToString(); } db.Close(); } }
public void LoadBillFromDb() { billCollect = new List <BillItem>(); billCollect.Clear(); using (var db = Connection.CreateConnection()) { db.Open(); var sql = "dbo.spLoadBill"; var cmd = new SqlCommand(sql, db); var reader = cmd.ExecuteReader(); if (!reader.HasRows) { return; } while (reader.Read()) { var item = new BillItem(); item.Bill_Id = Int32.Parse(reader["Bill_Id"].ToString()); item.Bill_Std_Id = Int32.Parse(reader["Bill_Std_Id"].ToString()); item.Bill_Description = reader["Bill_Description"].ToString(); item.Bill_TotalAmount = Decimal.Parse(reader["Bill_TotalAmount"].ToString()); item.Bill_Discount = Int32.Parse(reader["Bill_Discount"].ToString()); item.Bill_Status = reader["Bill_Status"].ToString(); item.Bill_PaymentMade = Decimal.Parse(reader["Bill_PaymentMade"].ToString()); item.Bill_DatePaid = reader["Bill_DatePaid"].ToString(); item.Bill_Balance = Decimal.Parse(reader["Bill_Balance"].ToString()); item.Bill_Semester = reader["Bill_Semester"].ToString(); item.Bill_SchoolYear = reader["Bill_SchoolYear"].ToString(); item.Bill_DueDate = reader["Bill_DueDate"].ToString(); item.Bill_IsOld = reader["Bill_IsOld"].ToString(); item.Bill_Deleted = reader["Bill_Deleted"].ToString(); billCollect.Add(item); } db.Close(); } }