Ejemplo n.º 1
0
        private void OnGridBeforeRowUpdate(object sender, Infragistics.Win.UltraWinGrid.CancelableRowEventArgs e)
        {
            //Event handler for data entry row updated
            try {
                //There is no selected row when updating- at a cell level
                string vendorID = "", operatorName = "";
                int    equipmentID = 0;
                switch (e.Row.Band.Key)
                {
                case "DriverEquipmentTable":
                    vendorID     = e.Row.Cells["FinanceVendorID"].Value.ToString();
                    operatorName = e.Row.Cells["OperatorName"].Value.ToString();
                    equipmentID  = Convert.ToInt32(e.Row.Cells["EquipmentID"].Value.ToString());
                    break;
                }

                //Add new or update existing terminal configuration
                if (vendorID.Length > 0 && operatorName.Length > 0 && equipmentID > 0)
                {
                    if (e.Row.IsAddRow)
                    {
                        FinanceGateway.CreateDriverEquipment(vendorID, operatorName, equipmentID);
                    }
                    else
                    {
                        FinanceGateway.UpdateDriverEquipment(vendorID, operatorName, equipmentID);
                    }
                }
                else
                {
                    e.Cancel = true;
                }
            }
            catch (Exception ex) { reportError(ex); }
        }
Ejemplo n.º 2
0
 private void OnControlLoad(object sender, EventArgs e)
 {
     //Event handler for control load event
     this.Cursor = Cursors.WaitCursor;
     try {
         #region Grid customizations from normal layout (to support cell editing)
         this.grdMain.DisplayLayout.Override.RowSelectors             = Infragistics.Win.DefaultableBoolean.True;
         this.grdMain.DisplayLayout.Override.SelectTypeRow            = SelectType.Single;
         this.grdMain.DisplayLayout.Override.SelectTypeCell           = SelectType.Single;
         this.grdMain.DisplayLayout.TabNavigation                     = TabNavigation.NextCell;
         this.grdMain.DisplayLayout.Override.AllowAddNew              = RoleServiceGateway.IsBillingSupervisor ? AllowAddNew.TemplateOnBottom : AllowAddNew.No;
         this.grdMain.DisplayLayout.Override.AllowUpdate              = DefaultableBoolean.True;
         this.grdMain.DisplayLayout.Override.AllowDelete              = DefaultableBoolean.False;
         this.grdMain.DisplayLayout.Override.MaxSelectedCells         = 1;
         this.grdMain.DisplayLayout.Override.CellClickAction          = CellClickAction.Edit;
         this.grdMain.DisplayLayout.Bands[0].Override.CellClickAction = CellClickAction.Edit;
         this.grdMain.DisplayLayout.Bands[0].Columns["FinanceVendorID"].SortIndicator = SortIndicator.Ascending;
         #endregion
         if (!this.DesignMode)
         {
             this.uddEquipType.DataSource    = FinanceGateway.GetDriverEquipmentTypes();
             this.uddEquipType.DataMember    = "EquipmentTypeTable";
             this.uddEquipType.DisplayMember = "Description";
             this.uddEquipType.ValueMember   = "ID";
             this.csRefresh.PerformClick();
         }
     }
     catch (Exception ex) { reportError(ex); }
     finally { this.Cursor = Cursors.Default; }
 }
Ejemplo n.º 3
0
        private void applyFSC(DriverCompDataset.DriverRouteTableRow driverRoute, RouteRates rates)
        {
            //Calculate FSC if required
            try {
                //1. FSC applies only if miles rates are present in the rating
                if (rates.MileBaseRate > 0 || rates.MileRate > 0)
                {
                    driverRoute.FSCMiles = driverRoute.Miles;
                }

                //2. Copy rates (for reference)
                driverRoute.FuelCost = this.mFuelCost;
                driverRoute.FSCGal   = FinanceGateway.GetDriverEquipmentMPG(driverRoute.EquipmentTypeID);
                if (driverRoute.FSCGal <= 0.0M)
                {
                    throw new ApplicationException("FSCGal (" + driverRoute.FSCGal.ToString() + "MPG) is invalid.");
                }
                driverRoute.FSCBaseRate = this.mTerminalConfig.FSBase;

                //3. Calculate FSC
                driverRoute.FSC = driverRoute.FSCMiles / driverRoute.FSCGal * (driverRoute.FuelCost - driverRoute.FSCBaseRate);
                if (driverRoute.FSC < 0)
                {
                    driverRoute.FSC = 0.0M;
                }
            }
            catch (ApplicationException ex) { throw ex; }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
        }
