示例#1
0
 private void InitEvents()
 {
     this.btnConfirm.Click += new EventHandler((sender, args) =>
     {
         if (Confirm())
         {
             if (this.IsAuthorized(RightsText.SignRecords))
             {
                 SetSignFormSize();
                 GetMeaning();
                 this.AcceptButton = this.btnSign;
             }
             else
             {
                 Utils.ShowMessageBox(Messages.NoSignRight, Messages.TitleError);
             }
         }
     });
     this.btnSign.Click += new EventHandler((sender, args) =>
     {
         this.SaveTheSignatureToDatabase();
     });
     this.clbMeanings.ItemCheck += new ItemCheckEventHandler((sender, e) =>
     {
         SelectedMeanChanged(e.Index);
     });
     this.clbMeanings.MouseMove += new MouseEventHandler(ShowMeaningTips);
 }
示例#2
0
        private void Save()
        {
            MeanEvent(form, new EventArgs());//先获取meaning的设置
            if (_userbll == null)
            {
                _userbll = new UserInfoBLL();
            }
            UserMeaning um = dic[WizardName.CreateMean] as UserMeaning;

            if (_userbll.InsertUserWizard(user, policy, (dic[WizardName.CreateRight] as UserRight).Right, um.mEntity))
            {
                UserProfileBLL userProfileBll = new UserProfileBLL();
                UserProfile    userProfile    = new UserProfile();
                userProfile.ID               = userProfileBll.GetProfilePKValue() + 1;
                userProfile.UserName         = user.UserName;
                userProfile.TempCurveRGB     = Common.GlobalProfile.TempCurveRGB;
                userProfile.AlarmLineRGB     = Common.GlobalProfile.AlarmLineRGB;
                userProfile.IdealRangeRGB    = Common.GlobalProfile.IdealRangeRGB;
                userProfile.IsShowAlarmLimit = Common.GlobalProfile.IsShowAlarmLimit;
                userProfile.IsShowMark       = Common.GlobalProfile.IsShowMark;
                userProfile.IsFillIdealRange = Common.GlobalProfile.IsFillIdealRange;
                userProfile.DateTimeFormator = Common.GlobalProfile.DateTimeFormator;
                userProfile.Remark           = DateTime.Now.ToString();

                userProfile.ContactInfo = "";
                userProfile.Logo        = ShineTech.TempCentre.Platform.Utils.CopyToBinary(Properties.Resources.tempsen);
                userProfile.DefaultPath = "";
                userProfile.ReportTitle = "";

                userProfile.IsGlobal     = (int)GlobalType.None;
                userProfile.IsShowHeader = false;
                userProfile.TempUnit     = "C";
                userProfileBll.InsertProfile(userProfile);

                //insert sys log
                InsertCreateUserLog();
                InsertAssignRightsLog();
                // new implementation of meanings
                if (flag)
                {
                    DialogResult result = Utils.ShowMessageBox(Messages.FirstCreate, Messages.TitleNotification, MessageBoxButtons.YesNo);
                    if (result == DialogResult.Yes)
                    {
                        form.DialogResult = DialogResult.OK;
                    }
                    else
                    {
                        form.DialogResult = DialogResult.No;
                    }
                }
                else
                {
                    form.DialogResult = DialogResult.OK;
                }
            }
            else
            {
                form.DialogResult = DialogResult.No;
            }
        }
示例#3
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();
     }
 }
示例#4
0
 public void InitEvents()
 {
     this.btnConnect.Click += new EventHandler((a, b) =>
     {
         if (this.ConnectDevice())
         {
             //初始化值
             if (tag is ITAGSingleUse)
             {
                 ((ITAGSingleUse)tag).Summary();
             }
             this.InitStatus();
             ConnectEvent(tag, null);
         }
     });
     this.btnAuto.Click += new EventHandler((a, b) =>
     {
         if (this.AutoConnect())
         {
             //初始化值
             if (tag is ITAGSingleUse)
             {
                 ((ITAGSingleUse)tag).Summary();
             }
             this.InitStatus();
             ConnectEvent(tag, null);
         }
         else
         {
             Utils.ShowMessageBox(Messages.ConnectDeviceFailed, Messages.TitleError);
         }
     });
 }
