Пример #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text.Length > 0)
     {
         SQLConnet sqlconnet = new SQLConnet();
         if (sqlconnet.checkit("select RoleName from roles where RoleName = '" + textBox1.Text + "'"))
         {
             MessageBox.Show("角色已存在!");
         }
         else
         {
             ArrayList filed = new ArrayList();
             filed.Add("RoleName");
             filed.Add("SystemManage");
             filed.Add("MajorManage");
             filed.Add("CourseManage");
             filed.Add("ScoreManage");
             ArrayList fdata = new ArrayList();
             fdata.Add(textBox1.Text);
             fdata.Add(checkBox1.Checked);
             fdata.Add(checkBox2.Checked);
             fdata.Add(checkBox3.Checked);
             fdata.Add(checkBox4.Checked);
             sqlconnet.addrow("select * from roles", "roles", filed, fdata);
             MessageBox.Show("添加成功!");
         }
         sqlconnet.close();
     }
     else
     {
         MessageBox.Show("请输入完整信息!");
     }
 }
Пример #2
0
        private void updata()
        {
            SQLConnet sqlconnet = new SQLConnet();

            sqlconnet.setdatatable(dataGridView1.DataSource as DataTable, "select * from teacherinfo", "teacherinfo");

            string xh = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value.ToString();

            if (xh.Length < 1)
            {
                xh = (sqlconnet.readone("SELECT   IDENT_CURRENT('teacherinfo') AS Expr", "Expr")); //查询自增序号
            }
            if (!sqlconnet.checkit("select * from userinfo where UName='t" + xh + "'"))            //新增学生添加账号
            {
                ArrayList filed = new ArrayList();
                filed.Add("UName");
                filed.Add("PWD");
                filed.Add("RoleName");
                ArrayList fdata = new ArrayList();
                fdata.Add("t" + xh);//新增学号
                fdata.Add("1");
                fdata.Add("教师");
                sqlconnet.addrow("select * from userinfo", "userinfo", filed, fdata);
            }
            sqlconnet.close();
        }
Пример #3
0
        private void AddStudentForm_Load(object sender, EventArgs e)
        {
            //初始控件数据
            comboBox1.SelectedIndex = 0;
            SQLConnet     sqlconnet = new SQLConnet();
            SqlDataReader reader    = sqlconnet.readrow("select TName from teacherinfo");

            while (reader.Read())
            {
                comboBox2.Items.Add(reader["TName"]);
            }
            comboBox2.SelectedIndex = 0;
            reader.Close();
            reader = sqlconnet.readrow("select MName from majorinfo");
            while (reader.Read())
            {
                comboBox3.Items.Add(reader["MName"]);
            }
            comboBox3.SelectedIndex = 0;
            reader.Close();
            sqlconnet.close();


            dateTimePicker1.Format       = DateTimePickerFormat.Custom;
            dateTimePicker1.CustomFormat = "yyyy-MM-dd";
        }
Пример #4
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text.Length > 0 && textBox2.Text.Length > 0 && textBox3.Text.Length > 0)
     {
         SQLConnet sqlconnet = new SQLConnet();
         if (sqlconnet.checkit("select * from courseinfo where MName = '" + comboBox1.Text + "' and CName='" + textBox1.Text + "'"))
         {
             MessageBox.Show("课程已存在!");
         }
         else
         {
             ArrayList filed = new ArrayList();
             filed.Add("MName");
             filed.Add("CName");
             filed.Add("CDate");
             filed.Add("CNum");
             filed.Add("CRemark");
             ArrayList fdata = new ArrayList();
             fdata.Add(comboBox1.Text);
             fdata.Add(textBox1.Text);
             fdata.Add(textBox2.Text);
             fdata.Add(textBox3.Text);
             fdata.Add(textBox4.Text);
             sqlconnet.addrow("select * from courseinfo", "courseinfo", filed, fdata);
             MessageBox.Show("添加成功!");
         }
         sqlconnet.close();
     }
     else
     {
         MessageBox.Show("请输入完整信息!");
     }
 }