Ejemplo n.º 4
0
        public void ImportRoutes()
        {
            //Get a list of all Roadshow routes for this terminal and date range
            try {
                this.mRoutes.Clear();
                this.mRoutes.Merge(FinanceGateway.ImportRoutes(this.mAgentNumber, this.mBeginDate, this.mEndDate));

                //Check-off new routes (those that don't exist in the driver's compensation)
                for (int i = 0; i < this.mRoutes.RoadshowRouteTable.Rows.Count; i++)
                {
                    int      termID    = this.mRoutes.RoadshowRouteTable[i].DepotNumber;
                    string   oper      = this.mRoutes.RoadshowRouteTable[i].Operator;
                    string   routeName = this.mRoutes.RoadshowRouteTable[i].Rt_Name;
                    DateTime routeDate = this.mRoutes.RoadshowRouteTable[i].Rt_Date;
                    DriverCompDataset.DriverRouteTableRow[] driverRoutes = (DriverCompDataset.DriverRouteTableRow[]) this.mCompensation.DriverRouteTable.Select("AgentNumber=" + termID + " AND Operator='" + oper + "' AND RouteName='" + routeName + "' AND RouteDate='" + routeDate + "'");
                    this.mRoutes.RoadshowRouteTable[i].New = (driverRoutes.Length == 0);
                }
            }
            catch (ApplicationException ex) { throw ex; }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            finally { if (this.RoutesChanged != null)
                      {
                          this.RoutesChanged(this, EventArgs.Empty);
                      }
            }
        }
Ejemplo n.º 5
0
        private void OnFormLoad(object sender, System.EventArgs e)
        {
            //Event handler for form load event
            this.Cursor = Cursors.WaitCursor;
            try {
                //Initialize controls
                Splash.Close();
                this.Visible = true;
                Application.DoEvents();
                #region Set user preferences
                try {
                    this.WindowState = global::Argix.Properties.Settings.Default.WindowState;
                    switch (this.WindowState)
                    {
                    case FormWindowState.Maximized: break;

                    case FormWindowState.Minimized: break;

                    case FormWindowState.Normal:
                        this.Location = global::Argix.Properties.Settings.Default.Location;
                        this.Size     = global::Argix.Properties.Settings.Default.Size;
                        break;
                    }
                    this.Font = this.msMain.Font = this.tsMain.Font = this.ssMain.Font = global::Argix.Properties.Settings.Default.Font;
                    this.msViewToolbar.Checked     = this.tsMain.Visible = Convert.ToBoolean(global::Argix.Properties.Settings.Default.Toolbar);
                    this.msViewStatusBar.Checked   = this.ssMain.Visible = Convert.ToBoolean(global::Argix.Properties.Settings.Default.StatusBar);
                    this.msViewTermConfigs.Checked = !global::Argix.Properties.Settings.Default.TermConfigWindow;
                    this.msViewEquip.Checked       = !global::Argix.Properties.Settings.Default.DriverEquipWindow;
                    this.msViewRates.Checked       = !global::Argix.Properties.Settings.Default.DriverRatesWindow;
                    App.CheckVersion();
                }
                catch (Exception ex) { App.ReportError(ex, true, LogLevel.Error); }
                #endregion
                #region Set tooltips
                this.mToolTip.InitialDelay = 500;
                this.mToolTip.AutoPopDelay = 3000;
                this.mToolTip.ReshowDelay  = 1000;
                this.mToolTip.ShowAlways   = true;              //Even when form is inactve
                #endregion

                //Set control defaults
                ServiceInfo t = FinanceGateway.GetServiceInfo();
                this.ssMain.SetTerminalPanel(t.TerminalID.ToString(), t.Description);
                this.ssMain.User1Panel.Width       = 144;
                this.ssMain.User1Panel.Text        = RoleServiceGateway.GetRoleForCurrentUser();
                this.ssMain.User1Panel.ToolTipText = "User role";

                this.tabMain.TabPages.Clear();
                this.msViewTermConfigs.PerformClick();
                this.msViewEquip.PerformClick();
                this.msViewRates.PerformClick();
            }
            catch (Exception ex) { App.ReportError(ex, true, LogLevel.Error); }
            finally { setUserServices(); this.Cursor = Cursors.Default; }
        }
Ejemplo n.º 6
0
 public void Refresh()
 {
     //Refresh the ratings cache for this instance
     try {
         this.mRates.Clear();
         this.mRates.Merge(FinanceGateway.ReadVehicleMileageRates(this.mEffectiveDate, this.mAgentNumber, -1));
         this.mRates.Merge(FinanceGateway.ReadVehicleUnitRates(this.mEffectiveDate, this.mAgentNumber, -1));
         this.mRates.Merge(FinanceGateway.ReadRouteMileageRates(this.mEffectiveDate, this.mAgentNumber, null));
         this.mRates.Merge(FinanceGateway.ReadRouteUnitRates(this.mEffectiveDate, this.mAgentNumber, null));
     }
     catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
 }
