Ejemplo n.º 1
0
 private void OK()
 {
     if (Common.TextBoxChecked(this.tbPwd) && Common.TextBoxChecked(this.tbNewPwd) &&
         Common.TextBoxChecked(this.tbConfirm) && Common.PasswordConfirmed(tbNewPwd, tbConfirm) && tbNewPwd.Text.TrimEnd() != Common.User.Pwd)
     {
         Common.User.Pwd = this.tbNewPwd.Text.TrimEnd();
         Common.User.LastPwdChangedTime = DateTime.Now;
         UserInfoBLL _bll = new UserInfoBLL();
         if (_bll.UdateUser(Common.User))
         {
             Utils.ShowMessageBox(Messages.ResetPasswordSuccessfully, Messages.TitleNotification);
             Undo();
             //记录成功的日志
             if (Common.User.UserName != Common.SUPERUSER)
             {
                 logBll.InsertLog(() =>
                 {
                     Dictionary <string, object> dic = new Dictionary <string, object>();
                     dic.Add("OperateTime", DateTime.UtcNow);
                     dic.Add("Action", LogAction.ChangePassword);
                     dic.Add("UserName", Common.User.UserName);
                     dic.Add("FullName", Common.User.FullName);
                     dic.Add("Detail", Common.User.UserName);
                     dic.Add("LogType", LogAction.SystemAuditTrail);
                     return(dic);
                 });
             }
         }
         else
         {
             Utils.ShowMessageBox(Messages.ResetPasswordFailed, Messages.TitleError);
         }
         //form.Close();
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 保存签名记录
        /// </summary>
        private void SaveTheSignatureToDatabase()
        {
            if (clbMeanings.CheckedItems.Count <= 0)
            {
                if (clbMeanings.Items.Count <= 0)
                {
                    Utils.ShowMessageBox(Messages.NoSignMeanings, Messages.TitleError);
                }
                else
                {
                    Utils.ShowMessageBox(Messages.NoSignMeanSelected, Messages.TitleError);
                }
                return;
            }
            string selectedItem = (clbMeanings.SelectedItem).GetType().GetProperty("Desc").GetValue(clbMeanings.SelectedItem, null).ToString();

            if (!string.IsNullOrEmpty(selectedItem))
            {
                DigitalSignature signature = new DigitalSignature();
                int id = _digital.GetDigitalSignaturePKValue();
                signature.ID          = id + 1;
                signature.UserName    = username;
                signature.MeaningDesc = selectedItem;
                signature.Remark      = DateTime.UtcNow.ToString();
                signature.SignTime    = DateTime.UtcNow;
                signature.SN          = ObjectManage.Tag.SerialNumber == null ? "" : this.sn;
                signature.TN          = ObjectManage.Tag.TripNumber == null ? "" : this.tn;
                signature.FullName    = fullname;
                //保存签名记录
                if (
                    _digital.InsertDigitalSignature(signature))
                {
                    //记录成功的日志
                    if (Common.User.UserName != Common.SUPERUSER)
                    {
                        logBll.InsertLog(() =>
                        {
                            Dictionary <string, object> dic = new Dictionary <string, object>();
                            dic.Add("OperateTime", DateTime.UtcNow);
                            dic.Add("Action", LogAction.Signrecord);
                            dic.Add("UserName", username);
                            dic.Add("FullName", fullname);
                            dic.Add("Detail", selectedItem + ": " + signature.SN + "_" + signature.TN);
                            dic.Add("LogType", LogAction.AnalysisAuditTrail);
                            return(dic);
                        });
                    }
                }
                this.DialogResult = DialogResult.OK;
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 判断是否登录成功,同时保存用户信息
 /// </summary>
 /// <returns></returns>
 public bool Login()
 {
     try
     {
         if (Common.TextBoxChecked(tbAccount) && Common.TextBoxChecked(tbPwd))
         {
             UserInfo user = processor.QueryOne <UserInfo>("SELECT * FROM UserInfo WHERE username=@username", delegate()
             {
                 Dictionary <string, object> dic = new Dictionary <string, object>();
                 dic.Add("username", tbAccount.Text.TrimEnd());
                 //dic.Add("pwd", tbPwd.Text.TrimEnd());
                 return(dic);
             });
             if (user.Locked == 0)
             {
                 if (LoginTimes <= Common.Policy.LockedTimes)
                 {
                     if (user.Userid != 0 && user.Pwd.Equals(this.tbPwd.Text))
                     {
                         Common.User = user;
                         LoginTimes  = 0;
                         this.SaveUserList();//保存列表
                         //记录成功的日志
                         logBll.InsertLog(() =>
                         {
                             Dictionary <string, object> dic = new Dictionary <string, object>();
                             dic.Add("OperateTime", DateTime.Now);
                             dic.Add("Action", "Log on");
                             dic.Add("UserName", user.UserName);
                             dic.Add("FullName", user.FullName);
                             dic.Add("Detail", "Success");
                             dic.Add("LogType", 0);
                             return(dic);
                         });
                         return(true);
                     }
                     else if (user.Userid == 0)
                     {
                         this.lbAccount.Text = "× user does not exist.";
                         //this.lbAccount.ForeColor = System.Drawing.Color.Red;
                         return(false);
                     }
                     else
                     {
                         this.lbPwd.Text = "× password invalid.";
                         //this.lbPwd.ForeColor = System.Drawing.Color.Red;
                         LoginTimes++;
                         //记录日志
                         logBll.InsertLog(() =>
                         {
                             Dictionary <string, object> dic = new Dictionary <string, object>();
                             dic.Add("OperateTime", DateTime.Now);
                             dic.Add("Action", "Log on");
                             dic.Add("UserName", user.UserName);
                             dic.Add("FullName", user.FullName);
                             dic.Add("Detail", "Failure");
                             dic.Add("LogType", 0);
                             return(dic);
                         });
                         return(false);
                     }
                 }
                 else
                 {
                     Dictionary <string, object> dic = new Dictionary <string, object>();
                     dic.Add("locked", 1);
                     dic.Add("username", this.tbAccount.Text.TrimEnd());
                     processor.ExecuteNonQuery("UPDATE userinfo set locked=@locked where username=@username", dic);
                     this.lbPwd.Text = "× over " + Common.Policy.LockedTimes.ToString() + " times";
                 }
             }
             else
             {
                 this.lbPwd.Text = "× account's locked.";
                 //记录账号锁定日志
                 logBll.InsertLog(() =>
                 {
                     Dictionary <string, object> dic = new Dictionary <string, object>();
                     dic.Add("OperateTime", DateTime.Now);
                     dic.Add("Action", "Log on");
                     dic.Add("UserName", user.UserName);
                     dic.Add("FullName", user.FullName);
                     dic.Add("Detail", "Failure");
                     dic.Add("LogType", 0);
                     return(dic);
                 });
             }
         }
         return(false);
     }
     catch (Exception exc) { return(false); }
 }