示例#5
0
        public void Print(bool isPreview)
        {
            FileHelper.DeleteTempFiles("print");
            string tempFileName = Path.Combine(System.Windows.Forms.Application.StartupPath, "temp", "temp.print");

            try
            {
                IReportExportService exporter = new  AuditTrailExporter(tempFileName, "", this.list, true);
                exporter.GenerateReport();
                PDFReportPrinter printer = new PDFReportPrinter(tempFileName);
                if (isPreview)
                {
                    this.printPreviewDialog.Document = printer.PrintDocument;
                    this.printPreviewDialog.Height   = 500;
                    this.printPreviewDialog.Width    = 800;
                    this.printPreviewDialog.ShowDialog();
                }
                else
                {
                    printer.PrintReport();
                }
            }
            catch (InvalidPrinterException ipe)
            {
                Utils.ShowMessageBox(Messages.NoPrinterInstalled, Messages.TitleError);
            }
            catch (Exception e)
            {
                Utils.ShowMessageBox(e.Message, Messages.TitleError);
            }
        }
示例#6
0
 private void printDocument_BeginPrint(object sender, PrintEventArgs e)
 {
     if (this.isPrintDialogShown)
     {
         if (this.printDialog.ShowDialog() == DialogResult.OK)
         {
             e.Cancel = true;
             if (!(this.printDialog.PrinterSettings.FromPage > 0 && this.printDialog.PrinterSettings.ToPage >= this.printDialog.PrinterSettings.FromPage && this.printDialog.PrinterSettings.ToPage <= this.pageCount))
             {
                 Utils.ShowMessageBox(Messages.IncorrectPrintSetting, Messages.TitleError);
                 return;
             }
             else
             {
                 this.isPrintDialogShown = false;
                 this.currentPageIndex   = this.printDialog.PrinterSettings.FromPage - 1;
                 this.endPageIndex       = this.printDialog.PrinterSettings.ToPage;
                 this.printDocument.Print();
             }
         }
         else
         {
             e.Cancel = true;
         }
     }
 }
示例#7
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;
            }
        }
 public void CreateEmailAndAddAttachments(string tpsFilePath)
 {
     try
     {
         Application application = new Application();
         MailItem    item        = application.CreateItem(OlItemType.olMailItem);
         item.Attachments.Add(tpsFilePath);
         item.Display();
     }
     catch (System.Exception)
     {
         Utils.ShowMessageBox(Messages.OutlookError, Messages.TitleError);
     }
 }
示例#9
0
        public bool IsExpire()
        {
            int day = (DateTime.Now.Date - Common.User.LastPwdChangedTime.Date).Days;

            if (day >= Common.Policy.PwdExpiredDay && Common.Policy.PwdExpiredDay > 0)
            {
                Utils.ShowMessageBox(Messages.PasswordExpired, Messages.TitleError);
                Resize();
                return(true);
            }
            else
            {
                Undo();
                return(false);
            }
        }
示例#10
0
 public static void LogOut(object sender, EventArgs args)
 {
     ////干掉当前的进程,重新新的进程
     //Process[] allProcess = Process.GetProcesses();
     //List<Process> pros = Process.GetProcesses().Where(p => p.ProcessName.Split(new char[] { '.' })[0].ToLower() + ".exe" == "TempCentre.exe".ToLower()).ToList();
     //if (pros != null && pros.Count > 0)
     //    pros.ForEach(p =>
     //    {
     //        p.Threads.Cast<ProcessThread>().ToList().ForEach(v =>
     //        {
     //            v.Dispose();
     //        });
     //        p.Kill();
     //    });
     //System.Diagnostics.Process.Start(Environment.CurrentDirectory + "\\TempCentre.exe");
     Utils.ShowMessageBox(Messages.SessionExpire, Messages.TitleWarning);
 }
