public CustomerBooking Fill(System.Data.DataRow item) { if (item == null) return null; CustomerBooking customerBooking = new CustomerBooking(); customerBooking.CustomerID = item.GetIntValue("CustomerID"); customerBooking.BookingRef = item.GetValue("BookingRef"); customerBooking.BookingDate = item.GetDateTimeValue("BookingDate"); customerBooking.BookingID = item.GetIntValue("BookingID"); customerBooking.DropPoint = item.GetValue("DropPoint"); customerBooking.PickupPoint = item.GetValue("PickupPoint"); customerBooking.FromDate = item.GetDateTimeValue("FromDate"); customerBooking.ToDate = item.GetDateTimeValue("ToDate"); customerBooking.Phone = item.GetValue("Phone"); customerBooking.AltPhone = item.GetValue("AltPhone"); customerBooking.GuestName = item.GetValue("GuestName"); customerBooking.CustomerName = item.GetValue("CustomerName"); customerBooking.BillingDetails = new CustomerBilling(); customerBooking.BillingDetails.BillingID = item.GetIntValue("BillingID"); customerBooking.BillingDetails.BookingID = customerBooking.BookingID; customerBooking.BillingDetails.DutySlipDate = item.GetDateTimeValue("DutySlipDate"); customerBooking.BillingDetails.DutySlipNo = item.GetValue("DutySlipNo"); customerBooking.BillingDetails.InMeterReading = item.GetLongValue("InMeterReading"); customerBooking.BillingDetails.OutMeterReading = item.GetLongValue("OutMeterReading"); customerBooking.BillingDetails.Discount = Math.Round(item.GetDecimalValue("Discount") ?? 0, 2); customerBooking.BillingDetails.GrossAmount = Math.Round(item.GetDecimalValue("GrossAmount") ?? 0, 2); customerBooking.BillingDetails.TotalAmount = Math.Round(item.GetDecimalValue("TotalAmount") ?? 0, 2); customerBooking.BillingDetails.TariffID = item.GetIntValue("TariffID"); customerBooking.TariffDetails = new Tariff(); customerBooking.TariffDetails.TariffID = customerBooking.BillingDetails.TariffID; customerBooking.TariffDetails.TariffCode = item.GetValue("TariffCode"); customerBooking.TariffDetails.StandCharges = Math.Round(item.GetDecimalValue("StandCharges") ?? 0,2); customerBooking.TariffDetails.BasePrice = Math.Round(item.GetDecimalValue("BasePrice") ?? 0,2); customerBooking.TariffDetails.ExtraHourRate = Math.Round(item.GetDecimalValue("ExtraHourRate") ?? 0,2); customerBooking.TariffDetails.ExtraKmRate = Math.Round(item.GetDecimalValue("ExtraKmRate") ?? 0,2); customerBooking.TariffDetails.Kms = item.GetIntValue("Kms"); return customerBooking; }
private void GetBooking() { try { pendingBookingsForBilling = Session["PendingBookingsForBilling"] as List<CustomerBooking>; if (pendingBookingsForBilling == null) pendingBookingsForBilling = customerBookingService.GetPendingBookingsForBilling(); if (pendingBookingsForBilling != null) { int selBookingId = int.Parse(ddlBookingRef.SelectedValue); if (selBookingId > 0) { CurrentBooking = pendingBookingsForBilling.FirstOrDefault(b => b.BookingID == selBookingId); } } else { lblMessage.Text = "NO Pending Booking exists in the system for payment"; lblMessage.Visible = true; } } catch (Exception e) { } }
protected void btnSubmit_Click(object sender, EventArgs e) { //check if we have available vehicle int vehicleType = int.Parse(ddlVehicletype.SelectedValue); int fuelType = int.Parse(ddlFueltype.SelectedValue); bool ac = int.Parse(ddlAc.SelectedValue) == (int)FleetManagement.Enums.YesNo.Yes ? true:false; DateTime fromDate = txtFromdate.Text.ToDateTime(); DateTime toDate = txtTodate.Text.ToDateTime(); bool driverNeeded = chkDriverNeeded.Checked; int vehicleToAllocate = 0, tariffID = 0; int? driverToAllocate = null; VehicleAvailabilityStatus vehicleAvailStatus = vehicleService.ChooseVehicleForAllocation(vehicleType, fuelType, ac,driverNeeded, fromDate, toDate, out vehicleToAllocate, out driverToAllocate,out tariffID); if (vehicleAvailStatus == VehicleAvailabilityStatus.NONE) { lblMessage.Text = "No vehicles are available for booking for selected dates"; lblMessage.Visible = true; return; } else if (vehicleAvailStatus == VehicleAvailabilityStatus.AllBooked) { lblMessage.Text = "No vehicles are available for booking for selected dates"; lblMessage.Visible = true; return; } else if (vehicleAvailStatus == VehicleAvailabilityStatus.NotAvailableForSelectedOptions) { lblMessage.Text = "No vehicles are available for selected options (Vehicle name, AC and FuelType). Try changing the options!"; lblMessage.Visible = true; return; } else if (vehicleAvailStatus == VehicleAvailabilityStatus.NoDriverAvailable) { lblMessage.Text = "No Driver available. If you want to book without driver, please uncheck the Driver Needed checkbox and proceed!"; lblMessage.Visible = true; return; } else if (vehicleAvailStatus == VehicleAvailabilityStatus.Available) { CustomerBooking customerBooking = new CustomerBooking(); customerBooking.FromDate = fromDate; customerBooking.ToDate = toDate; customerBooking.Phone = txtPhoneno.Text; customerBooking.PickupPoint = txtPickup.Text; customerBooking.DropPoint = txtDroppoint.Text; customerBooking.GuestName = txtGuestname.Text; customerBooking.CustomerID = int.Parse(ddlCustomername.SelectedValue); customerBooking.BillingDetails = new CustomerBilling(); customerBooking.BillingDetails.TariffID = tariffID; FleetManagement.Entities.VehicleAllocation vehicleAllocation = new FleetManagement.Entities.VehicleAllocation(); vehicleAllocation.VehicleID = vehicleToAllocate; vehicleAllocation.EmployeeID = driverToAllocate; int bookingId = 0; if (customerBookingService.CreateCustomerBooking(customerBooking, vehicleAllocation, out bookingId)) { //load booking again customerBooking = customerBookingService.Get(bookingId).FirstOrDefault(); lblMessage.Text = "Booking created successfully. Your booking reference no is " + customerBooking.BookingRef; clearFields(); lblMessage.Visible = true; return; } } }
public bool CreateCustomerBooking(CustomerBooking customerBooking, Entities.VehicleAllocation vehicleAllocation, out int bookingId) { bool success = false; bookingId = 0; try { List<SqlParameter> sqlParams = new List<SqlParameter>(); sqlParams.Add(new SqlParameter("CustomerID", customerBooking.CustomerID)); sqlParams.Add(new SqlParameter("PickupPoint", customerBooking.PickupPoint)); sqlParams.Add(new SqlParameter("DropPoint", customerBooking.DropPoint)); sqlParams.Add(new SqlParameter("FromDate", customerBooking.FromDate)); sqlParams.Add(new SqlParameter("ToDate", customerBooking.ToDate)); sqlParams.Add(new SqlParameter("GuestName", customerBooking.GuestName)); sqlParams.Add(new SqlParameter("Phone", customerBooking.Phone)); sqlParams.Add(new SqlParameter("VehicleID", vehicleAllocation.VehicleID)); sqlParams.Add(new SqlParameter("EmpID", vehicleAllocation.EmployeeID)); sqlParams.Add(new SqlParameter("TariffID", customerBooking.BillingDetails.TariffID)); object objBookingId = SqlHelper.ExecuteScalar("Create_CustomerBooking", sqlParams.ToArray()); bookingId = Convert.ToInt32(objBookingId); if (bookingId > 0) { success = true; } } catch(Exception ex){ success = false; } return success; }
public bool Update(CustomerBooking obj) { throw new NotImplementedException(); }
public bool Insert(CustomerBooking obj) { throw new NotImplementedException(); }