Exemplo n.º 1
0
        //模糊查询
        private void Click_QueryOnly(object sender, EventArgs e)
        {
            FrmInputs inputs = new FrmInputs("模糊查询", new string[] { "班级编号", "班级名称", "学院编号" }, new Dictionary <string, HZH_Controls.TextInputType>()
            {
                { "班级编号", HZH_Controls.TextInputType.Regex }, { "班级名称", HZH_Controls.TextInputType.Regex }, { "学院编号", HZH_Controls.TextInputType.Regex }
            }, new Dictionary <string, string>()
            {
                { "班级编号", @"^\d+$" }, { "班级名称", @"^[\u4E00-\u9FFF0-9]+$" }, { "学员编号", @"^\d+$" }
            });

            inputs.ShowDialog();
            var        values = inputs.Values;
            T_ClassDAL dal    = new T_ClassDAL();
            string     t_sql  = "FulzySearchInT_Class";

            SqlParameter[] pars = new SqlParameter[] {
                new SqlParameter("@classID", SqlDbType.VarChar)
                {
                    Value = "%" + values[0] + "%"
                },
                new SqlParameter("@className", SqlDbType.VarChar)
                {
                    Value = "%" + values[1] + "%"
                },
                new SqlParameter("@collegeID", SqlDbType.VarChar)
                {
                    Value = "%" + values[2] + "%"
                }
            };
            dataGridView1.DataSource = dal.FulzySearch(t_sql, CommandType.StoredProcedure, pars);
        }
Exemplo n.º 2
0
        //加载树
        private void LoadTreeNodes()
        {
            T_CollegeDAL collegeDal = new T_CollegeDAL();
            T_ClassDAL   classDal   = new T_ClassDAL();
            var          collegeRes = collegeDal.LoadCollege();

            TreeNode[] nodes = new TreeNode[collegeRes.Count];
            for (int i = 0; i < collegeRes.Count; i++)
            {
                TreeNode node = new TreeNode();
                node.Text = collegeRes[i].CollegeName;
                node.Tag  = collegeRes[i];
                nodes[i]  = node;
                var classRes = classDal.LoadClass(collegeRes[i].CollegeID);
                if (classRes == null)
                {
                    continue;
                }
                foreach (var item in classRes)
                {
                    TreeNode node1 = new TreeNode(item.ClassName);
                    node1.Tag = item;
                    nodes[i].Nodes.Add(node1);
                }
            }
            trvEx1.Nodes.AddRange(nodes);
        }
Exemplo n.º 3
0
        private void LoadClass()
        {
            T_ClassDAL     dal    = new T_ClassDAL();
            List <T_Class> @class = dal.LoadClass();

            comClass.DataSource            = @class;
            comClass.SelectedIndexChanged += ComClass_SelectedIndexChanged;
            ComClass_SelectedIndexChanged(comClass, null);
        }
Exemplo n.º 4
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, "保存失败,请检查输入是否正确");
            }
        }
Exemplo n.º 5
0
        //查询所有
        private void Click_QueryAll(object sender, EventArgs e)
        {
            T_ClassDAL dal = new T_ClassDAL();

            try
            {
                var res = dal.LoadPagiation(1, dataLength, -1);
                dataGridView1.DataSource = res;
                curIndex  = 1;
                collegeID = -1;
            }
            catch
            {
            }
        }
Exemplo n.º 6
0
        //下一页
        private void Click_JumpNextPage(object sender, EventArgs e)
        {
            int temp = curIndex;

            curIndex += 1;
            T_ClassDAL dal = new T_ClassDAL();
            var        res = dal.LoadPagiation(curIndex, dataLength, collegeID);

            if (res == null)
            {
                curIndex = temp;
                return;
            }
            dataGridView1.DataSource = res;
        }
Exemplo n.º 7
0
        private void FrmInsertedClassSetUpCourse_Load(object sender, EventArgs e)
        {
            //加载学院
            T_CollegeDAL dal = new T_CollegeDAL();

            comCollege.DataSource = dal.LoadCollege();
            //事件触发加载班级
            comCollege.SelectedIndexChanged += ComCollege_SelectedIndexChanged;
            comCollege.SelectedIndex         = 0;
            T_ClassDAL classDal = new T_ClassDAL();

            comClass.DataSource  = classDal.LoadClass();
            comCourse.DataSource = new T_CourseDAL().ExecuteListCourseName();
            comTeach.DataSource  = new T_TeachDAL().GetTeches();
        }
Exemplo n.º 8
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, "保存失败,请检查输入是否正确");
            }
        }
Exemplo n.º 9
0
        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, "保存失败", "提示");
            }
        }
Exemplo n.º 10
0
 private void FrmClassMana_Load(object sender, EventArgs e)
 {
     try
     {
         LoadNavMenuItem();
         LoadTreeNodes();
         //首先我们加载所有学生信息,以分页的方式显示出来
         var res = new T_ClassDAL().LoadPagiation(curIndex, dataLength, collegeID);
         if (res == null)
         {
             return;
         }
         dataGridView1.DataSource            = res;
         dataGridView1.AutoSizeColumnsMode   = DataGridViewAutoSizeColumnsMode.Fill;
         dataGridView1.Columns[0].HeaderText = "班级编号";
         dataGridView1.Columns[1].HeaderText = "班级名";
         dataGridView1.Columns[2].HeaderText = "学院编号";
     }
     catch {
         MessageBox.Show("错误");
     }
 }
Exemplo n.º 11
0
        private void trvEx1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            var college = e.Node.Tag as T_College;

            if (college == null)
            {
                return;
            }
            T_ClassDAL classDAL = new T_ClassDAL();
            int        cur      = 1;

            try
            {
                var res = classDAL.LoadClass(college.CollegeID);
                dataGridView1.DataSource = res;
                cur       = 1;
                collegeID = college.CollegeID;
            }
            catch
            {
                cur = curIndex;
            }
            curIndex = cur;
        }