예제 #1
0
파일: frm_login.cs 프로젝트: radtek/One
        private void Login(string userid, string pwd)
        {
            IsysService    service = sysService.GetService();
            UserInfoEntity ent     = service.Login(userid, pwd);

            if (ent.IsOK == 0)
            {
                DataCache.UserInfo = ent;
                LoadLocalSettings(DataCache.UserInfo);

                DataCache.CmnDict = service.GetCmn("");
                DataCache.Tbmenus = service.GetMenuByUserId(userid);

                var msg = GetExamInfo();

                if (!string.IsNullOrEmpty(msg))
                {
                    MsgBoxEx.Info(msg);
                    return;
                }

                //加载数据
                DataCache.RefreshCache();

                if (this.InvokeRequired)
                {
                    this.Invoke(new Action(() =>
                    {
                        System.Configuration.Configuration config = WR.Utils.Config.GetConfig();
                        config.AppSettings.Settings.Remove("userid");
                        config.AppSettings.Settings.Add("userid", userid);
                        config.Save();
                        WR.Utils.Config.Refresh();
                        frmMain.SetForm();
                    }));
                }
                else
                {
                    System.Configuration.Configuration config = WR.Utils.Config.GetConfig();
                    config.AppSettings.Settings.Remove("userid");
                    config.AppSettings.Settings.Add("userid", userid);
                    config.Save();
                    WR.Utils.Config.Refresh();
                    frmMain.SetForm();
                }
            }
            else
            {
                string msg = MessageConst.frm_login_msg003;
                switch (ent.IsOK)
                {
                case -99:
                    msg = MessageConst.frm_login_msg003;
                    break;

                case -1:
                    msg = MessageConst.const_msg001;
                    break;

                case -2:
                    msg = MessageConst.const_msg002;
                    break;

                case -3:
                    msg = MessageConst.const_msg003;
                    break;

                case -4:
                    msg = MessageConst.const_msg001;
                    break;

                default:
                    msg = MessageConst.const_msg001;
                    break;
                }

                if (this.InvokeRequired)
                {
                    this.Invoke(new Action(() =>
                    {
                        MsgBoxEx.Info(msg);
                        btnOK.Enabled    = true;
                        btnReset.Enabled = true;
                        lblMsg.Visible   = false;
                        txtUser.Enabled  = true;
                        txtPwd.Enabled   = true;
                        txtPwd.Focus();
                    }));
                }
                else
                {
                    MsgBoxEx.Info(msg);
                    btnOK.Enabled    = true;
                    btnReset.Enabled = true;
                    lblMsg.Visible   = false;
                    txtUser.Enabled  = true;
                    txtPwd.Enabled   = true;
                    txtPwd.Focus();
                }
            }
        }