示例#11
0
 private bool Confirm()
 {
     try
     {
         if (Common.TextBoxChecked(tbAccount) && Common.TextBoxChecked(tbPwd))
         {
             UserInfo user = _userBll.GetUserInfoByUsername(tbAccount.Text.Trim());
             if (user != null && user.Userid != 0)
             {
                 int day = (DateTime.Now.Date - user.LastPwdChangedTime.Date).Days;
                 if (day < Common.Policy.PwdExpiredDay || Common.Policy.PwdExpiredDay == 0)
                 {
                     if (user.Pwd == tbPwd.Text.Trim() && user.Locked == 0 && user.Disabled == 0)
                     {
                         username = user.UserName;
                         fullname = user.FullName;
                         return(true);
                     }
                     if (user.Locked == 1)
                     {
                         Utils.ShowMessageBox(Messages.UserLocked, Messages.TitleError);
                         return(false);
                     }
                 }
                 else
                 {
                     Utils.ShowMessageBox(Messages.PasswordExpired, Messages.TitleError);
                     return(false);
                 }
             }
             Utils.ShowMessageBox(Messages.WrongUserNameOrPassword, Messages.TitleError);
             return(false);
         }
         else
         {
             return(false);
         }
     }
     catch
     {
         return(false);
     }
 }
示例#12
0
        private void GetMeaning()
        {
            string username = tbAccount.Text.Trim().ToLower();
            List <UserMeanRelation> list    = _relation.GetMeaningByUser(username);
            List <Meanings>         allmean = _relation.GetAllMeans() as List <Meanings>;

            if (list != null && list.Count > 0)
            {
                var v = from p in list
                        join o in allmean on p.MeaningId equals o.Id
                        select new
                {
                    p.Username,
                    o.Id,
                    o.Desc
                };
                var dataSource = new List <MeaningViewModel>();
                foreach (var item in v)
                {
                    Meanings meaning = new Meanings()
                    {
                        Id = item.Id, Desc = item.Desc
                    };
                    dataSource.Add(new MeaningViewModel(meaning, clbMeanings.Font, clbMeanings.ClientSize.Width - 10));
                }

                if (v != null && v.Count() > 0)
                {
                    clbMeanings.DataSource    = dataSource;
                    clbMeanings.DisplayMember = "DisplayDesc";
                    clbMeanings.ValueMember   = "Id";
                }
                else
                {
                    Utils.ShowMessageBox(Messages.AssignMeaningFirst, Messages.TitleWarning);
                }
            }
            else
            {
                Utils.ShowMessageBox(Messages.AssignMeaningFirst, Messages.TitleWarning);
            }
        }
示例#13
0
 private void InitEvents()
 {
     this.btnLeft.Click += new EventHandler((sender, args) => {
         if (this.lbAssigned.MoveSelectedItem(lbAvailbale, true, () => Utils.ShowMessageBox(Messages.NoRightItemSelected, Messages.TitleError)))
         {
             if (lbAssigned.Items.Count == 0)
             {
                 this.btnLeft.Enabled = false;
             }
         }
         lbAssigned_TextChanged(lbAssigned, args);
     });
     this.btnRight.Click += new EventHandler((sender, args) => {
         if (this.lbAvailbale.MoveSelectedItem(lbAssigned, false, () => Utils.ShowMessageBox(Messages.NoRightItemSelected, Messages.TitleError)))
         {
             this.btnLeft.Enabled = true;
         }
         lbAssigned_TextChanged(lbAssigned, args);
     });
     this.initRightListBoxEvent();
 }
示例#14
0
        /// <summary>
        /// 点击next时设置userinfo属性
        /// </summary>
        private bool SetUserInfo()
        {
            bool       result     = false;
            UserCreate createUser = dic[WizardName.CreateUser] as UserCreate;
            string     message    = string.Empty;

            if (createUser != null)
            {
                message = this.checkAllUserInfoFields(createUser);

                if (string.IsNullOrEmpty(message))
                {
                    int userid = new UserInfoBLL().GetCurrentUserID();
                    if (user == null)
                    {
                        user = new UserInfo();
                    }
                    user.Userid             = userid + 1;
                    user.UserName           = createUser.UserName.Trim();
                    user.Account            = createUser.UserName.Trim();
                    user.FullName           = createUser.FullName;
                    user.Description        = createUser.Role;
                    user.Pwd                = createUser.Password;
                    user.Disabled           = 0; //false
                    user.Locked             = 0; //false
                    user.RoleId             = createUser.Group;
                    user.LastPwdChangedTime = DateTime.Now;
                    user.Remark             = DateTime.Now.ToString();
                    result = true;
                }
                else
                {
                    Utils.ShowMessageBox(message, Messages.TitleError);
                }
            }



            return(result);
        }
