标签:nlog 授权 oid result 密码 处理 inner partial img
一、事件定义类,即子窗体
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using DataMaintenance.Services; using DataMaintenance.Modle; using Utility; namespace DataMaintenance.UI { public partial class Frm_authorization : Form { public Frm_authorization() { InitializeComponent(); initializeDatasource(); } /// <summary> /// 初始化控件数据源 /// </summary> private void initializeDatasource() { cmb_user.DataSource = new UserService().getUserList().Where<UserModle>(c => c.DateOfCancellation == null).Select((c) => new { c.userID, c.name,c.pwd,c.RegistrationDate }).ToList(); cmb_user.DisplayMember = "name"; cmb_user.ValueMember = "userID"; } #region 事件 public event EventHandler<AuthorizationEventArgs> authorizPass; /// <summary> /// 事件处理方法,调用端实例化事件委托后就执行 /// </summary> /// <param name="authorizationEventArgs"></param> protected virtual void onAuthorizPass(AuthorizationEventArgs authorizationEventArgs) { authorizPass?.Invoke(this, authorizationEventArgs); } #endregion private void btn_certain_Click(object sender, EventArgs e) { //this.DialogResult = DialogResult.OK; if (txt_pwd.Text!="") { string pwd = Encrypt.Encode(txt_pwd.Text); if (new UserService().loginCheck(Convert.ToInt32(cmb_user.SelectedValue), pwd)) { //引发验证通过事件 AuthorizationEventArgs authorizationEventArgs = new AuthorizationEventArgs(); authorizationEventArgs.userAndPwdRight = true; onAuthorizPass(authorizationEventArgs); this.Close(); } else { lbl_information.Text = ""; lbl_information.Text = lbl_information.Text + "您输入受权密码不正确,请重新输入"; } } else { lbl_information.Text = ""; lbl_information.Text = "请输入受权密码"; } } private void btn_cancel_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.Cancel; } } public class AuthorizationEventArgs : EventArgs { public bool userAndPwdRight { get; set; } } }
二、事件订阅类,即主窗体
/// <summary> /// 更新ERP数据库中的模板参数 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_mend_Click(object sender, EventArgs e) { Frm_authorization f = new Frm_authorization(); f.authorizPass += modifyTemple; f.ShowDialog(); if (f.DialogResult == DialogResult.Cancel) { f.Close(); } } private void modifyTemple( object sender,AuthorizationEventArgs authorizationEventArgs) { int editAble; List<SqlParameter> sqlParameterList = new List<SqlParameter>(); SqlParameter sqlParameter1 = new SqlParameter("@VT_ID", "8173"); SqlParameter sqlParameter2 = new SqlParameter("@FieldName", "itaxprice"); SqlParameter sqlParameter3 = new SqlParameter("@vt_cardnumber", "88"); SqlParameter sqlParameter4 = new SqlParameter("@VT_TemplateMode", "0"); string sql = "update voucheritems_base set CanModify = @editAble where VT_ID = @VT_ID and FieldName =@FieldName; "; string sql2 = "update vouchertemplates_base set VT_TemplateMode=@VT_TemplateMode where vt_cardnumber =@vt_cardnumber and vt_id = @VT_ID "; if (rb_noEedit.Checked) { editAble = 0; SqlParameter sqlParameterEditAble = new SqlParameter("@editAble", editAble); sqlParameterList.Add(sqlParameterEditAble); }; if (rb_edit.Checked) { editAble = 1; SqlParameter sqlParameterEditAble = new SqlParameter("@editAble", editAble); sqlParameterList.Add(sqlParameterEditAble); } sqlParameterList.Add(sqlParameter1); sqlParameterList.Add(sqlParameter2); sqlParameterList.Add(sqlParameter3); sqlParameterList.Add(sqlParameter4); try { int influnceRows1 = Sqlhelper.UpdateWithparameters(sql + sql2, sqlParameterList.ToArray()); //int influnceRows2=Sqlhelper.UpdateWithparameters(sql2, sqlParameterList.ToArray()); //authorizationLog(); MessageBox.Show("更新" + influnceRows1 + "条记录,授权成功", "授权提示"); } catch (Exception ex) { MessageBox.Show("授权出错:" + ex.Message + ex.InnerException, "授权提示"); } }
标签:nlog 授权 oid result 密码 处理 inner partial img
原文地址:https://www.cnblogs.com/windy3417/p/13945912.html