Exemplo n.º 1
0
        //登录
        private void picLogin_Click(object sender, EventArgs e)
        {
            errInfo.Clear();

            if (String.IsNullOrEmpty(txtCode.Text.Trim()))
            {
                try
                {
                    errInfo.SetError(txtCode, "用户编码不能为空!");
                    return;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "软件提示");
                    throw ex;
                }
                finally
                {
                }
            }

            if (String.IsNullOrEmpty(txtPwd.Text.Trim()))
            {
                try
                {
                    errInfo.SetError(txtPwd, "用户密码不能为空!");
                    return;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "软件提示");
                    throw ex;
                }
                finally
                {
                }
            }

            string strSql = "select * from SYOperator where OperatorCode = '" + txtCode.Text.Trim() +
                            "' and PassWord = '******'";

            try
            {
                sdr = db.GetDataReader(strSql);
                sdr.Read();
                if (sdr.HasRows)
                {
                    AppMain AppForm = new AppMain();
                    Hide();
                    PropertyClass.OperatorCode = sdr["OperatorCode"].ToString();
                    PropertyClass.OperatorName = sdr["OperatorName"].ToString();
                    PropertyClass.PassWord = sdr["PassWord"].ToString();
                    PropertyClass.IsAdmin = sdr["IsAdmin"].ToString();
                    AppForm.Show();
                }
                else
                {
                    MessageBox.Show("用户编码或用户密码不正确!", "软件提示");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "软件提示");
                throw ex;
            }
            finally
            {
                sdr.Close();
            }
        }
Exemplo n.º 2
0
        //登录
        private void picLogin_Click(object sender, EventArgs e)
        {
            this.errInfo.Clear();

            if (String.IsNullOrEmpty(this.txtCode.Text.Trim()))
            {
                try
                {
                    this.errInfo.SetError(this.txtCode, "用户编码不能为空!");
                    return;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "软件提示");
                    throw ex;
                }
                finally
                {
                }
            }

            if (String.IsNullOrEmpty(this.txtPwd.Text.Trim()))
            {
                try
                {
                    this.errInfo.SetError(this.txtPwd, "用户密码不能为空!");
                    return;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "软件提示");
                    throw ex;
                }
                finally
                {
                }
            }

            string strSql = "select * from SYOperator where OperatorCode = '" + txtCode.Text.Trim() + "' and PassWord = '******'";

            try
            {
                sdr = db.GetDataReader(strSql);
                sdr.Read();
                if (sdr.HasRows)
                {
                    AppMain AppForm = new AppMain();
                    this.Hide();
                    PropertyClass.OperatorCode = sdr["OperatorCode"].ToString();
                    PropertyClass.OperatorName = sdr["OperatorName"].ToString();
                    PropertyClass.PassWord     = sdr["PassWord"].ToString();
                    PropertyClass.IsAdmin      = sdr["IsAdmin"].ToString();
                    AppForm.Show();
                }
                else
                {
                    MessageBox.Show("用户编码或用户密码不正确!", "软件提示");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "软件提示");
                throw ex;
            }
            finally
            {
                sdr.Close();
            }
        }