示例#15
0
        public void ExportAuditTrail()
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter = "PDF Files(.pdf)|*.pdf";
            Common.SetDefaultPathForSaveFileDialog(saveFileDialog, SavingFileType.AuditTrail);
            if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                try
                {
                    new AuditTrailExporter(saveFileDialog.FileName, "", this.list).GenerateReport();
                }
                catch (IOException)
                {
                    Utils.ShowMessageBox(Messages.SameNameFileOpened, Messages.TitleError);
                }
                catch (Exception e)
                {
                    Utils.ShowMessageBox(e.Message, Messages.TitleError);
                }
            }
        }
示例#16
0
 private void InitEvent()
 {
     this.btnCancel.Click += new EventHandler(delegate(object sender, EventArgs args){
         this.form.Close();
     });
     this.btnBrowse.Click += new EventHandler(delegate(object sender, EventArgs args)
     {
         FolderBrowserDialog folder = new FolderBrowserDialog();
         if (folder.ShowDialog() == DialogResult.OK)
         {
             this.tbFolder.Text = folder.SelectedPath;
         }
     });
     this.btnOk.Click += new EventHandler(delegate(object sender, EventArgs args)
     {
         if (id == 0)
         {
             Common.Policy.ID = Common.Policy.ID + 1;
         }
         Common.Policy.MinPwdSize     = Convert.ToInt32(this.mtbPwdSize.Text);
         Common.Policy.PwdExpiredDay  = Convert.ToInt32(this.mtbPwdExpired.Text);
         Common.Policy.LockedTimes    = Convert.ToInt32(this.mtbLocked.Text);
         Common.Policy.ProfileFolder  = this.tbFolder.Text;
         Common.Policy.InactivityTime = Convert.ToInt32(this.mtbInactivity.Text);
         Common.Policy.Remark         = DateTime.Now.ToString();
         processor = new DeviceProcessor();
         if (processor.InsertOrUpdate <Policy>(Common.Policy, null, id == 0 ? true : false))
         {
             Utils.ShowMessageBox(Messages.SavedSuccessfully, Messages.TitleNotification);
         }
         else
         {
             Utils.ShowMessageBox(Messages.SavedFailed, Messages.TitleError);
         }
     });
 }
示例#17
0
 public bool ConnectDevice()
 {
     try
     {
         if (cbSingleUse.Checked)
         {
             if (tag == null)
             {
                 tag = ObjectManage.GetDeviceInstance(DeviceType.ITAGSingleUse);
             }
             //ProgressEvent(null, null);
             return(_IsConnected = tag.Connect((int)DeviceType.ITAGSingleUse));
         }
         else
         {
             Utils.ShowMessageBox(Messages.ConnectWithNoDeviceSelected, Messages.TitleError);
         }
     }
     catch
     {
         return(false);
     }
     return(false);
 }
