public int UpdatePwd(Oper oper, BusiLog busiLog) { //SqlConnection conn = ConnectionPool.BorrowConnection(); int iRet = 0; using (SqlConnection conn = ConnectionPool.BorrowConnection()) { //conn.Open(); SqlTransaction trans = conn.BeginTransaction(); try { iRet = OperAccess.UpdatePwd(trans, oper); 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 DataTable GetAllOperNoAdmin() { SqlConnection conn = ConnectionPool.BorrowConnection(); DataTable dtRet = null; try { dtRet = OperAccess.GetAllOperNoAdmin(conn); } finally { ConnectionPool.ReturnConnection(conn); } return(dtRet); }
public Oper GetOper(Oper oper) { SqlConnection conn = ConnectionPool.BorrowConnection(); Oper OldOper = null; try { OldOper = OperAccess.GetOper(conn, oper); } finally { ConnectionPool.ReturnConnection(conn); } return(OldOper); }
public int AddOper(Oper oper, BusiLog busiLog) { int iRet = 0; using (SqlConnection conn = ConnectionPool.BorrowConnection()) { //conn.Open(); SqlTransaction trans = conn.BeginTransaction(); try { iRet = OperIDAccess.GetOperID(trans); oper.cnnOperID = iRet; oper.cnvcPwd = DataSecurity.Encrypt(oper.cnvcPwd); OperAccess.AddOper(trans, oper); 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); }
/// <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); } }