Пример #5
0
 private void button2_Click(object sender, EventArgs e)//确定
 {
     if (textBox1.Text.Length > 0)
     {
         SQLConnet sqlconnet = new SQLConnet();
         if (sqlconnet.checkit("select MName from majorinfo where MName = '" + textBox1.Text + "'"))
         {
             MessageBox.Show("专业已存在!");
         }
         else
         {
             ArrayList filed = new ArrayList();
             filed.Add("MName");
             filed.Add("MRemark");
             ArrayList fdata = new ArrayList();
             fdata.Add(textBox1.Text);
             fdata.Add(textBox2.Text);
             sqlconnet.addrow("select * from majorinfo", "majorinfo", filed, fdata);
             MessageBox.Show("添加成功!");
         }
         sqlconnet.close();
     }
     else
     {
         MessageBox.Show("请输入完整信息!");
     }
 }
Пример #6
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text.Length > 0)
     {
         SQLConnet sqlconnet = new SQLConnet();
         string    sid       = sqlconnet.readone("select * from studentinfo where SName = '" + comboBox1.Text + "'", "SID");
         if (sqlconnet.checkit("select * from scoreinfo where SID=" + sid + "and CName = '" + comboBox2.Text + "'"))
         {
             MessageBox.Show("成绩已存在!");
         }
         else
         {
             ArrayList filed = new ArrayList();
             filed.Add("SID");
             filed.Add("CName");
             filed.Add("Score");
             ArrayList fdata = new ArrayList();
             fdata.Add(Convert.ToInt32(sid));
             fdata.Add(comboBox2.Text);
             fdata.Add(textBox1.Text);
             sqlconnet.addrow("select * from scoreinfo", "scoreinfo", filed, fdata);
             MessageBox.Show("添加成功!");
         }
         sqlconnet.close();
     }
     else
     {
         MessageBox.Show("请输入完整信息!");
     }
 }
Пример #7
0
        private void renewtree()
        {
            label3.Text = treeView1.SelectedNode.Parent.Text + "专业  " + treeView1.SelectedNode.Text + "课程成绩";
            SQLConnet sqlconnet = new SQLConnet();
            //课程数据
            DataTable dtcourse = new DataTable();

            dtcourse.Columns.Add("Value");
            dtcourse.Columns.Add("Name");
            SqlDataReader course = sqlconnet.readrow("select CName from courseinfo where MName='" + treeView1.SelectedNode.Parent.Text + "'");
            DataRow       drcourse;

            while (course.Read())
            {
                drcourse    = dtcourse.NewRow();
                drcourse[0] = course["CName"];
                drcourse[1] = course["CName"];
                dtcourse.Rows.Add(drcourse);
            }
            course.Close();
            课程名称.ValueMember         = "Value";
            课程名称.DisplayMember       = "Name";
            课程名称.DataSource          = dtcourse;
            dataGridView1.DataSource = sqlconnet.getdatatable("select * from scoreinfo where CName='" + treeView1.SelectedNode.Text + "'", "scoreinfo");
            sqlconnet.close();
            treeView1.Focus();
        }
Пример #8
0
        private void updata()
        {
            SQLConnet sqlconnet = new SQLConnet();

            sqlconnet.setdatatable(dataGridView1.DataSource as DataTable, "select * from majorinfo", "majorinfo");
            sqlconnet.close();
        }
Пример #9
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            label3.Text = e.Node.Text + "专业学生表";
            SQLConnet sqlconnet = new SQLConnet();

            dataGridView1.DataSource = sqlconnet.getdatatable("select * from studentinfo where MName='" + e.Node.Text + "'", "studentinfo");
            sqlconnet.close();
        }
Пример #10
0
        private void renewtree()
        {
            SQLConnet sqlconnet = new SQLConnet();

            dataGridView1.DataSource = sqlconnet.getdatatable("select * from studentinfo where MName='" + treeView1.SelectedNode.Text + "'", "studentinfo");

            sqlconnet.close();
            treeView1.Focus();
        }
