protected void ASPxButton1_Click(object sender, EventArgs e)
    {
        Dictionary <object, int> lowerBoundStorage = Session["lowerBoundStorage"] as Dictionary <object, int>;

        if (lowerBoundStorage == null)
        {
            lowerBoundStorage = new Dictionary <object, int>();
        }

        int startIndex = ASPxGridView1.PageIndex * ASPxGridView1.SettingsPager.PageSize;
        int endIndex   = Math.Min(ASPxGridView1.VisibleRowCount, startIndex + ASPxGridView1.SettingsPager.PageSize);

        for (int i = startIndex; i < endIndex; i++)
        {
            ASPxSpinEdit txtLowerBound = (ASPxSpinEdit)ASPxGridView1.FindRowCellTemplateControl(i, (GridViewDataColumn)ASPxGridView1.Columns["LowerBound"], "txtLB");
            if (txtLowerBound.Text == "")
            {
                return;
            }
            int    lowerBound = int.Parse(txtLowerBound.Text.Trim());
            object key        = ASPxGridView1.GetRowValues(i, "CategoryID");
            if (!lowerBoundStorage.ContainsKey(key))
            {
                lowerBoundStorage.Add(key, lowerBound);
            }
            else
            {
                lowerBoundStorage[key] = lowerBound;
            }
        }
        Session["lowerBoundStorage"] = lowerBoundStorage;
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     list = new Record[ASPxGridView1.SettingsPager.PageSize];
     for (int i = 0; i < ASPxGridView1.SettingsPager.PageSize; i++)
     {
         list[i].id = -1;
         int         vi      = ASPxGridView1.VisibleStartIndex + i;
         ASPxTextBox txtBox1 = (ASPxTextBox)ASPxGridView1.FindRowCellTemplateControl(vi, (GridViewDataColumn)ASPxGridView1.Columns["Num"], "txtBox");
         if (txtBox1 == null)
         {
             continue;
         }
         try
         {
             StringBuilder sb = new StringBuilder();
             for (int j = 0; j < Codes.Length; j++)
             {
                 string             code = Codes.Substring(j, 1);
                 GridViewDataColumn col  = (GridViewDataColumn)ASPxGridView1.Columns[code];
                 ASPxComboBox       cbx  = (ASPxComboBox)ASPxGridView1.FindRowCellTemplateControl(vi, col, "cbx_" + code);
                 if (Convert.ToBoolean(cbx.Value))
                 {
                     sb.Append(code);
                 }
             }
             list[i].id   = Convert.ToInt32(ASPxGridView1.GetRowValues(vi, ASPxGridView1.KeyFieldName));
             list[i].num  = Convert.ToInt32(txtBox1.Text);
             list[i].code = sb.ToString();
         }
         catch { }
     }
     BindGridToData(ASPxGridView1);
     ASPxGridView1.JSProperties["cpCodes"] = Codes;
 }
示例#3
0
 protected void ASPxGridView1_HtmlDataCellPrepared(object sender, ASPxGridViewTableDataCellEventArgs e)
 {
     if (e.DataColumn.FieldName == "title")
     {
         ASPxTextBox textBox = ASPxGridView1.FindRowCellTemplateControl(e.VisibleIndex, e.DataColumn, "ASPxTextBox1") as ASPxTextBox;
         textBox.Text = Convert.ToString(e.CellValue);
     }
 }
示例#4
0
    protected void ASPxGridView2_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
    {
        ASPxGridView g2 = (ASPxGridView)sender;
        DataTable    dataSourceSelectedValues = new DataTable();

        dataSourceSelectedValues.Columns.Add(new DataColumn("CategoryID"));
        dataSourceSelectedValues.Columns.Add(new DataColumn("CategoryName"));
        dataSourceSelectedValues.Columns.Add(new DataColumn("Description"));
        dataSourceSelectedValues.Columns.Add(new DataColumn("LowerBound"));

        dataSourceSelectedValues.PrimaryKey = new DataColumn[] { dataSourceSelectedValues.Columns["CategoryID"] };
        int indexSelectedValues = 0;

        Dictionary <object, int> lowerBoundStorage = Session["lowerBoundStorage"] as Dictionary <object, int>;

        if (lowerBoundStorage == null)
        {
            lowerBoundStorage = new Dictionary <object, int>();
        }
        for (int i = 0; i < ASPxGridView1.VisibleRowCount; i++)
        {
            ASPxTextBox txtLowerBound = (ASPxTextBox)ASPxGridView1.FindRowCellTemplateControl(i, (GridViewDataColumn)ASPxGridView1.Columns["LowerBound"], "txtLB");
            int         lowerBound    = 0;
            object      key           = ASPxGridView1.GetRowValues(i, "CategoryID");
            if (txtLowerBound != null)
            {
                lowerBound = int.Parse(txtLowerBound.Text.Trim());
                if (!lowerBoundStorage.ContainsKey(key))
                {
                    lowerBoundStorage.Add(key, lowerBound);
                }
                else
                {
                    lowerBoundStorage[key] = lowerBound;
                }
            }
            else
            {
                if (lowerBoundStorage.ContainsKey(key))
                {
                    lowerBound = lowerBoundStorage[key];
                }
            }

            if (ASPxGridView1.Selection.IsRowSelected(i))
            {
                dataSourceSelectedValues.ImportRow(ASPxGridView1.GetDataRow(i));
                DataRow dataRow = dataSourceSelectedValues.Rows[indexSelectedValues];
                dataRow["LowerBound"] = lowerBound;
                indexSelectedValues++;
            }
        }
        Session["dataSourceSelectedValues"] = dataSourceSelectedValues;
        Session["lowerBoundStorage"]        = lowerBoundStorage;

        g2.DataSource = Session["dataSourceSelectedValues"];
        g2.DataBind();
    }