示例#18
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 COLLATE NOCASE", delegate()
             {
                 Dictionary <string, object> dic = new Dictionary <string, object>();
                 dic.Add("username", tbAccount.Text.Trim().ToLower());
                 //dic.Add("pwd", tbPwd.Text.TrimEnd());
                 return(dic);
             });
             if (user.Locked == 0)
             {
                 if (user.Userid != 0 && user.Pwd.Equals(this.tbPwd.Text) && user.Disabled == 0)
                 {
                     Common.User = user;
                     loginTimes[user.UserName] = 0;
                     this.SaveUserList();    //保存列表
                     //记录成功的日志
                     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.Logon);
                             dic.Add("UserName", user.UserName);
                             dic.Add("FullName", user.FullName);
                             dic.Add("Detail", "Successful");
                             dic.Add("LogType", LogAction.SystemAuditTrail);
                             return(dic);
                         });
                     }
                     return(true);
                 }
                 else if (user.Userid == 0 || user.Disabled == 1)
                 {
                     //TODO:
                     if (tbAccount.Text == Common.SUPERUSER && tbPwd.Text == Common.SUPERUSERPWD)
                     {
                         UserInfo super = new UserInfo()
                         {
                             UserName           = Common.SUPERUSER,
                             Pwd                = Common.SUPERUSERPWD,
                             FullName           = "super admin",
                             LastPwdChangedTime = DateTime.UtcNow,
                             RoleId             = 1
                         };
                         Common.User = super;
                         return(true);
                     }
                     else
                     {
                         Utils.ShowMessageBox(Messages.WrongUserNameOrPassword, Messages.TitleError);
                         return(false);
                     }
                 }
                 else if (user.Pwd != this.tbPwd.Text)
                 {
                     if (!loginTimes.ContainsKey(user.UserName))
                     {
                         loginTimes[user.UserName] = 0;
                     }
                     loginTimes[user.UserName]++;
                     if (loginTimes[user.UserName] >= Common.Policy.LockedTimes && Common.Policy.LockedTimes > 0)
                     {
                         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 COLLATE NOCASE", dic);
                         Utils.ShowMessageBox(Messages.WrongPasswordExcceedCertainTimes, Messages.TitleError);
                     }
                     else
                     {
                         Utils.ShowMessageBox(Messages.WrongUserNameOrPassword, Messages.TitleError);
                     }
                     //记录账号锁定日志
                     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.Logon);
                             dic.Add("UserName", user.UserName);
                             dic.Add("FullName", user.FullName);
                             dic.Add("Detail", "Failed");
                             dic.Add("LogType", LogAction.SystemAuditTrail);
                             return(dic);
                         });
                     }
                     return(false);
                 }
                 else
                 {
                     return(false);
                 }
             }
             else
             {
                 Utils.ShowMessageBox(Messages.UserLocked, Messages.TitleError);
             }
         }
         else
         {
             Utils.ShowMessageBox(Messages.WrongUserNameOrPassword, Messages.TitleError);
         }
         return(false);
     }
     catch { return(false); }
 }
示例#19
0
        private void OK()
        {
            string message = this.checkAllUserInfoFields();

            if (!string.IsNullOrEmpty(message))
            {
                Utils.ShowMessageBox(message, Messages.TitleError);
                return;
            }
            if (Common.TextBoxChecked(this.tbUserName) && Common.TextBoxChecked(this.tbFullName) &&
                Common.TextBoxChecked(this.tbDescription) && Common.TextBoxChecked(this.tbPwd) &&
                Common.TextBoxChecked(this.tbConfirm) && Common.PasswordConfirmed(tbPwd, tbConfirm))
            {
                /*密钥长度*/
                if (Common.Policy == null || Common.Policy.MinPwdSize > this.tbPwd.Text.Length)
                {
                    return;
                }

                bool isChangeGroup = false, isChangePwd = false, isEditUser = false, isDisableUser = false;
                /*记录日志*/
                if (user.RoleId != Convert.ToInt32(this.cbxRole.SelectedValue))
                {
                    isChangeGroup = true;
                }
                if (user.Pwd != tbPwd.Text)
                {
                    isChangePwd = true;
                }
                if (user.Description != tbDescription.Text || user.FullName != tbFullName.Text)
                {
                    isEditUser = true;
                }
                if (isChangePwd || isChangeGroup || isEditUser || isDisableUser)
                {
                    if (username == string.Empty)
                    {
                        user.Userid = ++userid;
                    }
                    user.Account            = this.tbUserName.Text.TrimEnd();
                    user.FullName           = this.tbFullName.Text.TrimEnd();
                    user.Description        = this.tbDescription.Text.TrimEnd();
                    user.LastPwdChangedTime = this.tbPwd.Text == user.Pwd ? user.LastPwdChangedTime : DateTime.Now;
                    user.Pwd    = this.tbPwd.Text.TrimEnd();
                    user.Remark = DateTime.Now.ToString();
                    user.RoleId = this.cbxRole.SelectedValue == null ? 1 : Convert.ToInt32(this.cbxRole.SelectedValue);
                    if (processor.InsertOrUpdate <UserInfo>(user, null, username == string.Empty ? true : false))
                    {
                        Utils.ShowMessageBox(Messages.SavedSuccessfully, Messages.TitleNotification);
                        if (isChangeGroup)
                        {
                            InsertChangeLog("Change group");
                        }
                        if (isChangePwd)
                        {
                            InsertChangeLog("Change password");
                        }
                        if (isEditUser)
                        {
                            InsertChangeLog("Edit user");
                        }
                        if (isDisableUser && user.Disabled != 0)
                        {
                            InsertChangeLog("Disable user");
                        }
                        form.DialogResult = DialogResult.OK;
                    }
                    else
                    {
                        Utils.ShowMessageBox(Messages.SavedFailed, Messages.TitleError);
                        form.DialogResult = DialogResult.No;
                    }
                }
                else
                {
                    form.DialogResult = DialogResult.OK;
                }
            }
        }
