コード例 #1
0
        private void button22_Click(object sender, EventArgs e)
        {
            sqlConnect cc = new sqlConnect();

            string  sql    = "select b.开课编号hjh, a.学生编号hjh from 学生hjh a,开课hjh b where a.班级编号hjh = b.班级编号hjh";
            DataSet ds     = cc.GetDataSet(sql);
            int     synNum = 0;

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                string sql2 = "select * from 选修hjh where 开课编号hjh = '" + dr[0].ToString() + "' " +
                              " and 学生编号hjh = '" + dr[1].ToString() + "'";

                DataSet ds2 = cc.GetDataSet(sql2);
                if (ds2.Tables[0].Rows.Count == 0)
                {
                    synNum++;
                    if (synNum == 1)
                    {
                        DataGridViewTextBoxColumn col1 = new DataGridViewTextBoxColumn();
                        DataGridViewTextBoxColumn col2 = new DataGridViewTextBoxColumn();
                        col1.Name       = "开课编号hjh";
                        col1.HeaderText = "开课编号hjh";
                        col2.Name       = "学生编号hjh";
                        col2.HeaderText = "学生编号hjh";
                        dataGridView1.Columns.Clear();
                        dataGridView1.DataSource = null;
                        dataGridView1.Columns.Add(col1);
                        dataGridView1.Columns.Add(col2);
                    }
                    sql += " insert into 选修hjh(开课编号hjh,学生编号hjh) values( '" + dr[0].ToString() + "','" + dr[1].ToString() + "' );";
                    string[] row = { dr[0].ToString(), dr[1].ToString() };
                    dataGridView1.Rows.Add(row);
                }
                ds2.Dispose();
            }
            try
            {
                if (synNum != 0)
                {
                    cc.ExecuteNonQuery(sql);
                    MessageBox.Show("共同步" + synNum.ToString() + "条记录!");
                }
                else
                {
                    MessageBox.Show("无可同步课程!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                cc.closeConnect();
            }
        }
コード例 #2
0
ファイル: glyInfo.cs プロジェクト: huajh/grade_manage_system
        private void glyInfo_Load(object sender, EventArgs e)
        {
            sqlConnect cc  = new sqlConnect();
            string     sql = "";

            if (this.tp == "系统管理员")
            {
                sql = "select * from " + this.tp + "hjh" + " where 用户名hjh = '" + this.num + "'";
            }
            else
            {
                sql = "select * from " + this.tp + "hjh" + " where " + this.tp + "编号hjh = '" + this.num + "'";
            }
            DataSet dataset = cc.GetDataSet(sql);
            DataRow dr      = dataset.Tables[0].Rows[0];

            if (this.tp == "系统管理员")
            {
                label6.Text = dr["用户名hjh"].ToString().Trim();
            }
            else
            {
                label6.Text = dr[this.tp + "编号hjh"].ToString().Trim();
            }
            textBox2.Text = dr["登录密码hjh"].ToString().Trim();
            cc.closeConnect();
            dataset.Dispose();
        }
コード例 #3
0
        private void StudentMain_Load(object sender, EventArgs e)
        {
            label7.Text = this.num;
            this.Text  += "(学生:" + this.num + ")";
            string     sql = "select * from 学生视图hjh where 学生编号hjh = '" + this.num + "'";
            sqlConnect cc  = new sqlConnect();

            try
            {
                DataSet ds = cc.GetDataSet(sql);
                label8.Text = ds.Tables[0].Rows[0]["姓名hjh"].ToString().Trim();
                label9.Text = ds.Tables[0].Rows[0]["专业名称hjh"].ToString().Trim() + "0" + ds.Tables[0].Rows[0]["班级序号hjh"].ToString().Trim();

                string         sql2 = "select * from 学院hjh";
                SqlDataAdapter da   = new SqlDataAdapter(sql2, cc.conn);
                DataSet        ds2  = new DataSet();
                da.Fill(ds2, "学院hjh");

                comboBox4.DisplayMember = "学院hjh.学院名称hjh";
                comboBox4.DataSource    = ds2;
                comboBox4.ValueMember   = "学院hjh.学院编号hjh";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }finally
            {
                cc.closeConnect();
            }
        }
コード例 #4
0
        private void ProfDevelopPlan_Load(object sender, EventArgs e)
        {
            label4.Text = this.num;
            string sql = " select a.姓名hjh,c.专业名称hjh,b.班级序号hjh,a.已修学分hjh,a.平均绩点hjh,c.毕业最少学分hjh " +
                         " from 学生hjh a, 班级hjh b,专业hjh c " +
                         " where a.学生编号hjh =  '" + this.num + "' and a.班级编号hjh = b.班级编号hjh " +
                         " and b.专业编号hjh = c.专业编号hjh ";

            string sql2 = "	select h.课程名称hjh,h.学分hjh,h.学时hjh,h.考核方式hjh,e.开课学期hjh,h.课程介绍hjh,g.成绩hjh,g.教学评定hjh " +
                          " from 学生hjh b,班级hjh c,开设hjh e,课程hjh h,选修hjh g,开课hjh k " +
                          " where b.学生编号hjh = '" + this.num + "' " +
                          " and b.班级编号hjh = c.班级编号hjh " +
                          " and c.专业编号hjh = e.专业编号hjh " +
                          " and e.课程编号hjh = h.课程编号hjh " +
                          " and g.学生编号hjh = b.学生编号hjh " +
                          " and k.班级编号hjh = c.班级编号hjh " +
                          " and k.课程编号hjh = h.课程编号hjh " +
                          " and k.开课编号hjh = g.开课编号hjh " +
                          " order by e.开课学期hjh ";
            sqlConnect cc = new sqlConnect();

            try
            {
                DataSet ds = cc.GetDataSet(sql);
                label6.Text  = ds.Tables[0].Rows[0]["姓名hjh"].ToString().Trim();
                label5.Text  = ds.Tables[0].Rows[0]["专业名称hjh"].ToString().Trim() + "0" + ds.Tables[0].Rows[0]["班级序号hjh"].ToString().Trim();
                label23.Text = ds.Tables[0].Rows[0]["已修学分hjh"].ToString().Trim();
                label24.Text = ds.Tables[0].Rows[0]["平均绩点hjh"].ToString().Trim();
                label7.Text  = "(毕业最少学分: " + ds.Tables[0].Rows[0]["毕业最少学分hjh"].ToString().Trim() + ")";

                this.Text = ds.Tables[0].Rows[0]["专业名称hjh"].ToString().Trim() + "专业(学生:" + this.num + ")";

                cc.BindDataGridView(dataGridView1, sql2);
                dataGridView1.Columns[0].ReadOnly = true;
                dataGridView1.Columns[1].ReadOnly = true;
                dataGridView1.Columns[2].ReadOnly = true;
                dataGridView1.Columns[3].ReadOnly = true;
                dataGridView1.Columns[4].ReadOnly = true;
                dataGridView1.Columns[5].ReadOnly = true;
                dataGridView1.Columns[6].ReadOnly = true;
                dataGridView1.Columns[7].ReadOnly = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                cc.closeConnect();
            }
        }
コード例 #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("学号不能为空!");
                return;
            }
            if (textBox2.Text == "")
            {
                MessageBox.Show("姓名不能为空!");
                return;
            }
            sqlConnect cc  = new sqlConnect();
            string     sql = "select * from 学生hjh where 学生编号hjh = '" + textBox1.Text + "'";
            DataSet    ds  = cc.GetDataSet(sql);

            if (ds.Tables[0].Rows.Count != 0)
            {
                MessageBox.Show("对不起,学号已经存在!");
                return;
            }
            if (textBox7.Text != "")
            {
                string sql2 = "select * from 班级hjh where 班级编号hjh = '" + textBox4.Text + "'";
                ds = cc.GetDataSet(sql2);
                if (ds.Tables[0].Rows.Count == 0)
                {
                    MessageBox.Show("对不起,班级编号不存在!");
                    return;
                }
            }
            string[] row = { textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text,
                             textBox5.Text, textBox6.Text, textBox7.Text };
            dr.Rows.Add(row);
            Close();
        }
