Пример #1
0
        public T_ScoreSearch(LoginIn_Teacher parent, string id)
        {
            InitializeComponent();
            pform = parent;
            tid   = id;
            string sql = "select cid from costea where tid = '" + tid + "'";


            if (ExecuteSql(sql) != 0)
            {
                this.cbox_cid.DataSource = Query(sql).Tables["costea"];
                cbox_cid.DisplayMember   = "cid";
            }
        }
Пример #2
0
        private void btn_login_Click(object sender, EventArgs e)
        {
            if (login_id.Text.Trim() == "")
            {
                MessageBox.Show("登陆名不能为空");
            }
            else if (login_pwd.Text.Trim() == "")
            {
                MessageBox.Show("密码不能为空");
            }
            else
            {
                string        id  = login_id.Text.Trim();
                string        pwd = login_pwd.Text.Trim();
                string        sql;
                SqlConnection con = new SqlConnection(connectionString); //创建一个数据库连接
                if (radioButton_ad.Checked)                              //管理员
                {
                    sql = "select * from users where uid = " + id + " and upasswd = " + pwd + " and ugroup = 1";
                }
                else if (radioButton_t.Checked) //教师
                {
                    sql = "select * from users where uid = " + id + " and upasswd = " + pwd + " and ugroup = 2";
                }
                //else if (radioButton_stu.Checked) //学生
                else
                {
                    sql = "select * from users where uid = " + id + " and upasswd = " + pwd + " and ugroup = 3";
                }

                SqlCommand cmd = new SqlCommand(sql, con);//创建一个SqlCommand,用于对数据库进行操作
                try
                {
                    con.Open();//打开连接
                    SqlDataReader reader = cmd.ExecuteReader();
                    if (!reader.Read())
                    {
                        MessageBox.Show("用户名或密码错误,请重试!");
                        login_id.Text  = "";
                        login_pwd.Text = "";
                    }
                    else
                    {
                        string time = DateTime.Now.ToString();
                        if (radioButton_ad.Checked)
                        {
                            LoginIn_Ad childrenForm = new LoginIn_Ad(id, time);
                            childrenForm.Owner = this;
                            this.Hide();
                            childrenForm.Show();
                        }
                        else if (radioButton_stu.Checked)
                        {
                            LoginIn_Stu childrenForm = new LoginIn_Stu(id, time);
                            childrenForm.Owner = this;
                            this.Hide();
                            childrenForm.Show();
                        }
                        else if (radioButton_t.Checked)
                        {
                            LoginIn_Teacher childrenForm = new LoginIn_Teacher(id, time);
                            childrenForm.Owner = this;
                            this.Hide();
                            childrenForm.Show();
                        }
                    }
                }
                catch (SqlException e1)
                {
                    MessageBox.Show(e1.Message);
                }
                finally
                {
                    cmd.Dispose();//cmd处理
                    con.Close();
                }
            }
        }
 public T_StuSearch(LoginIn_Teacher parent)
 {
     InitializeComponent();
     pform = parent;
 }