Ejemplo n.º 7
0
        public string ExportCompensation(bool updateAsExported)
        {
            //Export this driver compensation to file
            StringBuilder export = null;

            try {
                //Setup
                export = new StringBuilder();
                PayPeriod payPeriod = FinanceGateway.GetPayPeriod(this.mEndDate);

                //Export driver compensations and admin charges
                foreach (DriverCompDataset.DriverCompTableRow comp in this.mCompensation.DriverCompTable.Rows)
                {
                    if (comp.Select && comp.TotalAmount > 0)
                    {
                        //Export driver compensation
                        export.AppendLine(formatDriverRecord(payPeriod, comp));

                        //Export Admin fees if applicable
                        DriverCompDataset.DriverRouteTableRow[] routes = (DriverCompDataset.DriverRouteTableRow[]) this.mCompensation.DriverRouteTable.Select("AgentNumber=" + this.mAgentNumber + " AND Operator='" + comp.Operator + "'");
                        decimal adminFee = 0.0M;
                        for (int i = 0; i < routes.Length; i++)
                        {
                            adminFee += routes[i].AdminCharge;
                        }
                        if (adminFee != 0)
                        {
                            export.AppendLine(formatAdminRecord(payPeriod, comp, adminFee));
                        }

                        if (updateAsExported)
                        {
                            //Update all routes as exported
                            for (int i = 0; i < routes.Length; i++)
                            {
                                routes[i].Exported    = DateTime.Today;
                                routes[i].LastUpdated = DateTime.Now;
                                routes[i].UserID      = Environment.UserName;
                                FinanceGateway.UpdateDriverRoute(routes[i]);
                            }
                        }
                    }
                }
                //Refresh routes if they were updated (otherwise, don't change export selections)
                if (updateAsExported)
                {
                    ViewCompensation();
                }
            }
            catch (ApplicationException ex) { throw ex; }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            return(export.ToString());
        }
Ejemplo n.º 8
0
 private void OnFormLoad(object sender, System.EventArgs e)
 {
     //Event handler for form load event
     this.Cursor = Cursors.WaitCursor;
     try {
         this.cboTerminal.DataSource    = FinanceGateway.GetLocalTerminals();
         this.cboTerminal.SelectedIndex = 0;
         this.dtpEnd.Value = getLastSaturday();
         OnEndDateChanged(this.dtpEnd, EventArgs.Empty);;
     }
     catch (Exception ex) { App.ReportError(ex, true, LogLevel.Error); }
     finally { OnValidateForm(null, EventArgs.Empty); this.Cursor = Cursors.Default; }
 }
Ejemplo n.º 9
0
        public void ViewCompensation()
        {
            //View all rated routes and the associated driver compensation
            try {
                //Read all rated routes for specified terminal and date range
                this.mCompensation.Clear();
                this.mCompensation.Merge(FinanceGateway.ReadDriverRoutes(this.mAgentNumber, this.mBeginDate, this.mEndDate));
                for (int i = 0; i < this.mCompensation.DriverRouteTable.Rows.Count; i++)
                {
                    //Build driver compensation for each driver
                    DriverCompDataset.DriverRouteTableRow driverRoute = (DriverCompDataset.DriverRouteTableRow) this.mCompensation.DriverRouteTable.Rows[i];
                    if (this.mCompensation.DriverCompTable.Select("Operator='" + driverRoute.Operator + "'").Length == 0)
                    {
                        //Create driver compensation for driverRoute.Operator and initialize
                        DriverCompDataset.DriverCompTableRow driverComp = this.mCompensation.DriverCompTable.NewDriverCompTableRow();
                        #region Set members
                        driverComp.Select          = driverRoute.IsExportedNull();
                        driverComp.IsNew           = driverComp.IsCombo = driverComp.IsAdjust = false;
                        driverComp.AgentNumber     = driverRoute.AgentNumber;
                        driverComp.FinanceVendorID = driverRoute.FinanceVendorID;
                        driverComp.FinanceVendor   = driverRoute.Payee;
                        driverComp.Operator        = driverRoute.Operator;
                        //driverComp.EquipmentTypeID = driverRoute.EquipmentTypeID;
                        driverComp.Miles         = driverComp.Trip = driverComp.Stops = driverComp.Cartons = driverComp.Pallets = driverComp.PickupCartons = 0;
                        driverComp.MilesAmount   = driverComp.DayAmount = driverComp.TripAmount = driverComp.StopsAmount = driverComp.CartonsAmount = driverComp.PalletsAmount = driverComp.PickupCartonsAmount = driverComp.Amount = 0.0M;
                        driverComp.FSCMiles      = 0;
                        driverComp.FuelCost      = driverComp.FSCGal = driverComp.FSCBaseRate = driverComp.FSC = 0.0M;
                        driverComp.MinimunAmount = driverComp.AdminCharge = driverComp.AdjustmentAmount1 = driverComp.AdjustmentAmount2 = driverComp.TotalAmount = 0.0M;
                        #endregion
                        this.mCompensation.DriverCompTable.AddDriverCompTableRow(driverComp);

                        //Calculate driver compensation for driverRoute.Operator for all rated routes
                        CalculateCompensation(driverRoute.Operator, false);
                    }
                }
                this.mCompensation.AcceptChanges();
            }
            catch (ApplicationException ex) { throw ex; }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            finally { if (this.Changed != null)
                      {
                          this.Changed(this, EventArgs.Empty);
                      }
            }
        }
