예제 #1
0
 private static void SetMissingDropDownTextForRateHeaderRow(RateHeaderRow HeaderRow)
 {
     foreach (var col in HeaderRow.RateHeaderColumns)
     {
         if (col.IsDropDown == true)
         {
             if (col.DropDownType == ColumnDropDownType.Unit)
             {
                 col.Text = col.Value == "K" ? "KG" : "LB";
             }
             else if (col.DropDownType == ColumnDropDownType.Port)
             {
                 col.Text = col.Value;
             }
             else if (col.DropDownType == ColumnDropDownType.Carrier)
             {
                 col.Text = col.Text;
             }
         }
         else
         {
             if (col.Value == "" || col.Value == null)
             {
                 col.Text = "";
                 if (col.IsMin)
                 {
                     col.Text = "MIN.($)";
                 }
                 if (col.IsProfitShare)
                 {
                     col.Text = "Profit Share(%)";
                 }
             }
         }
     }
 }
예제 #2
0
        private static Rate GenerateEmptyRateAndCreateHeaderText(RateRouting routing, RateHeaderRow HeaderRow)
        {
            Rate emptyRate = new Rate();

            emptyRate.CarrierCode = "-1";
            int ratedef_id         = 1;
            RateDefinitionColum wb = new RateDefinitionColum();
            int HeaderStartIndex   = 0;
            int HeaderRowCount     = 0;

            if (HeaderRow.RateType == RateType.CustomerSellingRate)
            {
                HeaderStartIndex = AppConstants.CustomerSellingRateHeaderColumnStartIndex;
                HeaderRowCount   = AppConstants.CustomerSellingRateDataColumnCount;
            }
            else if (HeaderRow.RateType == RateType.AirLineBuyingRate)
            {
                HeaderStartIndex = AppConstants.AirLineBuyingRateHeaderColumnStartIndex;
                HeaderRowCount   = AppConstants.AirLineBuyingRateDataColumnCount;
            }
            else if (HeaderRow.RateType == RateType.AgentBuyingRate)
            {
                HeaderStartIndex = AppConstants.AgentBuyingRateHeaderColumnStartIndex;
                HeaderRowCount   = AppConstants.AgentBuyingRateDataColumnCount;
            }
            else if (HeaderRow.RateType == RateType.IATARate)
            {
                HeaderStartIndex = AppConstants.IATARateHeaderColumnStartIndex;
                HeaderRowCount   = AppConstants.CustomerSellingRateDataColumnCount;
            }
            bool ValueExist = false;

            for (int i = HeaderStartIndex; i < HeaderRowCount - 1; i++)
            {
                if (HeaderRow.RateHeaderColumns[i].Value != null && HeaderRow.RateHeaderColumns[i].Value != "")
                {
                    ValueExist = true;
                    emptyRate.RateDefinitionColums.Add(new RateDefinitionColum()
                    {
                        Value = HeaderRow.RateHeaderColumns[i].Value, Rate = "", ID = ratedef_id++
                    });
                }
            }
            if (!ValueExist)
            {
                throw new Exception("At least one Rate Break shoud exist!");
            }
            RateManagementBL bl = new RateManagementBL();

            bl.GetNextRateID();
            emptyRate.RateID  = bl.GetNextRateID();
            emptyRate.RouteID = routing.ID;
            return(emptyRate);
        }