コード例 #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox5.Text == "")
            {
                MessageBox.Show("开课编号不能为空!");
                return;
            }
            if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "")
            {
                MessageBox.Show("信息不足,不可添加!");
                return;
            }
            string     sql = "select * from 开课hjh where 开课编号hjh = '" + textBox5.Text + "'";
            sqlConnect cc  = new sqlConnect();
            DataSet    ds  = cc.GetDataSet(sql);

            if (ds.Tables[0].Rows.Count != 0)
            {
                MessageBox.Show("已经存在该开课编号!");
                return;
            }

            ds.Clear();

            string sql2 = "select * from 开课hjh where 班级编号hjh = '" + textBox2.Text + "' " +
                          " and 课程编号hjh = '" + textBox1.Text + "'";

            ds = cc.GetDataSet(sql2);
            if (ds.Tables[0].Rows.Count != 0)
            {
                MessageBox.Show("发现该班级已经开设此课程!不能重复添加!");
                return;
            }
            string[] row = { textBox5.Text, textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text };
            dataGridView1.Rows.Add(row);
        }
コード例 #7
0
        private void StudentInfo_Load(object sender, EventArgs e)
        {
            sqlConnect cc = new sqlConnect();

            this.Text += "(学生:" + this.num + ")";

            /*
             *
             *  select a.教师编号hjh,a.姓名hjh,a.性别hjh,a.出生年月hjh,a.联系电话hjh,
             *              a.学历hjh,a.职称hjh,b.学院名称hjh,a.电子邮箱hjh
             *  from 教师hjh a,学院hjh b
             *  where 教师编号hjh = '' and a.学院编号hjh = b.学院编号hjh
             *
             *
             * */
            string sql = "select 学生编号hjh,姓名hjh,性别hjh,出生年月hjh,联系电话hjh,专业名称hjh,班级序号hjh,学院名称hjh,生源地hjh" +
                         " from 学生视图hjh" +
                         " where 学生编号hjh = '" + this.num + "'";

            DataSet ds = cc.GetDataSet(sql);
            DataRow dr = ds.Tables[0].Rows[0];

            label10.Text = dr.ItemArray[0].ToString().Trim();
            label11.Text = dr.ItemArray[1].ToString().Trim();

            if (dr.ItemArray[2].ToString().Trim() == "男")
            {
                radioButton1.Checked = true;
            }
            else
            {
                radioButton2.Checked = true;
            }

            textBox1.Text = dr.ItemArray[3].ToString().Trim();
            textBox2.Text = dr.ItemArray[4].ToString().Trim();
            label12.Text  = dr.ItemArray[5].ToString().Trim() + "0" + dr.ItemArray[6].ToString().Trim();
            label14.Text  = dr.ItemArray[7].ToString().Trim();
            textBox3.Text = dr.ItemArray[8].ToString().Trim();
        }