Ejemplo n.º 10
0
 private void OnItemClick(object sender, EventArgs e)
 {
     //Event handler for menu item selections
     try {
         ToolStripItem menu = (ToolStripItem)sender;
         switch (menu.Name)
         {
         case "csRefresh":
         case "tsRefresh":
             this.Cursor             = Cursors.WaitCursor;
             this.grdMain.DataSource = FinanceGateway.ReadTerminalConfigurations();
             this.grdMain.DataBind();
             break;
         }
     }
     catch (Exception ex) { reportError(ex); }
     finally { this.Cursor = Cursors.Default; }
 }
Ejemplo n.º 11
0
 //Interface
 public CompensationAgent(string agentNumber, string agentName, DateTime startDate, DateTime endDate)
 {
     //Constructor
     try {
         this.mAgentNumber    = agentNumber;
         this.mAgentName      = agentName;
         this.mBeginDate      = startDate;
         this.mEndDate        = endDate;
         this.mCompensation   = new DriverCompDataset();
         this.mRoutes         = new DriverCompDataset();
         this.mRates          = new AgentRates(this.mAgentNumber, this.mAgentName, this.mEndDate);
         this.mTerminalConfig = FinanceGateway.GetTerminalConfiguration(this.mAgentNumber);
         this.mFuelCost       = FinanceGateway.GetFuelCost(this.mEndDate, this.mAgentNumber);
         ViewCompensation();
         ImportRoutes();
     }
     catch (ApplicationException ex) { throw ex; }
     catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
 }
Ejemplo n.º 12
0
        public bool SaveCompensation()
        {
            //Save
            bool result = false;

            try {
                //Save all new routes
                for (int i = 0; i < this.mCompensation.DriverRouteTable.Rows.Count; i++)
                {
                    //Validate route as new (NULL Import date)
                    if (this.mCompensation.DriverRouteTable[i].IsImportedNull())
                    {
                        DriverCompDataset.DriverRouteTableRow driverRoute = this.mCompensation.DriverRouteTable[i];
                        driverRoute.Imported = DateTime.Now;
                        result = FinanceGateway.CreateDriverRoute(driverRoute);
                    }
                }
                ViewCompensation();
            }
            catch (ApplicationException ex) { throw ex; }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            return(result);
        }
