예제 #1
0
    void Populate()
    {
        string errorMessage = null;

        if (Session[_contextKey] != null)
        {
            DEAContext context = Session[_contextKey] as DEAContext;
            DataSet    ds      = context.ToDataSet(out errorMessage);
            if (ds != null)
            {
                GridViewProjects.Columns.Clear();
                BoundField bf = new BoundField();
                bf.HeaderText = context.ProjectIDFieldName;
                bf.DataField  = "NAME";
                GridViewProjects.Columns.Add(bf);

                foreach (DataRow r in ds.Tables["VARIABLES"].Rows)
                {
                    string varName = r["NAME"].ToString();
                    bf = new BoundField();
                    bf.HeaderStyle.CssClass      = "text-right";
                    bf.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                    bf.HeaderText       = varName;
                    bf.DataField        = varName;
                    bf.DataFormatString = "{0:f6}";
                    GridViewProjects.Columns.Add(bf);
                }

                bf = new BoundField();
                bf.HeaderStyle.CssClass      = "text-right";
                bf.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                bf.HeaderText       = "Relative Efficiency";
                bf.DataField        = "RELATIVE_Efficiency";
                bf.DataFormatString = "{0:f6}";
                GridViewProjects.Columns.Add(bf);

                if (ds.Tables["CONSTRAINTS"].Rows != null && ds.Tables["CONSTRAINTS"].Rows.Count > 0)
                {
                    bf = new BoundField();
                    bf.HeaderStyle.CssClass      = "text-right";
                    bf.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                    bf.HeaderText = "Selected";
                    bf.DataField  = "SELECTED";
                    bf.ReadOnly   = true;
                    GridViewProjects.Columns.Add(bf);
                }

                bf = new BoundField();
                bf.HeaderStyle.CssClass = "text-right";
                bf.HeaderText           = "Approximate";
                bf.DataField            = "APPROXIMATE";
                bf.DataFormatString     = "{0}";
                GridViewProjects.Columns.Add(bf);

                GridViewProjects.DataSource = ds.Tables["PROJECTS"];
                GridViewProjects.DataBind();
            }
        }
    }
예제 #2
0
 private void load_grid()
 {
     GridViewProjects.DataSource = (from p in dbContext.projects
                                    select p).ToList();
     GridViewProjects.DataBind();
 }
예제 #3
0
 protected void dvTask_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
 {
     mvProjects.ActiveViewIndex = 0;
     GridViewProjects.DataBind();
 }
예제 #4
0
 protected void btnBackToProjects_Click(object sender, EventArgs e)
 {
     mvProjects.ActiveViewIndex = 0;
     GridViewProjects.DataBind();
 }
예제 #5
0
    public void Populate(string err = null)
    {
        string  errorMessage = null;
        DataSet ds           = null;

        try
        {
            if (Session[_contextKey] != null)
            {
                DEAContext context = Session[_contextKey] as DEAContext;
                ds = context.ToDataSet(out errorMessage);
                if (ds != null)
                {
                    GridViewParams.DataSource = ds.Tables["PARAMETERS"];
                    GridViewParams.DataBind();

                    GridViewVars.DataSource = ds.Tables["VARIABLES"];
                    GridViewVars.DataBind();

                    GridViewConst.DataSource = ds.Tables["CONSTRAINTS"];
                    GridViewConst.DataBind();

                    if (ds.Tables["CONSTRAINTS"].Rows == null || ds.Tables["CONSTRAINTS"].Rows.Count < 1)
                    {
                        LabelConst.Visible = false;
                    }

                    GridViewProjects.Columns.Clear();
                    BoundField bf = new BoundField();
                    bf.HeaderText = context.ProjectIDFieldName;
                    bf.DataField  = "NAME";
                    GridViewProjects.Columns.Add(bf);

                    foreach (DataRow r in ds.Tables["VARIABLES"].Rows)
                    {
                        string varName = r["NAME"].ToString();
                        bf = new BoundField();
                        bf.HeaderStyle.CssClass      = "text-right";
                        bf.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                        bf.HeaderText       = varName;
                        bf.DataField        = varName;
                        bf.DataFormatString = "{0:f6}";
                        GridViewProjects.Columns.Add(bf);
                    }
                    GridViewProjects.DataSource = ds.Tables["PROJECTS"];
                    GridViewProjects.DataBind();
                }
            }
        }
        catch (Exception ex)
        {
            errorMessage       = ex.Message;
            LabelError.Text    = errorMessage;
            LabelError.Visible = true;
            ButtonRun.Visible  = false;
        }

        if (string.IsNullOrEmpty(errorMessage))
        {
            ButtonRun.Visible = true;
            if (ds != null)
            {
                if (ds.Tables["CONSTRAINTS"].Rows != null && ds.Tables["CONSTRAINTS"].Rows.Count > 0)
                {
                    ButtonRun.ToolTip = "Click to rank projects by their relative efficiency and apply constraints to their selection.";
                }
                else
                {
                    ButtonRun.ToolTip = "Click to rank projects by their relative efficiency.";
                }
            }


            if (!string.IsNullOrEmpty(err))
            {
                LabelError.Text    = err;
                LabelError.Visible = true;
            }
        }
    }