private void cmbDept_ValueChanged(object sender, System.EventArgs e) { //初始化操作员 try { SecurityManage security = new SecurityManage(); DataTable dtOper = security.getAllOperByDept(cmbDept.SelectedItem.DataValue.ToString()); txtOperName.DataSource = dtOper; txtOperName.DisplayMember = "cnvcOperName"; txtOperName.ValueMember = "cnnOperID"; txtOperName.DataBind(); txtOperName.SelectedIndex = 0; } catch (BusinessException bex) { MessageBox.Show(this, bex.Message, bex.Type, MessageBoxButtons.OK, MessageBoxIcon.Error); this.txtOperName.Focus(); //isLogin = false; } catch (System.Exception ex) { MessageBox.Show(this, ex.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); //this.btnLogin.DialogResult = DialogResult.Cancel; } }
private static void LogIn(string strOperName, string strPWD, string strL6Name, string strL8Name) { if (!Membership.ValidateUser(strOperName, strPWD)) { throw new BusinessException("登录错误", "操作员或密码输入错误"); } SecurityManage security = new SecurityManage(); Oper oper = security.GetOperByName(strOperName); Dept dept = new Dept(); dept.cnnDeptID = 0; dept.cnnDiscount = 0; dept.cnvcDeptName = "云南人才中心"; if (oper.cnnDeptID != 0) { dept = security.GetDeptById(oper.cnnDeptID); } List <string> lFunc = security.GetFuncById(oper.cnnOperID, oper.cnnDeptID, constApp.strCardType, strL6Name, strL8Name); List <string> lAllFunc = security.GetAllFunc(constApp.strCardType, strL6Name, strL8Name); MyIdentity myidentity = new MyIdentity(oper, dept, Membership.Provider.Name); MyPrincipal myprincipal = new MyPrincipal(myidentity, lFunc, lAllFunc); Thread.CurrentPrincipal = myprincipal; //AppDomain.CurrentDomain.SetThreadPrincipal(myprincipal); //return security; }
private void button1_Click(object sender, EventArgs e) { //保存 List <Dept> ldept = new List <Dept>(); foreach (TreeNode tn in treeView2.Nodes) { if (tn.Checked) { ldept.Add(tn.Tag as Dept); } } TreeNode tnSel = treeView1.SelectedNode; if (tnSel != null && ldept.Count > 0) { if (tnSel.Name.StartsWith("oper-")) { string operid = tnSel.Name.Substring("oper-".Length); SecurityManage sm = new SecurityManage(); sm.ModifyOperDept(ldept, operid); MessageBox.Show("数据权限修改成功"); } } }
private void Login_Load(object sender, System.EventArgs e) { //初始化部门 //getAllDept if (CheckForUpdate.IsUpdate()) { //this.Close(); Application.Exit(); Process.Start("AutoUpdate.exe"); return; } //this.Visible = false; if (File.Exists(Application.StartupPath + @"\BatchScript.bat") && File.Exists(Application.StartupPath + @"\Script.sql")) { Process.Start("BatchScript.bat"); } if (File.Exists(Application.StartupPath + @"\AutoUpdate.exe.delete")) { //Process.Start("BatchScript.bat"); File.Delete(Application.StartupPath + @"\AutoUpdate.exe.delete"); } try { SecurityManage security = new SecurityManage(); DataTable dtDept = security.getAllDept(); cmbDept.DataSource = dtDept; cmbDept.DisplayMember = "部门名称"; cmbDept.ValueMember = "部门ID"; cmbDept.DataBind(); cmbDept.SelectedIndex = 0; } catch (BusinessException bex) { MessageBox.Show(this, bex.Message, bex.Type, MessageBoxButtons.OK, MessageBoxIcon.Error); this.txtOperName.Focus(); //isLogin = false; } catch (System.Exception ex) { MessageBox.Show(this, ex.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); //this.btnLogin.DialogResult = DialogResult.Cancel; } }
private void ultraButton2_Click(object sender, EventArgs e) { List <NT77> lnt = new List <NT77>(); //ultraGrid1.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.ExitEditMode); //ultraGrid1.UpdateData(); foreach (UltraGridRow gr in this.ultraGrid1.Rows) { NT77 nt = new NT77(); nt.HardwareID = gr.Cells["HardwareID"].Value.ToString(); nt.CardNo = gr.Cells["CardNo"].Value.ToString(); nt.CreateDate = Convert.ToDateTime(gr.Cells["CreateDate"].Value); nt.bIsUse = Convert.ToBoolean(gr.Cells["bIsUse"].Value); nt.OperName = gr.Cells["OperName"].Value.ToString(); lnt.Add(nt); } ynhrMemberManage.BusinessFacade.MemberBusiness.SecurityManage sm = new SecurityManage(); sm.UpdateNT77(lnt); MessageBox.Show("ekey使用信息更新成功", "ekey管理"); }
private void button1_Click(object sender, EventArgs e) { //保存 List <FuncList> lfunc = new List <FuncList>(); foreach (TreeNode tnParent in treeView2.Nodes) { foreach (TreeNode tn in tnParent.Nodes) { if (tn.Checked) { lfunc.Add(tn.Tag as FuncList); } } } TreeNode tnSel = treeView1.SelectedNode; if (tnSel != null && lfunc.Count > 0) { SecurityManage sm = new SecurityManage(); if (tnSel.Name.StartsWith("dept-")) { string deptid = tnSel.Name.Substring("dept-".Length); if (deptid != "0") { sm.AddDeptFunc(lfunc, deptid); } } if (tnSel.Name.StartsWith("oper-")) { string operid = tnSel.Name.Substring("oper-".Length); sm.ModifyOperFunc(lfunc, operid); } } MessageBox.Show("权限修改成功"); }
private void btnBrushCard_Click(object sender, System.EventArgs e) { //刷卡登录 try { //读取会员卡号 iLoginTime += 1; if (iLoginTime > 3) { Application.Exit(); } else { CardM1 m1 = new CardM1(); string strCardNo = ""; string strRet = m1.ReadCard(out strCardNo); //,out dtemp,out itemp); if (strRet != ConstMsg.RFOK) { throw new BusinessException("卡操作失败", "读取操作员卡失败!"); } DataTable dtOper = Helper.Query("select * from tbOper where cnvcCardNo is not null and cnvcCardNo = '" + strCardNo + "'"); if (dtOper.Rows.Count == 0) { throw new BusinessException("登录", "未找到操作员"); } if (dtOper.Rows.Count > 1) { throw new BusinessException("登录", "未找到操作员"); } Oper oper = new Oper(dtOper); byte[] bIn = Convert.FromBase64String(oper.cnvcPwd); byte[] bRet = Cryptographer.DecryptSymmetric("Custom Symmetric Cryptography Provider", bIn); if (bRet == null) { throw new BusinessException("登录", "密码错误"); } string strpwd = Encoding.UTF8.GetString(bRet); SysInit.LoadPara(Login.constApp); LogIn(oper.cnvcOperName, strpwd, Login.constApp.strCardTypeL6Name, Login.constApp.strCardTypeL8Name); SecurityManage security = new SecurityManage(); //security.OperLogin(oper.cnvcOperName);//,oper.cnvcPwd); //constApp.alOperFunc = security.alOperFunc; //constApp.oper = security.oper; //constApp.iDiscount = security.iDiscount; //SysInit.LoadPara(Login.constApp); OperLogin login = new OperLogin(oper.ToTable()); login.cndLoginDate = DateTime.Now; login.cnvcLoginMethod = "刷卡"; login.cnnAgainTime = iLoginTime; security.LoginLog(login); MainForm mForm = new MainForm(); //mForm.ll = this; mForm.Owner = this; mForm.Show(); this.Hide(); // = false; } } catch (BusinessException bex) { MessageBox.Show(this, bex.Message, bex.Type, MessageBoxButtons.OK, MessageBoxIcon.Error); } //catch (System.Exception ex) //{ // MessageBox.Show(this,ex.Message,"系统错误",MessageBoxButtons.OK,MessageBoxIcon.Error); //} }
private void btnLogin_Click(object sender, System.EventArgs e) { //登录 try { if (iLoginTime > 3) { Application.Exit(); } else { string strOperName = txtOperName.Text.Trim(); string strPWD = txtPWD.Text.Trim(); if (strOperName.Length == 0) { throw new BusinessException("登录错误", "请输入用户名!"); } if (strPWD.Length == 0) { throw new BusinessException("登录错误", "请输入密码!"); } SysInit.LoadPara(Login.constApp); LogIn(strOperName, strPWD, Login.constApp.strCardTypeL6Name, Login.constApp.strCardTypeL8Name); SecurityManage security = new SecurityManage(); //security.OperLogin(strOperName);//,DataSecurity.Encrypt(strPWD); //constApp.alOperFunc = security.alOperFunc; //constApp.oper = security.oper; //constApp.iDiscount = security.iDiscount; //isLogin = true; //constApp = new ConstApp(); //LogAdapter.WriteFeaturesException(new Exception("导入基本数据前")); //LogAdapter.WriteFeaturesException(new Exception("导入基本数据后")); OperLogin login = new OperLogin(); if (cmbDept.SelectedItem != null) { login.cnnDeptID = int.Parse(cmbDept.SelectedItem.DataValue.ToString()); } login.cnvcOperName = txtOperName.Text; login.cndLoginDate = DateTime.Now; login.cnvcLoginMethod = "录入"; login.cnnAgainTime = iLoginTime; security.LoginLog(login); //LogAdapter.WriteFeaturesException(new Exception("写登录日志")); MainForm mForm = new MainForm(); mForm.Owner = this; //mForm.ll = this; //LogAdapter.WriteFeaturesException(new Exception("主窗体new完成")); mForm.Show(); //LogAdapter.WriteFeaturesException(new Exception("主窗体show完成")); this.Hide(); //LogAdapter.WriteFeaturesException(new Exception("主窗体打开完成")); } } catch (BusinessException bex) { iLoginTime += 1; //MessageBox.Show(this, bex.Message, bex.Type,MessageBoxButtons.OK,MessageBoxIcon.Error); this.txtOperName.Focus(); throw bex; //isLogin = false; } //catch (System.Exception ex) //{ // MessageBox.Show(this, ex.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); // Application.Exit(); // //this.btnLogin.DialogResult = DialogResult.Cancel; //} }