Exemple #1
0
        public void SaveDriverExpense()
        {
            var driverCost = 0.0;

            try
            {
                driverCost = Double.Parse(txtDriverCost.Text);
            }
            catch { }
            var driverExpenseId = -1;

            try
            {
                driverExpenseId = Int32.Parse(hidExpenseDriverId.Value);
            }
            catch { }
            var driverExpense = TransferRequestByDateBLL.ExpenseGetById(driverExpenseId);

            if (driverExpense == null)
            {
                driverExpense = new Expense();
            }
            driverExpense.BusByDate = BusByDate;
            driverExpense.Name      = txtDriverName.Text;
            driverExpense.Phone     = txtDriverPhone.Text;
            driverExpense.Cost      = driverCost;
            driverExpense.Type      = "Drivers";
            driverExpense.Date      = Date.HasValue ? Date.Value : DateTime.Today;
            TransferRequestByDateBLL.ExpenseSaveOrUpdate(driverExpense);
            var expenseService = TransferRequestByDateBLL.ExpenseServiceGetByExpenseId(driverExpenseId);

            if (expenseService == null)
            {
                expenseService = new ExpenseService();
            }
            var listCostType    = TransferRequestByDateBLL.CostTypeGetAll().Future().ToList();
            var expenseTypeNull = TransferRequestByDateBLL.ExpenseGetAllByCriterion(BusByDate.Date).Where(z => z.Type == null).FutureValue().Value;

            expenseService.Cost         = driverExpense.Cost;
            expenseService.Name         = driverExpense.BusByDate != null ? driverExpense.BusByDate.Driver_Name : "";
            expenseService.Type         = listCostType.Where(z => z.Name == "Driver").FirstOrDefault();
            expenseService.Expense      = expenseTypeNull;
            expenseService.ExpenseIdRef = driverExpense.Id;
            TransferRequestByDateBLL.ExpenseServiceSaveOrUpdate(expenseService);
            BusByDate.Driver_Name  = txtDriverName.Text;
            BusByDate.Driver_Phone = txtDriverPhone.Text;
            TransferRequestByDateBLL.BusByDateSaveOrUpdate(BusByDate);
        }
Exemple #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         var listTransportBooking = TransferRequestByDateBLL.BookingGetAllByCriterionTransfer(BusType, Route, Way, Date)
                                    .Future()
                                    .ToList()
                                    .Where(x => x.ListBookingBusByDate
                                           .Where(y => y.BusByDate != null && y.BusByDate.Route.Way == Route.Way &&
                                                  y.BusByDate.Route.Group == Route.Group &&
                                                  y.BusByDate.Group == Group)
                                           .ToList().Count > 0).ToList();
         if (BusType.Name == "Standard")
         {
             var listBookingUpgraded = new List <Booking>();
             listTransportBooking.ForEach(standardBooking =>
             {
                 var bookingUpgraded = standardBooking.ListBookingBusByDate
                                       .Any(x => x.BusByDate.BusType.Id != standardBooking.Transfer_BusType.Id);
                 if (bookingUpgraded)
                 {
                     listBookingUpgraded.Add(standardBooking);
                 }
             });
             listTransportBooking = listTransportBooking.Except(listBookingUpgraded).ToList();
         }
         if (BusType.Name == "Limousine")
         {
             var standardBusType = TransferRequestByDateBLL.BusTypeGetAll()
                                   .Future()
                                   .ToList()
                                   .Where(x => x.Name == "Standard")
                                   .SingleOrDefault();
             var listStandardTransportBooking = TransferRequestByDateBLL.BookingGetAllByCriterionTransfer(standardBusType, Route, Way, Date)
                                                .Future()
                                                .ToList()
                                                .Where(x => x.ListBookingBusByDate
                                                       .Where(y => y.BusByDate != null && y.BusByDate.BusType.Name == "Limousine" &&
                                                              y.BusByDate.Route.Way == Route.Way &&
                                                              y.BusByDate.Route.Group == Route.Group &&
                                                              y.BusByDate.Group == Group)
                                                       .ToList()
                                                       .Count > 0).ToList();
             listStandardTransportBooking.ForEach(standardTransportBooking =>
             {
                 standardTransportBooking.Transfer_Upgraded = true;
                 listTransportBooking.Add(standardTransportBooking);
             });
         }
         rptTransportBooking.DataSource = listTransportBooking;
         rptTransportBooking.DataBind();
         rptTransportBookingWithoutGroup.DataSource = TransferRequestByDateBLL.BookingGetAllByCriterionTransfer(BusType, Route, Way, Date)
                                                      .Future()
                                                      .ToList()
                                                      .Where(x => x.ListBookingBusByDate.Count <= 0).ToList();
         rptTransportBookingWithoutGroup.DataBind();
         btnSave.Enabled = !LockingTransferBoolean;
         var driverExpense = BusByDate.ListExpense.Where(x => x.Type == "Drivers").FirstOrDefault();
         if (driverExpense != null)
         {
             hidExpenseDriverId.Value = driverExpense.Id.ToString();
             var expenseService = TransferRequestByDateBLL.ExpenseServiceGetByExpenseId(driverExpense.Id);
             txtDriverName.Text  = BusByDate.Driver_Name;
             txtDriverPhone.Text = BusByDate.Driver_Phone;
             txtDriverCost.Text  = expenseService.Cost.ToString("#,##0.##");
         }
     }
 }