Beispiel #1
0
        private void OK_Login()
        {
            if (string.IsNullOrEmpty(WmsConstring))
            {
                MessageBox.Show(@"服务器填写错误,或者服务器端未配置正确!", @"注意", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }


            lblLogin.Image = Properties.Resources.LoginForm_login_btn_click;

            if (string.IsNullOrEmpty(utxtUser.Text.Trim()) || string.IsNullOrEmpty(utxtPassword.Text))
            {
                MessageBox.Show(@"用户名和密码必填!", @"注意", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }


            var con = new SqlConnection(WmsConstring);
            var cmd = new SqlCommand
            {
                Connection  = con,
                CommandText =
                    "select uName,uRole,uCode from BUser where (uName=@uName or uCode=@uName) and uPassword=@uPassword"
            };

            cmd.Parameters.Clear();
            cmd.Parameters.AddWithValue("@uName", utxtUser.Text);
            cmd.Parameters.AddWithValue("@uPassword", WmsFunction.GetMd5Hash(utxtPassword.Text));
            con.Open();
            var dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);

            if (dr.Read()) //直接登陆
            {
                Account = "";
                Server  = "";
                Properties.Settings.Default.cUser    = utxtUser.Text;
                Properties.Settings.Default.cServer  = Server;
                Properties.Settings.Default.cAccount = Account;
                Properties.Settings.Default.Save();

                Lname = dr["uName"].ToString(); //把登陆名和登陆服务器保存到静态变量中
                Ltime = DateTime.Now;
                Lrole = dr["uRole"].ToString();
                LCode = dr["uCode"].ToString();
                dr.Close();
                Hide();
                var pdaMain = new PDAMain(this);
                pdaMain.ShowDialog();
            }
            else
            {
                MessageBox.Show(@"用户名或密码错误,请联系管理员!", @"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Beispiel #2
0
        private void OK_Login()
        {
            if (string.IsNullOrEmpty(WmsConstring))
            {
                MessageBox.Show(@"服务器填写错误,或者服务器端未配置正确!", @"注意", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            lblLogin.Image = Properties.Resources.LoginForm_login_btn_click;

            if (string.IsNullOrEmpty(utxtUser.Text.Trim()) || string.IsNullOrEmpty(utxtPassword.Text))
            {
                MessageBox.Show(@"用户名和密码必填!", @"注意", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            var con = new SqlConnection(WmsConstring);
            var cmd = new SqlCommand
            {
                Connection = con,
                CommandText =
                    "select uName,uRole,uCode from BUser where (uName=@uName or uCode=@uName) and uPassword=@uPassword"
            };

            cmd.Parameters.Clear();
            cmd.Parameters.AddWithValue("@uName", utxtUser.Text);
            cmd.Parameters.AddWithValue("@uPassword", WmsFunction.GetMd5Hash(utxtPassword.Text));
            con.Open();
            var dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            if (dr.Read()) //直接登陆
            {
                Account = "";
                Server = "";
                Properties.Settings.Default.cUser = utxtUser.Text;
                Properties.Settings.Default.cServer = Server;
                Properties.Settings.Default.cAccount = Account;
                Properties.Settings.Default.Save();

                Lname = dr["uName"].ToString(); //把登陆名和登陆服务器保存到静态变量中
                Ltime =DateTime.Now;
                Lrole = dr["uRole"].ToString();
                LCode = dr["uCode"].ToString();
                dr.Close();
                Hide();
                var pdaMain = new PDAMain(this);
                pdaMain.ShowDialog();
            }
            else
            {
                MessageBox.Show(@"用户名或密码错误,请联系管理员!", @"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }