private bool CheckedIsNeedSave()
        {
            appLog.Info("Check If Need Save...");
            if (AllSalaryList == null)
            {
                appLog.Info("AllSalaryList==null,return.");
                return(false);
            }
            //检查添加项
            if (AllSalaryList.Count != dataManager.AllSalaryList.Count)
            {
                appLog.InfoFormat("Check New Item,AllSalaryList.Count={0},dataManager.AllSalaryList.Count={1}", AllSalaryList.Count, dataManager.AllSalaryList.Count);
                needAddList = new ObservableCollection <SalaryInfo>(AllSalaryList.Where(s => s.ID == 0));
                return(true);
            }
            else
            {
                //检查并获取编辑项
                appLog.Info("Check and Get edited Items.");
                var tempList = new ObservableCollection <SalaryInfo>(AllSalaryList.Where(s => s.Year == (int)YearComboBox.SelectedItem && s.Month == (int)MonthComboBox.SelectedItem));
                needUpdateList = AlgorithmClass.CompareCollectionIsChanged <SalaryInfo>(dataManager.AllSalaryList, tempList, "ID");
                if (needUpdateList.Count != 0)
                {
                    return(true);
                }
            }

            return(false);
        }
        public static bool DealChangeFuncPassword(string username, string password, string newpassword, AppLog applog, ref string message)
        {
            UserInfo userInfo = null;

            //查看账号是否存在
            if (!Access.GetUserByCard(username, ref userInfo))
            {
                applog.InfoFormat("用户:{0}--->修改功能密码时查询账号异常.", username);
                message = "很抱歉,操作异常请重试!";

                return(false);
            }

            if (userInfo == null)
            {
                applog.InfoFormat("用户:{0}--->修改功能密码时账号不存在.", username);
                message = "很抱歉,该账号不存在!";

                return(false);
            }

            //查看密码是否匹配
            if (Md5Hash.VerifyMd5Hash(password, userInfo.FuncPassWord))
            {
                applog.InfoFormat("用户:{0}--->帐号存在.", username);

                //更新密码
                if (Access.ResetFuncPassword(username, Md5Hash.GetMd5Hash(newpassword)) == 0)
                {
                    applog.InfoFormat("用户:{0}--->修改功能密码异常:{1}", username);
                    message = "很抱歉,操作异常请重试!";

                    return(false);
                }

                applog.Info("用户:{0}--->修改功能密码成功.");
                return(true);
            }
            else
            {
                applog.InfoFormat("用户:{0}--->原始密码错误.", username);
                message = "很抱歉,原始密码输入有误!";

                return(false);
            }
        }
        public static bool DealFunc(string username, string password, AppLog applog, ref string message)
        {
            if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
            {
                message = "账号或密码不能为空!";
                return(false);
            }

            UserInfo userInfo = null;

            //查看账号是否存在
            if (!Access.GetUserByCard(username, ref userInfo))
            {
                applog.InfoFormat("用户:{0}--->登陆时查询账号异常.", username);
                message = "很抱歉,操作异常请重试!";

                return(false);
            }

            if (userInfo == null)
            {
                applog.InfoFormat("用户:{0}--->登陆账号不存在.", username);
                message = "很抱歉,该账号不存在!";

                return(false);
            }

            //查看密码是否匹配
            if (Md5Hash.VerifyMd5Hash(password, userInfo.FuncPassWord))
            {
                applog.InfoFormat("用户:{0}--->功能密码正确.", username);
                return(true);
            }
            else
            {
                applog.InfoFormat("用户:{0}--->密码错误.", username);
                message = "很抱歉,功能密码输入不正确!";

                return(false);
            }
        }
        private void LoadingProcedure(object state)
        {
            LoginStateObject stateObject = state as LoginStateObject;

            try
            {
                this.Dispatcher.BeginInvoke((Action)(() =>
                {
                    LoadingText.Text = "用户正在登录...";
                }));
                string message = null;
                if (!LoginDeal.DealLogin(stateObject.UserName, stateObject.Password, appLog, ref message))
                {
                    this.Dispatcher.BeginInvoke((Action)(() =>
                    {
                        LoginBtn.IsEnabled = true;
                        LoadingPanel.Visibility = Visibility.Collapsed;
                        MessageBox.Show(message, "消息", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }));
                }
                else
                {
                    this.Dispatcher.BeginInvoke((Action)(() =>
                    {
                        LoadingText.Text = "正在加载数据...";
                    }));

                    stateObject.dataManager.BeginLoadData();
                    stateObject.dataManager.CurUserName = stateObject.UserName;

                    this.Dispatcher.BeginInvoke((Action)(() =>
                    {
                        LoadingPanel.Visibility = Visibility.Collapsed;
                        this.DialogResult = true;
                        this.Close();
                    }));
                }
            }
            catch (Exception ex)
            {
                appLog.InfoFormat("Load Data Error:{0}", ex.Message + ex.StackTrace);
                this.Dispatcher.BeginInvoke((Action)(() =>
                {
                    LoginBtn.IsEnabled = true;
                    LoadingPanel.Visibility = Visibility.Collapsed;
                    MessageBox.Show("抱歉,操作发生异常,请重试.");
                }));
            }
        }
        /// <summary>
        /// 返回用户信息
        /// </summary>
        /// <param name="cardword">账号</param>
        /// <returns>是否成功</returns>
        public static bool GetUserByCard(string username, ref UserInfo userInfo)
        {
            ISqlMapper mapper = GetSqlMapper.GetMapper();

            //查看账号是否存在
            try
            {
                mapper.BeginTransaction();
                userInfo = mapper.QueryForObject <UserInfo>("GetUserByCard", username);
                mapper.CommitTransaction();
            }
            catch (Exception ex)
            {
                applog.InfoFormat("Access.GetUserByCard() Error:{0}", ex.Message);
                mapper.RollBackTransaction();
                return(false);
            }

            return(true);
        }
        public static bool DealLogin(string username, string password, AppLog applog, ref string message)
        {
            if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
            {
                message = "账号或密码不能为空!";
                return(false);
            }

            UserInfo userInfo = null;

            //查看账号是否存在
            if (!Access.GetUserByCard(username, ref userInfo))
            {
                applog.InfoFormat("用户:{0}--->登陆时查询账号异常.", username);
                message = "很抱歉,操作异常请重试!";

                return(false);
            }

            if (userInfo == null)
            {
                applog.InfoFormat("用户:{0}--->登陆账号不存在.", username);
                message = "很抱歉,该账号不存在!";

                return(false);
            }

            /*
             #if Release
             * if (userInfo.Status == "Y")
             * {
             *  applog.InfoFormat("用户:{0}--->该账号已登录.", username);
             *  message="很抱歉,该账号已登录!";
             *
             *  return false;
             * }
             #endif
             */
            //查看密码是否匹配
            if (Md5Hash.VerifyMd5Hash(password, userInfo.LoginPassWord))
            {
                applog.InfoFormat("用户:{0}--->登陆成功.", username);

                /*
                 * //更新状态
                 * if (!Access.UpdateStatus_Y(username))
                 * {
                 *  applog.InfoFormat("用户:{0}--->登陆时修改状态异常:{1}", username);
                 *  message = "很抱歉,操作异常请重试!";
                 *
                 *  return false;
                 * }
                 *
                 * applog.InfoFormat("用户:{0}--->更新在线状态为:Y.", username);
                 * */
                return(true);
            }
            else
            {
                applog.InfoFormat("用户:{0}--->密码错误.", username);
                message = "很抱歉,密码输入不正确!";

                return(false);
            }
        }