Ejemplo n.º 13
0
        private void OnLoad(object sender, EventArgs e)
        {
            //Event handler for control load event
            this.Cursor = Cursors.WaitCursor;
            try {
                this.grdMileageRates.Visible = this.grdUnitRates.Visible = this.grdMileageRouteRates.Visible = this.grdUnitRouteRates.Visible = false;
                #region Grid customizations from normal layout (to support cell editing)
                this.grdMileageRates.UpdateMode = UpdateMode.OnRowChangeOrLostFocus & UpdateMode.OnUpdate;
                this.grdMileageRates.DisplayLayout.Override.RowSelectors                         = Infragistics.Win.DefaultableBoolean.True;
                this.grdMileageRates.DisplayLayout.Override.RowFilterMode                        = RowFilterMode.AllRowsInBand;
                this.grdMileageRates.DisplayLayout.Override.SelectTypeRow                        = SelectType.Single;
                this.grdMileageRates.DisplayLayout.Override.SelectTypeCell                       = SelectType.Single;
                this.grdMileageRates.DisplayLayout.TabNavigation                                 = TabNavigation.NextCell;
                this.grdMileageRates.DisplayLayout.Override.AllowAddNew                          = RoleServiceGateway.IsBillingSupervisor ? AllowAddNew.TemplateOnBottom : AllowAddNew.No;
                this.grdMileageRates.DisplayLayout.Override.AllowUpdate                          = DefaultableBoolean.True;
                this.grdMileageRates.DisplayLayout.Override.AllowDelete                          = DefaultableBoolean.False;
                this.grdMileageRates.DisplayLayout.Override.MaxSelectedCells                     = 1;
                this.grdMileageRates.DisplayLayout.Override.CellClickAction                      = CellClickAction.Edit;
                this.grdMileageRates.DisplayLayout.Bands[0].Override.CellClickAction             = CellClickAction.Edit;
                this.grdMileageRates.DisplayLayout.Bands[0].Columns["AgentNumber"].SortIndicator = SortIndicator.Ascending;

                this.grdUnitRates.UpdateMode = UpdateMode.OnRowChangeOrLostFocus | UpdateMode.OnUpdate;
                this.grdUnitRates.DisplayLayout.Override.RowSelectors                         = Infragistics.Win.DefaultableBoolean.True;
                this.grdUnitRates.DisplayLayout.Override.RowFilterMode                        = RowFilterMode.AllRowsInBand;
                this.grdUnitRates.DisplayLayout.Override.SelectTypeRow                        = SelectType.Single;
                this.grdUnitRates.DisplayLayout.Override.SelectTypeCell                       = SelectType.Single;
                this.grdUnitRates.DisplayLayout.TabNavigation                                 = TabNavigation.NextCell;
                this.grdUnitRates.DisplayLayout.Override.AllowAddNew                          = RoleServiceGateway.IsBillingSupervisor ? AllowAddNew.TemplateOnBottom : AllowAddNew.No;
                this.grdUnitRates.DisplayLayout.Override.AllowUpdate                          = DefaultableBoolean.True;
                this.grdUnitRates.DisplayLayout.Override.AllowDelete                          = DefaultableBoolean.False;
                this.grdUnitRates.DisplayLayout.Override.MaxSelectedCells                     = 1;
                this.grdUnitRates.DisplayLayout.Override.CellClickAction                      = CellClickAction.Edit;
                this.grdUnitRates.DisplayLayout.Bands[0].Override.CellClickAction             = CellClickAction.Edit;
                this.grdUnitRates.DisplayLayout.Bands[0].Columns["AgentNumber"].SortIndicator = SortIndicator.Ascending;

                this.grdMileageRouteRates.UpdateMode = UpdateMode.OnRowChangeOrLostFocus | UpdateMode.OnUpdate;
                this.grdMileageRouteRates.DisplayLayout.Override.RowSelectors                         = Infragistics.Win.DefaultableBoolean.True;
                this.grdMileageRouteRates.DisplayLayout.Override.RowFilterMode                        = RowFilterMode.AllRowsInBand;
                this.grdMileageRouteRates.DisplayLayout.Override.SelectTypeRow                        = SelectType.Single;
                this.grdMileageRouteRates.DisplayLayout.Override.SelectTypeCell                       = SelectType.Single;
                this.grdMileageRouteRates.DisplayLayout.TabNavigation                                 = TabNavigation.NextCell;
                this.grdMileageRouteRates.DisplayLayout.Override.AllowAddNew                          = RoleServiceGateway.IsBillingSupervisor ? AllowAddNew.TemplateOnBottom : AllowAddNew.No;
                this.grdMileageRouteRates.DisplayLayout.Override.AllowUpdate                          = DefaultableBoolean.True;
                this.grdMileageRouteRates.DisplayLayout.Override.AllowDelete                          = DefaultableBoolean.False;
                this.grdMileageRouteRates.DisplayLayout.Override.MaxSelectedCells                     = 1;
                this.grdMileageRouteRates.DisplayLayout.Override.CellClickAction                      = CellClickAction.Edit;
                this.grdMileageRouteRates.DisplayLayout.Bands[0].Override.CellClickAction             = CellClickAction.Edit;
                this.grdMileageRouteRates.DisplayLayout.Bands[0].Columns["AgentNumber"].SortIndicator = SortIndicator.Ascending;

                this.grdUnitRouteRates.UpdateMode = UpdateMode.OnRowChangeOrLostFocus | UpdateMode.OnUpdate;
                this.grdUnitRouteRates.DisplayLayout.Override.RowSelectors                         = Infragistics.Win.DefaultableBoolean.True;
                this.grdUnitRouteRates.DisplayLayout.Override.RowFilterMode                        = RowFilterMode.AllRowsInBand;
                this.grdUnitRouteRates.DisplayLayout.Override.SelectTypeRow                        = SelectType.Single;
                this.grdUnitRouteRates.DisplayLayout.Override.SelectTypeCell                       = SelectType.Single;
                this.grdUnitRouteRates.DisplayLayout.TabNavigation                                 = TabNavigation.NextCell;
                this.grdUnitRouteRates.DisplayLayout.Override.AllowAddNew                          = RoleServiceGateway.IsBillingSupervisor ? AllowAddNew.TemplateOnBottom : AllowAddNew.No;
                this.grdUnitRouteRates.DisplayLayout.Override.AllowUpdate                          = DefaultableBoolean.True;
                this.grdUnitRouteRates.DisplayLayout.Override.AllowDelete                          = DefaultableBoolean.False;
                this.grdUnitRouteRates.DisplayLayout.Override.MaxSelectedCells                     = 1;
                this.grdUnitRouteRates.DisplayLayout.Override.CellClickAction                      = CellClickAction.Edit;
                this.grdUnitRouteRates.DisplayLayout.Bands[0].Override.CellClickAction             = CellClickAction.Edit;
                this.grdUnitRouteRates.DisplayLayout.Bands[0].Columns["AgentNumber"].SortIndicator = SortIndicator.Ascending;
                #endregion
                if (!this.DesignMode)
                {
                    this.uddAgentType.DataSource    = FinanceGateway.GetLocalTerminals();
                    this.uddAgentType.DataMember    = "LocalTerminalTable";
                    this.uddAgentType.DisplayMember = "Description";
                    this.uddAgentType.ValueMember   = "AgentNumber";

                    this.uddEquipType.DataSource    = FinanceGateway.GetDriverEquipmentTypes();
                    this.uddEquipType.DataMember    = "EquipmentTypeTable";
                    this.uddEquipType.DisplayMember = "Description";
                    this.uddEquipType.ValueMember   = "ID";
                }
                this.csRefresh.Enabled         = this.tsRefresh.Enabled = this.cboRateType.Enabled = this.mRates != null;
                this.cboRateType.SelectedIndex = 0;
            }
            catch (Exception ex) { reportError(ex); }
            finally { this.Cursor = Cursors.Default; }
        }