コード例 #8
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("请输入开课编号!");
                return;
            }
            sqlConnect cc   = new sqlConnect();
            string     sql2 = "select * from 开课hjh where 开课编号hjh = '" + textBox1.Text
                              + "' and 教师编号hjh = '" + this.num + "'";
            DataSet ds = cc.GetDataSet(sql2);

            if (ds.Tables[0].Rows.Count == 0)
            {
                MessageBox.Show("对不起,该课程不存在或不是您的课!");
                return;
            }
            string sql = "select b.开课编号hjh,c.学生编号hjh,c.姓名hjh,b.成绩hjh " +
                         " from 选修hjh b,学生hjh c" +
                         "  where  b.开课编号hjh = '" + textBox1.Text + "'and b.学生编号hjh = c.学生编号hjh ";

            try
            {
                cc.BindDataGridView(dataGridView1, sql);
                dataGridView1.Columns[0].ReadOnly = true;
                dataGridView1.Columns[1].ReadOnly = true;
                dataGridView1.Columns[2].ReadOnly = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                cc.closeConnect();
            }
        }
コード例 #9
0
        private void StudentGradeResult_Load(object sender, EventArgs e)
        {
            label18.Text = this.jidian.ToString();
            label19.Text = this.unpassed.ToString();
            label20.Text = this.excellent.ToString();

            string sql =
                "select b.学生编号hjh,sum((g.成绩hjh-50)*h.学分hjh)/(SUM(h.学分hjh)*10) '绩点hjh'" +
                " from 学生hjh b,班级hjh c,开设hjh e,开课hjh f,选修hjh g,课程hjh h,教师hjh i " +
                " where " +
                " b.班级编号hjh = c.班级编号hjh and c.专业编号hjh = e.专业编号hjh ";

            if (this.type == "学期")
            {
                sql += " and e.开课学期hjh = '" + kk + "' ";
            }
            else if (this.type == "学年")
            {
                sql += " and e.开课学期hjh like '" + kk + "%' ";
            }
            sql += " and e.课程编号hjh = f.课程编号hjh and b.班级编号hjh = f.班级编号hjh  " +
                   " and g.开课编号hjh = f.开课编号hjh and g.学生编号hjh = b.学生编号hjh " +
                   " and f.课程编号hjh = h.课程编号hjh and f.教师编号hjh = i.教师编号hjh " +
                   " and b.班级编号hjh = ( " +
                   " select b.班级编号hjh " +
                   " from 学生hjh a,班级hjh b " +
                   " where a.学生编号hjh = '" + this.num + "' and a.班级编号hjh = b.班级编号hjh ) " +
                   " group by b.学生编号hjh,g.成绩hjh " +
                   " having (g.成绩hjh >=60 and sum((g.成绩hjh-50)*h.学分hjh)/(SUM(h.学分hjh)*10) >" + this.jidian + ") ";

            string sql2 =
                "select b.学生编号hjh,sum((g.成绩hjh-50)*h.学分hjh)/(SUM(h.学分hjh)*10) '绩点hjh'" +
                " from 学生hjh b,班级hjh c,开设hjh e,开课hjh f,选修hjh g,课程hjh h,教师hjh i " +
                " where " +
                " b.班级编号hjh = c.班级编号hjh and c.专业编号hjh = e.专业编号hjh ";

            if (this.type == "学期")
            {
                sql2 += " and e.开课学期hjh = '" + kk + "' ";
            }
            else if (this.type == "学年")
            {
                sql2 += " and e.开课学期hjh like '" + kk + "%' ";
            }
            sql2 += " and e.课程编号hjh = f.课程编号hjh and b.班级编号hjh = f.班级编号hjh  " +
                    " and g.开课编号hjh = f.开课编号hjh and g.学生编号hjh = b.学生编号hjh " +
                    " and f.课程编号hjh = h.课程编号hjh and f.教师编号hjh = i.教师编号hjh " +
                    " and c.专业编号hjh = ( " +
                    " select b.专业编号hjh " +
                    " from 学生hjh a,班级hjh b " +
                    " where a.学生编号hjh = '" + this.num + "' and a.班级编号hjh = b.班级编号hjh ) " +
                    " group by b.学生编号hjh,g.成绩hjh " +
                    " having (g.成绩hjh >=60 and sum((g.成绩hjh-50)*h.学分hjh)/(SUM(h.学分hjh)*10) >" + this.jidian + ") ";

            sqlConnect cc = new sqlConnect();

            try
            {
                DataSet ds  = cc.GetDataSet(sql);
                DataSet ds2 = cc.GetDataSet(sql2);

                MessageBox.Show(ds.Tables[0].Rows.Count.ToString());

                label21.Text = (ds.Tables[0].Rows.Count + 1).ToString();
                label22.Text = (ds2.Tables[0].Rows.Count + 1).ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                cc.closeConnect();
            }
        }
