Exemple #1
0
        //插入数据
        private void Click_OpenInsertDataInforamtion(object sender, EventArgs e)
        {
            FrmInputs inputs = new FrmInputs("插入班级信息", new string[] { "班级名称", "学院编号" }, new Dictionary <string, HZH_Controls.TextInputType>()
            {
                { "班级名称", HZH_Controls.TextInputType.Regex }, { "学院编号", HZH_Controls.TextInputType.Regex }
            }, new Dictionary <string, string>()
            {
                { "班级名称", @"^[\u4E00-\u9FFF0-9]+$" }, { "学员编号", @"^\d+$" }
            });

            inputs.ShowDialog();
            var values = inputs.Values;

            foreach (var item in values)
            {
                if (item == null || item == string.Empty)
                {
                    return;
                }
            }
            string t_sql = "InsertintoT_Class";

            SqlParameter[] pars = new SqlParameter[] {
                new SqlParameter("@className", SqlDbType.VarChar, 20)
                {
                    Value = values[0]
                },
                new SqlParameter("@collegeID", SqlDbType.Int)
                {
                    Value = values[1]
                },
            };
            T_ClassDAL dal   = new T_ClassDAL();
            int        temp1 = curIndex;
            int        temp2 = collegeID;

            try
            {
                var res = (int)dal.ExecuteScalar(t_sql, CommandType.StoredProcedure, pars);
                if (res == 1)
                {
                    curIndex = 1;
                    dataGridView1.DataSource = dal.LoadPagiation(curIndex, dataLength, collegeID);
                    FrmDialog.ShowDialog(this, "保存成功");
                }
                else
                {
                    throw new Exception();
                }
            }
            catch
            {
                curIndex  = temp1;
                collegeID = temp2;
                FrmDialog.ShowDialog(this, "保存失败,请检查输入是否正确");
            }
        }
Exemple #2
0
        private void Click_DeleteDataInforamtion(object sender, EventArgs e)
        {
            //删除信息
            var rows = dataGridView1.SelectedRows;

            if (rows.Count == 0)
            {
                FrmDialog.ShowDialog(this, "请选择一行");
                return;
            }
            var row = rows[0].DataBoundItem as T_Class;

            if (row == null)
            {
                return;
            }
            string       t_sql = "DeleteIntoT_Class";
            SqlParameter par   = new SqlParameter("@classID", SqlDbType.Int)
            {
                Value = row.ClassID
            };
            T_ClassDAL dal   = new T_ClassDAL();
            int        temp1 = curIndex;
            int        temp2 = collegeID;

            try
            {
                var res = (int)dal.ExecuteScalar(t_sql, CommandType.StoredProcedure, par);
                if (res == 1)
                {
                    dataGridView1.DataSource = dal.LoadPagiation(curIndex, dataLength, collegeID);
                    FrmDialog.ShowDialog(this, "保存成功");
                }
                else
                {
                    throw new Exception();
                }
            }
            catch
            {
                curIndex  = temp1;
                collegeID = temp2;
                FrmDialog.ShowDialog(this, "保存失败,请检查输入是否正确");
            }
        }
        private void ucBtnSave_BtnClick(object sender, EventArgs e)
        {
            var b1 = verNameValidate.Verification();
            var b2 = verCollegeIDValidate.Verification();

            if (b1 == false || b2 == false)
            {
                return;
            }
            //验证通过,提交修改
            T_ClassDAL dal   = new T_ClassDAL();
            string     t_sql = "ModifyIntoT_Class";

            SqlParameter[] pars = new SqlParameter[] {
                new SqlParameter("@classID", SqlDbType.Int)
                {
                    Value = txtUPclassID.Text
                },
                new SqlParameter("@className", SqlDbType.VarChar, 20)
                {
                    Value = txtUPClassName.Text
                },
                new SqlParameter("@collegeID", SqlDbType.Int)
                {
                    Value = txtUPCollegeID.Text
                }
            };
            try
            {
                var res = (int)dal.ExecuteScalar(t_sql, CommandType.StoredProcedure, pars);
                if (res == 1)
                {
                    FrmDialog.ShowDialog(this, "保存成功", "提示");
                }
                else
                {
                    throw new Exception();
                }
            }
            catch
            {
                FrmDialog.ShowDialog(this, "保存失败", "提示");
            }
        }