示例#1
0
    protected void btnDeleteBreak_Click(object sender, EventArgs e)
    {
        List <RateDefinitionColum> wb = ExtractBreaksFromGridBreak();

        wb.RemoveAt(int.Parse(((ImageButton)sender).CommandArgument));
        GridBreak.DataSource = wb;
        GridBreak.DataBind();
    }
示例#2
0
    protected void btnAddNewBreak_Click(object sender, EventArgs e)
    {
        List <RateDefinitionColum> wb = ExtractBreaksFromGridBreak();

        wb.Add(new RateDefinitionColum()
        {
            ID = wb.Count
        });
        GridBreak.DataSource = wb;
        GridBreak.DataBind();
    }
示例#3
0
    private void ResetGridBreak()
    {
        ComboDestination.Value = "";
        ComboOrigin.Value      = "";
        ddlUnit.SelectedIndex  = 0;
        List <RateDefinitionColum> wb = new List <RateDefinitionColum>();

        wb.Add(new RateDefinitionColum());
        wb.Add(new RateDefinitionColum());
        wb.Add(new RateDefinitionColum());
        wb.Add(new RateDefinitionColum());
        wb.Add(new RateDefinitionColum());
        GridBreak.DataSource = wb;
        GridBreak.DataBind();
    }
示例#4
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);
    }