public void AddOperFunc(OperFunc func) { try { conn = ConnectionPool.BorrowConnection(); trans = conn.BeginTransaction(); EntityMapping.Create(func, trans); trans.Commit(); } catch (BusinessException bex) //业务异常 { //LogAdapter.WriteBusinessException(bex); trans.Rollback(); throw new BusinessException(bex.Type, bex.Message); } catch (SqlException sex) //数据库异常 { //事务回滚 trans.Rollback(); //LogAdapter.WriteDatabaseException(sex); throw new BusinessException("数据库异常", sex.Message); } catch (Exception ex) //其他异常 { //事务回滚 trans.Rollback(); //LogAdapter.WriteFeaturesException(ex); throw new BusinessException("其它异常", ex.Message); } finally { ConnectionPool.ReturnConnection(conn); } }
public int AddOperFunc(OperFunc operFunc, BusiLog busiLog) { //SqlConnection conn = ConnectionPool.BorrowConnection(); int iRet = 0; using (SqlConnection conn = ConnectionPool.BorrowConnection()) { //conn.Open(); SqlTransaction trans = conn.BeginTransaction(); try { iRet = OperFuncAccess.AddOperFunc(trans, operFunc); BusiLogAccess.AddBusiLog(trans, busiLog); trans.Commit(); } catch (SqlException sex) { trans.Rollback(); throw sex; } catch (Exception ex) { trans.Rollback(); throw ex; } finally { ConnectionPool.ReturnConnection(conn); } } return(iRet); }
public void AddOperFunc(ArrayList alOperFuncList, int iOperID) { try { conn = ConnectionPool.BorrowConnection(); trans = conn.BeginTransaction(); for (int i = 0; i < alOperFuncList.Count; i++) { string strFuncCode = alOperFuncList[i].ToString(); OperFunc func = new OperFunc(); func.cnnOperID = iOperID; func.cnvcFuncCode = strFuncCode; OperFunc oldFunc = EntityMapping.Get(func, trans) as OperFunc; if (null == oldFunc) { EntityMapping.Create(func, trans); } } trans.Commit(); } catch (BusinessException bex) //业务异常 { //LogAdapter.WriteBusinessException(bex); trans.Rollback(); throw new BusinessException(bex.Type, bex.Message); } catch (SqlException sex) //数据库异常 { //事务回滚 trans.Rollback(); //LogAdapter.WriteDatabaseException(sex); throw new BusinessException("数据库异常", sex.Message); } catch (Exception ex) //其他异常 { //事务回滚 trans.Rollback(); //LogAdapter.WriteFeaturesException(ex); throw new BusinessException("其它异常", ex.Message); } finally { ConnectionPool.ReturnConnection(conn); } }
public void ModifyOperFunc(List <FuncList> alOperFuncList, string iOperID) //,string strCardType) { try { conn = ConnectionPool.BorrowConnection(); trans = conn.BeginTransaction(); SqlHelper.ExecuteNonQuery(trans, CommandType.Text, "delete from tbOperFunc where cnnOperID = " + iOperID); //+" and cnvcCardType='"+strCardType+"'"); for (int i = 0; i < alOperFuncList.Count; i++) { //string strFuncCode = alOperFuncList[i]; FuncList fl = alOperFuncList[i] as FuncList; OperFunc func = new OperFunc(); func.cnnOperID = Convert.ToInt32(iOperID); func.cnvcFuncCode = fl.cnvcFuncCode; //strFuncCode; func.cnvcCardType = fl.cnvcCardType; //strCardType; EntityMapping.Create(func, trans); } trans.Commit(); } catch (BusinessException bex) //业务异常 { //LogAdapter.WriteBusinessException(bex); trans.Rollback(); throw new BusinessException(bex.Type, bex.Message); } catch (SqlException sex) //数据库异常 { //事务回滚 trans.Rollback(); //LogAdapter.WriteDatabaseException(sex); throw new BusinessException("数据库异常", sex.Message); } catch (Exception ex) //其他异常 { //事务回滚 trans.Rollback(); //LogAdapter.WriteFeaturesException(ex); throw new BusinessException("其它异常", ex.Message); } finally { ConnectionPool.ReturnConnection(conn); } }
public static void DeleteOperFunc(OperFunc operFunc, Oper oper) { using (SqlConnection conn = ConnectionPool.BorrowConnection()) { //conn.Open(); SqlTransaction trans = conn.BeginTransaction(); try { string strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString(); DateTime dtSysTime = DateTime.Parse(strSysTime); EntityMapping.Delete(operFunc, trans); BusiLog busiLog = new BusiLog(); busiLog.cndOperDate = dtSysTime; busiLog.cnnBusiSerialNo = Helper.GetSerialNo(trans); busiLog.cnvcComments = operFunc.cnvcFuncCode; busiLog.cnvcFuncCode = "删除权限"; busiLog.cnvcOperID = oper.cnvcOperID; busiLog.cnvcIPAddress = ""; EntityMapping.Create(busiLog, trans); trans.Commit(); } catch (SqlException sex) { trans.Rollback(); LogAdapter.WriteDatabaseException(sex); throw sex; } catch (Exception ex) { trans.Rollback(); LogAdapter.WriteFeaturesException(ex); throw ex; } finally { ConnectionPool.ReturnConnection(conn); } } }
public void ModifyOperFunc(ArrayList alOperFuncList, int iOperID) { try { conn = ConnectionPool.BorrowConnection(); trans = conn.BeginTransaction(); SqlHelper.ExecuteNonQuery(trans, CommandType.Text, "delete from tbOperFunc where cnnOperID = " + iOperID.ToString()); for (int i = 0; i < alOperFuncList.Count; i++) { string strFuncCode = alOperFuncList[i].ToString(); OperFunc func = new OperFunc(); func.cnnOperID = iOperID; func.cnvcFuncCode = strFuncCode; EntityMapping.Create(func, trans); } trans.Commit(); } catch (BusinessException bex) //业务异常 { //LogAdapter.WriteBusinessException(bex); trans.Rollback(); throw new BusinessException(bex.Type, bex.Message); } catch (SqlException sex) //数据库异常 { //事务回滚 trans.Rollback(); //LogAdapter.WriteDatabaseException(sex); throw new BusinessException("数据库异常", sex.Message); } catch (Exception ex) //其他异常 { //事务回滚 trans.Rollback(); //LogAdapter.WriteFeaturesException(ex); throw new BusinessException("其它异常", ex.Message); } finally { ConnectionPool.ReturnConnection(conn); } }
public static int AddOperFunc(OperFunc operFunc, BusiLog busiLog) { int ret = 0; try { BusinessRules.SysManage.Authorization auth = new BusinessRules.SysManage.Authorization(); ret = auth.AddOperFunc(operFunc, busiLog); } catch (SqlException sex) { LogAdapter.WriteDatabaseException(sex); throw new Exception("数据库访问异常。"); } catch (Exception ex) { LogAdapter.WriteFeaturesException(ex); throw new Exception("业务规则层异常。"); } return(ret); }
private void btnOK_Click(object sender, System.Web.UI.ImageClickEventArgs e) { try { //更新功能列表 // if (rblOper.SelectedValue == "") // { // throw new BusinessException("tbOper","请选择操作员!"); // } string strOperID = txtOperID.Text; //rblOper.SelectedValue; //查询某操作员已具有的功能 DataTable dtHaveOperFunction = Helper.Query("select * from tbOperFunc where cnvcOperID='" + strOperID + "'"); foreach (ListItem liOperFunction in cblFunctionList.Items) { if (liOperFunction.Selected) { OperFunc operFunc = new OperFunc(); operFunc.cnvcOperID = strOperID; operFunc.cnvcFuncCode = liOperFunction.Value; bool bIsAdd = true; if (dtHaveOperFunction.Rows.Count > 0) { foreach (DataRow drHaveOperFunction in dtHaveOperFunction.Rows) { //已有的不做操作 if (drHaveOperFunction["cnvcFuncCode"].ToString().Equals(liOperFunction.Value)) { bIsAdd = false; } } } if (bIsAdd) { SysManageFacade.AddOperFunc(operFunc, oper); } } else { //已有的取消了的删除 foreach (DataRow drHaveOperFunction in dtHaveOperFunction.Rows) { if (dtHaveOperFunction.Rows.Count > 0) { if (drHaveOperFunction["cnvcFuncCode"].ToString().Equals(liOperFunction.Value)) { OperFunc operFunc = new OperFunc(); operFunc.cnvcOperID = strOperID; operFunc.cnvcFuncCode = liOperFunction.Value; SysManageFacade.DeleteOperFunc(operFunc, oper); } } } } } Popup("权限修改成功!"); } catch (BusinessException bex) { Popup(bex.Message); } }
/// <summary> /// 执行登录 /// </summary> /// <returns></returns> public Oper Login(out ArrayList lstPurview, out ArrayList lstPage) { SqlConnection conn = ConnectionPool.BorrowConnection(); try { #region 取操作员实体 DataTable dtOper = OperAccess.GetOperByName(conn, strOperName); if (dtOper.Rows.Count > 1) { throw new BusinessException("操作员登录", "有同名操作员存在,登录失败!"); } // 取操作员实体 Oper operLogin = new Oper(dtOper); if (null == operLogin) { throw new BusinessException("操作员登录", "操作员不存在,登录失败!"); } if (!operLogin.cnbValidate) { throw new BusinessException("操作员登录", "账号已失效,登录失败!"); } if (operLogin.cnvcPwd != DataSecurity.Encrypt(strPassword)) { throw new BusinessException("操作员登录", "操作员密码不正确,登录失败!"); } #endregion #region 处理操作人员权限 // 处理操作人员权限 lstPurview = new ArrayList(); lstPage = new ArrayList(); DataTable dtOperFunc = OperFuncAccess.GetOneOperFuncList(conn, operLogin.cnnOperID.ToString()); foreach (DataRow row in dtOperFunc.Rows) { OperFunc operFunc = new OperFunc(row); lstPurview.Add(operFunc.cnvcFuncName); lstPage.Add(operFunc.cnvcFuncAddress); } #endregion #region 写登录日志 // 写登录日志 LoginLog loginLog = new LoginLog(); loginLog.cnvcOperName = strOperName; loginLog.cnvcIPAddress = strLoginIP; loginLog.cnvcBrowser = strBrowser; loginLog.cndLoginTime = DateTime.Now; EntityMapping.Create(loginLog, conn); #endregion return(operLogin); } finally { ConnectionPool.ReturnConnection(conn); } }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { foreach (TreeNode tnParent in treeView2.Nodes) { tnParent.Checked = false; } string strdeptsql = ""; string stropersql = ""; switch (Login.constApp.strCardType) { case "l6": strdeptsql = "select * from tbDeptFunc where cnnDeptID={0} and cnvcCardType in('l6','l6l8')"; stropersql = "select * from tbOperFunc where cnnOperID={0} and cnvcCardType in('l6','l6l8')"; break; case "l8": strdeptsql = "select * from tbDeptFunc where cnnDeptID={0} and cnvcCardType in('l8','l6l8')"; stropersql = "select * from tbOperFunc where cnnOperID={0} and cnvcCardType in('l8','l6l8')"; break; case "l6l8": strdeptsql = "select * from tbDeptFunc where cnnDeptID={0} and cnvcCardType in('l6','l8','l6l8')"; stropersql = "select * from tbOperFunc where cnnOperID={0} and cnvcCardType in('l6','l8','l6l8')"; break; } if (e.Node.Name.StartsWith("dept-")) { string deptid = e.Node.Name.Substring("dept-".Length); DataTable dt = Helper.Query(string.Format(strdeptsql, deptid));//("select * from tbDeptFunc where cnnDeptID=" + deptid+" and cnvcCardType='"+Login.constApp.strCardType+"'"); foreach (DataRow dr in dt.Rows) { DeptFunc df = new DeptFunc(dr); TreeNode[] tns = treeView2.Nodes.Find(df.cnvcFuncCode, true); if (tns.Length > 0) { for (int i = 0; i < tns.Length; i++) { tns[i].Checked = true; } } } } if (e.Node.Name.StartsWith("oper-")) { string operid = e.Node.Name.Substring("oper-".Length); DataTable dt = Helper.Query(string.Format(stropersql, operid));//("select * from tbOperFunc where cnnOperID=" + operid + " and cnvcCardType='" + Login.constApp.strCardType + "'"); foreach (DataRow dr in dt.Rows) { OperFunc of = new OperFunc(dr); TreeNode[] tns = treeView2.Nodes.Find(of.cnvcFuncCode, true); if (tns.Length > 0) { for (int i = 0; i < tns.Length; i++) { tns[i].Checked = true; } } } } }
//添加某个某个操作员的功能 public static int AddOperFunc(SqlTransaction trans, OperFunc operFunc) { return((int)EntityMapping.Create(operFunc, trans)); }
//删除某个某个操作员的功能 public static int DeleteOperFunc(SqlTransaction trans, OperFunc operFunc) { return(EntityMapping.Delete(operFunc, trans)); }
private void btnOK_Click(object sender, System.Web.UI.ImageClickEventArgs e) { try { //更新功能列表 if (rblOper.SelectedValue == "") { throw new BusinessException("tbOper", "请选择操作员!"); } string strOperID = rblOper.SelectedValue; //查询某操作员已具有的功能 DataTable dtHaveOperFunc = OperFacade.GetOneOperFuncList(strOperID); Dept curDept = Session[ConstValue.LOGIN_DEPT_SESSION] as Dept; Oper curOper = Session[ConstValue.LOGIN_USER_SESSION] as Oper; BusiLog busiLog = new BusiLog(); busiLog.cndOperDate = DateTime.Now; busiLog.cnvcOperName = curOper.cnvcOperName; busiLog.cnvcDeptID = curDept.cnvcDeptID; busiLog.cnvcDeptName = curDept.cnvcDeptName; busiLog.cnvcSource = "网站"; foreach (ListItem liOperFunc in cblFunctionList.Items) { if (liOperFunc.Selected) { OperFunc operFunc = new OperFunc(); operFunc.cnnOperID = int.Parse(strOperID); operFunc.cnvcFuncName = liOperFunc.Text; operFunc.cnvcFuncAddress = liOperFunc.Value; bool bIsAdd = true; if (dtHaveOperFunc.Rows.Count > 0) { foreach (DataRow drHaveOperFunc in dtHaveOperFunc.Rows) { //已有的不做操作 if (drHaveOperFunc["cnvcFuncName"].ToString().Equals(liOperFunc.Text)) { bIsAdd = false; } } } if (bIsAdd) { busiLog.cnnSerial = Guid.NewGuid(); busiLog.cnvcComments = "添加权限:" + operFunc.cnvcFuncName; busiLog.cnvcOperType = "BS009"; OperFacade.AddOperFunc(operFunc, busiLog); } } else { //已有的取消了的删除 foreach (DataRow drHaveOperFunc in dtHaveOperFunc.Rows) { if (dtHaveOperFunc.Rows.Count > 0) { if (drHaveOperFunc["cnvcFuncName"].ToString().Equals(liOperFunc.Text)) { OperFunc operFunc = new OperFunc(); operFunc.cnnOperID = int.Parse(strOperID); operFunc.cnvcFuncName = liOperFunc.Text; operFunc.cnvcFuncAddress = liOperFunc.Value; busiLog.cnnSerial = Guid.NewGuid(); busiLog.cnvcComments = "删除权限权限:" + operFunc.cnvcFuncName; busiLog.cnvcOperType = "BS010"; OperFacade.DeleteOperFunc(operFunc, busiLog); } } } } } foreach (ListItem liOperFunc in cblCSFunctionList.Items) { if (liOperFunc.Selected) { OperFunc operFunc = new OperFunc(); operFunc.cnnOperID = int.Parse(strOperID); operFunc.cnvcFuncName = liOperFunc.Text; operFunc.cnvcFuncAddress = liOperFunc.Value; bool bIsAdd = true; if (dtHaveOperFunc.Rows.Count > 0) { foreach (DataRow drHaveOperFunc in dtHaveOperFunc.Rows) { //已有的不做操作 if (drHaveOperFunc["cnvcFuncName"].ToString().Equals(liOperFunc.Text)) { bIsAdd = false; } } } if (bIsAdd) { busiLog.cnnSerial = Guid.NewGuid(); busiLog.cnvcComments = "添加权限:" + operFunc.cnvcFuncName; busiLog.cnvcOperType = "BS009"; OperFacade.AddOperFunc(operFunc, busiLog); } } else { //已有的取消了的删除 foreach (DataRow drHaveOperFunc in dtHaveOperFunc.Rows) { if (dtHaveOperFunc.Rows.Count > 0) { if (drHaveOperFunc["cnvcFuncName"].ToString().Equals(liOperFunc.Text)) { OperFunc operFunc = new OperFunc(); operFunc.cnnOperID = int.Parse(strOperID); operFunc.cnvcFuncName = liOperFunc.Text; operFunc.cnvcFuncAddress = liOperFunc.Value; busiLog.cnnSerial = Guid.NewGuid(); busiLog.cnvcComments = "删除权限权限:" + operFunc.cnvcFuncName; busiLog.cnvcOperType = "BS010"; OperFacade.DeleteOperFunc(operFunc, busiLog); } } } } } Popup("权限修改成功!"); } catch (BusinessException bex) { Popup(bex.Message); } }