コード例 #1
0
        private void OnWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            frmLogin.SetEnable(true);

            if (user == null)
            {
                if (hasException)
                {
                    MsgBox.Warn(exception.Message);
                }
                else
                {
                    MsgBox.Warn("帐号不存在。");
                }
            }
            else if (user.UserPwd != password)
            {
                MsgBox.Warn("密码错误。");
            }
            else if (user != null)
            {
                //检验是否被注销登录
                if (user.IsActive == "N")
                {
                    MsgBox.Warn("该帐号已被禁用,无法登录。");
                }
                else
                {
                    user.IPAddress            = IPUtil.GetLocalIP();
                    GlobeSettings.LoginedUser = user;

                    //LoginLogEntiy LoginLog = new LoginLogEntiy();
                    //LoginLog.UserCode = user.UserCode;
                    //LoginLog.IP = user.IPAddress;
                    //LoginLog.LoginDate = System.DateTime.Now;
                    //LoginLog.LoginType = "登录";
                    //userDal.InsertLoginLog(LoginLog);

                    //登录成功后,记住用户名和密码
                    frmLogin.SaveMe();

                    frmLogin.DialogResult = DialogResult.OK;
                }
            }
        }
コード例 #2
0
        private void OnWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            frmLogin.SetEnable(true);

            #region
            //#region 同步erp登录接口
            //System.Text.StringBuilder loStr = new System.Text.StringBuilder();
            //loStr.Append("userCode=").Append(usercode).Append("&");
            //loStr.Append("passWord="******"&");
            //loStr.Append("local=").Append(WebWork.URL_ADDRESS);
            //string loData = WebWork.SendRequest(loStr.ToString(), WebWork.USER_LOGIN);
            //if (string.IsNullOrEmpty(loData))
            //{
            //    MsgBox.Warn("没有获取到数据!");
            //    return;
            //}

            //if (loData.ToUpper().Equals("NETWORK_EXCEPTION"))
            //{
            //    MsgBox.Warn("连接失败,网络异常!");
            //    return;
            //}

            //JsonLogin loLoginMsg = JsonConvert.DeserializeObject<JsonLogin>(loData);

            //if (loLoginMsg == null)
            //{
            //    MsgBox.Warn("用户编号不存在。");
            //    return;
            //}
            //if (loLoginMsg.flag != 0)
            //{
            //    MsgBox.Warn(loLoginMsg.error);
            //    return;
            //}
            //if (loLoginMsg.result.Length <= 0)
            //{
            //    MsgBox.Warn("没有查询到该用户信息");
            //    return;
            //}
            //user = new UserEntity();
            //user.UserCode = loLoginMsg.result[0].userCode;
            //user.UserName = loLoginMsg.result[0].userName;
            //user.UserPwd = pwd;
            //user.IsActive = loLoginMsg.result[0].isActive;
            //user.WarehouseCode = loLoginMsg.result[0].wh_code;
            //user.WarehouseName = loLoginMsg.result[0].wh_name;
            //user.IsCenter = loLoginMsg.result[0].is_center_wh;
            //user.whType = loLoginMsg.result[0].wareHouseType;
            //user.CenterWarehouseCode = loLoginMsg.result[0].center_wh_code;
            //#endregion
            //WebWork.USER_CODE = user.UserCode;

            //user.IPAddress = IPUtil.GetLocalIP();
            //GlobeSettings.LoginedUser = user;

            ////登录成功后,记住用户名和密码
            //frmLogin.SaveMe();

            //frmLogin.DialogResult = DialogResult.OK;
            #endregion

            #region 原先登录接口
            if (user == null)
            {
                if (hasException)
                {
                    MsgBox.Warn(exception.Message);
                }
                else
                {
                    MsgBox.Warn("帐号不存在。");
                }
            }
            else if (user.UserPwd != password)
            {
                MsgBox.Warn("密码错误。");
            }
            else if (user != null)
            {
                //检验是否被注销登录
                if (user.IsActive == "N")
                {
                    MsgBox.Warn("该帐号已被禁用,无法登录。");
                }
                else
                {
                    user.IPAddress            = IPUtil.GetLocalIP();
                    GlobeSettings.LoginedUser = user;

                    //LoginLogEntiy LoginLog = new LoginLogEntiy();
                    //LoginLog.UserCode = user.UserCode;
                    //LoginLog.IP = user.IPAddress;
                    //LoginLog.LoginDate = System.DateTime.Now;
                    //LoginLog.LoginType = "登录";
                    //userDal.InsertLoginLog(LoginLog);

                    //登录成功后,记住用户名和密码
                    frmLogin.SaveMe();

                    frmLogin.DialogResult = DialogResult.OK;
                }
            }
            #endregion
        }