Пример #11
0
        private void setdatagirdview()
        {
            SQLConnet sqlconnet = new SQLConnet();
            DataTable sqltable  = sqlconnet.getdatatable("select * from majorinfo", "majorinfo");

            label3.Text = "共有" + sqltable.Rows.Count + "条记录";
            dataGridView1.DataSource = sqltable;
            sqlconnet.close();
        }
Пример #12
0
        private void AddCourseForm_Load(object sender, EventArgs e)
        {
            SQLConnet     sqlconnet = new SQLConnet();
            SqlDataReader majob     = sqlconnet.readrow("select MName from majorinfo");

            while (majob.Read())
            {
                comboBox1.Items.Add(majob["MName"]);
            }
            comboBox1.SelectedIndex = 0;
            majob.Close();
            sqlconnet.close();
        }
Пример #13
0
        private void AddUserForm_Load(object sender, EventArgs e)
        {
            SQLConnet     sqlconnet = new SQLConnet();
            SqlDataReader reader    = sqlconnet.readrow("select RoleName from roles");

            while (reader.Read())
            {
                comboBox1.Items.Add(reader["RoleName"]);
            }
            comboBox1.SelectedIndex = 0;
            reader.Close();
            sqlconnet.close();
        }
Пример #14
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("是否删除选中行?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
     {
         string    xh        = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value.ToString();
         SQLConnet sqlconnet = new SQLConnet();
         sqlconnet.runsql("delete from userinfo where UName='s" + xh + "'");
         sqlconnet.close();
         dataGridView1.Rows.Remove(dataGridView1.SelectedRows[0]);
         updata();
         renewtree();
     }
 }
Пример #15
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text.Length > 0 && textBox2.Text.Length > 0 && textBox3.Text.Length > 0)
     {
         try
         {
             int       sid       = Convert.ToInt32(textBox1.Text);
             SQLConnet sqlconnet = new SQLConnet();
             string    tid       = sqlconnet.readone("select * from teacherinfo where TName = '" + comboBox2.Text + "'", "TID");
             if (sqlconnet.checkit("select * from studentinfo where SID=" + sid) || sqlconnet.checkit("select * from studentinfo where SNum='" + textBox3.Text + "'"))
             {
                 MessageBox.Show("学号或身份证已存在!");
             }
             else
             {
                 ArrayList filed = new ArrayList();
                 filed.Add("SID");
                 filed.Add("SName");
                 filed.Add("SSex");
                 filed.Add("SNum");
                 filed.Add("TID");
                 filed.Add("SBirth");
                 filed.Add("MName");
                 filed.Add("SRemark");
                 ArrayList fdata = new ArrayList();
                 fdata.Add(Convert.ToInt32(sid));
                 fdata.Add(textBox2.Text);
                 fdata.Add(comboBox1.Text);
                 fdata.Add(textBox3.Text);
                 fdata.Add(Convert.ToInt32(tid));
                 fdata.Add(dateTimePicker1.Value);
                 fdata.Add(comboBox3.Text);
                 fdata.Add(textBox4.Text);
                 sqlconnet.addrow("select * from studentinfo", "studentinfo", filed, fdata);
                 MessageBox.Show("添加成功!");
             }
             sqlconnet.close();
         }
         catch (Exception)
         {
             MessageBox.Show("请输入数字学号!");
         }
     }
     else
     {
         MessageBox.Show("请输入完整信息!");
     }
 }
