示例#1
0
        // 单击登录事件
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                if (!CheckInput())
                {
                    return;
                }
                // 判断用户类型
                if (RadioStudent.Checked == true)
                {
                    StudentData student = new StudentData();
                    student.StuNo  = TxtName.Text.Trim();
                    student.StuPwd = TxtPwd.Text.Trim();
                    if (sm.CheckStudentLogin(TxtName.Text.Trim(), TxtPwd.Text.Trim()))
                    {
                        this.Visible = false;
                        StudentForm f1 = new StudentForm();
                        f1.ShowDialog();
                        this.Visible = true;
                    }
                    else
                    {
                        MessageBox.Show(INPUTNOEXIST, INPUTWARN, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else if (RadioTeacher.Checked == true)
                {
                    if (tm.CheckTeacherLogin(TxtName.Text.Trim(), TxtPwd.Text.Trim()))
                    {
                        this.Visible = false;
                        Teacher f2 = new Teacher();
                        f2.ShowDialog();
                        this.Visible = true;
                    }
                    else
                    {
                        MessageBox.Show(INPUTNOEXIST, INPUTWARN, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    AdminData adminData = new AdminData();
                    adminData.AdminNo = TxtName.Text.Trim();

                    adminData.AdminPwd = TxtPwd.Text.Trim();
                    if (ad_ServicesBLL.CheckAdminLogin(adminData) == 2)
                    {
                        this.Visible = false;
                        MainForm f3 = new MainForm();
                        f3.ShowDialog();
                        this.Visible = true;
                    }
                    else
                    {
                        MessageBox.Show(INPUTNOEXIST, INPUTWARN, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, LOGINFAILED, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }