Beispiel #1
0
        /// <summary>
        /// 密码校验
        /// </summary>
        /// <param name="EmpNo"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        private bool CheckLoginSuss(string EmpNo, string password)
        {
            user = new PW_User();
            using (ASRS_Volvo.ServiceForVolvo.ASRS_ServiceSoapClient srv = new ASRS_ServiceSoapClient())
            {
                string cesarPassword = srv.CommonMethod_StringEncoding(password);
                var    _user         = srv.PW_User_GetUserInfoByEmpno(EmpNo);

                if (_user.PASSWORD == cesarPassword)
                {
                    user = _user;
                }
                else
                {
                    user = new PW_User();
                    return(false);
                }
                if (ckBForce.Checked)
                {
                    _user.ISLOGININ = "N";
                    srv.PW_User_UpdateUserInfo(user);
                    wait(1000);
                }
                return(true);
            }
        }
Beispiel #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string empno, password;

            empno = tbLoginName.Text.Trim();
            if (string.Empty == empno)
            {
                MessageBox.Show("请输入用户名!", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                this.tbLoginName.Focus();
                this.tbLoginName.SelectAll();
                return;
            }
            password = tbLoginPassword.Text.Trim();

            bool blogin = CheckLoginSuss(empno, password);  //调用数据库,校验逻辑

            if (!blogin)
            {
                MessageBox.Show(this, "用户名或密码错误!", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                this.tbLoginName.Focus();
                this.tbLoginName.SelectAll();

                return;
            }
            if (user.ISLOGININ == "Y")
            {
                MessageBox.Show(this, "该用户已在别处登录!", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                this.tbLoginName.Focus();
                this.tbLoginName.SelectAll();
                return;
            }

            user.ISLOGININ = "Y";
            using (ASRS_Volvo.ServiceForVolvo.ASRS_ServiceSoapClient srv = new ASRS_ServiceSoapClient())
            {
                if (!srv.PW_User_UpdateUserInfo(user))
                {
                    MessageBox.Show(this, "登录失败!", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    this.tbLoginName.Focus();
                    this.tbLoginName.SelectAll();
                    return;
                }
                else
                {
                    FormMain fmain = new FormMain();
                    fmain.Show();
                }
            }
            this.Hide();
        }
Beispiel #3
0
        /// <summary>
        /// 登录者信号握手
        /// </summary>
        private void LoginHandShake()
        {
            int    tryCount     = 0;
            string oldHandShake = string.Empty;

            while (true)
            {
                Thread.Sleep(2000);
                try
                {
                    using (ASRS_ServiceSoapClient srv = new ASRS_ServiceSoapClient())
                    {
                        var user = srv.PW_User_GetOneByUserID(FormLogin.user.ID);

                        if (user.ISLOGININ == "N")//如果不在线
                        {
                            MessageBox.Show("系统已离线!");
                            Environment.Exit(0);
                        }
                        if (oldHandShake != user.HANDSHAKE)
                        {
                            oldHandShake              = user.HANDSHAKE;
                            tryCount                  = 0;
                            tSLabelDataBase.Text      = "数据库连接:正常";
                            tSLabelDataBase.ForeColor = Color.Blue;
                            tSLableEmployeeNo.Text    = user.ID;
                            tSLabelName.Text          = user.USERNAME;
                            SRM_Communicate();
                        }
                        else
                        {
                            tryCount++;
                            tSLabelDataBase.Text      = "数据库连接:中断";
                            tSLabelDataBase.ForeColor = Color.Red;
                            if (tryCount > 5)//如果连续五次握手失败则表明断线
                            {
                                user.ISLOGININ = "N";
                            }
                        }
                        user.HANDSHAKE = Guid.NewGuid().ToString();
                        srv.PW_User_UpdateUserInfo(user);
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
Beispiel #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string peoplenName = tBName.Text.Trim();
            string userid      = tBUserId.Text.Trim();
            string Password    = tBPassWord.Text.Trim();
            string GroupId     = cmB_Group.SelectedValue.ToString();

            if (tBPassWord.Text.Length < 8)
            {
                MessageBox.Show("密码长度小于8位!");
                tBPassWord.SelectAll();
                tBPassWord.Focus();
                return;
            }
            if (tBUserId.Text.Trim() == string.Empty)
            {
                MessageBox.Show("工号不能为空!");
                tBUserId.SelectAll();
                tBUserId.Focus();
                return;
            }
            PW_User wkrs = new PW_User();

            using (ASRS_Volvo.ServiceForVolvo.ASRS_ServiceSoapClient srv = new ASRS_ServiceSoapClient())
            {
                srv.PW_User_GetOneByUserID(userid);
                wkrs.PASSWORD  = srv.CommonMethod_StringEncoding(Password);//解密
                wkrs.ID        = userid;
                wkrs.USERNAME  = peoplenName;
                wkrs.USERGROUP = GroupId;
                if (tBUserId.Enabled == false)
                {
                    if (srv.PW_User_UpdateUserInfo(wkrs))
                    {
                        tBUserId.Clear();
                        tBPassWord.Clear();
                        tBName.Clear();
                        tBUserId.Focus();
                        Close();
                    }
                    else
                    {
                        MessageBox.Show("保存失败!");
                        tBUserId.Focus();
                        tBUserId.SelectAll();
                        return;
                    }
                }
                else if (tBUserId.Enabled == true)
                {
                    if (srv.PW_User_InsertOne(wkrs))
                    {
                        tBUserId.Clear();
                        tBPassWord.Clear();
                        tBName.Clear();
                        tBUserId.Focus();
                    }
                    else
                    {
                        MessageBox.Show("保存失败!");
                        tBUserId.Focus();
                        tBUserId.SelectAll();
                        return;
                    }
                }
            }
        }