public void AddCard(Oper opers)
        {
            try
            {
                conn = ConnectionPool.BorrowConnection();

                trans = conn.BeginTransaction();

                DataTable dtOper = SqlHelper.ExecuteDataTable(trans, CommandType.Text, "select * from tbOper where cnvcCardNo is not null and cnvcCardNo = 'aaa" + opers.cnvcCardNo + "'");
                if (dtOper.Rows.Count > 0)
                {
                    throw new BusinessException("操作员管理", "操作员卡号已存在!");
                }
                CardM1 m1        = new CardM1();
                string strReturn = m1.PutOutCard("aaa" + opers.cnvcCardNo);
                if (strReturn.Equals("OPSUCCESS"))
                {
                    SqlHelper.ExecuteNonQuery(trans, CommandType.Text, "update tbOper set cnvcCardNo = 'aaa" + opers.cnvcCardNo + "' where cnnOperID=" + opers.cnnOperID.ToString());
                    trans.Commit();
                }
                else
                {
                    throw new BusinessException("卡操作异常", strReturn);
                }
            }
            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 AddOper(Oper opers)
        {
            try
            {
                conn = ConnectionPool.BorrowConnection();

                trans = conn.BeginTransaction();
                DataTable dtOper = SqlHelper.ExecuteDataTable(trans, CommandType.Text, "select * from tbOper where cnvcOperName = '" + opers.cnvcOperName + "'");
                if (dtOper.Rows.Count > 0)
                {
                    throw new BusinessException("操作员管理", "操作员已存在!");
                }
                if (opers.cnvcCardNo.Length > 0)
                {
                    DataTable dtCard = SqlHelper.ExecuteDataTable(trans, CommandType.Text, "select * from tbOper where cnvcCardNo = 'aaa" + opers.cnvcCardNo + "'");
                    if (dtCard.Rows.Count > 0)
                    {
                        throw new BusinessException("操作员管理", "操作员卡号已存在!");
                    }
                    CardM1 m1        = new CardM1();
                    string strReturn = m1.PutOutCard("aaa" + opers.cnvcCardNo);
                    if (strReturn.Equals("OPSUCCESS"))
                    {
                        opers.cnvcCardNo = "aaa" + opers.cnvcCardNo;
                        EntityMapping.Create(opers, trans);
                        trans.Commit();
                    }
                    else
                    {
                        throw new BusinessException("卡操作异常", strReturn);
                    }
                }
                else
                {
                    EntityMapping.Create(opers, 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 string CreateUser(Oper oper)
        {
            string password = oper.cnvcPwd;
            string username = oper.cnvcOperName;

            if (!SecUtility.ValidateParameter(ref password, true, true, false, 128))
            {
                return(MyMembershipCreateStatus.InvalidPassword);
            }

            //string salt = GenerateSalt();
            string pass = EncodePassword(oper.cnvcPwd);

            if (pass.Length > 128)
            {
                return(MyMembershipCreateStatus.InvalidPassword);
            }

            if (!SecUtility.ValidateParameter(ref username, true, true, true, 256))
            {
                return(MyMembershipCreateStatus.InvalidUserName);
            }

            if (oper.cnvcPwd.Length < MinRequiredPasswordLength)
            {
                return(MyMembershipCreateStatus.InvalidPassword);
            }

            int count = 0;

            for (int i = 0; i < oper.cnvcPwd.Length; i++)
            {
                if (!char.IsLetterOrDigit(oper.cnvcPwd, i))
                {
                    count++;
                }
            }

            if (count < MinRequiredNonAlphanumericCharacters)
            {
                return(MyMembershipCreateStatus.InvalidPassword);
            }

            if (PasswordStrengthRegularExpression.Length > 0)
            {
                if (!Regex.IsMatch(oper.cnvcPwd, PasswordStrengthRegularExpression))
                {
                    return(MyMembershipCreateStatus.InvalidPassword);
                }
            }
            oper.cnvcPwd = pass;
            DataTable dtOper = SqlHelper.ExecuteDataTable(CommandType.Text, "select * from tbOper where cnvcOperName = '" + oper.cnvcOperName + "'");

            if (dtOper.Rows.Count > 0)
            {
                return(MyMembershipCreateStatus.DuplicateUserName);
            }
            if (oper.cnvcCardNo.Length > 0)
            {
                DataTable dtCard = SqlHelper.ExecuteDataTable(CommandType.Text, "select * from tbOper where cnvcCardNo = 'aaa" + oper.cnvcCardNo + "'");
                if (dtCard.Rows.Count > 0)
                {
                    return(MyMembershipCreateStatus.DuplicateCardNo);
                }
                CardM1 m1        = new CardM1();
                string strReturn = m1.PutOutCard("aaa" + oper.cnvcCardNo);
                if (strReturn.Equals("OPSUCCESS"))
                {
                    oper.cnvcCardNo = "aaa" + oper.cnvcCardNo;
                    EntityMapping.Create(oper);
                }
                else
                {
                    return(MyMembershipCreateStatus.CardOperException);
                }
            }
            else
            {
                EntityMapping.Create(oper);
            }

            return(MyMembershipCreateStatus.Success);
        }