Exemple #1
0
        public static DriverCompDataset GetRateTypes()
        {
            //
            DriverCompDataset       types  = null;
            DriverCompServiceClient client = null;

            try {
                ObjectCache cache = MemoryCache.Default;
                types = cache["rateTypes"] as DriverCompDataset;
                if (types == null)
                {
                    types  = new DriverCompDataset();
                    client = new DriverCompServiceClient();
                    DataSet ds = client.GetRateTypes();
                    client.Close();
                    if (ds.Tables["RateTypeTable"] != null && ds.Tables["RateTypeTable"].Rows.Count > 0)
                    {
                        types.Merge(ds);
                    }

                    DateTimeOffset policy = new DateTimeOffset(DateTime.Now.AddMinutes(_cacheTimeout));
                    cache.Set("rateTypes", types, policy);
                }
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <DriverCompensationFault> cfe) { client.Abort(); throw new ApplicationException(cfe.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(types);
        }
Exemple #2
0
        public static bool CreateDriverEquipment(string financeVendorID, string operatorName, int equipmentID)
        {
            //
            bool created = false;
            DriverCompServiceClient client = null;

            try {
                //Validate
                DriverCompDataset equipment = ReadDriverEquipment();
                DataRow[]         rows      = equipment.DriverEquipmentTable.Select("FinanceVendorID='" + financeVendorID + "' AND OperatorName='" + operatorName + "'");
                if (rows.Length > 0)
                {
                    throw new ApplicationException("Equipment already specified for " + operatorName + ".");
                }

                //Save driver equipment
                client  = new DriverCompServiceClient();
                created = client.CreateDriverEquipment(financeVendorID, operatorName, equipmentID);
                client.Close();
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <DriverCompensationFault> cfe) { client.Abort(); throw new ApplicationException(cfe.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(created);
        }
Exemple #3
0
        public static DriverCompDataset ReadDriverRoutes(string agentNumber, DateTime startDate, DateTime endDate)
        {
            //
            DriverCompDataset       routes = new DriverCompDataset();
            DriverCompServiceClient client = null;

            try {
                client = new DriverCompServiceClient();
                DataSet ds = client.ReadDriverRoutes(agentNumber, startDate, endDate);
                if (ds.Tables["DriverRouteTable"] != null && ds.Tables["DriverRouteTable"].Rows.Count > 0)
                {
                    routes.Merge(ds);
                    for (int i = 0; i < routes.DriverRouteTable.Rows.Count; i++)
                    {
                        //Set local fields (i.e. not persisted)
                        DriverCompDataset.DriverRouteTableRow route = (DriverCompDataset.DriverRouteTableRow)routes.DriverRouteTable.Rows[i];
                        route.IsNew    = false;
                        route.IsCombo  = (routes.DriverRouteTable.Select("Operator='" + route.Operator + "' AND RouteDate='" + route.RouteDate + "'").Length > 1);
                        route.IsAdjust = route.RouteName.Contains("ADJUST");
                    }
                    routes.AcceptChanges();
                }
                client.Close();
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <DriverCompensationFault> cfe) { client.Abort(); throw new ApplicationException(cfe.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(routes);
        }
Exemple #4
0
 //Interface
 public AgentRates(string agentNumber, string agentName, DateTime effectiveDate)
 {
     //Constructor
     try {
         //Cache the rate tables for this rates date
         this.mAgentNumber   = agentNumber;
         this.mAgentName     = agentName;
         this.mEffectiveDate = effectiveDate;
         this.mRates         = new DriverCompDataset();
         Refresh();
     }
     catch (ApplicationException ex) { throw ex; }
     catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
 }
Exemple #5
0
 public DriverRates(DateTime ratesDate, string agentNumber, string agentName)
 {
     //Constructor
     try {
         //Cache the rate tables for this rates date
         this.mRatesDate   = ratesDate;
         this.mAgentNumber = agentNumber;
         this.mAgentName   = agentName;
         this.mRates       = new DriverCompDataset();
         Refresh();
     }
     catch (ApplicationException ex) { throw ex; }
     catch (Exception ex) { throw new ApplicationException("Unexpected error while creating new DriverRates instance.", ex); }
 }
Exemple #6
0
        public static DriverCompDataset GetUnitRouteRates(DateTime date, string terminalAgent, string route)
        {
            //Return applicable route-based unit rates (i.e. multi-trip, carton, pallet) for the specified date
            DriverCompDataset rates = new DriverCompDataset();

            try {
                DataSet ds = Mediator.FillDataset(USP_RATEUNITROUTE, TBL_RATEUNITROUTE, new object[] { date, terminalAgent, route });
                if (ds.Tables[TBL_RATEUNITROUTE].Rows.Count > 0)
                {
                    rates.Merge(ds);
                }
            }
            catch (ApplicationException ex) { throw ex; }
            catch (Exception ex) { throw new DriverRateException("Unexpected error while reading rates.", ex); }
            return(rates);
        }
Exemple #7
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); }
 }
Exemple #8
0
        public static DriverCompDataset GetMileageRates(DateTime date, string terminalAgent, int equipmentTypeID)
        {
            //Return applicable mileage rates for the specified date
            DriverCompDataset rates = new DriverCompDataset();

            try {
                object id = null; if (equipmentTypeID > -1)
                {
                    id = equipmentTypeID;
                }
                DataSet ds = Mediator.FillDataset(USP_RATEMILEAGE, TBL_RATEMILEAGE, new object[] { date, terminalAgent, id });
                if (ds.Tables[TBL_RATEMILEAGE].Rows.Count > 0)
                {
                    rates.Merge(ds);
                }
            }
            catch (ApplicationException ex) { throw ex; }
            catch (Exception ex) { throw new DriverRateException("Unexpected error while reading rates.", ex); }
            return(rates);
        }
Exemple #9
0
        public static DriverCompDataset ImportRoutes(string agentNumber, DateTime startDate, DateTime endDate)
        {
            //
            DriverCompDataset       routes = new DriverCompDataset();
            DriverCompServiceClient client = null;

            try {
                client = new DriverCompServiceClient();
                DataSet ds = client.ReadRoadshowRoutes(agentNumber, startDate, endDate);
                if (ds.Tables["RoadshowRouteTable"] != null && ds.Tables["RoadshowRouteTable"].Rows.Count > 0)
                {
                    routes.Merge(ds);
                }
                client.Close();
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <DriverCompensationFault> cfe) { client.Abort(); throw new ApplicationException(cfe.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(routes);
        }
Exemple #10
0
        public static DataSet ReadRouteUnitRates(DateTime effectiveDate, string terminalAgent, string route)
        {
            //
            DriverCompDataset       rates  = new DriverCompDataset();
            DriverCompServiceClient client = null;

            try {
                client = new DriverCompServiceClient();
                DataSet ds = client.ReadRouteUnitRates(effectiveDate, terminalAgent, route);
                client.Close();
                if (ds.Tables["RateUnitRouteTable"] != null && ds.Tables["RateUnitRouteTable"].Rows.Count > 0)
                {
                    rates.Merge(ds);
                }
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <DriverCompensationFault> cfe) { client.Abort(); throw new ApplicationException(cfe.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(rates);
        }
Exemple #11
0
        public static DriverCompDataset ReadDriverEquipment()
        {
            //
            DriverCompDataset       equipment = new DriverCompDataset();
            DriverCompServiceClient client    = null;

            try {
                client = new DriverCompServiceClient();
                DataSet ds = client.ReadDriverEquipment(null, null);
                client.Close();
                if (ds.Tables["DriverEquipmentTable"] != null && ds.Tables["DriverEquipmentTable"].Rows.Count > 0)
                {
                    equipment.Merge(ds);
                }
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <DriverCompensationFault> cfe) { client.Abort(); throw new ApplicationException(cfe.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(equipment);
        }
Exemple #12
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(dlgRates));
     this.btnOK          = new System.Windows.Forms.Button();
     this.btnCancel      = new System.Windows.Forms.Button();
     this.mDriverRatesDS = new Argix.Finance.DriverCompDataset();
     this.ctlRates1      = new Argix.Finance.ctlRates();
     ((System.ComponentModel.ISupportInitialize)(this.mDriverRatesDS)).BeginInit();
     this.SuspendLayout();
     //
     // btnOK
     //
     this.btnOK.Anchor       = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
     this.btnOK.Font         = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.btnOK.Location     = new System.Drawing.Point(366, 324);
     this.btnOK.Name         = "btnOK";
     this.btnOK.Size         = new System.Drawing.Size(96, 24);
     this.btnOK.TabIndex     = 0;
     this.btnOK.Text         = "&OK ";
     this.btnOK.Visible      = false;
     //
     // btnCancel
     //
     this.btnCancel.Anchor       = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
     this.btnCancel.Font         = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.btnCancel.Location     = new System.Drawing.Point(468, 324);
     this.btnCancel.Name         = "btnCancel";
     this.btnCancel.Size         = new System.Drawing.Size(96, 24);
     this.btnCancel.TabIndex     = 1;
     this.btnCancel.Text         = "&Close";
     //
     // mDriverRatesDS
     //
     this.mDriverRatesDS.DataSetName             = "DriverCompRatesDS";
     this.mDriverRatesDS.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
     //
     // ctlRates1
     //
     this.ctlRates1.Cursor        = System.Windows.Forms.Cursors.Default;
     this.ctlRates1.Location      = new System.Drawing.Point(1, 2);
     this.ctlRates1.Name          = "ctlRates1";
     this.ctlRates1.Rates         = null;
     this.ctlRates1.Size          = new System.Drawing.Size(571, 316);
     this.ctlRates1.TabIndex      = 2;
     this.ctlRates1.ErrorMessage += new Argix.Finance.ErrorEventHandler(this.OnErrorMessage);
     //
     // dlgRates
     //
     this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
     this.ClientSize        = new System.Drawing.Size(570, 352);
     this.Controls.Add(this.ctlRates1);
     this.Controls.Add(this.btnCancel);
     this.Controls.Add(this.btnOK);
     this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
     this.Icon            = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
     this.MaximizeBox     = false;
     this.MinimizeBox     = false;
     this.Name            = "dlgRates";
     this.ShowInTaskbar   = false;
     this.StartPosition   = System.Windows.Forms.FormStartPosition.CenterParent;
     this.Text            = "Driver Rates";
     this.TopMost         = true;
     this.Load           += new System.EventHandler(this.OnFormLoad);
     ((System.ComponentModel.ISupportInitialize)(this.mDriverRatesDS)).EndInit();
     this.ResumeLayout(false);
 }
Exemple #13
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);
        }
Exemple #14
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(dlgOpen));
     this.btnOK        = new System.Windows.Forms.Button();
     this.btnCancel    = new System.Windows.Forms.Button();
     this.cboTerminal  = new System.Windows.Forms.ComboBox();
     this.mTerminals   = new Argix.Finance.DriverCompDataset();
     this._lblTerminal = new System.Windows.Forms.Label();
     this._lblSDate    = new System.Windows.Forms.Label();
     this._lblEDate    = new System.Windows.Forms.Label();
     this.dtpStart     = new System.Windows.Forms.DateTimePicker();
     this.dtpEnd       = new System.Windows.Forms.DateTimePicker();
     ((System.ComponentModel.ISupportInitialize)(this.mTerminals)).BeginInit();
     this.SuspendLayout();
     //
     // btnOK
     //
     this.btnOK.Anchor       = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
     this.btnOK.Location     = new System.Drawing.Point(126, 132);
     this.btnOK.Name         = "btnOK";
     this.btnOK.Size         = new System.Drawing.Size(96, 24);
     this.btnOK.TabIndex     = 0;
     this.btnOK.Text         = "&OK ";
     //
     // btnCancel
     //
     this.btnCancel.Anchor       = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
     this.btnCancel.Location     = new System.Drawing.Point(228, 132);
     this.btnCancel.Name         = "btnCancel";
     this.btnCancel.Size         = new System.Drawing.Size(96, 24);
     this.btnCancel.TabIndex     = 1;
     this.btnCancel.Text         = "&Cancel";
     //
     // cboTerminal
     //
     this.cboTerminal.DataSource                = this.mTerminals;
     this.cboTerminal.DisplayMember             = "LocalTerminalTable.Description";
     this.cboTerminal.DropDownStyle             = System.Windows.Forms.ComboBoxStyle.DropDownList;
     this.cboTerminal.Location                  = new System.Drawing.Point(82, 12);
     this.cboTerminal.Name                      = "cboTerminal";
     this.cboTerminal.Size                      = new System.Drawing.Size(240, 21);
     this.cboTerminal.TabIndex                  = 3;
     this.cboTerminal.ValueMember               = "LocalTerminalTable.AgentNumber";
     this.cboTerminal.SelectionChangeCommitted += new System.EventHandler(this.OnValidateForm);
     //
     // mTerminals
     //
     this.mTerminals.DataSetName             = "DriverCompDataset";
     this.mTerminals.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
     //
     // _lblTerminal
     //
     this._lblTerminal.Location  = new System.Drawing.Point(6, 12);
     this._lblTerminal.Name      = "_lblTerminal";
     this._lblTerminal.Size      = new System.Drawing.Size(72, 18);
     this._lblTerminal.TabIndex  = 4;
     this._lblTerminal.Text      = "Terminal";
     this._lblTerminal.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
     //
     // _lblSDate
     //
     this._lblSDate.Enabled   = false;
     this._lblSDate.Location  = new System.Drawing.Point(6, 48);
     this._lblSDate.Name      = "_lblSDate";
     this._lblSDate.Size      = new System.Drawing.Size(72, 19);
     this._lblSDate.TabIndex  = 5;
     this._lblSDate.Text      = "Start Date";
     this._lblSDate.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
     //
     // _lblEDate
     //
     this._lblEDate.Location  = new System.Drawing.Point(6, 75);
     this._lblEDate.Name      = "_lblEDate";
     this._lblEDate.Size      = new System.Drawing.Size(72, 19);
     this._lblEDate.TabIndex  = 6;
     this._lblEDate.Text      = "End Date";
     this._lblEDate.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
     //
     // dtpStart
     //
     this.dtpStart.Enabled       = false;
     this.dtpStart.Location      = new System.Drawing.Point(82, 48);
     this.dtpStart.Name          = "dtpStart";
     this.dtpStart.ShowUpDown    = true;
     this.dtpStart.Size          = new System.Drawing.Size(192, 20);
     this.dtpStart.TabIndex      = 7;
     this.dtpStart.ValueChanged += new System.EventHandler(this.OnStartDateChanged);
     //
     // dtpEnd
     //
     this.dtpEnd.Location      = new System.Drawing.Point(82, 75);
     this.dtpEnd.MaxDate       = new System.DateTime(2108, 12, 31, 0, 0, 0, 0);
     this.dtpEnd.MinDate       = new System.DateTime(1961, 8, 2, 0, 0, 0, 0);
     this.dtpEnd.Name          = "dtpEnd";
     this.dtpEnd.ShowUpDown    = true;
     this.dtpEnd.Size          = new System.Drawing.Size(192, 20);
     this.dtpEnd.TabIndex      = 8;
     this.dtpEnd.Value         = new System.DateTime(2008, 8, 29, 0, 0, 0, 0);
     this.dtpEnd.ValueChanged += new System.EventHandler(this.OnEndDateChanged);
     //
     // dlgOpen
     //
     this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
     this.ClientSize        = new System.Drawing.Size(330, 160);
     this.Controls.Add(this.dtpEnd);
     this.Controls.Add(this.dtpStart);
     this.Controls.Add(this._lblEDate);
     this.Controls.Add(this._lblSDate);
     this.Controls.Add(this._lblTerminal);
     this.Controls.Add(this.cboTerminal);
     this.Controls.Add(this.btnCancel);
     this.Controls.Add(this.btnOK);
     this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
     this.Icon            = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
     this.MaximizeBox     = false;
     this.MinimizeBox     = false;
     this.Name            = "dlgOpen";
     this.ShowInTaskbar   = false;
     this.StartPosition   = System.Windows.Forms.FormStartPosition.CenterParent;
     this.Text            = "Open Driver Compensation";
     this.TopMost         = true;
     this.Load           += new System.EventHandler(this.OnFormLoad);
     ((System.ComponentModel.ISupportInitialize)(this.mTerminals)).EndInit();
     this.ResumeLayout(false);
 }