예제 #1
0
        public ModifySchool_ID()
        {
            //
            // Windows 窗体设计器支持所必需的
            //
            InitializeComponent();

            string str_Sql = "Select * from School";

            if (conn.GetRowCount(str_Sql) == 0)
            {
                MessageBox.Show("请先输入学校信息!", "警告!",
                                MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                button1.Enabled = false;
                return;
            }

            conn.BindComboBox("SELECT QuXian_Code,QuXian_Name FROM QuXian", comboBox_QuXian, "QuXian_Code", "QuXian_Name");
            conn.BindComboBox("SELECT School_Type_ID,School_Type_Name FROM School_Type", comboBox_School_Type, "School_Type_ID", "School_Type_Name");
            conn.BindComboBox("Select * FROM School WHERE School_Type_ID=" + comboBox_School_Type.SelectedValue + " AND School_ID Like '____" + comboBox_QuXian.SelectedValue + "%' Order By School_Type_ID,School_ID", comboBox_School, "School_ID", "School_Name");

            if (comboBox_School.Items.Count != 0)
            {
                textBox_Old_School_ID.Text = comboBox_School.SelectedValue.ToString();
            }
            //
            // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
            //
        }
        public AddClass_Type()
        {
            //
            // Windows 窗体设计器支持所必需的
            //
            InitializeComponent();

            //按数据库里边存储的学校类型绑定下拉列表

            string str_Sql, errorstring;

            errorstring = conn.BindComboBox("Select * from School_Type", comboBox1_School_Type, "School_Type_ID", "School_Type_Name");
            if (errorstring != "OK")
            {
                MessageBox.Show("请检查数据库!" + errorstring, "提醒!",
                                MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                button1.Enabled = false;
                return;
            }

            //按学校类型代码内联显示学校类型的名称,绑定DataGrid显示
            str_Sql = "SELECT Class_Type.Class_Type_ID AS 班级类别代码,Class_Type.Class_Type_Name AS 班级类别名,School_Type.School_Type_Name AS 学校类别名 FROM Class_Type inner join School_Type on Class_Type.School_Type_ID_Class_Belong=School_Type.School_Type_ID";
            if (conn.GetRowCount(str_Sql) == 0)
            {
                MessageBox.Show("请检查数据库!", "警告!",
                                MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                this.Dispose();
            }
            conn.Fill(str_Sql);
            DataGrid1.SetDataBinding(conn.ds, "TableIn");
            textBox_Class_Type_ID.Text = conn.GetMaxId("Class_Type_ID", "Class_Type");
            //
            // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
            //
        }
예제 #3
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            bool   HadSome = false;
            string errorstring, str_Sql = "Select * FROM School";

            DialogResult result = MessageBox.Show(this, "真的要进行删除吗?", "提醒!", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (result == DialogResult.OK)
            {
                //条件有输入的内容则参与查找,查找到的内容和DataGrid绑定
                if (checkBox_InQuXian.Checked == true && checkBox_School_Type.Checked == false)
                {
                    str_Sql = "Select * FROM School WHERE School_ID Like '____" + comboBox_QuXian.SelectedValue + "%'";
                    HadSome = true;
                }

                //条件有输入的内容则参与查找,查找到的内容和DataGrid绑定
                if (checkBox_InQuXian.Checked == false && checkBox_School_Type.Checked == true)
                {
                    str_Sql = "Select * FROM School WHERE School_Type_ID=" + comboBox_School_Type.SelectedValue;
                    HadSome = true;
                }

                //条件有输入的内容则参与查找,查找到的内容和DataGrid绑定
                if (checkBox_InQuXian.Checked == true && checkBox_School_Type.Checked == true)
                {
                    str_Sql = "Select * FROM School WHERE School_Type_ID=" + comboBox_School_Type.SelectedValue + " AND School_ID Like '____" + comboBox_QuXian.SelectedValue + "%'";
                    HadSome = true;
                }

                int i = conndelete.GetRowCount(str_Sql);
                conndelete.Fill(str_Sql);

                if (HadSome == true && i > 0)
                {
                    for (; i > 0; i--)
                    {
                        conndelete.dr = conndelete.ds.Tables[0].Rows[i - 1];

                        str_Sql     = "DELETE from Student WHERE School_ID='" + conndelete.dr["School_ID"].ToString() + "'";
                        errorstring = conn.ExeSql(str_Sql);

                        str_Sql     = "DELETE from Class WHERE School_ID='" + conndelete.dr["School_ID"].ToString() + "'";
                        errorstring = conn.ExeSql(str_Sql);

                        str_Sql     = "DELETE from Teacher WHERE School_ID='" + conndelete.dr["School_ID"].ToString() + "'";
                        errorstring = conn.ExeSql(str_Sql);

                        str_Sql     = "DELETE from School WHERE School_ID='" + conndelete.dr["School_ID"].ToString() + "'";
                        errorstring = conn.ExeSql(str_Sql);
                    }
                }
                MessageBox.Show("成功删除!", "提醒!",
                                MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                return;
            }
        }
        public SearchBrowseStudent()
        {
            //
            // Windows 窗体设计器支持所必需的
            //
            InitializeComponent();

            //测试数据连接
            string errorstring;

            errorstring = conn.ExeSql("Select * FROM School");
            if (errorstring != "OK")
            {
                MessageBox.Show("请检查本地数据库!" + errorstring, "提醒!",
                                MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                button1.Enabled = false;
                return;
            }

            string str_Sql = "Select * from Class";

            if (conn.GetRowCount(str_Sql) == 0)
            {
                MessageBox.Show("请先输入班级信息!", "警告!",
                                MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                button1.Enabled = false;
                return;
            }

            //conn.BindComboBox("Select * FROM School Order By School_Type_ID,School_ID",comboBox_School,"School_ID","School_Name");
            conn.BindComboBox("SELECT QuXian_Code,QuXian_Name FROM QuXian", comboBox_QuXian, "QuXian_Code", "QuXian_Name");
            conn.BindComboBox("SELECT QuXian_ID,QuXian_Name FROM QuXian", comboBox_Student_QuXian, "QuXian_ID", "QuXian_Name");

            str_Sql     = "SELECT School_Name AS 学校名称,Class_Type_Name AS 年级,Class_Name AS 班级,Student_ID As 身份证号码,Name As 姓名,Sex AS 性别,convert(char(10),Birthday,120) As 出生日期,Father AS 父亲,Mother AS 母亲,Keeper AS 监护人,StudentTel AS 联系电话,Student_Address AS 家庭住址,Father_Job AS 父亲职业,Father_XueLi AS 父亲学历,Mother_Job AS 母亲职业,Mother_XueLi AS 母亲学历 FROM View_StudentClass_Detail_City Where School_ID='000'";      //"+comboBox_School.SelectedValue+"'";
            errorstring = conn.Fill(str_Sql);
            if (errorstring != "OK")
            {
                MessageBox.Show("查找失败!请检查数据库!" + errorstring, "提醒!",
                                MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                button1.Enabled = false;
                return;
            }
            DataGrid1.SetDataBinding(conn.ds, "TableIn");

            DataGridTableStyle MyStyle = new DataGridTableStyle();

            MyStyle.MappingName = "TableIn";
            DataGrid1.TableStyles.Add(MyStyle);
            MyStyle.GridColumnStyles["学校名称"].Width  = 150;
            MyStyle.GridColumnStyles["身份证号码"].Width = 120;
            MyStyle.GridColumnStyles["性别"].Width    = 30;
            MyStyle.GridColumnStyles["家庭住址"].Width  = 200;
            MyStyle.GridColumnStyles["联系电话"].Width  = 80;

            //
            // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
            //
        }
예제 #5
0
        public BrowseTeacher()
        {
            //
            // Windows 窗体设计器支持所必需的
            //
            InitializeComponent();

            conn.BindComboBox("SELECT QuXian_Code,QuXian_Name FROM QuXian", comboBox_QuXian, "QuXian_Code", "QuXian_Name");
            conn.BindComboBox("SELECT School_Type_ID,School_Type_Name FROM School_Type", comboBox_School_Type, "School_Type_ID", "School_Type_Name");

            //绑定DataGrid显示
            string str_Sql, errorstring;

            str_Sql     = "SELECT View_Class.Class_ID AS 班级代码,View_Class.Class_Type_Name AS 班级类别,View_Class.Class_Name AS 班级名,View_Class.TeacherInCharge AS 班主任 FROM View_Class";
            errorstring = conn.Fill(str_Sql);
            if (errorstring != "OK")
            {
                MessageBox.Show("请检查数据库!" + errorstring, "提醒!",
                                MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                button1.Enabled = false;
                return;
            }
            str_Sql = "Select * from School";
            if (conn.GetRowCount(str_Sql) == 0)
            {
                MessageBox.Show("请先输入学校信息!", "警告!",
                                MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                button1.Enabled = false;
                return;
            }

            conn.BindComboBox("Select * FROM School WHERE School_Type_ID=" + comboBox_School_Type.SelectedValue + " AND School_ID Like '____" + comboBox_QuXian.SelectedValue + "%' Order By School_Type_ID,School_ID", comboBox_School, "School_ID", "School_Name");

            str_Sql = "SELECT Teacher_ID As 身份证号码,Name As 姓名,Sex AS 性别,convert(char(10),Birthday,120) As 出生日期,convert(char(10),WorkTime,120) As 参加工作时间,SchoolType AS 学历,PostCan AS 职称,PostIn AS 职务,SchoolGrad AS 毕业院校,convert(char(10),GradTime,120)  毕业日期,SpecialIn AS 所学专业,InWorkSheet As 在编,IsFullTime AS 专任教师,LessonTeach AS 担任课程 FROM Teacher WHERE School_ID='000'";
            conn.Fill(str_Sql);
            DataGrid1.SetDataBinding(conn.ds, "TableIn");

            DataGridTableStyle MyStyle = new DataGridTableStyle();

            MyStyle.MappingName = "TableIn";
            DataGrid1.TableStyles.Add(MyStyle);
            MyStyle.GridColumnStyles["身份证号码"].Width = 120;
            MyStyle.GridColumnStyles["性别"].Width    = 30;
            MyStyle.GridColumnStyles["在编"].Width    = 30;
            MyStyle.GridColumnStyles["专任教师"].Width  = 60;
            //
            // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
            //
        }
예제 #6
0
        public BrowseClass()
        {
            //
            // Windows 窗体设计器支持所必需的
            //
            InitializeComponent();

            conn.BindComboBox("SELECT QuXian_Code,QuXian_Name FROM QuXian", comboBox_QuXian, "QuXian_Code", "QuXian_Name");
            conn.BindComboBox("SELECT School_Type_ID,School_Type_Name FROM School_Type", comboBox_School_Type, "School_Type_ID", "School_Type_Name");

            //绑定DataGrid显示
            string str_Sql, errorstring;

            str_Sql     = "SELECT View_Class.Class_ID AS 班级代码,View_Class.Class_Type_Name AS 班级类别,View_Class.Class_Name AS 班级名,View_Class.TeacherInCharge AS 班主任,Student_Count AS 学生人数 FROM View_Class";
            errorstring = conn.Fill(str_Sql);
            if (errorstring != "OK")
            {
                MessageBox.Show("请检查数据库!" + errorstring, "提醒!",
                                MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                button1.Enabled = false;
                return;
            }

            str_Sql = "Select * from School";
            if (conn.GetRowCount(str_Sql) == 0)
            {
                MessageBox.Show("请先输入学校信息!", "警告!",
                                MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                button1.Enabled = false;
                return;
            }
            conn.BindComboBox("Select * FROM School WHERE School_Type_ID=" + comboBox_School_Type.SelectedValue + " AND School_ID Like '____" + comboBox_QuXian.SelectedValue + "%' Order By School_Type_ID,School_ID", comboBox_School, "School_ID", "School_Name");

            if (comboBox_School.Items.Count != 0)
            {
                str_Sql     = "SELECT View_Class.Class_ID AS 班级代码,View_Class.Class_Type_Name AS 班级类别,View_Class.Class_Name AS 班级名,View_Class.TeacherInCharge AS 班主任,Student_Count AS 学生人数 FROM View_Class WHERE View_Class.School_ID='" + comboBox_School.SelectedValue.ToString() + "'";
                errorstring = conn.Fill(str_Sql);
                DataGrid1.SetDataBinding(conn.ds, "TableIn");
            }
            //
            // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
            //
        }
        public DataOut()
        {
            //
            // Windows 窗体设计器支持所必需的
            //
            InitializeComponent();

            string str_Sql = "Select * from School";

            if (conn.GetRowCount(str_Sql) == 0)
            {
                MessageBox.Show("请先输入学校信息!", "警告!",
                                MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                button1.Enabled = false;
                return;
            }
            //
            // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
            //
        }
예제 #8
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            config connFirst = new config();
            //测试数据库连接
            string str_Sql     = "SELECT School_Type_ID As 学校类别代码,School_Type_Name As 学校类别名,School_Type_Year As 学校类别学制 FROM School_Type";
            string errorstring = connFirst.Fill(str_Sql);

            if (errorstring != "OK")
            {
                MessageBox.Show("请检查数据库!" + errorstring, "提醒!",
                                MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                connFirst.Close();
                return;
            }

            //特殊字符不能用
            if (connFirst.Sniffer_In(textBox_User.Text) || connFirst.Sniffer_In(textBox_PassWord.Text))
            {
                MessageBox.Show("用户名或密码不得用空格或者'\"?%=等特殊字符!" + errorstring, "提醒!",
                                MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                connFirst.Close();
                return;
            }

            //判断用户合法
            str_Sql = "Select * FROM Users WHERE UserName= '******' AND PassWord='******'";
            if (connFirst.GetRowCount(str_Sql) != 1)
            {
                MessageBox.Show("错误的用户名或密码!" + errorstring, "提醒!",
                                MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                connFirst.Close();

                button1.Enabled = true;
                return;
            }
            else
            {
                str_User_login = textBox_User.Text;
                this.Close();
            }
        }
        public StatisticsTeacher()
        {
            //
            // Windows 窗体设计器支持所必需的
            //
            InitializeComponent();

            string str_Sql = "Select * from School";

            if (conn.GetRowCount(str_Sql) == 0)
            {
                MessageBox.Show("请先输入学校信息!", "警告!",
                                MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                button1.Enabled = false;
                return;
            }

            conn.BindComboBox("SELECT QuXian_Code,QuXian_Name FROM QuXian", comboBox_QuXian, "QuXian_Code", "QuXian_Name");
            conn.BindComboBox("SELECT School_Type_ID,School_Type_Name FROM School_Type", comboBox_School_Type, "School_Type_ID", "School_Type_Name");

            conn.BindComboBox("Select * FROM School Order By School_Type_ID,School_ID", comboBox_School, "School_ID", "School_Name");

            str_Sql = "Select * from View_Teacher_Statistics   WHERE View_Teacher_Statistics.学校代码='" + comboBox_School.SelectedValue.ToString() + "'";
            string errorstring = conn.Fill(str_Sql);

            DataGrid1.SetDataBinding(conn.ds, "TableIn");

            DataGridTableStyle MyStyle = new DataGridTableStyle();

            MyStyle.MappingName = "TableIn";
            DataGrid1.TableStyles.Add(MyStyle);
            MyStyle.GridColumnStyles["学校代码"].Width = 90;
            MyStyle.GridColumnStyles["学校名称"].Width = 200;
            //
            // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
            //
        }
예제 #10
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            if (checkBox_First.Checked == true)
            {
                try
                {
                    string      path = "SchoolManage.exe.config";
                    XmlDocument xd   = new XmlDocument();
                    xd.Load(path);
                    //判断节点是否存在,如果存在则修改当前节点
                    foreach (XmlNode xn1 in xd.SelectNodes("/configuration/appSettings/add"))
                    {
                        if (xn1.Attributes["key"].Value == "Database")
                        {
                            xn1.Attributes["value"].Value = textBox_Database.Text;
                            //break;
                        }
                        if (xn1.Attributes["key"].Value == "DatabaseServer")
                        {
                            xn1.Attributes["value"].Value = textBox_DBServer.Text;
                            //break;
                        }
                        if (xn1.Attributes["key"].Value == "DatabaseUser")
                        {
                            xn1.Attributes["value"].Value = textBox_DbUser.Text;
                            break;
                        }

                        /*if(xn1.Attributes["key"].Value=="DatabasePassword")
                         * {
                         *      xn1.Attributes["value"].Value=textBox_DbPassWord.Text;
                         *      break;
                         * }*/
                    }
                    //保存web.config
                    xd.Save(path);
                    //return true;
                    MessageBox.Show("成功修改!", "提醒!",
                                    MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                catch
                {
                    //return false;
                    throw new Exception("Config设置文件读取失败!");
                }
            }

            //测试数据库连接
            string str_Sql, errorstring;

            str_Sql     = "SELECT School_Type_ID As 学校类别代码,School_Type_Name As 学校类别名,School_Type_Year As 学校类别学制 FROM School_Type";
            errorstring = conn.Fill(str_Sql);
            if (errorstring != "OK")
            {
                MessageBox.Show("请检查数据库!" + errorstring, "提醒!",
                                MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                conn.Close();
                return;
            }

            //特殊字符不能用
            if (conn.Sniffer_In(textBox_User.Text) || conn.Sniffer_In(textBox_PassWord.Text))
            {
                MessageBox.Show("用户名或密码不得用空格或者'\"?%=等特殊字符!" + errorstring, "提醒!",
                                MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                conn.Close();
                return;
            }

            //判断用户合法
            str_Sql = "Select * FROM Users WHERE UserName= '******' AND PassWord='******'";
            if (conn.GetRowCount(str_Sql) != 1)
            {
                MessageBox.Show("错误的用户名或密码!" + errorstring, "提醒!",
                                MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                conn.Close();

                button1.Enabled = true;
                return;
            }
            else
            {
                str_User_login = textBox_User.Text;

                this.Close();
            }
        }
        public BrowseStudent()
        {
            //
            // Windows 窗体设计器支持所必需的
            //
            InitializeComponent();

            conn.BindComboBox("SELECT QuXian_Code,QuXian_Name FROM QuXian", comboBox_QuXian, "QuXian_Code", "QuXian_Name");
            conn.BindComboBox("SELECT School_Type_ID,School_Type_Name FROM School_Type", comboBox_School_Type, "School_Type_ID", "School_Type_Name");

            string str_Sql, errorstring;

            str_Sql = "Select * from Class";
            if (conn.GetRowCount(str_Sql) == 0)
            {
                MessageBox.Show("请先输入班级信息!", "警告!",
                                MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                button1.Enabled = false;
                return;
            }
            //绑定下拉列表显示数据库中所有的学校
            conn.BindComboBox("Select * FROM School WHERE School_Type_ID=" + comboBox_School_Type.SelectedValue + " AND School_ID Like '____" + comboBox_QuXian.SelectedValue + "%' Order By School_Type_ID,School_ID", comboBox_School, "School_ID", "School_Name");

            if (comboBox_School.Items.Count == 0)
            {
                return;
            }
            else
            {
                //根据选择的学校绑定下拉列表显示该学校对应的所有班级类型
                conn.BindComboBox("Select * FROM Class_Type WHERE School_Type_ID_Class_Belong=" + conn.School_IDtoWhat(comboBox_School.SelectedValue.ToString(), "School_Type_ID"), comboBox_Class_Type, "Class_Type_ID", "Class_Type_Name");
                //根据选择的学校和选择的班级类型绑定下拉列表显示该学校的这种班级类型对应的班级
                conn.BindComboBox("Select * FROM Class WHERE Class_Type_ID=" + comboBox_Class_Type.SelectedValue.ToString() + "AND School_ID='" + comboBox_School.SelectedValue.ToString() + "'", comboBox_Class, "Class_ID", "Class_Name");
            }

            if (comboBox_Class.Items.Count == 0)
            {
                return;
            }
            else
            {
                //绑定DataGrid显示

                DataGrid1.CaptionText = comboBox_Class_Type.Text.ToString() + "-"
                                        + comboBox_Class.Text.ToString() + "  "
                                        + "现有学生信息";

                str_Sql = "SELECT Student_ID As 身份证号码,Name As 姓名,Sex AS 性别,convert(char(10),Birthday,120) As 出生日期,Father AS 父亲,Mother AS 母亲,Keeper AS 监护人,StudentTel AS 联系电话,Student_Address AS 家庭住址,Father_Job AS 父亲职业,Father_XueLi AS 父亲学历,Mother_Job AS 母亲职业,Mother_XueLi AS 母亲学历,QuXian_Name AS 区县,Office_Name AS 办事处,Committee_Name AS 居委会 FROM View_StudentClass_Detail_City4 WHERE Class_ID=" + comboBox_Class.SelectedValue + " AND School_ID='" + comboBox_School.SelectedValue.ToString() + "'";
                conn.Fill(str_Sql);
                DataGrid1.SetDataBinding(conn.ds, "TableIn");

                DataGridTableStyle MyStyle = new DataGridTableStyle();
                MyStyle.MappingName = "TableIn";
                DataGrid1.TableStyles.Add(MyStyle);
                MyStyle.GridColumnStyles["身份证号码"].Width = 120;
                MyStyle.GridColumnStyles["性别"].Width    = 30;
                MyStyle.GridColumnStyles["家庭住址"].Width  = 200;
                MyStyle.GridColumnStyles["联系电话"].Width  = 80;
            }
            //
            // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
            //
        }