Exemplo n.º 1
0
        private bool updateDriverRoute(DriverCompDS.DriverRouteTableRow route)
        {
            //Update a driver route
            bool result = false;

            try {
                //Update the specified route
                route.LastUpdated = DateTime.Now;
                route.UserID      = Environment.UserName;
                object exported = null;
                if (!route.IsExportedNull())
                {
                    exported = route.Exported;
                }
                result = this.mMediator.ExecuteNonQuery(App.USP_ROUTEUPDATE, new object[] {
                    route.RouteDate, route.RouteName, route.AgentNumber, route.Operator,
                    route.AdjustmentAmount1, route.AdjustmentAmount1TypeID,
                    route.AdjustmentAmount2, route.AdjustmentAmount2TypeID,
                    0.0, 0,
                    route.AdminCharge, route.TotalAmount, exported,
                    route.LastUpdated, route.UserID
                });
            }
            catch (ApplicationException ex) { throw ex; }
            catch (Exception ex) { throw new ApplicationException("Unexpected error while updating driver route...", ex); }
            return(result);
        }
Exemplo n.º 2
0
        public void RefreshDriverRoutes()
        {
            //Add all driver routes (from database) to the compensation
            try {
                this.mCompDS.Clear();
                this.mCompDS.DriverRouteTable.BeginLoadData();
                DriverCompDS routes = readDriverRoutes();
                for (int i = 0; i < routes.DriverRouteTable.Rows.Count; i++)
                {
                    //Iterate through each saved route and build the viewable dataset (this.mCompDS)
                    DriverCompDS.DriverRouteTableRow _route = (DriverCompDS.DriverRouteTableRow)routes.DriverRouteTable.Rows[i];
                    if (this.mCompDS.DriverCompTable.Select("Operator='" + _route.Operator + "'").Length == 0)
                    {
                        //Operator not added yet- add the summary record for this operator
                        DriverCompDS.DriverCompTableRow sumComp = this.mCompDS.DriverCompTable.NewDriverCompTableRow();
                        #region Set members
                        sumComp.Select          = _route.IsExportedNull();
                        sumComp.IsNew           = sumComp.IsCombo = sumComp.IsAdjust = false;
                        sumComp.AgentNumber     = _route.AgentNumber;
                        sumComp.FinanceVendorID = _route.FinanceVendorID;
                        sumComp.FinanceVendor   = _route.Payee;
                        sumComp.Operator        = _route.Operator;
                        //sumComp.EquipmentTypeID = _route.EquipmentTypeID;
                        sumComp.Miles         = sumComp.Trip = sumComp.Stops = sumComp.Cartons = sumComp.Pallets = sumComp.PickupCartons = 0;
                        sumComp.MilesAmount   = sumComp.DayAmount = sumComp.TripAmount = sumComp.StopsAmount = sumComp.CartonsAmount = sumComp.PalletsAmount = sumComp.PickupCartonsAmount = sumComp.Amount = 0.0M;
                        sumComp.FSCMiles      = 0;
                        sumComp.FuelCost      = sumComp.FSCGal = sumComp.FSCBaseRate = sumComp.FSC = 0.0M;
                        sumComp.MinimunAmount = sumComp.AdminCharge = sumComp.AdjustmentAmount1 = sumComp.AdjustmentAmount2 = sumComp.TotalAmount = 0.0M;
                        #endregion
                        this.mCompDS.DriverCompTable.AddDriverCompTableRow(sumComp);

                        //Add all routes for this operator
                        DriverCompDS.DriverRouteTableRow[] _routes = (DriverCompDS.DriverRouteTableRow[])routes.DriverRouteTable.Select("AgentNumber=" + _route.AgentNumber + " AND Operator='" + _route.Operator + "'");
                        for (int j = 0; j < _routes.Length; j++)
                        {
                            DriverCompDS.DriverRouteTableRow dayComp = this.mCompDS.DriverRouteTable.NewDriverRouteTableRow();
                            #region Set members
                            dayComp.ID                      = _routes[j].ID;
                            dayComp.IsNew                   = _routes[j].IsNew;
                            dayComp.IsCombo                 = (routes.DriverRouteTable.Select("Operator='" + _route.Operator + "' AND RouteDate='" + _routes[j].RouteDate + "'").Length > 1);
                            dayComp.IsAdjust                = _routes[j].RouteName.Contains("ADJUST");
                            dayComp.AgentNumber             = _routes[j].AgentNumber;
                            dayComp.FinanceVendorID         = _routes[j].FinanceVendorID;
                            dayComp.EquipmentTypeID         = _routes[j].EquipmentTypeID;
                            dayComp.RouteDate               = _routes[j].RouteDate;
                            dayComp.RouteName               = _routes[j].RouteName;
                            dayComp.Operator                = _routes[j].Operator;
                            dayComp.Payee                   = _routes[j].Payee;
                            dayComp.RateTypeID              = _routes[j].RateTypeID;
                            dayComp.Miles                   = _routes[j].Miles;
                            dayComp.MilesBaseRate           = _routes[j].MilesBaseRate;
                            dayComp.MilesRate               = _routes[j].MilesRate;
                            dayComp.MilesAmount             = _routes[j].MilesAmount;
                            dayComp.DayRate                 = _routes[j].DayRate;
                            dayComp.DayAmount               = _routes[j].DayAmount;
                            dayComp.Trip                    = _routes[j].Trip;
                            dayComp.TripRate                = _routes[j].TripRate;
                            dayComp.TripAmount              = _routes[j].TripAmount;
                            dayComp.Stops                   = _routes[j].Stops;
                            dayComp.StopsRate               = _routes[j].StopsRate;
                            dayComp.StopsAmount             = _routes[j].StopsAmount;
                            dayComp.Cartons                 = _routes[j].Cartons;
                            dayComp.CartonsRate             = _routes[j].CartonsRate;
                            dayComp.CartonsAmount           = _routes[j].CartonsAmount;
                            dayComp.Pallets                 = _routes[j].Pallets;
                            dayComp.PalletsRate             = _routes[j].PalletsRate;
                            dayComp.PalletsAmount           = _routes[j].PalletsAmount;
                            dayComp.PickupCartons           = _routes[j].PickupCartons;
                            dayComp.PickupCartonsRate       = _routes[j].PickupCartonsRate;
                            dayComp.PickupCartonsAmount     = _routes[j].PickupCartonsAmount;
                            dayComp.FSCMiles                = _routes[j].IsFSCMilesNull() ? 0 : _routes[j].FSCMiles;
                            dayComp.FuelCost                = _routes[j].FuelCost;
                            dayComp.FSCGal                  = _routes[j].FSCGal;
                            dayComp.FSCBaseRate             = _routes[j].FSCBaseRate;
                            dayComp.FSC                     = _routes[j].FSC;
                            dayComp.MinimunAmount           = _routes[j].MinimunAmount;
                            dayComp.AdminCharge             = _routes[j].AdminCharge;
                            dayComp.AdjustmentAmount1       = _routes[j].AdjustmentAmount1;
                            dayComp.AdjustmentAmount1TypeID = _routes[j].AdjustmentAmount1TypeID;
                            dayComp.AdjustmentAmount2       = _routes[j].AdjustmentAmount2;
                            dayComp.AdjustmentAmount2TypeID = _routes[j].AdjustmentAmount2TypeID;
                            dayComp.TotalAmount             = _routes[j].TotalAmount;
                            dayComp.Imported                = _routes[j].Imported;
                            if (!_routes[j].IsExportedNull())
                            {
                                dayComp.Exported = _routes[j].Exported;
                            }
                            dayComp.LastUpdated = _routes[j].LastUpdated;
                            dayComp.UserID      = _routes[j].UserID;
                            #endregion
                            this.mCompDS.DriverRouteTable.AddDriverRouteTableRow(dayComp);
                        }
                        //Compute summary compensation
                        UpdateSummary(_route.Operator);
                    }
                }
                this.mCompDS.AcceptChanges();
                this.mCompDS.DriverRouteTable.EndLoadData();
            }
            catch (ApplicationException ex) { throw ex; }
            catch (Exception ex) { throw new ApplicationException("Unexpected error...", ex); }
            finally { if (this.DriverRoutesChanged != null)
                      {
                          this.DriverRoutesChanged(this, EventArgs.Empty);
                      }
            }
        }