Exemple #1
0
        private void btnback_Click(object sender, EventArgs e)
        {
            this.Hide();
            controller form = new controller();

            form.Show();
        }
Exemple #2
0
        private void btnsubmit_Click_1(object sender, EventArgs e)
        {
            uID   = txtuser.Text;
            uPswd = txtpswd.Text;
            if (uID == "")
            {
                MessageBox.Show("请输入用户名!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (uPswd == "")
            {
                MessageBox.Show("请输入密码!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (power == 0)
            {
                MessageBox.Show("请选择权限!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                SqlConnection conn = new SqlConnection("Data Source = (local);Initial Catalog = one;Integrated Security=SSPI");
                conn.Open();
                SqlCommand cmd = new SqlCommand("select * from login where Username ='" + uID + "'and password ='******'", conn);
                int        num = Convert.ToInt32(cmd.ExecuteScalar());

                if (num == power)
                {
                    if (power == 1)
                    {
                        app.value = 1;
                        conn.Close();
                        MessageBox.Show("管理员登录成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Hide();
                        controller form = new controller();
                        form.Show();
                    }
                    else if (power == 2)
                    {
                        SqlCommand cmd1 = new SqlCommand("select * from stu_infor where 姓名 ='" + uID + "'", conn);
                        app.value = Convert.ToInt32(cmd1.ExecuteScalar());
                        conn.Close();
                        MessageBox.Show("学生登录成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Hide();
                        student form = new student();
                        form.Show();
                    }
                    else
                    {
                        SqlCommand cmd1 = new SqlCommand("select * from tea_infor where 姓名 ='" + uID + "'", conn);
                        app.value = Convert.ToInt32(cmd1.ExecuteScalar());
                        conn.Close();
                        MessageBox.Show("教师登录成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Hide();
                        teacher form = new teacher();
                        form.Show();
                    }
                }
                else
                {
                    conn.Close();
                    MessageBox.Show("用户名或密码错误", "警告", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtuser.Text = null;
                    txtpswd.Text = null;
                }
            }
        }