Пример #16
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            relogin = false;//重新登陆状态,用于在主窗体关闭窗口时判断是否关掉登录窗体(关闭整个程序)
            //数据库初始化

            //初始化菜单

            //状态栏初始化
            tssl_user.Text = logininfo;
            tssl_time.Text = DateTime.Now.ToLongDateString();

            //判断权限
            string    sql       = "select * from userinfo where UName= '" + logininfo + "'";
            SQLConnet sqlconnet = new SQLConnet();

            rolename = sqlconnet.readone(sql, "RoleName");
            sql      = "select * from roles where RoleName= '" + rolename + "'";
            SqlDataReader role = sqlconnet.readrow(sql);

            role.Read();

            if (role["SystemManage"].ToString() == "False")
            {
                系统管理ToolStripMenuItem.Visible = false;
            }
            if (role["MajorManage"].ToString() == "False")
            {
                专业管理ToolStripMenuItem.Visible = false;
            }
            if (role["CourseManage"].ToString() == "False")
            {
                课程管理ToolStripMenuItem.Visible = false;
            }
            if (role["ScoreManage"].ToString() == "False")
            {
                成绩管理ToolStripMenuItem.Visible = false;
            }
            if (role["SystemManage"].ToString() == "False" && role["MajorManage"].ToString() == "False" && role["CourseManage"].ToString() == "False" && role["ScoreManage"].ToString() == "False")
            {
                研究生管理ToolStripMenuItem.Visible = false;
                tsb_viewstudent.Visible        = false;
            }
            role.Close();
            sqlconnet.close();
        }
Пример #17
0
        private void ViewMajobForm_Load(object sender, EventArgs e)
        {
            //权限
            SQLConnet     sqlconnet = new SQLConnet();
            string        sql       = "select * from roles where RoleName= '" + rolename + "'";
            SqlDataReader role      = sqlconnet.readrow(sql);

            role.Read();
            if (role["MajorManage"].ToString() == "False")
            {
                button1.Visible        = false;
                button3.Visible        = false;
                dataGridView1.ReadOnly = true;
            }
            role.Close();
            sqlconnet.close();

            setdatagirdview();
        }
Пример #18
0
        private void AddScoreForm_Load(object sender, EventArgs e)
        {
            SQLConnet     sqlconnet = new SQLConnet();
            SqlDataReader reader    = sqlconnet.readrow("select SName from studentinfo");

            while (reader.Read())
            {
                comboBox1.Items.Add(reader["SName"]);
            }
            comboBox1.SelectedIndex = 0;
            reader.Close();
            reader = sqlconnet.readrow("select CName from courseinfo");
            while (reader.Read())
            {
                comboBox2.Items.Add(reader["CName"]);
            }
            comboBox2.SelectedIndex = 0;
            reader.Close();
            sqlconnet.close();
        }
Пример #19
0
        private void updata()
        {
            SQLConnet sqlconnet = new SQLConnet();

            sqlconnet.setdatatable(dataGridView1.DataSource as DataTable, "select * from studentinfo", "studentinfo");
            string xh = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value.ToString();

            if (!sqlconnet.checkit("select * from userinfo where UName='s" + xh + "'"))//新增学生添加账号
            {
                ArrayList filed = new ArrayList();
                filed.Add("UName");
                filed.Add("PWD");
                filed.Add("RoleName");
                ArrayList fdata = new ArrayList();
                fdata.Add("s" + xh);//新增学号
                fdata.Add("1");
                fdata.Add("学生");
                sqlconnet.addrow("select * from userinfo", "userinfo", filed, fdata);
            }
            sqlconnet.close();
        }
