Пример #1
0
        private bool login()
        {
            if (textBox1.Text == "" || textBox2.Text == "" || comboBox1.Text == "")
            {
                MessageBox.Show("输入不完整或者错误,请重新输入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }

            if (comboBox1.Text == "学生")
            {
                string      sql = "select *from student where Name='" + textBox1.Text + "'and Password='******'";
                Dao1        dao = new Dao1();
                IDataReader dr  = dao.read(sql);
                if (dr.Read())
                {
                    return(true);
                }
                else
                {
                    MessageBox.Show("输入有误,请检查后重新输入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }
            }
            if (comboBox1.Text == "老师")
            {
                string      sql = "select *from Teacher where Name='" + textBox1.Text + "'and Password='******'";
                Dao1        dao = new Dao1();
                IDataReader dr  = dao.read(sql);
                if (dr.Read())
                {
                    return(true);
                }
                else
                {
                    MessageBox.Show("输入有误,请检查后重新输入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }
            }
            if (comboBox1.Text == "管理员")
            {
                if (textBox1.Text == "admin" && textBox2.Text == "123456")
                {
                    return(true);
                }
                else
                {
                    MessageBox.Show("输入有误,请检查后重新输入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }
            }
            return(false);
        }
Пример #2
0
        private void Table()
        {
            string      sql = "select*from class";
            Dao1        dao = new Dao1();
            IDataReader dr  = dao.read(sql);

            while (dr.Read())
            {
                string a, b, c;
                a = dr["Date"].ToString();
                b = dr["Sjd"].ToString();
                c = dr["Id"].ToString();
                string[] str = { a, b, c };
                dataGridView1.Rows.Add(str);
            }
            dr.Close();
        }
Пример #3
0
        private void Table()
        {
            dataGridView1.Rows.Clear();
            string      sql = "select*from Yy";
            Dao1        dao = new Dao1();
            IDataReader dr  = dao.read(sql);

            while (dr.Read())
            {
                string a, b, c, d, o;
                a = dr["Id"].ToString();
                b = dr["Name"].ToString();
                c = dr["Date"].ToString();
                d = dr["Sjd"].ToString();
                o = dr["Classid"].ToString();
                string[] str = { a, b, c, d, o };
                dataGridView1.Rows.Add(str);
            }
            dr.Close();
        }
Пример #4
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text == "" || textBox2.Text == "")
     {
         MessageBox.Show("学号和姓名不能为空,请重新输入!");
     }
     else
     {
         string      sql = "select *from Yy where Id='" + textBox1.Text + "'and Name='" + textBox2.Text + "'";
         Dao1        dao = new Dao1();
         IDataReader dr  = dao.read(sql);
         if (dr.Read())
         {
             table();
         }
         else
         {
             MessageBox.Show("没有查询到信息,请检查后重新输入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
 }