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);
            }
        }
        private void ultraButton1_Click(object sender, EventArgs e)
        {
            this.txtMemberCardNo.Enabled = false;
            this.ultraButton2.Text       = "输入卡号";
            CardM1 m1        = new CardM1();
            string strCardNo = "";
            string strRet    = m1.ReadCard(out strCardNo);//,out dtemp,out itemp);

            if (strRet != ConstMsg.RFOK)
            {
                throw new BusinessException("卡操作失败", "读取会员卡失败!");
            }
            if (strCardNo.Length > 6)
            {
                throw new BusinessException("刷卡签到", "请放入一通卡");
            }
            //string strCardNo = "123465";// "00201346";
            this.btnQuery_Click(strCardNo);
        }
        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 OperCardCallBack(string strOperName)
        {
            string strRet3 = "";

            try
            {
                conn  = ConnectionPool.BorrowConnection();
                trans = conn.BeginTransaction();
                CardM1 m1        = new CardM1();
                string strCardNo = "";
                string strRet    = m1.ReadCard(out strCardNo);             //,out dtemp,out itemp);

                if (strRet != ConstMsg.RFOK)
                {
                    strRet3 += " 读卡失败";
                }
                DataTable dtOper = SqlHelper.ExecuteDataTable(trans, CommandType.Text, "select * from tbOper where cnvcCardNo is not null and cnvcCardNo='" + strCardNo + "'");

                if (dtOper.Rows.Count == 0)
                {
                    strRet3 += " 操作员不存在";
                }
                else
                {
                    Oper oldOper = new Oper(dtOper);
                    oldOper.cnvcCardNo = "";
                    EntityMapping.Update(oldOper, trans);
                    //流水
                    SeqSerialNo serial = new SeqSerialNo();
                    serial.cnvcFill = "0";
                    decimal dSerialNo = EntityMapping.Create(serial, trans);

                    //操作日志
                    OperLog operLog = new OperLog();
                    operLog.cnnSerialNo  = dSerialNo;
                    operLog.cnvcOperName = strOperName;                    //member.cnvcOperName;
                    operLog.cndOperDate  = DateTime.Now;
                    operLog.cnvcOperFlag = ConstApp.Oper_Flag_OperInCallBack;
                    EntityMapping.Create(operLog, trans);
                }
                trans.Commit();
                string strRet2 = m1.RecycleCard();
                if (strRet != ConstMsg.RFOK)
                {
                    strRet3 += " 操作员卡回收失败";
                }
            }
            catch (BusinessException bex)             //业务异常
            {
                //事务回滚
                trans.Rollback();
                //LogAdapter.WriteBusinessException(bex);
                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);
            }
            return(strRet3);
        }
        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);
        }
Beispiel #6
0
        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);
            //}
        }