Exemplo n.º 1
0
    private void Edit(int filter_id)
    {
        DataRow dr = ProfileMetric.GetThreshold(filter_id);

        if (dr != null)
        {
            ltfilter_displayname.Text = dr["threshold_filter_displayname"].ToString();

            txtfilter_ytd.Text = dr["threshold_filter_ytd"].ToString();
            txtfilter_yoy.Text = dr["threshold_filter_yoy"].ToString();

            if (dr["threshold_filter_ytd_operator"] != System.DBNull.Value &&
                ddlfilter_ytd_operator.Items.FindByValue(dr["threshold_filter_ytd_operator"].ToString()) != null)
            {
                ddlfilter_ytd_operator.SelectedValue = dr["threshold_filter_ytd_operator"].ToString();
            }

            if (dr["threshold_filter_yoy_operator"] != System.DBNull.Value &&
                ddlfilter_yoy_operator.Items.FindByValue(dr["threshold_filter_yoy_operator"].ToString()) != null)
            {
                ddlfilter_yoy_operator.SelectedValue = dr["threshold_filter_yoy_operator"].ToString();
            }
        }

        ViewState["edit_filter_id"] = filter_id;
        pnlAddEdit.Visible          = true;
    }
Exemplo n.º 2
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            if (ViewState["edit_filter_id"] != null && (int)ViewState["edit_filter_id"] > 0)
            {
                DataRow dr = ProfileMetric.GetThreshold((int)ViewState["edit_filter_id"]);

                if (dr != null)
                {
                    if (dr != null)
                    {
                        if (txtfilter_ytd.Text == string.Empty)
                        {
                            dr["threshold_filter_ytd"] = System.DBNull.Value;
                        }
                        else
                        {
                            dr["threshold_filter_ytd"] = decimal.Parse(txtfilter_ytd.Text);
                        }

                        if (txtfilter_yoy.Text == string.Empty)
                        {
                            dr["threshold_filter_yoy"] = System.DBNull.Value;
                        }
                        else
                        {
                            dr["threshold_filter_yoy"] = decimal.Parse(txtfilter_yoy.Text);
                        }

                        dr["threshold_filter_ytd_operator"] = int.Parse(ddlfilter_ytd_operator.SelectedValue);
                        dr["threshold_filter_yoy_operator"] = int.Parse(ddlfilter_yoy_operator.SelectedValue);
                    }

                    dr.AcceptChanges();
                }

                ltMessage.Text = "Threshold update successful";
            }
            else
            {
                ltMessage.Text = "Error occurred while saving changes";
            }

            if (ViewState["redirect"] != null)
            {
                Response.Redirect(ViewState["redirect"].ToString());
            }
            else
            {
                Clear();
                BindGrid();
            }
        }
    }
    protected void gvThresholds_RowEditing(object sender, GridViewEditEventArgs e)
    {
        int filter_id = (int)gvThresholds.DataKeys[e.NewEditIndex].Value;

        DataRow dr = ProfileMetric.GetThreshold(filter_id);

        if (dr != null)
        {
            txtfilter_desc.Text        = dr["threshold_filter_desc"].ToString();
            txtfilter_displayname.Text = dr["threshold_filter_displayname"].ToString();
            txtfilter_ytd.Text         = dr["threshold_filter_ytd"].ToString();
            txtfilter_yoy.Text         = dr["threshold_filter_yoy"].ToString();
            if (ddlfilter_formatstring.Items.FindByValue(dr["threshold_filter_formatstring"].ToString()) != null)
            {
                ddlfilter_formatstring.SelectedValue = dr["threshold_filter_formatstring"].ToString();
            }

            chkfilter_percentage.Checked = (dr["threshold_filter_percentage"] != System.DBNull.Value &&
                                            (bool)dr["threshold_filter_percentage"] == true);

            if (dr["threshold_filter_ytd_operator"] != System.DBNull.Value &&
                ddlfilter_ytd_operator.Items.FindByValue(dr["threshold_filter_ytd_operator"].ToString()) != null)
            {
                ddlfilter_ytd_operator.SelectedValue = dr["threshold_filter_ytd_operator"].ToString();
            }

            if (dr["threshold_filter_yoy_operator"] != System.DBNull.Value &&
                ddlfilter_yoy_operator.Items.FindByValue(dr["threshold_filter_yoy_operator"].ToString()) != null)
            {
                ddlfilter_yoy_operator.SelectedValue = dr["threshold_filter_yoy_operator"].ToString();
            }
        }

        ViewState["edit_filter_id"] = filter_id;
        e.Cancel = true;

        btnSave.Text = "Save Threshold";
    }