Beispiel #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
                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); }
        }