示例#5
0
    protected void ToSave(object sender, EventArgs e)
    {
        SqlConnection  con = new SqlConnection(clsSQLCommond.Online);
        SqlCommand     cmd = new SqlCommand();
        SqlTransaction trans;

        con.Open();
        cmd.Connection  = con;
        trans           = con.BeginTransaction();
        cmd.Transaction = trans;
        string uID  = Session["uID"].ToString();
        string sErr = "";

        try
        {
            GridViewDataColumn column1 = ASPxGridView1.Columns["iCheck"] as GridViewDataColumn;

            for (int i = 0; i < ASPxGridView1.VisibleRowCount; i++)
            {
                ASPxCheckBox checkBox = (ASPxCheckBox)ASPxGridView1.FindRowCellTemplateControl(i, column1, "ASPxCheckBox1");
                if (checkBox != null)
                {
                    bool   isVisible = checkBox.Checked;
                    string ID        = ASPxGridView1.GetRowValues(i, "vchrRoleID").ToString();
                    if (ID != "")
                    {
                        sSQL = "select * from _UserRoleInfo where vchrRoleID='" + ID + "' and vchrUserID='" + ASPxTextBox1.Value + "'";
                        dt   = clsSQLCommond.ExecQuery(sSQL);
                        if (isVisible == true && dt.Rows.Count == 0)
                        {
                            sSQL            = "insert into _UserRoleInfo(vchrRoleID,vchrUserID) values('" + ID + "','" + ASPxTextBox1.Value + "') ";
                            cmd.CommandText = sSQL;
                            cmd.ExecuteNonQuery();
                        }
                        else if (isVisible == false && dt.Rows.Count == 1)
                        {
                            sSQL            = "delete from _UserRoleInfo where vchrRoleID='" + ID + "' and vchrUserID='" + ASPxTextBox1.Value + "'";
                            cmd.CommandText = sSQL;
                            cmd.ExecuteNonQuery();
                        }
                    }
                }
            }
            if (sErr != "")
            {
                throw new Exception(sErr);
            }
            trans.Commit();
            System.Web.HttpContext.Current.Response.Write("<script>alert('保存成功!');window.location=document.location.href</script>");
            ASPxGridView1.DataBind();
        }
        catch (Exception ee)
        {
            trans.Rollback();
            System.Web.HttpContext.Current.Response.Write("<script>alert('" + ee.Message + "');</script>");
        }
    }
    private DateTime CheckDateEdit(string dateEditName, int visibleIndex)
    {
        ASPxDateEdit de2 = ASPxGridView1.FindRowCellTemplateControl(visibleIndex, (GridViewDataColumn)ASPxGridView1.Columns[dateEditName], dateEditName + visibleIndex) as ASPxDateEdit;

        if (de2 != null)
        {
            DateTime date2 = (DateTime)de2.Value;
            return(date2);
        }
        return(DateTime.MinValue);
    }
示例#7
0
    protected void ASPxButton1_Click(object sender, EventArgs e)
    {
        int startIndex = ASPxGridView1.PageIndex * ASPxGridView1.SettingsPager.PageSize;
        int endIndex   = Math.Min(ASPxGridView1.VisibleRowCount, startIndex + ASPxGridView1.SettingsPager.PageSize);

        for (int i = startIndex; i < endIndex; i++)
        {
            ASPxRadioButtonList rb   = (ASPxRadioButtonList)ASPxGridView1.FindRowCellTemplateControl(i, (GridViewDataColumn)ASPxGridView1.Columns[4], string.Format("rb_{0}", i));
            ASPxComboBox        cmb  = (ASPxComboBox)ASPxGridView1.FindRowCellTemplateControl(i, (GridViewDataColumn)ASPxGridView1.Columns[5], string.Format("cmb_{0}", i));
            ASPxMemo            memo = (ASPxMemo)ASPxGridView1.FindRowCellTemplateControl(i, (GridViewDataColumn)ASPxGridView1.Columns[5], string.Format("memo_{0}", i));
            //SAVE DATA
        }
    }
