private void btnTestConn_Click(object sender, EventArgs e)
        {
            string connstr = "server=" + txtServerIP.Text + ";port=" + txtPort.Text + ";database=" + txtDBName.Text
                             + ";uid=" + txtUID.Text + ";pwd=" + txtPSW.Text + ";Allow User Variables = True";

            if (!MysqlEasy.IsCanConnected(connstr))
            {
                XtraMessageBox.Show("数据库连接失败,请检查配置是否正确", "提示");
            }
            else
            {
                XtraMessageBox.Show("数据库连接成功", "提示");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (!MysqlEasy.IsCanConnected(MysqlEasy.ConnectionString))
            {
                XtraMessageBox.Show("数据库连接失败,请检查配置是否正确", "提示");
                return;
            }


            if (textUsername.Text == "" || textPsd.Text == "")
            {
                XtraMessageBox.Show("用户名和密码不能为空!", "提示");
                if (textUsername.Text == "")
                {
                    textUsername.Focus();
                }

                if (textUsername.Text != "" && textPsd.Text == "")
                {
                    textPsd.Focus();
                }

                return;
            }
            try
            {
                var userName = textUsername.Text;
                var password = textPsd.Text;


                UserInfoBean uiblogin = UserInfoBll.Instance.GetLogin(new UserInfoBean {
                    UserName = userName, Password = UserInfoBll.Instance.encryptPWD(password)
                });
                if (uiblogin != null)
                {
                    if (uiblogin.Status == "0")//在审核状态
                    {
                        XtraMessageBox.Show("该用户正在审核中,请联系管理员!", "提示");
                        return;
                    }
                    else if (uiblogin.Status == "2")
                    {
                        XtraMessageBox.Show("该用户未通过审核,请联系管理员!", "提示");
                        return;
                    }
                    else
                    {
                        SystemInfo.CurrentUserInfo = uiblogin;
                        this.DialogResult          = DialogResult.OK;
                        StartDAS();
                    }
                }
                else
                {
                    XtraMessageBox.Show("用户名或密码错误!", "提示");
                    return;
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "错误");
            }
        }