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 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);
        }
Beispiel #3
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);
            //}
        }