Exemple #1
0
        private bool login()
        {
            if (textBox1.Text == "" || textBox2.Text == "" || comboBox1.Text == "")
            {
                MessageBox.Show("输入不完整,请检查", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                textBox1.Focus();
                return(false);
            }
            if (comboBox1.Text == "员工")
            {
                #region 旧方法

                /*string sql = "select *from staffmessage where name='" + textBox1.Text + "'and password='******'";
                 *      Dao dao = new Dao();
                 *      IDataReader dr = dao.read(sql);
                 *      if (dr.Read())
                 *      {
                 *          return true;
                 *      }
                 *      else
                 *      {
                 *          MessageBox.Show("用户名或密码错误,请重试!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 *          return false;
                 *      }*/
                #endregion
                if (!sm.CheckStaffLogin(textBox1.Text.Trim(), textBox2.Text.Trim()))
                {
                    MessageBox.Show("用户名或密码错误,请重试!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    textBox2.Focus();
                    return(false);
                }
                return(true);
            }
            if (comboBox1.Text == "人事管理员")
            {
                #region 旧方法

                /*string sql = "select *from personel_admin where name='" + textBox1.Text + "'and password='******'";
                 *      Dao dao = new Dao();
                 *      IDataReader dr = dao.read(sql);
                 *      if (dr.Read())
                 *      {
                 *          return true;
                 *      }
                 *      else
                 *      {
                 *          MessageBox.Show("用户名或密码错误,或您未含有该权限,请重试!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 *          return false;
                 *      }*/
                #endregion
                if (!pam.CheckPersonelAdminLogin(textBox1.Text.Trim(), textBox2.Text.Trim()))
                {
                    MessageBox.Show("用户名或密码错误,请重试!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    textBox2.Focus();
                    return(false);
                }
                return(true);
            }
            if (comboBox1.Text == "财务管理员")
            {
                #region 旧方法

                /*string sql = "select *from financial_admin where name='" + textBox1.Text + "'and password='******'";
                 *      Dao dao = new Dao();
                 *      IDataReader dr = dao.read(sql);
                 *      if (dr.Read())
                 *      {
                 *          return true;
                 *      }
                 *      else
                 *      {
                 *          MessageBox.Show("用户名或密码错误,请重试!或您未含有该权限,", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 *          return false;
                 *      }*/
                #endregion
                if (!fam.CheckFinancialAdminLogin(textBox1.Text.Trim(), textBox2.Text.Trim()))
                {
                    MessageBox.Show("用户名或密码错误,请重试!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    textBox2.Focus();
                    return(false);
                }
                return(true);
            }
            if (comboBox1.Text == "系统管理员")
            {
                if (textBox1.Text == "admin" && textBox2.Text == "admin")
                {
                    return(true);
                }
                else
                {
                    MessageBox.Show("用户名或密码错误,请重试!或您未含有该权限,", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }
            }
            return(false);
        }