Пример #20
0
        protected override void OnClosing(CancelEventArgs e)//关闭前操作
        {
            SQLConnet     sqlconnet = new SQLConnet();
            string        sql       = "select * from roles where RoleName= '" + rolename + "'";
            SqlDataReader role      = sqlconnet.readrow(sql);

            role.Read();
            if (!(role["MajorManage"].ToString() == "False"))
            {
                if (MessageBox.Show("关闭前是否保存修改操作?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    updata();
                }
            }
            role.Close();
            sqlconnet.close();
            //重置工具栏状态
            MainForm mainform = new MainForm();

            mainform = (MainForm)this.MdiParent;
            mainform.renewtool();
        }
Пример #21
0
        private void ViewUserForm_Load(object sender, EventArgs e)
        {
            SQLConnet     sqlconnet = new SQLConnet();
            string        sql       = "select * from roles where RoleName= '" + rolename + "'";
            SqlDataReader role      = sqlconnet.readrow(sql);

            role.Read();
            if (role["SystemManage"].ToString() == "False" && role["MajorManage"].ToString() == "False" && role["CourseManage"].ToString() == "False" && role["ScoreManage"].ToString() == "False")
            {
                button1.Visible        = false;
                button3.Visible        = false;
                dataGridView1.ReadOnly = true;
            }
            role.Close();
            //专业  数据和树状
            DataTable dtmajob = new DataTable();

            dtmajob.Columns.Add("Value");
            dtmajob.Columns.Add("Name");
            SqlDataReader majob = sqlconnet.readrow("select RoleName from roles");
            DataRow       drmajob;

            treeView1.Nodes.Clear();//清空树状图
            while (majob.Read())
            {
                treeView1.Nodes.Add(majob["RoleName"].ToString());

                drmajob    = dtmajob.NewRow();
                drmajob[0] = majob["RoleName"];
                drmajob[1] = majob["RoleName"];
                dtmajob.Rows.Add(drmajob);
            }
            majob.Close();
            角色名称.ValueMember   = "Value";
            角色名称.DisplayMember = "Name";
            角色名称.DataSource    = dtmajob;
            sqlconnet.close();
        }
Пример #22
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text.Length > 0 && textBox2.Text.Length > 0 && textBox3.Text.Length > 0)
     {
         if (textBox2.Text == textBox3.Text)
         {
             SQLConnet sqlconnet = new SQLConnet();
             if (sqlconnet.checkit("select * from userinfo where UName='" + textBox1.Text + "'"))
             {
                 MessageBox.Show("用户已存在!");
             }
             else
             {
                 ArrayList filed = new ArrayList();
                 filed.Add("UName");
                 filed.Add("PWD");
                 filed.Add("RoleName");
                 ArrayList fdata = new ArrayList();
                 fdata.Add(textBox1.Text);
                 fdata.Add(textBox2.Text);
                 fdata.Add(comboBox1.Text);
                 sqlconnet.addrow("select * from userinfo", "userinfo", filed, fdata);
                 MessageBox.Show("添加成功!");
             }
             sqlconnet.close();
         }
         else
         {
             MessageBox.Show("两次输入密码不一致!");
         }
     }
     else
     {
         MessageBox.Show("请输入完整信息!");
     }
 }
Пример #23
0
        private void ViewScoreForm_Load(object sender, EventArgs e)
        {
            //权限
            SQLConnet     sqlconnet = new SQLConnet();
            string        sql       = "select * from roles where RoleName= '" + rolename + "'";
            SqlDataReader role      = sqlconnet.readrow(sql);

            role.Read();
            if (role["ScoreManage"].ToString() == "False")
            {
                button1.Visible        = false;
                button3.Visible        = false;
                dataGridView1.ReadOnly = true;
            }
            role.Close();

            treeView1.Nodes.Clear();//清空树状图
            //专业、课程 树状
            SqlDataReader majob = sqlconnet.readrow("select MName from majorinfo");
            int           i     = 0;

            while (majob.Read())
            {
                treeView1.Nodes.Add(majob["MName"].ToString());
                i++;
            }
            majob.Close();

            SqlDataReader course;

            for (int k = 0; k < i; k++)
            {
                course = sqlconnet.readrow("select CName from courseinfo where MName='" + treeView1.Nodes[k].Text + "'");
                while (course.Read())
                {
                    treeView1.Nodes[k].Nodes.Add(course["CName"].ToString());
                }
                course.Close();
            }

            //姓名数据
            DataTable dtstudent = new DataTable();

            dtstudent.Columns.Add("Value");
            dtstudent.Columns.Add("Name");
            dtstudent.Columns[0].DataType = Type.GetType("System.Int32");
            DataRow       drstudent;
            SqlDataReader student = sqlconnet.readrow("select * from studentinfo");

            while (student.Read())
            {
                drstudent    = dtstudent.NewRow();
                drstudent[0] = student["SID"];
                drstudent[1] = student["SName"];
                dtstudent.Rows.Add(drstudent);
            }
            student.Close();
            姓名.ValueMember   = "Value";
            姓名.DisplayMember = "Name";
            姓名.DataSource    = dtstudent;



            sqlconnet.close();
            //默认tree
            treeView1.SelectedNode = treeView1.Nodes[0].Nodes[0];
        }