Ejemplo n.º 14
0
        private void OnGridBeforeRowUpdate(object sender, Infragistics.Win.UltraWinGrid.CancelableRowEventArgs e)
        {
            //Event handler for data entry row updated
            try {
                //There is no selected row when updating- at a cell level
                int      id = 0;
                string   agent = "", route = "", maxTrigFld = "";
                DateTime date;
                double   mile = 0.0;
                decimal  baseRate = 0.0M, rate = 0.0M;
                int      equip = 0, status = 1, maxTrigVal = 0;
                decimal  dayRate = 0.0M, tripRate = 0.0M, stopRate = 0.0M, ctnRate = 0.0M, palletRate = 0.0M, pickupCtnRate = 0.0M, minAmt = 0.0M, maxAmt = 0.0M, fsBase = 0.0M;
                switch (e.Row.Band.Key)
                {
                case "RateMileageTable":
                    id       = Convert.ToInt32(e.Row.Cells["ID"].Value);
                    agent    = e.Row.Cells["AgentNumber"].Value.ToString();
                    equip    = Convert.ToInt32(e.Row.Cells["EquipmentTypeID"].Value);
                    date     = Convert.ToDateTime(e.Row.Cells["EffectiveDate"].Value);
                    mile     = Convert.ToDouble(e.Row.Cells["Mile"].Value);
                    baseRate = Convert.ToDecimal(e.Row.Cells["BaseRate"].Value);
                    rate     = Convert.ToDecimal(e.Row.Cells["Rate"].Value);
                    if (agent.Length > 0 && equip > 0 && date > DateTime.MinValue)
                    {
                        if (e.Row.IsAddRow)
                        {
                            FinanceGateway.CreateVehicleMileageRate(agent, equip, date, mile, baseRate, rate);
                        }
                        else
                        {
                            FinanceGateway.UpdateVehicleMileageRate(id, equip, mile, baseRate, rate);
                        }
                    }
                    else
                    {
                        e.Cancel = true;
                    }
                    break;

                case "RateUnitTable":
                    id            = Convert.ToInt32(e.Row.Cells["ID"].Value);
                    agent         = e.Row.Cells["AgentNumber"].Value.ToString();
                    equip         = Convert.ToInt32(e.Row.Cells["EquipmentTypeID"].Value);
                    date          = Convert.ToDateTime(e.Row.Cells["EffectiveDate"].Value);
                    dayRate       = Convert.ToDecimal(e.Row.Cells["DayRate"].Value);
                    tripRate      = Convert.ToDecimal(e.Row.Cells["MultiTripRate"].Value);
                    stopRate      = Convert.ToDecimal(e.Row.Cells["StopRate"].Value);
                    ctnRate       = Convert.ToDecimal(e.Row.Cells["CartonRate"].Value);
                    palletRate    = Convert.ToDecimal(e.Row.Cells["PalletRate"].Value);
                    pickupCtnRate = Convert.ToDecimal(e.Row.Cells["PickupCartonRate"].Value);
                    minAmt        = Convert.ToDecimal(e.Row.Cells["MinimumAmount"].Value);
                    maxAmt        = Convert.ToDecimal(e.Row.Cells["MaximumAmount"].Value);
                    maxTrigFld    = e.Row.Cells["MaximumTriggerField"].Value.ToString();
                    maxTrigVal    = Convert.ToInt32(e.Row.Cells["MaximumTriggerValue"].Value);
                    fsBase        = Convert.ToDecimal(e.Row.Cells["FSBase"].Value);
                    if (agent.Length > 0 && equip > 0 && date > DateTime.MinValue)
                    {
                        if (e.Row.IsAddRow)
                        {
                            FinanceGateway.CreateVehicleUnitRate(agent, equip, date, dayRate, tripRate, stopRate, ctnRate, palletRate, pickupCtnRate, minAmt, maxAmt, maxTrigFld, maxTrigVal, fsBase);
                        }
                        else
                        {
                            FinanceGateway.UpdateVehicleUnitRate(id, equip, dayRate, tripRate, stopRate, ctnRate, palletRate, pickupCtnRate, minAmt, maxAmt, maxTrigFld, maxTrigVal, fsBase);
                        }
                    }
                    else
                    {
                        e.Cancel = true;
                    }
                    break;

                case "RateMileageRouteTable":
                    id       = Convert.ToInt32(e.Row.Cells["ID"].Value);
                    agent    = e.Row.Cells["AgentNumber"].Value.ToString();
                    route    = e.Row.Cells["Route"].Value.ToString();
                    date     = Convert.ToDateTime(e.Row.Cells["EffectiveDate"].Value);
                    mile     = Convert.ToDouble(e.Row.Cells["Mile"].Value);
                    baseRate = Convert.ToDecimal(e.Row.Cells["BaseRate"].Value);
                    rate     = Convert.ToDecimal(e.Row.Cells["Rate"].Value);
                    status   = Convert.ToInt32(e.Row.Cells["Status"].Value);
                    if (agent.Length > 0 && route.Length > 0 && date > DateTime.MinValue)
                    {
                        if (e.Row.IsAddRow)
                        {
                            FinanceGateway.CreateRouteMileageRate(agent, route, date, mile, baseRate, rate, status);
                        }
                        else
                        {
                            FinanceGateway.UpdateRouteMileageRate(id, route, mile, baseRate, rate, status);
                        }
                    }
                    else
                    {
                        e.Cancel = true;
                    }
                    break;

                case "RateUnitRouteTable":
                    id            = Convert.ToInt32(e.Row.Cells["ID"].Value);
                    agent         = e.Row.Cells["AgentNumber"].Value.ToString();
                    route         = e.Row.Cells["Route"].Value.ToString();
                    date          = Convert.ToDateTime(e.Row.Cells["EffectiveDate"].Value);
                    dayRate       = Convert.ToDecimal(e.Row.Cells["DayRate"].Value);
                    tripRate      = Convert.ToDecimal(e.Row.Cells["MultiTripRate"].Value);
                    stopRate      = Convert.ToDecimal(e.Row.Cells["StopRate"].Value);
                    ctnRate       = Convert.ToDecimal(e.Row.Cells["CartonRate"].Value);
                    palletRate    = Convert.ToDecimal(e.Row.Cells["PalletRate"].Value);
                    pickupCtnRate = Convert.ToDecimal(e.Row.Cells["PickupCartonRate"].Value);
                    minAmt        = Convert.ToDecimal(e.Row.Cells["MinimumAmount"].Value);
                    maxAmt        = Convert.ToDecimal(e.Row.Cells["MaximumAmount"].Value);
                    maxTrigFld    = e.Row.Cells["MaximumTriggerField"].Value.ToString();
                    maxTrigVal    = Convert.ToInt32(e.Row.Cells["MaximumTriggerValue"].Value);
                    fsBase        = Convert.ToDecimal(e.Row.Cells["FSBase"].Value);
                    status        = Convert.ToInt32(e.Row.Cells["Status"].Value);
                    if (agent.Length > 0 && route.Length > 0 && date > DateTime.MinValue)
                    {
                        if (e.Row.IsAddRow)
                        {
                            FinanceGateway.CreateRouteUnitRate(agent, route, date, dayRate, tripRate, stopRate, ctnRate, palletRate, pickupCtnRate, minAmt, maxAmt, maxTrigFld, maxTrigVal, fsBase, status);
                        }
                        else
                        {
                            FinanceGateway.UpdateRouteUnitRate(id, route, dayRate, tripRate, stopRate, ctnRate, palletRate, pickupCtnRate, minAmt, maxAmt, maxTrigFld, maxTrigVal, fsBase, status);
                        }
                    }
                    else
                    {
                        e.Cancel = true;
                    }
                    break;
                }
                this.mRates.Refresh();
            }
            catch (Exception ex) { reportError(ex); }
        }