示例#20
0
        public void InitEvents()
        {
            this.btnAddMean.Click += new EventHandler((a, b) =>
            {
                InputBoxDialog newMeanDialog = new InputBoxDialog(InputBoxTitle.AddMeaning, InputBoxTipMessage.AddMeaning, false);
                if (newMeanDialog.ShowDialog(this) == DialogResult.OK)
                {
                    Meanings meaning = new Meanings()
                    {
                        Id = this._meanBll.GetMeaningPKValue() + 1, Desc = newMeanDialog.InputBoxText.TrimEnd(), Remark = DateTime.Now.ToString()
                    };
                    this._meanBll.InsertOrUpdateMeaning(meaning);
                    this.allMeanings.Add(meaning);
                    if (this.clbMeans != null)
                    {
                        this.clbMeans.AddMean(meaning);
                    }
                }
            });

            this.btnEditMean.Click += new EventHandler((send, args) =>
            {
                InputBoxDialog updateMeanDialog = new InputBoxDialog(InputBoxTitle.EditMeaning, InputBoxTipMessage.EditMeaning, false);
                int selectedMeanId    = this.clbMeans.GetCurrentSelectedMean();
                Meanings selectedMean = null;
                if (allMeanings != null)
                {
                    selectedMean = allMeanings.Where <Meanings>(m => m.Id == selectedMeanId).FirstOrDefault();
                }
                if (selectedMean != null)
                {
                    updateMeanDialog.InputBoxText = selectedMean.Desc;
                    if (updateMeanDialog.ShowDialog(this) == DialogResult.OK)
                    {
                        if (!updateMeanDialog.InputBoxText.TrimEnd().Equals(selectedMean.Desc, StringComparison.Ordinal))
                        {
                            selectedMean.Desc   = updateMeanDialog.InputBoxText.TrimEnd();
                            selectedMean.Remark = DateTime.Now.ToString();
                            this._meanBll.InsertOrUpdateMeaning(selectedMean);
                            this.clbMeans.Refresh();
                        }
                    }
                }
            });

            this.btnDeleteMean.Click += new EventHandler((send, args) =>
            {
                if (DialogResult.Yes == Utils.ShowMessageBox(Messages.DeleteMeaning, Messages.TitleWarning, MessageBoxButtons.YesNo))
                {
                    int selectedMeanId    = this.clbMeans.GetCurrentSelectedMean();
                    Meanings selectedMean = null;
                    if (allMeanings != null)
                    {
                        selectedMean = allMeanings.Where <Meanings>(m => m.Id == selectedMeanId).FirstOrDefault();
                    }
                    if (selectedMean != null)
                    {
                        this._meanBll.DeleteMeaningAndRelation(selectedMean);
                        allMeanings.Remove(selectedMean);
                        this.clbMeans.Items.Remove(selectedMean);
                        foreach (var item in this.newUserRelation.Values)
                        {
                            item.Remove(selectedMeanId);
                        }
                        this.clbMeans.Refresh();
                    }
                }
            });
        }