Exemple #1
0
        protected void ButtonAdd_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(TextBoxSql.Value.Trim()))
            {
                TextBoxSql.Focus();
                MessageBox.Show(this, "文件数据Sql不能为空");
                return;
            }
            else if (string.IsNullOrEmpty(TextBoxParaName.Text.Trim()))
            {
                TextBoxParaName.Focus();
                MessageBox.Show(this, "参数名称不能为空");
                return;
            }
            else if (string.IsNullOrEmpty(TextBoxParaOrderBy.Text.Trim()))
            {
                TextBoxParaOrderBy.Focus();
                MessageBox.Show(this, "参数排序号不能为空");
                return;
            }
            else if (string.IsNullOrEmpty(DropDownListIllustrate.SelectedValue))
            {
                DropDownListIllustrate.Focus();
                MessageBox.Show(this, "参数值来源不能为空");
                return;
            }
            else if (TextBoxSql.Value.Trim().IndexOf((TextBoxParaName.Text.Trim())) < 0)
            {
                TextBoxParaName.Focus();
                MessageBox.Show(this, "文件数据Sql不包含参数名称!");
                return;
            }

            if (!string.IsNullOrEmpty(TextBoxParaName.Text.Trim()))
            {
                string forematname = TextBoxParaName.Text.Trim().Substring(0, 1);
                if (forematname != "@")
                {
                    TextBoxParaName.Focus();
                    MessageBox.Show(this, "参数名称必需以 @ 开头!");
                    return;
                }
            }


            AddRow();
        }
Exemple #2
0
        protected void gridview_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
        {
            int id = Convert.ToInt32(e.CommandArgument);

            if (e.CommandName == "Delete")
            {
                ConfigToSqlParameter cp = listmodel.Find(c => c.OrderBy == id);
                if (cp != null)
                {
                    listmodel.Remove(cp);
                    MessageBox.Show(this, "删除成功");
                }
                else
                {
                    MessageBox.Show(this, "删除失败");
                }

                listmodel.Sort(new CompareTeacher());
                gridview.DataSource = listmodel;
                gridview.DataBind();
            }
            else if (e.CommandName == "Update")
            {
                ConfigToSqlParameter cp = listmodel.Find(c => c.OrderBy == id);

                TextBoxParaName.Text    = cp.ParameterName;
                TextBoxParaOrderBy.Text = cp.OrderBy.ToString();
                DropDownListIllustrate.SelectedValue = cp.Illustrate;
                DropDownListParaType.SelectedValue   = cp.ParameterType;
                TextBoxParaName.Focus();

                listmodel.Sort(new CompareTeacher());
                gridview.DataSource = listmodel;
                gridview.DataBind();
            }
        }