コード例 #10
0
        private void button1_Click(object sender, EventArgs e)
        {
            sqlConnect cc = new sqlConnect();

            string sql  = "update 学生hjh set ";
            int    flag = 0;

            if (comboBox1.Text != dgvr.Cells[3].Value.ToString().Trim() ||
                textBox5.Text != dgvr.Cells[4].Value.ToString().Trim() ||
                textBox6.Text != dgvr.Cells[5].Value.ToString().Trim()
                )
            {
                string sql2 = "select 班级编号hjh from 学院hjh a, 专业hjh b ,班级hjh c where " +
                              " a.学院名称hjh = '" + comboBox1.Text + "' and " +
                              " b.专业名称hjh = '" + textBox5.Text + "' and " +
                              " c.班级序号hjh = " + textBox6.Text + " and " +
                              " a.学院编号hjh = b.学院编号hjh and " +
                              " b.专业编号hjh = c.专业编号hjh";

                try
                {
                    DataSet ds = cc.GetDataSet(sql2);
                    if (ds.Tables[0].Rows.Count == 0)
                    {
                        MessageBox.Show("找到该学生的班级编号,学院、专业、或班级信息有误!");
                        return;
                    }
                    string str = ds.Tables[0].Rows[0].ItemArray[0].ToString().Trim();
                    ds.Dispose();
                    sql += "班级编号hjh = '" + str + "' ";
                    flag = 1;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                finally { }
            }
            if (textBox2.Text != dgvr.Cells[1].Value.ToString().Trim())
            {
                if (flag == 1)
                {
                    sql += ",";
                }
                sql += "姓名hjh = '" + textBox2.Text + "'";
                flag = 1;
            }
            if (textBox3.Text != dgvr.Cells[2].Value.ToString().Trim())
            {
                if (flag == 1)
                {
                    sql += ",";
                }
                sql += "性别hjh = '" + textBox3.Text + "'";
                flag = 1;
            }
            if (textBox7.Text != dgvr.Cells[6].Value.ToString().Trim())
            {
                if (flag == 1)
                {
                    sql += ",";
                }
                sql += "出生年月hjh = '" + textBox7.Text + "'";
                flag = 1;
            }
            if (textBox8.Text != dgvr.Cells[7].Value.ToString().Trim())
            {
                if (flag == 1)
                {
                    sql += ",";
                }
                sql += "联系电话hjh = '" + textBox8.Text + "'";
                flag = 1;
            }
            if (textBox9.Text != dgvr.Cells[8].Value.ToString().Trim())
            {
                if (flag == 1)
                {
                    sql += ",";
                }
                sql += "已修学分hjh = " + textBox9.Text;
                flag = 1;
            }
            if (textBox10.Text != dgvr.Cells[9].Value.ToString().Trim())
            {
                if (flag == 1)
                {
                    sql += ",";
                }
                sql += "平均绩点hjh = " + textBox10.Text;
                flag = 1;
            }
            if (textBox11.Text != dgvr.Cells[10].Value.ToString().Trim())
            {
                if (flag == 1)
                {
                    sql += ",";
                }
                sql += "生源地hjh = '" + textBox11.Text + "'";
                flag = 1;
            }
            if (textBox12.Text != dgvr.Cells[11].Value.ToString().Trim())
            {
                if (flag == 1)
                {
                    sql += ",";
                }
                sql += "权限级别hjh = " + textBox12.Text;
                flag = 1;
            }
            sql += " where 学生编号hjh = '" + label13.Text + "'";
            try
            {
                if (flag == 1)
                {
                    cc.ExecuteNonQuery(sql);
                    MessageBox.Show("修改成功!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                cc.closeConnect();
                this.Close();
            }
        }
コード例 #11
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("课程号不能为空!");
                return;
            }
            if (textBox2.Text == "")
            {
                MessageBox.Show("课程名称不能为空!");
                return;
            }

            sqlConnect cc = new sqlConnect();

            string  sql = "select * from 课程hjh where 课程编号hjh = '" + textBox1.Text + "'";
            DataSet ds  = cc.GetDataSet(sql);

            if (ds.Tables[0].Rows.Count != 0)
            {
                MessageBox.Show("对不起,课程号已经存在!");
                return;
            }
            ds.Dispose();
            if (comboBox1.Text == "  ------选择------")
            {
                MessageBox.Show("请选择开课学院!");
                return;
            }

            if (comboBox2.Text == "  ----选择----")
            {
                comboBox2.Text = "";
            }
            if (comboBox3.Text == "  ----选择----")
            {
                comboBox3.Text = "";
            }

            string sql2 = "select * from 学院hjh where 学院名称hjh = '" + comboBox1.Text + "'";

            ds = cc.GetDataSet(sql2);
            if (ds.Tables[0].Rows.Count == 0)
            {
                MessageBox.Show("未能到该学院名称的学院编号,学院信息有误!");
                return;
            }
            comboBox1.Text = ds.Tables[0].Rows[0].ItemArray[0].ToString().Trim();
            ds.Dispose();

            string str = "";

            if (radioButton1.Checked)
            {
                str = radioButton1.Text;
            }
            else
            {
                str = radioButton2.Text;
            }

            string[] row = { textBox1.Text,  textBox2.Text,  comboBox1.Text, str,
                             comboBox2.Text, comboBox3.Text, textBox4.Text };

            dr.Rows.Add(row);
            Close();
        }
コード例 #12
0
ファイル: Form1.cs プロジェクト: huajh/grade_manage_system
        private void button1_Click(object sender, EventArgs e)
        {
            string tp  = comboBox1.Text;
            string num = textBox1.Text;
            string pwd = textBox2.Text;

            if (tp != "教师" && tp != "学生" && tp != "系统管理员")
            {
                MessageBox.Show("请选择登录身份!");
                return;
            }
            if (num == "")
            {
                MessageBox.Show("用户名不能为空!");
                return;
            }
            if (pwd == "")
            {
                MessageBox.Show("请输入密码!");
                return;
            }
            string strSQL = "";

            if (tp == "系统管理员")
            {
                strSQL += "select * from 系统管理员hjh where '" + num + "' = 用户名hjh and 登录密码hjh = '" + pwd + "'";
            }
            else
            {
                strSQL += "select * from " + tp + "hjh where '" + num + "' = " + tp + "编号hjh and 登录密码hjh = '" + pwd + "'";
            }
            sqlConnect cc      = new sqlConnect();
            DataSet    dataset = new DataSet();

            try
            {
                dataset = cc.GetDataSet(strSQL);
                if (dataset.Tables[0].Rows.Count == 0)
                {
                    MessageBox.Show("密码错误,请重新登录!");
                    return;
                }
                DataRow dr = dataset.Tables[0].Rows[0];
                if (dr["权限级别hjh"].ToString() == "1")
                {
                    StudentMain frm = new StudentMain(tp, num);
                    frm.Show();
                }
                else if (dr["权限级别hjh"].ToString() == "2")
                {
                    TeacherMain frm2 = new TeacherMain(tp, num);
                    frm2.Show();
                }
                else if (dr["权限级别hjh"].ToString() == "5")
                {
                    SystemManage frm3 = new SystemManage(tp, num);
                    frm3.Show();
                }
                this.Hide();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                cc.closeConnect();
                dataset.Dispose();
            }
        }
コード例 #13
0
        private void button1_Click(object sender, EventArgs e)
        {
            sqlConnect cc   = new sqlConnect();
            string     sql  = "update 教师hjh set ";
            int        flag = 0;

            if (comboBox1.Text != dgvr.Cells[3].Value.ToString().Trim())
            {
                string  sql2 = "select * from 学院hjh where 学院名称hjh = '" + comboBox1.Text + "'";
                DataSet ds   = cc.GetDataSet(sql2);
                if (ds.Tables[0].Rows.Count == 0)
                {
                    MessageBox.Show("未能到该学院名称的学院编号,学院信息有误!");
                    return;
                }
                string str = ds.Tables[0].Rows[0].ItemArray[0].ToString().Trim();
                ds.Dispose();
                sql += "学院编号hjh = '" + str + "' ";
                flag = 1;
            }
            if (textBox2.Text != dgvr.Cells[1].Value.ToString().Trim())
            {
                if (flag == 1)
                {
                    sql += ",";
                }
                sql += "姓名hjh = '" + textBox2.Text + "'";
                flag = 1;
            }
            if (textBox3.Text != dgvr.Cells[2].Value.ToString().Trim())
            {
                if (flag == 1)
                {
                    sql += ",";
                }
                sql += "性别hjh = '" + textBox3.Text + "'";
                flag = 1;
            }
            if (textBox5.Text != dgvr.Cells[4].Value.ToString().Trim())
            {
                if (flag == 1)
                {
                    sql += ",";
                }
                sql += "出生年月hjh = '" + textBox5.Text + "'";
                flag = 1;
            }
            if (textBox6.Text != dgvr.Cells[5].Value.ToString().Trim())
            {
                if (flag == 1)
                {
                    sql += ",";
                }
                sql += "学历hjh = '" + textBox6.Text + "'";
                flag = 1;
            }
            if (textBox7.Text != dgvr.Cells[6].Value.ToString().Trim())
            {
                if (flag == 1)
                {
                    sql += ",";
                }
                sql += "职称hjh = '" + textBox7.Text + "'";
                flag = 1;
            }
            if (textBox8.Text != dgvr.Cells[7].Value.ToString().Trim())
            {
                if (flag == 1)
                {
                    sql += ",";
                }
                sql += "电子邮箱hjh = '" + textBox8.Text + "'";
                flag = 1;
            }
            if (textBox9.Text != dgvr.Cells[8].Value.ToString().Trim())
            {
                if (flag == 1)
                {
                    sql += ",";
                }
                sql += "联系电话hjh = '" + textBox9.Text + "'";
                flag = 1;
            }
            if (textBox10.Text != dgvr.Cells[9].Value.ToString().Trim())
            {
                if (flag == 1)
                {
                    sql += ",";
                }
                sql += "权限级别hjh = " + textBox10.Text;
                flag = 1;
            }
            sql += " where 教师编号hjh = '" + label11.Text + "'";
            try
            {
                if (flag == 1)
                {
                    cc.ExecuteNonQuery(sql);
                    MessageBox.Show("修改成功!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                cc.closeConnect();
                this.Close();
            }
        }
コード例 #14
0
        private void button21_Click(object sender, EventArgs e)
        {
            sqlConnect cc = new sqlConnect();

            if (comboBox10.SelectedValue == null || comboBox10.DisplayMember == null)
            {
                MessageBox.Show("请选择一个班级!");
                return;
            }
            string  sql = "select 开课编号hjh from 开课hjh  where 班级编号hjh = '" + comboBox10.SelectedValue.ToString().Trim() + "'";
            DataSet ds  = cc.GetDataSet(sql);

            sql = "select 学生编号hjh from 学生hjh where 班级编号hjh = '" + comboBox10.SelectedValue.ToString().Trim() + "'";
            DataSet ds2    = cc.GetDataSet(sql);
            int     synNum = 0;

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                foreach (DataRow dr2 in ds2.Tables[0].Rows)
                {
                    string sql2 = "select * from 选修hjh where 开课编号hjh = '" + dr[0].ToString() + "' and " +
                                  "学生编号hjh = '" + dr2[0].ToString() + "'";
                    DataSet ds3 = cc.GetDataSet(sql2);
                    if (ds3.Tables[0].Rows.Count == 0)
                    {
                        synNum++;
                        if (synNum == 1)
                        {
                            DataGridViewTextBoxColumn col1 = new DataGridViewTextBoxColumn();
                            DataGridViewTextBoxColumn col2 = new DataGridViewTextBoxColumn();
                            col1.Name       = "开课编号hjh";
                            col1.HeaderText = "开课编号hjh";
                            col2.Name       = "学生编号hjh";
                            col2.HeaderText = "学生编号hjh";
                            dataGridView1.Columns.Clear();
                            dataGridView1.DataSource = null;
                            dataGridView1.Columns.Add(col1);
                            dataGridView1.Columns.Add(col2);
                        }
                        sql += " insert into 选修hjh(开课编号hjh,学生编号hjh) values( '" + dr[0].ToString() + "','" + dr2[0].ToString() + "' );";
                        string[] row = { dr[0].ToString(), dr2[0].ToString() };
                        dataGridView1.Rows.Add(row);
                    }
                    ds3.Dispose();
                }
            }
            try
            {
                if (synNum != 0)
                {
                    cc.ExecuteNonQuery(sql);
                    MessageBox.Show("共同步" + synNum.ToString() + "条记录!");
                }
                else
                {
                    MessageBox.Show("无需再次同步,该班级同学选修情况已经全部与班级开课同步!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                cc.closeConnect();
            }
        }