Example #1
0
        /// <summary>
        /// 通过id和密码查找管理员信息
        /// </summary>
        /// <param name="_id">string类型 管理员id</param>
        /// <param name="_psw">string类型 管理员密码</param>
        /// <returns>DTO4ManagerInfo类型的对象</returns>
        public DTO4ManagerInfo selectAllByIdAndPsw(string _id, string _psw)
        {
            string          sql   = "select * from managerInfo where id =" + _id + " and psw = '" + _psw + "'";
            DTO4ManagerInfo dto4m = new DTO4ManagerInfo();
            DataSet         dt    = DBOperater.selectSql(sql);

            if (dt != null && dt.Tables.Count > 0 && dt.Tables[0].Rows.Count > 0)
            {
                dto4m.Id   = dt.Tables[0].Rows[0]["id"].ToString();
                dto4m.Name = (string)dt.Tables[0].Rows[0]["name"];
                dto4m.Psw  = (string)dt.Tables[0].Rows[0]["psw"];
            }
            return(dto4m);
        }
Example #2
0
        //通过登录界面输入的账号密码来查询在数据库中是否存在这条数据,借此判断账号密码是否正确

        public DTO4ManagerInfo ManagerLogin(string id, string password)
        {
            DAO4ManagerInfo mDao    = new DAO4ManagerInfo();
            DTO4ManagerInfo manager = mDao.selectAllByIdAndPsw(id, password);

            if (manager != null)
            {
                return(manager);
            }
            else
            {
                throw new Exception("登录失败");
            }
        }
Example #3
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("请确认您的账户密码是否正确");
            }
        }