Пример #1
0
    protected void goBtn_Click(object sender, ImageClickEventArgs e)
    {
        bl.ClearRateRoutings();

        if (ComboCompanyList.Value != null)
        {
            customer_org_num = int.Parse(ComboCompanyList.Value.ToString());
        }
        rate_type = int.Parse(ddlRateType.SelectedValue);
        bl.SetParms(elt_account_number, customer_org_num, rate_type);
        GridMaster.DataBind();
        GridMaster.Visible = true;
        HideShowColumns(GridMaster);
    }
Пример #2
0
    protected void btnCreate_Click(object sender, EventArgs e)
    {
        if (ComboOrigin.SelectedItem == null)
        {
            ScriptManager.RegisterClientScriptBlock(this, GetType(), "nonum", "alert('Origin is required!');", true);
            return;
        }
        if (ComboDestination.SelectedItem == null)
        {
            ScriptManager.RegisterClientScriptBlock(this, GetType(), "nonum", "alert('Destination is required!');", true);
            return;
        }
        RateRouting routing = new RateRouting();

        routing.Origin   = ComboOrigin.SelectedItem.Value.ToString();
        routing.Dest     = ComboDestination.SelectedItem.Value.ToString();
        routing.Unit     = ddlUnit.SelectedItem.Value.ToString();
        routing.UnitText = ddlUnit.SelectedItem.Text.ToString();
        List <RateRouting> list = bl.GetRateRoutings(elt_account_number, customer_org_num, rate_type);
        var exist = from c in list where c.Origin == routing.Origin && c.Dest == routing.Dest && c.Unit == routing.Unit select c;

        if (exist.Count() > 0)
        {
            ScriptManager.RegisterClientScriptBlock(this, GetType(), "reroute", "alert('Route already exists!');", true);
            return;
        }
        if (rate_type == 4)
        {
            routing.customer_org_account_number = int.Parse(ComboCompanyList.SelectedItem.Value.ToString());
            ClientProfileBL ClientProfileBL = new ClientProfileBL();
            routing.CustomerOrgName = ClientProfileBL.GetClient(elt_account_number, routing.customer_org_account_number).dba_name;
        }
        else if (rate_type == 1)
        {
            routing.agent_org_account_number = int.Parse(ComboCompanyList.SelectedItem.Value.ToString());
            ClientProfileBL ClientProfileBL = new ClientProfileBL();
            routing.AgentOrgName = ClientProfileBL.GetClient(elt_account_number, routing.customer_org_account_number).dba_name;
        }

        Rate defaultRate = new Rate();

        defaultRate.RateID  = bl.GetNextRateID();
        defaultRate.RouteID = routing.ID;
        defaultRate.Share   = "0";
        routing.Rates.Add(defaultRate);
        int null_count = 0;

        for (int i = 0; i < GridBreak.Rows.Count; i++)
        {
            var text = ((TextBox)GridBreak.Rows[i].Cells[1].Controls[1]).Text;
            if (string.IsNullOrEmpty(text))
            {
                null_count++;
                continue;
            }
            if (!ELT.COMMON.Util.IsNumber(text))
            {
                List <RateDefinitionColum> wb = ExtractBreaksFromGridBreak();
                GridBreak.DataSource = wb;
                GridBreak.DataBind();
                ScriptManager.RegisterClientScriptBlock(this, GetType(), "nonum", "alert('Range should be a number!');", true);

                return;
            }
            defaultRate.RateDefinitionColums.Add(new RateDefinitionColum()
            {
                ID = i, Caption = text, Value = text
            });
        }
        if (null_count == GridBreak.Rows.Count)
        {
            ScriptManager.RegisterClientScriptBlock(this, GetType(), "noelem", "alert('At least one Range Start is required!');", true);
            return;
        }
        var count = defaultRate.RateDefinitionColums.GroupBy(w => w.Caption).Select(x => x.Count() > 1).FirstOrDefault();

        if (count)
        {
            ScriptManager.RegisterClientScriptBlock(this, GetType(), "samenum", "alert('You cannot have duplicate Ranage Start!');", true);
            return;
        }
        int routeid = bl.InsertRoute(routing);

        GridMaster.DataBind();
        ResetGridBreak();
        ScriptManager.RegisterClientScriptBlock(this, GetType(), "CloseNewRouting", "CloseNewRouting();", true);
        ScriptManager.RegisterClientScriptBlock(this, GetType(), "SaveBreaks", "redirectBack();", true);
    }