예제 #3
0
        private void GetNewRouteInfoFromView(RateTable model, RateRouting routing)
        {
            RateManagementBL bl = new RateManagementBL();
            var rRList          = bl.GetRateRoutingFromSession((int)model.RateType);

            RateHeaderRow HeaderRow = model.RateRoutes[0].HeaderRow;

            try
            {
                if (model.RateType == RateType.CustomerSellingRate)
                {
                    //Check if 같은 customer , 같은 destination 그리고 같은 orgin 그리고 같은 Unit 이 있는지 보라.

                    routing.customer_org_account_number = int.Parse(HeaderRow.RateHeaderColumns[0].Value);
                    routing.CustomerOrgName             = HeaderRow.RateHeaderColumns[0].Text;
                    routing.Origin             = HeaderRow.RateHeaderColumns[1].Value;
                    routing.Dest               = HeaderRow.RateHeaderColumns[2].Value;
                    routing.elt_account_number = int.Parse(GetCurrentELTUser().elt_account_number);
                    routing.Unit               = HeaderRow.RateHeaderColumns[3].Value;
                    routing.UnitText           = HeaderRow.RateHeaderColumns[3].Text;

                    if (routing.Origin == routing.Dest)
                    {
                        throw new Exception("Destination cannot be the same as the Origination!");
                    }

                    var exists = from c in rRList where c.Dest == routing.Dest && c.Origin == routing.Dest && c.Unit == routing.Unit && c.customer_org_account_number == routing.customer_org_account_number select c;
                    if (exists.Count() > 0)
                    {
                        throw new Exception("Same route exists!");
                    }

                    Rate emptyRate = GenerateEmptyRateAndCreateHeaderText(routing, HeaderRow);
                    routing.Rates.Add(emptyRate);
                }
                if (model.RateType == RateType.AgentBuyingRate)
                {
                    //Check if 같은 agent, 같은 destination 그리고 같은 orgin 그리고 같은 Unit 이 있는지 보라.
                    routing.agent_org_account_number = int.Parse(HeaderRow.RateHeaderColumns[0].Value);
                    routing.AgentOrgName             = HeaderRow.RateHeaderColumns[0].Text;
                    routing.Origin             = HeaderRow.RateHeaderColumns[1].Value;
                    routing.Dest               = HeaderRow.RateHeaderColumns[2].Value;
                    routing.elt_account_number = int.Parse(GetCurrentELTUser().elt_account_number);
                    routing.Unit               = HeaderRow.RateHeaderColumns[3].Value;
                    routing.UnitText           = HeaderRow.RateHeaderColumns[3].Text;
                    var exists = from c in rRList where c.Dest == routing.Dest && c.Origin == routing.Dest && c.Unit == routing.Unit && c.agent_org_account_number == routing.agent_org_account_number select c;
                    if (exists.Count() > 0)
                    {
                        throw new Exception("Same route exists!");
                    }
                    if (routing.Origin == routing.Dest)
                    {
                        throw new Exception("Destination cannot be the same as the Origination!");
                    }
                    Rate emptyRate = GenerateEmptyRateAndCreateHeaderText(routing, HeaderRow);
                    routing.Rates.Add(emptyRate);
                }

                if (model.RateType == RateType.AirLineBuyingRate)
                {
                    //Check if  같은 destination 그리고 같은 orgin 그리고 같은 Unit 이 있는지 보라.

                    routing.Origin             = HeaderRow.RateHeaderColumns[0].Value;
                    routing.Dest               = HeaderRow.RateHeaderColumns[1].Value;
                    routing.elt_account_number = int.Parse(GetCurrentELTUser().elt_account_number);
                    routing.Unit               = HeaderRow.RateHeaderColumns[2].Value;
                    routing.UnitText           = HeaderRow.RateHeaderColumns[2].Text;

                    var exists = from c in rRList where c.Dest == routing.Dest && c.Origin == routing.Dest && c.Unit == routing.Unit select c;
                    if (exists.Count() > 0)
                    {
                        throw new Exception("Same route exists!");
                    }
                    if (routing.Origin == routing.Dest)
                    {
                        throw new Exception("Destination cannot be the same as the Origination!");
                    }

                    Rate emptyRate = GenerateEmptyRateAndCreateHeaderText(routing, HeaderRow);
                    routing.Rates.Add(emptyRate);
                }

                if (model.RateType == RateType.IATARate)
                {
                    //Check if  같은 destination 그리고 같은 orgin 그리고 같은 Unit 이 있는지 보라.
                    routing.Origin             = HeaderRow.RateHeaderColumns[0].Value;
                    routing.Dest               = HeaderRow.RateHeaderColumns[1].Value;
                    routing.elt_account_number = int.Parse(GetCurrentELTUser().elt_account_number);
                    routing.Unit               = HeaderRow.RateHeaderColumns[2].Value;
                    routing.UnitText           = HeaderRow.RateHeaderColumns[2].Text;

                    var exists = from c in rRList where c.Dest == routing.Dest && c.Origin == routing.Dest && c.Unit == routing.Unit select c;
                    if (exists.Count() > 0)
                    {
                        throw new Exception("Same route exists!");
                    }
                    if (routing.Origin == routing.Dest)
                    {
                        throw new Exception("Destination cannot be the same as the Origination!");
                    }
                    Rate emptyRate = GenerateEmptyRateAndCreateHeaderText(routing, HeaderRow);
                    routing.Rates.Add(emptyRate);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }