Exemple #1
0
    protected void gvSheets_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        GridViewRow row    = e.Row;
        int         rowidx = e.Row.RowIndex;

        if (row.RowType == DataControlRowType.DataRow)
        {
            for (int i = 0; i < 6; i++)
            {
                DropDownList ddl = (DropDownList)row.FindControlRecursive("ddl" + i.ToString());


                if (i == 1)
                {
                    DataTable methods = Master.SQL.DataTable_from_SQLstring("select method from gev.method");
                    ddl.DataSource     = methods;
                    ddl.DataTextField  = "method";
                    ddl.DataValueField = "method";
                }
                else
                {
                    string        cols_csv = colNames[rowidx];
                    List <string> cols     = cols_csv.Split('|').ToList();
                    ddl.DataSource = cols;
                }
                ddl.DataBind();
            }
        }
    }
        public void SaveMarks(object sender, EventArgs e)
        {
            GridView list = (GridView)Page.FindControlRecursive("fileList");

            for (int i = 0; i < list.Rows.Count; i++)
            {
                GridViewRow     row        = list.Rows[i];
                TextBox         mark       = (TextBox)row.FindControlRecursive("mark");
                HiddenField     userid     = (HiddenField)row.FindControlRecursive("userid");
                HiddenField     resourceid = (HiddenField)row.FindControlRecursive("resourceid");
                AddJoinUserMark join       = new AddJoinUserMark();
                bool            addSuccess = join.UpdateMark(int.Parse(resourceid.Value), userid.Value, float.Parse(mark.Text));
                if (addSuccess)
                {
                    Response.Redirect(Request.RawUrl);
                }
            }
        }
        /// <summary>
        /// Handles the RowUpdating event of the m_AvailableGridView control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridViewUpdateEventArgs" /> instance containing the event data.</param>
        protected void m_AvailableGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            SPGridView _sender = sender as SPGridView;

            if (_sender == null)
            {
                return;
            }
            //Update the values.
            GridViewRow row      = _sender.Rows[e.RowIndex];
            Label       _idLabel = (Label)row.FindControlRecursive(m_IDEditLabel);
            double      _qtty    = default(double);

            Selection.SelectionTableRow _slctdItem = m_ControlState.AvailableItems.SelectionTable.FindByID(_idLabel.Text);
            TextBox _quantityTB = (TextBox)row.FindControlRecursive(m_QuantityNewValue);

            if (!double.TryParse(_quantityTB.Text, out _qtty) || (_slctdItem.Quantity < _qtty))
            {
                _quantityTB.Text        = _slctdItem.Quantity.ToString("F2");
                _quantityTB.BorderColor = System.Drawing.Color.Red;
                _quantityTB.BackColor   = System.Drawing.Color.Yellow;
                e.Cancel = true;
                return;
            }
            Selection.SelectionTableRow _assignedRow = m_ControlState.AssignedItems.SelectionTable.FindByID(_idLabel.Text);
            if (_assignedRow == null)
            {
                m_ControlState.AssignedItems.SelectionTable.ImportRow(_slctdItem);
                _assignedRow          = m_ControlState.AssignedItems.SelectionTable.FindByID(_idLabel.Text);
                _assignedRow.Quantity = _qtty;
            }
            else
            {
                _assignedRow.Quantity += _qtty;
            }
            _assignedRow.AcceptChanges();
            _assignedRow.SetAdded();
            _slctdItem.Quantity -= _qtty;
            _sender.EditIndex    = -1;
            e.Cancel             = true;
        }
        private static void GetRow(SPGridView sender, GridViewSelectEventArgs e, Selection.SelectionTableDataTable destination, Selection.SelectionTableDataTable source)
        {
            if (sender == null)
            {
                return;
            }
            GridViewRow row = sender.Rows[e.NewSelectedIndex];
            string      _id = ((Label)row.FindControlRecursive(m_IDItemLabel)).Text;

            destination.GetRow(source, _id);
            e.NewSelectedIndex = -1;
            e.Cancel           = true;
        }
Exemple #5
0
    protected void SaveSheet(int idx)
    {
        SQL_utils sql = new SQL_utils("backend");

        GridViewRow row = gvSheets.Rows[idx - 1];

        bool validSelections = true;

        string[] ddl_values = new string[6];

        if (row.RowType == DataControlRowType.DataRow)
        {
            for (int i = 0; i < 6; i++)
            {
                DropDownList ddl = (DropDownList)row.FindControlRecursive("ddl" + i.ToString());
                ddl_values[i] = ddl.SelectedValue;

                if (ddl.SelectedValue == "..select..")
                {
                    validSelections = false;
                }
            }

            if (!validSelections)
            {
                lblSubmitInfo.Text      = "Select a value for each parameter. (Use **NA** if the parameter is not present in the data).";
                lblSubmitInfo.ForeColor = System.Drawing.Color.Red;
            }

            else
            {   //Proceed - no invalid selections
                lblSubmitInfo.Text = "";

                List <SqlParameter> p = new List <SqlParameter>();

                DataTable dt = dset.Tables[idx - 1];

                int filepk = 0;
                filepk = sql.IntScalar_from_SQLstring("select coalesce(max(filepk) + 1,1) from gev.files");


                DataColumn methodCol = new System.Data.DataColumn("method", typeof(System.String));
                methodCol.DefaultValue = ddl_values[1];
                dt.Columns.Add(methodCol);


                p.Add(sql.CreateParam("filepk", filepk.ToString(), "int"));
                p.Add(sql.CreateParam("filename", FileName, "text"));
                p.Add(sql.CreateParam("sheetname", dt.TableName, "text"));
                p.Add(sql.CreateParam("numrows", dt.Rows.Count.ToString(), "int"));
                p.Add(sql.CreateParam("numcols", dt.Columns.Count.ToString(), "int"));
                p.Add(sql.CreateParam("col_id", ddl_values[0], "text"));
                p.Add(sql.CreateParam("col_method", "method", "text"));
                p.Add(sql.CreateParam("col_gene", ddl_values[2], "text"));
                p.Add(sql.CreateParam("col_region", ddl_values[3], "text"));
                p.Add(sql.CreateParam("col_eventtype", ddl_values[4], "text"));
                p.Add(sql.CreateParam("col_inheritance", ddl_values[5], "text"));

                //OUTPUT Parameter not working
                //p.Add(Master.SQL.CreateParam("output", "output", "int", "output"));

                string p_vals =
                    "filename " + FileName + "<br/>" +
                    "sheetname " + dt.TableName + "<br/>" +
                    "numrows " + dt.Rows.Count.ToString() + "<br/>" +
                    "numcols " + dt.Columns.Count.ToString() + "<br/>" +
                    "col_id " + ddl_values[0] + "<br/>" +
                    "col_method " + ddl_values[1] + "<br/>" +
                    "col_gene " + ddl_values[2] + "<br/>" +
                    "col_region " + ddl_values[3] + "<br/>" +
                    "col_eventtype " + ddl_values[4] + "<br/>" +
                    "col_inheritance " + ddl_values[5] + "<br/>";


                string sfilepk = "";

                try
                {
                    sfilepk            = sql.StringScalar_from_ProcName("gev.spFiles_INSERT", p);
                    lblSubmitInfo.Text = "New filepk = " + filepk.ToString() + ".  ";


                    //Hide this row
                    gvSheets.Rows[idx - 1].Visible = false;

                    int n_visible = 0;
                    for (int r = 0; r < gvSheets.Rows.Count; r++)
                    {
                        if (gvSheets.Rows[r].Visible == true)
                        {
                            n_visible++;
                        }
                    }
                    if (n_visible == 0)
                    {
                        panelSheets.Visible = false;
                    }


                    if (filepk > 0)
                    {
                        SaveDataTableToSQL(dt, filepk);
                    }
                }
                catch (Exception ex)
                {
                    lblSubmitInfo.Text += sfilepk + "<br/>" + ex.Message;
                }
            }
        }
    }