Ejemplo n.º 15
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            //Event handler for form load event
            try {
                //Set control defaults
                #region Grid customizations from normal layout (to support cell editing)
                this.grdRates.DisplayLayout.Bands[0].Override.RowFilterMode = RowFilterMode.AllRowsInBand;
                #endregion

                //Get all tariffs and create dataset schema
                this.mRates = new DataSet();
                this.mRates.Tables.Add("LTLRatesTable");
                this.mRates.Tables["LTLRatesTable"].Columns.Add("Origin");
                this.mRates.Tables["LTLRatesTable"].Columns.Add("Destination");
                this.mRates.Tables["LTLRatesTable"].Columns.Add("NMFC");
                this.mRates.Tables["LTLRatesTable"].Columns.Add("Weight");
                DataModule[] tariffs = FinanceGateway.GetAvailableTariffs();
                for (int k = 0; k < tariffs.Length; k++)
                {
                    this.mRates.Tables["LTLRatesTable"].Columns.Add(tariffs[k].effectiveDateField);
                }
                this.mRates.Tables["LTLRatesTable"].Columns.Add("PSP");
                this.mRates.AcceptChanges();

                //Loop thru all delivery locations
                DataSet destinations = FinanceGateway.ViewDeliveryZips();
                DataRow row          = null;
                //for(int j = 0; j < destinations.Tables["DeliveryZipTable"].Rows.Count; j=j+100) {
                for (int j = 0; j < 5; j++)
                {
                    //Get an LTL rate for each tariff for this destination
                    row                = this.mRates.Tables["LTLRatesTable"].NewRow();
                    row["Origin"]      = "07657";
                    row["Destination"] = destinations.Tables["DeliveryZipTable"].Rows[j]["Zip"].ToString();
                    row["NMFC"]        = "50";
                    row["Weight"]      = "1500";
                    for (int i = 0; i < tariffs.Length; i++)
                    {
                        //Setup the request for NMFC=50, weight=100lbs, Origin=Ridgefield
                        DataModule tariff = tariffs[i];

                        LTLRateShipmentSimpleRequest request = new LTLRateShipmentSimpleRequest();
                        request.tariffNameField            = tariff != null ? tariff.tariffNameField : "";
                        request.shipmentDateCCYYMMDDField  = tariff != null ? tariff.effectiveDateField : "";
                        request.destinationCountryField    = request.originCountryField = "USA";
                        request.originPostalCodeField      = "07657";
                        request.destinationPostalCodeField = destinations.Tables["DeliveryZipTable"].Rows[j]["Zip"].ToString();
                        LTLRequestDetail detail = new LTLRequestDetail();
                        detail.nmfcClassField = "50";
                        detail.weightField    = "1500";
                        request.detailsField  = new LTLRequestDetail[] { detail };

                        //Get the LTL rate and add a datarow
                        LTLRateShipmentSimpleResponse response = FinanceGateway.CalculateLTLSimpleRate(request);
                        row[tariff.effectiveDateField] = response.totalChargeField;
                    }

                    //Get the PSP rate for this destination
                    LTLQuote2 quote = new LTLQuote2();
                    quote.ShipDate       = DateTime.Today;
                    quote.OriginZip      = "07657";
                    quote.DestinationZip = destinations.Tables["DeliveryZipTable"].Rows[j]["Zip"].ToString();
                    quote.Pallet1Weight  = 100;
                    quote      = FreightGateway.CreateQuote(quote);
                    row["PSP"] = quote.TotalCharge.ToString();

                    //Ad the results for this destination
                    this.mRates.Tables["LTLRatesTable"].Rows.Add(row);
                }
                this.grdRates.DataSource = this.mRates;
                this.grdRates.DataMember = "LTLRatesTable";
            }
            catch (Exception ex) { App.ReportError(ex, true, LogLevel.Error); }
        }
