public double GetDepositAmount(int bookingID) { double depositAmount = 0; double totalAmount = 0; string rates = null; DateTime arriveDate = DateTime.Now; DateTime departDate = DateTime.Now; SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@BookingID", bookingID) }; using (DataTable table = DBHelper.ExecuteParamerizedSelectCommand("sp_GetDepositAmount", CommandType.StoredProcedure, parameters)) { if (table.Rows.Count >= 1) { DataRow row = table.Rows[0]; rates = row["Rates"].ToString(); arriveDate = Convert.ToDateTime(row["ArriveDate"]); departDate = Convert.ToDateTime(row["DepartDate"]); } } double noOfDays = (departDate - arriveDate).TotalDays; string[] seperateRates = rates.Split('#'); int rateCount = seperateRates.Count(); for (int i = 0; i < rateCount - 1; i++) { totalAmount += (Convert.ToDouble(seperateRates[i])) * noOfDays; } BusinessDBAccess businessDBAccess = new BusinessDBAccess(); Business business = businessDBAccess.GetBusinessDetails(); double depositPercent = business.DepositPercent; depositPercent = depositPercent / 100; depositAmount = totalAmount * depositPercent; return depositAmount; }
public BusinessHandler() { businessDB = new BusinessDBAccess(); }