Ejemplo n.º 1
0
 private void FormConfigDataServer_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (m_connDbServer)
     {
         GlobalParameter.DataServerIP = this.txtServerIP.Text.Replace(" ", "");
         GlobalParameter.Save();
         this.DialogResult = DialogResult.OK;
     }
     else
     {
         this.DialogResult = DialogResult.Cancel;
     }
 }
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOk_Click(object sender, EventArgs e)
        {
            try
            {
                if (cmbSystem.Text == "")
                {
                    MessageDialog.ShowPromptMessage("请选择【系统平台】");
                    return;
                }

                if (FindWindow(null, cmbSystem.Text + "信息化系统") != IntPtr.Zero)
                {
                    MessageDialog.ShowPromptMessage("您已经运行了一个【" + cmbSystem.Text + "信息化】程序,无法运行多个");
                    return;
                }

                if (txtUserCode.Text == "" || txtPwd.Text == "")
                {
                    MessageDialog.ShowPromptMessage("请填写完整用户信息!");
                    return;
                }

                GlobalParameter.Init(cmbSystem.Text);
                DBOperateERP.AccessDB.InitDBOperate();

                GlobalObject.DatabaseServer.IsConnection();

                string loginNotice = UniversalFunction.GetSwitchKey()[13];

                string workID = UniversalFunction.GetWorkID(txtUserCode.Text);

                if (AuthenticationManager.IdentifyAuthority(workID, txtPwd.Text))
                {
                    LoggingFlag = true;

                    //if ((loginNotice != null && loginNotice.Length > 0)
                    //    && loginNotice != GlobalParameter.LoginNotice)
                    //{
                    //    登陆界面温馨提示 frm = new 登陆界面温馨提示(loginNotice);
                    //    frm.ShowDialog();
                    //}

                    IAuthentication authentication = AuthenticationManager.Authentication;
                    List <string>   listRoles      = new List <string>();
                    string[]        roleCodes      = new string[authentication.Roles.Count];

                    for (int i = 0; i < authentication.Roles.Count; i++)
                    {
                        listRoles.Add(authentication.Roles[i].角色名称);
                        roleCodes[i] = authentication.Roles[i].角色编码;
                    }

                    View_HR_Personnel personnelInfo = UniversalFunction.GetPersonnelInfo(workID);

                    if (personnelInfo == null || personnelInfo.工号 == null)
                    {
                        throw new Exception("【工号】:" + workID + " 不存在,请咨询人力资源");
                    }
                    else if (!personnelInfo.是否在职)
                    {
                        throw new Exception("【工号】:" + workID + " 已【离职】,请咨询人力资源");
                    }

                    BasicInfo.LoginID        = personnelInfo.工号;
                    BasicInfo.LoginName      = personnelInfo.姓名;
                    BasicInfo.DeptCode       = personnelInfo.部门编码;
                    BasicInfo.DeptName       = personnelInfo.部门名称;
                    BasicInfo.BaseSwitchInfo = UniversalFunction.GetSwitchKey();

                    GlobalParameter.UserCode    = txtUserCode.Text;
                    GlobalParameter.LoginNotice = loginNotice;

                    GlobalParameter.Save();

                    BasicInfo.ListRoles = listRoles;
                    BasicInfo.RoleCodes = roleCodes;

                    if (BasicInfo.ListRoles.Contains("物流公司") &&
                        BasicInfo.ListRoles.Contains("物流公司_库管理员") &&
                        BasicInfo.ListRoles.Count() == 2 &&
                        cmbSystem.SelectedIndex == 0)
                    {
                        throw new Exception("物流公司,无法登陆【湖南容大】信息化系统");
                    }

                    this.Close();
                }
            }
            catch (Exception err)
            {
                MessageDialog.ShowErrorMessage(err.Message);
                return;
            }
        }