Example #1
0
 //查询按钮
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         if (FormMain.Power == "学生")
         {
             DBOperate operate = new DBOperate();
             string    name    = operate.GetName();
             string    str1    =//创建查询字符串
                                 "select A.stu_class as 班级,A.stu_id as 学号,A.stu_name as 姓名,B.Cour_Name as 课程名,B.Score as 成绩 from Student as A JOIN SC_result AS B ON A.stu_id=B.Stu_Id join Coures as C ON C.Cour_Id=B.Cour_Id where A.stu_name='" + name + "' and C.Cour_Semester='" + cbbSemester.SelectedItem.ToString() + "' and B.Cour_Name='" + cbbCourse.SelectedItem.ToString() + "'";
             operate.BindDataGridView(dataGridView1, str1);
         }
         else
         {
             if (cbbCourse.Text == "")
             {
                 string str =//创建查询字符串
                              "select A.stu_class as 班级,A.stu_id as 学号,A.stu_name as 姓名,B.Cour_Name as 课程名,B.Score as 成绩 from Student as A JOIN SC_result AS B ON A.stu_id=B.Stu_Id join Coures as C ON C.Cour_Id=B.Cour_Id where A.stu_name='" + cbbstudent.SelectedItem.ToString() + "' and C.Cour_Semester='" + cbbSemester.SelectedItem.ToString() + "' and A.Stu_class='" + cbbClass.SelectedItem.ToString() + "'";
                 operate.BindDataGridView(dataGridView1, str);
             }
             else
             {
                 string str =                                  //创建查询字符串
                              "select A.stu_class as 班级,A.stu_id as 学号,A.stu_name as 姓名,B.Cour_Name as 课程名,B.Score as 成绩 from Student as A JOIN SC_result AS B ON A.stu_id=B.Stu_Id join Coures as C ON C.Cour_Id=B.Cour_Id where B.Cour_Name='" + cbbCourse.SelectedItem.ToString() + "' and C.Cour_Semester='" + cbbSemester.SelectedItem.ToString() + "' and A.Stu_class='" + cbbClass.SelectedItem.ToString() + "'";
                 operate.BindDataGridView(dataGridView1, str); //将查询信息绑定到DATAGRIDVIEW控件
             }
         }
     }
     catch
     {
         MessageBox.Show("你还有未选择的项", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Example #2
0
 private void cbbClass_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cbbSemester.SelectedIndex != -1 && cbbClass.SelectedIndex != -1)
     {
         string str1 = "select distinct Student.stu_class as 班级,Coures.Cour_Id as 课程编号,Coures.Cour_Name as 课程名,Coures.Cour_Semester as 学期 from SC_result join Student on SC_result.Stu_Id=Student.stu_id join Coures on Coures.Cour_Id=SC_result.Cour_Id where Student.stu_class='" + cbbClass.SelectedItem.ToString() + "'and Coures.Cour_Semester='" + cbbSemester.SelectedItem.ToString() + "'";
         operate.BindDataGridView(dataGridView1, str1); //将查询信息绑定到DATAGRIDVIEW控件
         dataGridView1.Columns[0].Width = 80;           //定义数据列宽度
         dataGridView1.Columns[1].Width = 80;           //定义数据列宽度
     }
 }
Example #3
0
        private void FormManageLogin_Load(object sender, EventArgs e)
        {
            string str;

            if (FormMain.Power == "管理员")
            {
                str = "select UserName as '用户名',UserPwd as '用户密码',UserPower as '用户权限',LoginTime as '登录时间' from wang_User order by LoginTime desc";
            }
            else
            {
                str            = "select UserName as '用户名',UserPwd as '用户密码',UserPower as '用户权限',LoginTime as '登录时间' from wang_User where UserName='******'";
                delete.Enabled = false;
            }
            operate.BindDataGridView(dataGridView1, str);
            dataGridView1.Columns[0].Width = 100;
            dataGridView1.Columns[1].Width = 145;
            dataGridView1.Columns[2].Width = 100;
            dataGridView1.Columns[3].Width = 120;
        }
Example #4
0
        //保存按钮事件
        private void FormCheckuser_Z_score_Load(object sender, EventArgs e)
        {
            N = "0";
            string str1 = //创建查询字符串
                          "select A.stu_class as 班级,A.stu_id as 学号,A.stu_name as 姓名,B.COUR_ID AS 课程号,B.Cour_Name as 课程名,B.Score as 成绩 from Student as A JOIN SC_result AS B ON A.stu_id=B.Stu_Id join Coures as C ON C.Cour_Id=B.Cour_Id  where A.Stu_id='" + XTID + "' and B.Score='" + "暂无成绩" + "'";

            operate.BindDataGridView(dataGridView1, str1); //将查询信息绑定到DATAGRIDVIEW控件
            dataGridView1.Columns[0].Width = 80;           //定义数据列宽度
            dataGridView1.Columns[1].Width = 100;          //定义数据列宽度

            adapter = new SqlDataAdapter("select A.stu_class as 班级,A.stu_id as 学号,A.stu_name as 姓名,B.COUR_ID AS 课程号,B.Cour_Name as 课程名,B.Score as 成绩 from Student as A JOIN SC_result AS B ON A.stu_id=B.Stu_Id join Coures as C ON C.Cour_Id=B.Cour_Id  where A.Stu_id='" + XTID + "' and B.Score='" + "暂无成绩" + "'", conn);
            dSet    = new DataSet();
            adapter.Fill(dSet);

            dataGridView1.DataSource = dSet.Tables[0];
        }
Example #5
0
        private void FormCheckuser_Load(object sender, EventArgs e)
        {
            string str =//创建查询字符串
                         "select Tea_id as '教师编号', Tea_name as '教师姓名',Tea_Dept '部门',Tea_Birthday as '生日',Tea_Nation as '民族',Tea_Marriage as '婚否',Tea_MCCP as '政治面貌',Tea_Phone as '电话',Tea_Accession as '就职日期',Tea_Pay as '薪资' from Teacher";

            operate.BindDataGridView(dataGridView1, str);     //将查询信息绑定到DATAGRIDVIEW控件
            dataGridView1.Columns[0].Width = 60;              //定义数据列宽度
            dataGridView1.Columns[1].Width = 100;             //定义数据列宽度
            treeView1.Nodes.Add("所有学生");                      //添加根节点
            TreeNode      tn   = treeView1.Nodes.Add("所有教师"); //添加根节点
            SqlConnection conn = DBConnection.MyConnection(); //创建数据库连接对象

            conn.Open();
            SqlCommand    cmd = new SqlCommand("select distinct tea_dept from Teacher", conn); //创建命令对象
            SqlDataReader sdr = cmd.ExecuteReader();                                           //创建数据阅读器

            while (sdr.Read())
            {
                tn.Nodes.Add(sdr[0].ToString());                         //添加节点
            }
            sdr.Close();                                                 //关闭数据读取器
            conn.Close();                                                //关闭数据连接
            treeView1.ExpandAll();                                       //展开所有节点
            string sql = "select DISTINCT count(tea_dept) from Teacher"; //定义sql字符串

            Text = "当前教师编号:" + dataGridView1.SelectedCells[0].Value.ToString();
            string TeaId = dataGridView1.SelectedCells[0].Value.ToString(); //得到编号(学生或者教师编号)

            operate.TeaGet_Image(TeaId, pictureBox1);                       //显示图片信息
            treeView1.SelectedNode = treeView1.Nodes[0];
            if (FormMain.Power == "教师")
            {
                delete.Enabled = false;
                ADD.Enabled    = false;
                treeView1.CollapseAll();
            }
        }