示例#8
0
        protected void ASPxButton1_Click(object sender, EventArgs e)
        {
            for (int i = ASPxGridView1.VisibleStartIndex; i < ASPxGridView1.VisibleStartIndex + ASPxGridView1.VisibleRowCount; i++)
            {
                ASPxRadioButton discontinued = ASPxGridView1.FindRowCellTemplateControl(i, ASPxGridView1.Columns["Discontinued"] as GridViewDataColumn, "btnDiscontinued") as ASPxRadioButton;
                object[]        vals         = (object[])ASPxGridView1.GetRowValues(i, new string[] { "ProductName", "UnitPrice", "ProductID" });

                SqlDataSource1.UpdateParameters["ProductName"].DefaultValue  = vals[0].ToString();
                SqlDataSource1.UpdateParameters["UnitPrice"].DefaultValue    = vals[1].ToString();
                SqlDataSource1.UpdateParameters["ProductID"].DefaultValue    = vals[2].ToString();
                SqlDataSource1.UpdateParameters["Discontinued"].DefaultValue = discontinued.Checked.ToString();
                //SqlDataSource1.Update();  //uncomment this line to submit changes to the database
            }
        }
示例#9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int start = ASPxGridView1.PageIndex * ASPxGridView1.SettingsPager.PageSize;
            int end   = (ASPxGridView1.PageIndex + 1) * ASPxGridView1.SettingsPager.PageSize;
            GridViewDataColumn column1 = ASPxGridView1.Columns["CategoryName"] as GridViewDataColumn;
            GridViewDataColumn column2 = ASPxGridView1.Columns["Description"] as GridViewDataColumn;

            for (int i = start; i < end; i++)
            {
                ASPxTextBox txtBox1 = (ASPxTextBox)ASPxGridView1.FindRowCellTemplateControl(i, column1, "txtBox");
                ASPxTextBox txtBox2 = (ASPxTextBox)ASPxGridView1.FindRowCellTemplateControl(i, column2, "txtBox");
                if (txtBox1 == null || txtBox2 == null)
                {
                    continue;
                }
                int id = Convert.ToInt32(ASPxGridView1.GetRowValues(i, ASPxGridView1.KeyFieldName));
                list.Add(new Record(id, txtBox1.Text, txtBox2.Text));
            }
        }
