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); } }); }
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; } } }
private void InitEvents() { #region checkbox cbCompanyName.CheckedChanged += new EventHandler(delegate(object sender, EventArgs args) { this.tbCompanyName.Enabled = cbCompanyName.Checked; this.tbCompanyName.Focus(); }); cbAdress.CheckedChanged += new EventHandler(delegate(object sender, EventArgs args) { this.tbAdress.Enabled = this.cbAdress.Checked; tbAdress.Focus(); }); this.cbContactPhone.CheckedChanged += new EventHandler(delegate(object sender, EventArgs args) { this.tbContactPhone.Enabled = this.cbContactPhone.Checked; tbContactPhone.Focus(); }); this.cbEMail.CheckedChanged += new EventHandler(delegate(object sender, EventArgs args) { this.tbEMail.Enabled = this.cbEMail.Checked; tbEMail.Focus(); }); this.cbFax.CheckedChanged += new EventHandler(delegate(object sender, EventArgs args) { this.tbFax.Enabled = this.cbFax.Checked; tbFax.Focus(); }); this.cbReportTitle.CheckedChanged += new EventHandler(delegate(object sender, EventArgs args) { this.tbReportTitle.Enabled = this.cbReportTitle.Checked; tbReportTitle.Focus(); }); this.cbWebSite.CheckedChanged += new EventHandler(delegate(object sender, EventArgs args) { this.tbWebSite.Enabled = this.cbWebSite.Checked; tbWebSite.Focus(); }); this.cbLogo.CheckedChanged += new EventHandler(delegate(object sender, EventArgs args) { this.btnOpen.Enabled = this.cbLogo.Checked; btnOpen.Focus(); }); #endregion #region button this.btnOpen.Click += new EventHandler(delegate(object sender, EventArgs args){ OpenFileDialog file = new OpenFileDialog(); if (file.ShowDialog() == DialogResult.OK) { string src = file.FileName.ToString(); pbLogo.Image = System.Drawing.Image.FromFile(src); } }); this.btnSave.Click += new EventHandler(delegate(object sender, EventArgs args) { ReportConfig config; bool flag = false; if (ID == 0) { config = new ReportConfig(); config.Id = (int)(ID + 1); flag = true; } else { config = rc; flag = false; } config.ReportTitle = this.tbReportTitle.Text; config.CompanyName = this.tbCompanyName.Text; config.ContactPhone = this.tbCompanyName.Text; config.Email = this.tbEMail.Text; config.Fax = this.tbFax.Text; config.WebSite = this.tbWebSite.Text; config.Adress = this.tbAdress.Text; if (pbLogo.Image != null) { config.Logo = Utils.CopyToBinary(pbLogo.Image); } if (processor.InsertOrUpdate <ReportConfig>(config, null, flag)) { MessageBox.Show("Saved Corrected", "OK", MessageBoxButtons.OK); } else { MessageBox.Show("Saved Failure", "Error", MessageBoxButtons.OK); } }); #endregion }
private void InitEvents() { this.btnOK.Click += new EventHandler(delegate(object sender, EventArgs args){ 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; } 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.Locked = this.cbLocked.Checked == true ? 1 : 0; user.ChangePwd = this.cbChangePwd.Checked == true ? 1 : 0; 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)) { MessageBox.Show("Saved Successfully"); form.DialogResult = DialogResult.OK; } else { MessageBox.Show("Saved Failure"); form.DialogResult = DialogResult.No; } } }); this.btnCancel.Click += new EventHandler(delegate(object sender, EventArgs args){ form.Close(); }); this.tbUserName.Leave += new EventHandler(delegate(object sender, EventArgs args) { if (Common.TextBoxChecked((TextBox)sender)) { //判断用户名是否使用过 UserInfo user = processor.QueryOne <UserInfo>("select * from userinfo where username=@username", delegate() { Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("username", tbUserName.Text); return(dic); }); if (user.Userid == 0) { lbAlarmUn.Text = "√"; } else { this.lbAlarmUn.Text = "x " + tbUserName.Text + " has been used"; this.tbUserName.Focus(); } } else { this.tbUserName.Focus(); this.lbAlarmUn.Text = "x none content"; } }); this.tbFullName.Leave += new EventHandler(delegate(object sender, EventArgs args) { if (Common.TextBoxChecked((TextBox)sender)) { this.lbAlarmFN.Text = "√"; } else { //this.tbFullName.Focus(); this.lbAlarmFN.Text = "x none content"; } }); this.tbDescription.Leave += new EventHandler(delegate(object sender, EventArgs args) { if (Common.TextBoxChecked(tbDescription)) { this.lbAlarmDesc.Text = "√"; } else { //this.tbDescription.Focus(); this.lbAlarmDesc.Text = "x none content"; } }); this.tbPwd.Leave += new EventHandler(delegate(object sender, EventArgs args) { if (Common.TextBoxChecked(tbPwd)) { //判断密钥长度 if (Common.Policy == null) { this.lbAlarmPwd.Text = "√"; } else { if (tbPwd.Text.TrimEnd().Length >= Common.Policy.MinPwdSize) { this.lbAlarmPwd.Text = "√"; } else { this.lbAlarmPwd.Text = "x min pwd size is " + Common.Policy.MinPwdSize.ToString(); //this.tbPwd.Focus(); } } } else if (!Common.TextBoxChecked(tbPwd)) { //this.tbPwd.Focus(); this.lbAlarmPwd.Text = "x none content"; } if (Common.PasswordConfirmed(tbPwd, tbConfirm)) { this.lbAlarmConfirm.Text = "√"; } }); this.tbConfirm.Leave += new EventHandler(delegate(object sender, EventArgs args) { if (Common.TextBoxChecked(tbConfirm)) { if (Common.PasswordConfirmed(tbPwd, tbConfirm)) { this.lbAlarmConfirm.Text = "√"; } else { this.lbAlarmConfirm.Text = "x confirmed failure"; } } else { //this.tbConfirm.Focus(); this.lbAlarmConfirm.Text = "x none content"; } }); }