示例#1
0
        private void button4_Click(object sender, EventArgs e)
        {
            try
            {
                string          id       = TextUserid.Text.Trim();
                string          password = TextPassName.Text.Trim();
                BUser           mgr      = new BUser();
                DTO4ManagerInfo manager  = mgr.ManagerLogin(id, password);

                if (id == null || id == "")                                     //输入名和密码不能为空
                {
                    MessageBox.Show("输入名为空!");
                }
                if (password == null || password == "")
                {
                    MessageBox.Show("输入密码不能为空!");
                }

                //通过设置公共类app在窗体之间传递参数

                if (manager.Id == id && manager.Psw == password)
                {
                    app.a             = 1;
                    app.user_name     = manager.Name;
                    app.user_id       = manager.Id;
                    app.user_office   = "管理层";
                    app.user_jobtitle = "管理者";

                    Form1 form1 = new Form1();
                    this.Hide();
                    if (form1.ShowDialog() == DialogResult.OK)
                    {
                        this.Close();
                    }
                }
                else
                {
                    DTO4DoctorInfo doctor = mgr.DoctorLogin(id);
                    if (doctor.Psw == password)
                    {
                        app.a = 0;

                        app.user_name     = doctor.Name;
                        app.user_id       = doctor.Id;
                        app.user_office   = doctor.Office;
                        app.user_jobtitle = doctor.JobTitle;

                        Form1 form1 = new Form1();
                        this.Hide();
                        if (form1.ShowDialog() == DialogResult.OK)
                        {
                            this.Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show("登录失败");
                    }
                }
            }
            catch
            {
                MessageBox.Show("请确认您的账户密码是否正确");
            }
        }