Example #1
0
        private void calcFSC(DriverCompDS.DriverRouteTableRow dayComp, RouteRatings ratings)
        {
            //Calculate FSC if required
            try {
                //1. FSC applies only if miles rates are present in the rating
                if (ratings.MileBaseRate > 0 || ratings.MileRate > 0)
                {
                    dayComp.FSCMiles = dayComp.Miles;
                }

                //2. Copy rates (for reference)
                dayComp.FuelCost = FinanceFactory.GetFuelCost(this.EndDate, this.mAgentNumber);
                dayComp.FSCGal   = EnterpriseFactory.GetDriverEquipmentMPG(dayComp.EquipmentTypeID);
                if (dayComp.FSCGal <= 0.0M)
                {
                    throw new ApplicationException("FSCGal (" + dayComp.FSCGal.ToString() + "MPG) is invalid.");
                }
                dayComp.FSCBaseRate = this.mTerminalConfig.FSBase;

                //3. Calculate FSC
                dayComp.FSC = dayComp.FSCMiles / dayComp.FSCGal * (dayComp.FuelCost - dayComp.FSCBaseRate);
                if (dayComp.FSC < 0)
                {
                    dayComp.FSC = 0.0M;
                }
            }
            catch (ApplicationException ex) { throw ex; }
            catch (Exception ex) { throw new ApplicationException("Unexpected error while calculating FSC.", ex); }
        }
Example #2
0
        private void configApplication()
        {
            try {
                //Create event log and database trace listeners, and log application as started
                try {
                    ArgixTrace.AddListener(new DBTraceListener((LogLevel)App.Config.TraceLevel, App.Mediator, App.USP_TRACE, App.EventLogName));
                }
                catch {
                    ArgixTrace.AddListener(new DBTraceListener(LogLevel.Debug, App.Mediator, App.USP_TRACE, App.EventLogName));
                    ArgixTrace.WriteLine(new TraceMessage("Log level not found; setting log levels to Debug.", App.EventLogName, LogLevel.Warning, "Log Level"));
                }
                ArgixTrace.WriteLine(new TraceMessage(App.Version, App.EventLogName, LogLevel.Information, "App Started"));

                //Create business objects with configuration values
                App.Mediator.DataStatusUpdate += new DataStatusHandler(OnDataStatusUpdate);
                EnterpriseFactory.Mediator     = App.Mediator;
                EnterpriseFactory.RefreshCache();
                FinanceFactory.Mediator = App.Mediator;
                FinanceFactory.RefreshCache();
                DriverRatingFactory.Mediator = App.Mediator;
                this.stbMain.SetTerminalPanel(EnterpriseFactory.LocalTerminal.TerminalID.ToString(), EnterpriseFactory.LocalTerminal.Description);
                bool createError = App.Config.ReadOnly;
            }
            catch (Exception ex) { throw new ApplicationException("Configuration Failure", ex); }
        }
Example #3
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)
                    {
                        FinanceFactory.CreateDriverEquipment(vendorID, operatorName, equipmentID);
                    }
                    else
                    {
                        FinanceFactory.UpdateDriverEquipment(vendorID, operatorName, equipmentID);
                    }
                }
                else
                {
                    e.Cancel = true;
                }
            }
            catch (Exception ex) { reportError(ex); }
        }
Example #4
0
 private void applyAdminFee(string _operator)
 {
     //Apply admin fee to this route for the specified operator
     try {
         //Get all daily compensation for this operator and apply admin fee to one route only
         DriverCompDS.DriverRouteTableRow[] dayComps = (DriverCompDS.DriverRouteTableRow[]) this.mCompDS.DriverRouteTable.Select("AgentNumber=" + this.mAgentNumber + " AND Operator='" + _operator + "'");
         dayComps[0].AdminCharge = FinanceFactory.GetRouteAdminFee(this.mAgentNumber, _operator);
     }
     catch (Exception ex) { throw new ApplicationException("Unexpected error while applying administrative fee.", ex); }
 }
Example #5
0
 private void OnItemClick(object sender, EventArgs e)
 {
     //Event handler for menu item selections
     try {
         ToolStripItem menu = (ToolStripItem)sender;
         switch (menu.Text)
         {
         case "ctxRefresh":
         case "btnRefresh":
             this.Cursor = Cursors.WaitCursor;
             FinanceFactory.RefreshCache();
             break;
         }
     }
     catch (Exception ex) { reportError(ex); }
     finally { this.Cursor = Cursors.Default; }
 }
Example #6
0
 public DriverComp(string terminalID, string terminal, DateTime start, DateTime end, Mediator mediator)
 {
     //Constructor
     try {
         this.mMediator       = mediator;
         this.mAgentNumber    = terminalID;
         this.mAgentName      = terminal;
         this.mStart          = start;
         this.mEnd            = end;
         this.mRoutesDS       = new DriverCompDS();
         this.mCompDS         = new DriverCompDS();
         this.mRates          = new DriverRates(this.mEnd, this.mAgentNumber, this.mAgentName);
         this.mTerminalConfig = FinanceFactory.GetTerminalConfiguration(this.mAgentNumber);
         RefreshDriverRoutes();
         RefreshRoadshowRoutes();
     }
     catch (ApplicationException ex) { throw ex; }
     catch (Exception ex) { throw new ApplicationException("Failed to instantiate a new ship schedule.", ex); }
 }