示例#10
0
    protected void ToDel(object sender, EventArgs e)
    {
        SqlConnection  con = new SqlConnection(clsSQLCommond.Online);
        SqlCommand     cmd = new SqlCommand();
        SqlTransaction trans;

        con.Open();
        cmd.Connection  = con;
        trans           = con.BeginTransaction();
        cmd.Transaction = trans;
        string uID  = Session["uID"].ToString();
        string sErr = "";

        try
        {
            GridViewDataColumn column1 = ASPxGridView1.Columns["iCheck"] as GridViewDataColumn;

            for (int i = 0; i < ASPxGridView1.VisibleRowCount; i++)
            {
                ASPxCheckBox checkBox = (ASPxCheckBox)ASPxGridView1.FindRowCellTemplateControl(i, column1, "ASPxCheckBox1");
                if (checkBox != null)
                {
                    bool isVisible = checkBox.Checked;
                    if (isVisible == true)
                    {
                        string ID = ASPxGridView1.GetRowValues(i, "vchrRoleID").ToString();

                        if (ID != "")
                        {
                            if (ID == "administrator" || ID == "systemset")
                            {
                                sErr = sErr + "账号" + ID + "为系统账号,不可删除" + "\\n";
                            }
                            else
                            {
                                sSQL            = @"delete from _RoleRight where vchrRoleID='" + ID + "'";
                                cmd.CommandText = sSQL;
                                cmd.ExecuteNonQuery();
                                sSQL            = @"delete from _UserRoleInfo where vchrRoleID='" + ID + "'";
                                cmd.CommandText = sSQL;
                                cmd.ExecuteNonQuery();
                                sSQL            = @"delete from " + tablename + " where vchrRoleID='" + ID + "'";
                                cmd.CommandText = sSQL;
                                cmd.ExecuteNonQuery();
                            }
                        }
                    }
                }
            }
            if (sErr != "")
            {
                throw new Exception(sErr);
            }
            trans.Commit();
            System.Web.HttpContext.Current.Response.Write("<script>alert('删除成功!');</script>");
            ASPxGridView1.DataBind();
        }
        catch (Exception ee)
        {
            trans.Rollback();
            System.Web.HttpContext.Current.Response.Write("<script>alert('" + ee.Message + "');</script>");
        }
    }
        protected void ASPxGridView1_HtmlRowPrepared(object sender, ASPxGridViewTableRowEventArgs e)
        {
            try
            {
                //string xMetric = ASPxGridView1.GetRowValues(0, "smetric").ToString();
                string xMetric = Convert.ToString(e.GetValue("smetric"));

                e.Row.Cells[6].Text = loadHighlights(xMetric);
                e.Row.Cells[9].Text = loadUpdates(xMetric);
                string[] xValoresM = loadMonthly(xMetric);
                string[] xValoresY = loadYearly(xMetric);
                decimal  v1        = Convert.ToDecimal(xValoresM[0]);
                decimal  v2        = Convert.ToDecimal(xValoresM[1]);
                decimal  v3        = Convert.ToDecimal(xValoresY[0]);
                decimal  v4        = Convert.ToDecimal(xValoresY[1]);
                if (regresValueType(xMetric) == 1)
                {
                    e.Row.Cells[1].Text = String.Format("{0:N0}", v1);
                    e.Row.Cells[2].Text = String.Format("{0:N0}", v2);
                    e.Row.Cells[3].Text = String.Format("{0:N0}", v3);
                    e.Row.Cells[4].Text = String.Format("{0:N0}", v4);
                }
                if (regresValueType(xMetric) == 2)
                {
                    e.Row.Cells[1].Text = String.Format("{0:C2}", v1 / 1000000) + "M";
                    e.Row.Cells[2].Text = String.Format("{0:C2}", v2 / 1000000) + "M";
                    e.Row.Cells[3].Text = String.Format("{0:C2}", v3 / 1000000) + "M";
                    e.Row.Cells[4].Text = String.Format("{0:C2}", v4 / 1000000) + "M";
                }
                if (regresValueType(xMetric) == 3)
                {
                    e.Row.Cells[1].Text = String.Format("{0:N2}", v1) + "%";
                    e.Row.Cells[2].Text = String.Format("{0:N2}", v2) + "%";
                    e.Row.Cells[3].Text = String.Format("{0:N2}", v3) + "%";
                    e.Row.Cells[4].Text = String.Format("{0:N2}", v4) + "%";
                }
                if (regresValueType(xMetric) == 33)
                {
                    e.Row.Cells[1].Text = String.Format("{0:N2}", v1) + "";
                    e.Row.Cells[2].Text = String.Format("{0:N2}", v2) + "";
                    e.Row.Cells[3].Text = String.Format("{0:N2}", v3) + "";
                    e.Row.Cells[4].Text = String.Format("{0:N2}", v4) + "";
                }
                if (regresValueType(xMetric) == 22)
                {
                    e.Row.Cells[1].Text = String.Format("{0:C2}", v1 / 1000) + "K";
                    e.Row.Cells[2].Text = String.Format("{0:C2}", v2 / 1000) + "K";
                    e.Row.Cells[3].Text = String.Format("{0:C2}", v3 / 1000) + "K";
                    e.Row.Cells[4].Text = String.Format("{0:C2}", v4 / 1000) + "K";
                }

                ASPxImage img = ASPxGridView1.FindRowCellTemplateControl(e.VisibleIndex, null, "imgControl") as ASPxImage;
                if (regresaIconType(xMetric) == 1)
                {
                    if (v1 < v2)
                    {
                        img.ImageUrl = "img/bad.png";
                    }
                    else
                    {
                        img.ImageUrl = "img/good.png";
                    }
                }
                else
                {
                    if (v1 < v2)
                    {
                        img.ImageUrl = "img/goodB.png";
                    }
                    else
                    {
                        img.ImageUrl = "img/badB.png";
                    }
                }
            }
            catch (Exception ex)
            {
                int    errNum  = -99999999;
                string errDesc = "";
                HttpContext.Current.Items.Add("Exception", ex);

                if (ex is SqlException)
                {
                    // Handle more specific SqlException exception here.
                    SqlException odbcExc = (SqlException)ex;
                    errNum  = odbcExc.Number;
                    errDesc = odbcExc.Message;
                }
                else
                {
                    // Handle generic ones here.
                    errDesc = ex.Message;
                }
                Server.Transfer("~\\CustomErrors\\Errors.aspx?handler=Dashboard.aspx&msg=" + errNum + "&errDesc=" + errDesc);
            }
        }