Ejemplo n.º 16
0
        public bool UpdateCompensation()
        {
            //Update
            bool result = false;

            try {
                //Updated routes
                DriverCompDataset driverRoutes = (DriverCompDataset)this.mCompensation.GetChanges(DataRowState.Modified);
                if (driverRoutes != null && driverRoutes.DriverRouteTable.Rows.Count > 0)
                {
                    //Update all modified driver compensations
                    foreach (DriverCompDataset.DriverRouteTableRow driverRoute in driverRoutes.DriverRouteTable.Rows)
                    {
                        try {
                            driverRoute.LastUpdated = DateTime.Now;
                            driverRoute.UserID      = Environment.UserName;
                            result = FinanceGateway.UpdateDriverRoute(driverRoute);
                            if (result)
                            {
                                driverRoute.AcceptChanges();
                            }
                            else
                            {
                                driverRoute.RejectChanges();
                            }
                        }
                        catch (Exception) {
                            driverRoute.RejectChanges();
                            System.Windows.Forms.MessageBox.Show("Failed to update route (" + driverRoute.RouteDate.ToShortDateString() + ", " + driverRoute.Operator, "Route Update", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                        }
                    }
                }

                //Deleted routes- need to re-assess fees and bonus
                driverRoutes = (DriverCompDataset)this.mCompensation.GetChanges(DataRowState.Deleted);
                if (driverRoutes != null && driverRoutes.DriverRouteTable.Rows.Count > 0)
                {
                    //Delete all deleted driverRoutes
                    DriverCompDataset.DriverRouteTableRow driverRoute = null;
                    for (int i = driverRoutes.DriverRouteTable.Rows.Count - 1; i >= 0; i--)
                    {
                        try {
                            driverRoute = (DriverCompDataset.DriverRouteTableRow)driverRoutes.DriverRouteTable.Rows[i];
                            driverRoute.RejectChanges();
                            if (!driverRoute.IsImportedNull())
                            {
                                result = FinanceGateway.DeleteDriverRoute(driverRoute.ID);
                            }
                            else
                            {
                                result = true;
                            }
                            if (result)
                            {
                                driverRoute.Delete(); driverRoute.AcceptChanges();
                            }
                        }
                        catch (Exception) {
                            System.Windows.Forms.MessageBox.Show("Failed to update route (" + driverRoute.RouteDate.ToShortDateString() + ", " + driverRoute.Operator, "Route Update", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                        }
                    }
                }
                this.mCompensation.AcceptChanges();
                ImportRoutes();
            }
            catch (Exception ex) {
                this.mCompensation.RejectChanges();
                throw new ApplicationException(ex.Message, ex);
            }
            return(result);
        }