Пример #24
0
        private void ViewStudentForm_Load(object sender, EventArgs e)
        {
            //权限
            SQLConnet     sqlconnet = new SQLConnet();
            string        sql       = "select * from roles where RoleName= '" + rolename + "'";
            SqlDataReader role      = sqlconnet.readrow(sql);

            role.Read();
            if (role["SystemManage"].ToString() == "False" && role["MajorManage"].ToString() == "False" && role["CourseManage"].ToString() == "False" && role["ScoreManage"].ToString() == "False")
            {
                button1.Visible        = false;
                button3.Visible        = false;
                dataGridView1.ReadOnly = true;
            }
            role.Close();
            //专业  数据和树状
            DataTable dtmajob = new DataTable();

            dtmajob.Columns.Add("Value");
            dtmajob.Columns.Add("Name");
            SqlDataReader majob = sqlconnet.readrow("select MName from majorinfo");
            DataRow       drmajob;

            treeView1.Nodes.Clear();//清空树状图
            while (majob.Read())
            {
                treeView1.Nodes.Add(majob["MName"].ToString());

                drmajob    = dtmajob.NewRow();
                drmajob[0] = majob["MName"];
                drmajob[1] = majob["MName"];
                dtmajob.Rows.Add(drmajob);
            }
            majob.Close();

            专业名称.ValueMember   = "Value";
            专业名称.DisplayMember = "Name";
            专业名称.DataSource    = dtmajob;
            //性别
            DataTable dtSex = new DataTable();

            dtSex.Columns.Add("Value");
            dtSex.Columns.Add("Name");
            DataRow drSex;

            drSex    = dtSex.NewRow();
            drSex[0] = "男";
            drSex[1] = "男";
            dtSex.Rows.Add(drSex);
            drSex    = dtSex.NewRow();
            drSex[0] = "女";
            drSex[1] = "女";
            dtSex.Rows.Add(drSex);
            性别.ValueMember   = "Value";
            性别.DisplayMember = "Name";
            性别.DataSource    = dtSex;


            //导师
            DataTable dtteacher = new DataTable();

            dtteacher.Columns.Add("Value");
            dtteacher.Columns.Add("Name");
            dtteacher.Columns[0].DataType = Type.GetType("System.Int32");
            DataRow       drteacher;
            SqlDataReader teacher = sqlconnet.readrow("select * from teacherinfo");

            while (teacher.Read())
            {
                drteacher    = dtteacher.NewRow();
                drteacher[0] = teacher["TID"];
                drteacher[1] = teacher["TName"];
                dtteacher.Rows.Add(drteacher);
            }
            teacher.Close();
            导师姓名.ValueMember   = "Value";
            导师姓名.DisplayMember = "Name";
            导师姓名.DataSource    = dtteacher;
            //日期
            dataGridView1.Controls.Add(dtp);                //把时间控件加入DataGridView
            dtp.Visible      = false;                       //先不让它显示
            dtp.Format       = DateTimePickerFormat.Custom; //设置日期格式为2010-08-05
            dtp.CustomFormat = "yyyy-MM-dd";
            dataGridView1.Columns[5].DefaultCellStyle.Format = "yyyy-MM-dd";
            dtp.TextChanged += new EventHandler(dtp_TextChange); //为时间控件加入事件dtp_TextChange


            sqlconnet.close();
        }