private void lblBtnChangePwd_Click(object sender, EventArgs e)
        {
            ChangePassword changePwd = new ChangePassword(DefaultLanguage);

            changePwd.ShowDialog();
        }
        /// <summary>
        /// 登录按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLogin_Click(object sender, EventArgs e)
        {
            #region 检测网络连接是否正常

            if (!CommonService.IsConnectInternet())
            {
                string productName = ResourceCulture.GetString("AppName");  //Application.ProductName
                string exMsg       = string.Format(ResourceCulture.GetString("GeneralMsg_NetworkOffline"), Application.ProductName);
                MessageBox.Show(exMsg, productName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            #endregion

            //string userName = this.cbxUserName.Text.Trim();
            string userName = this.txtUserName.Text.Trim();
            string password = this.txtPassword.Text.Trim();

            if (string.IsNullOrWhiteSpace(userName))
            {
                MessageBox.Show(ResourceCulture.GetString("GeneralMsg_EmptyUser"), ResourceCulture.GetString("GeneralTitle_Prompt"));
                return;
            }
            else if (string.IsNullOrWhiteSpace(password))
            {
                MessageBox.Show(ResourceCulture.GetString("GeneralMsg_EmptyPwd"), ResourceCulture.GetString("GeneralTitle_Prompt"));
                return;
            }

            bool   loginResult  = false;        //登录结果
            string loginUserId  = string.Empty; //登录用户对应 OA 系统用户 id
            string loginMessage = string.Empty; //登录结果提示信息

            try
            {
                #region LDAP 登录&OA验证&初始密码验证

                loginResult = EoopService.LoginVerify(userName, password, out loginUserId, out loginMessage);

                if (!loginResult)
                {
                    MessageBox.Show(loginMessage, ResourceCulture.GetString("GeneralTitle_Prompt"));
                    return;
                }

                if (loginResult && !string.IsNullOrEmpty(loginMessage) && loginMessage.Trim() == "1")//默认密码登录,强制更新密码
                {
                    this.Hide();
                    ChangePassword changePwdForm = new ChangePassword(DefaultLanguage, userName, password, true);
                    changePwdForm.ShowDialog();
                    return;
                }

                #endregion

                #region OA 系统验证登录用户信息

                List <HrmResource> loginHrmUsers = EoopService.GetHrmResource(userName);
                if (loginHrmUsers.Count != 1)//"AD 人事系统登录用户({userName}不存在/不唯一";
                {
                    string showMsg = loginHrmUsers.Count == 0 ? string.Format(ResourceCulture.GetString("LoginMsg_NotExistUser"), userName)
                                                              : string.Format(ResourceCulture.GetString("LoginMsg_NotUniqueUser"), userName);
                    MessageBox.Show(showMsg, ResourceCulture.GetString("GeneralTitle_Prompt"));
                    return;
                }
                LoginHrmUser = loginHrmUsers[0];

                #endregion

                #region OA 系统验证资产用户信息

                //string loginId = CurrentAsset != null ? CurrentAsset.loginid : "";
                //List<HrmResource> thisHrmUsers = EoopService.GetHrmResource(loginId);
                //if (thisHrmUsers.Count != 1)//"AD 人事系统登录用户({userName}不存在/不唯一";
                //{
                //    string showMsg = thisHrmUsers.Count == 0 ? string.Format(ResourceCulture.GetString("LoginMsg_NotExistAssetUser"), userName) : string.Format(ResourceCulture.GetString("LoginMsg_NotUniqueAssetUser"), userName);
                //    MessageBox.Show(showMsg, ResourceCulture.GetString("GeneralTitle_Prompt"));
                //    return;
                //}
                //CurrentAssetHrmUser = thisHrmUsers.Count > 0 ? thisHrmUsers[0] : new HrmResource();

                #endregion

                #region 判断用户是否可使用该资产登录

                if (CurrentAsset.tinyintfield2.Trim() != "1")//非公共资产
                {
                    List <Property> loginUserPropertyList = EoopService.GetUserAssetList(userName);
                    if (loginUserPropertyList == null || loginUserPropertyList.Where(p => p.id == CurrentAsset.id).Count() == 0)//非为资产本人登录
                    {
                        //同一用户组判断
                        var groupMembers = EoopService.GetGroupMembers(CurrentAssetHrmUser.userId, LoginHrmUser.loginid);
                        var departRoles  = EoopService.GetDepartRoleMapping(LoginHrmUser.departmentid);
                        if (groupMembers.Count == 0 && departRoles.Count == 0)//非资产所属用户组用户登录
                        {
                            MessageBox.Show(ResourceCulture.GetString("LoginMsg_NotSameGroup"), ResourceCulture.GetString("LoginMsg_Title"));
                            return;
                        }
                    }
                }

                #endregion

                #region 记住用户 & 记住密码

                #region 注释代码:记住多个用户

                //List<LogUser> userList = new List<LogUser>();

                //using (FileStream fStream = new FileStream("data.bin", FileMode.OpenOrCreate, FileAccess.ReadWrite))
                //{
                //    BinaryFormatter bFormat = new BinaryFormatter();
                //    List<LogUser> users = fStream.Length > 0 ? bFormat.Deserialize(fStream) as List<LogUser> : new List<LogUser>();
                //    if (chxUser.Checked)
                //    {
                //        LogUser user = new LogUser();
                //        user.Username = userName;
                //        user.Password = chxPassword.Checked ? password : "";        //如果单击了记住密码的功能则在文件中保存密码,否则不在文件中保存密码
                //        var containsUsers = users.Where(u => u.Username == userName);
                //        if (containsUsers != null && containsUsers.Count() > 0)   //选在集合中是否存在用户名
                //        {
                //            int index = users.IndexOf(containsUsers.SingleOrDefault());
                //            users.RemoveAt(index);
                //        }
                //        users.Add(user);
                //    }
                //    else
                //    {
                //        var containsUsers = users.Where(u => u.Username == userName);
                //        if (containsUsers != null && containsUsers.Count() > 0)          //选在集合中是否存在用户名
                //        {
                //            int index = users.IndexOf(containsUsers.SingleOrDefault());
                //            users.RemoveAt(index);
                //        }
                //    }
                //    userList = users;
                //}

                //using (FileStream fStream = new FileStream("data.bin", FileMode.Open, FileAccess.ReadWrite))
                //{
                //    BinaryFormatter bFormat = new BinaryFormatter();
                //    bFormat.Serialize(fStream, userList);               //要先将User类先设为可以序列化(即在类的前面加[Serializable])
                //}

                #endregion

                #region 记录最近一次登录用户

                /*using (FileStream fStream = new FileStream(Application.StartupPath + @"\data.bin", FileMode.Create))
                 * {
                 *  BinaryFormatter bFormat = new BinaryFormatter();
                 *  List<LogUser> users = fStream.Length > 0 ? bFormat.Deserialize(fStream) as List<LogUser> : new List<LogUser>();
                 *  if (chxUser.Checked)
                 *  {
                 *      LogUser user = new LogUser();
                 *      user.Username = userName;
                 *      user.Password = chxPassword.Checked ? password : "";        //如果单击了记住密码的功能则在文件中保存密码,否则不在文件中保存密码
                 *      var containsUsers = users.Where(u => u.Username == userName);
                 *      if (containsUsers != null && containsUsers.Count() > 0)   //选在集合中是否存在用户名
                 *      {
                 *          int index = users.IndexOf(containsUsers.SingleOrDefault());
                 *          users.RemoveAt(index);
                 *      }
                 *      users.Add(user);
                 *  }
                 *  else
                 *  {
                 *      var containsUsers = users.Where(u => u.Username == userName);
                 *      if (containsUsers != null && containsUsers.Count() > 0)          //选在集合中是否存在用户名
                 *      {
                 *          int index = users.IndexOf(containsUsers.SingleOrDefault());
                 *          users.RemoveAt(index);
                 *      }
                 *  }
                 *
                 *  bFormat.Serialize(fStream, users);               //要先将User类先设为可以序列化(即在类的前面加[Serializable])
                 * }*/

                if (chxUser.Checked)
                {
                    Properties.Settings.Default.UserName = userName;
                    Properties.Settings.Default.Password = password;
                }
                else
                {
                    Properties.Settings.Default.UserName = "";
                    Properties.Settings.Default.Password = "";
                }
                Properties.Settings.Default.Save();

                #endregion

                #endregion

                #region 登录,进入程序主界面 MainForm

                //if (!Cef.IsInitialized)
                //{
                //    Cef.RunMessageLoop();
                //    Cef.Shutdown();
                //}

                MainForm mainForm = new MainForm(loginUserId, userName, password, DefaultLanguage, CurrentSLCode, CurrentSLCodeList, CurrentAsset, LoginHrmUser);
                this.Hide();
                mainForm.WindowState = FormWindowState.Maximized;
                mainForm.Show();

                //初始化 CefSharp 浏览器内核组件
                InitializeCefSharp(DefaultLanguage);

                txtPassword.Text    = string.Empty;
                chxUser.Checked     = false;
                chxPassword.Checked = false;

                #endregion
            }
            catch (Exception ex)
            {
                string exMessage = ResourceCulture.GetString("GeneralMsg_AppException");
                if (Program.ReleaseType == "DEBUG")
                {
                    exMessage = ex.Message + ex.StackTrace;
                }
                MessageBox.Show(exMessage, ResourceCulture.GetString("LoginMsg_Title"));
            }
        }