Exemple #1
0
        private void btnRead_Click(object sender, System.EventArgs e)
        {
            Ping      ping = new Ping();
            PingReply pr   = ping.Send("10.10.10.203");

            if (pr.Status != IPStatus.Success)
            {
                MessageBox.Show("童鞋,挂失失败!vpn掉线了或者网速太慢!,请检查vpn连接!");
                return;
            }
            string strresult = "";

            CMSMStruct.CardHardStruct chs = cs.ReadCardInfo("", out strresult);
            if (!strresult.Equals(CardCommon.CardDef.ConstMsg.RFOK))
            {
                if (strresult == CardCommon.CardDef.ConstMsg.RFAUTHENTICATION_A_ERR)
                {
                    MessageBox.Show("该卡不属于本系统使用的卡,请检查!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                    return;
                }
                if (strresult.Substring(0, 2) == "RF")
                {
                    MessageBox.Show("刷卡失败,请重试!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("刷卡失败,请重试!\n" + strresult, "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                }
                if (strresult != null)
                {
                    clog.WriteLine(strresult);
                }
                return;
            }
            if (chs.strCardID == "")
            {
                MessageBox.Show("会员卡号不正确,请重试!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                return;
            }
            else if (chs.strCardID.Substring(0, 1) == "F")
            {
                MessageBox.Show("此卡为员工卡,不可进行充值撤消!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                return;
            }
            else
            {
                err = null;
                CMSMData.CMSMStruct.AssociatorStruct assres = new CMSMData.CMSMStruct.AssociatorStruct();
                assres = cs.GetAssociatorName(chs.strCardID, out err);
                if (assres != null)
                {
                    DataRow[] drn = SysInitial.dsSys.Tables["AS"].Select("vcCommCode='" + assres.strAssState + "'");
                    if (drn == null || drn.Length == 0)
                    {
                        MessageBox.Show("会员状态参数错误,请检查参数或重新启动系统!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                        return;
                    }
                    else
                    {
                        string strAssState = drn[0]["vcCommName"].ToString();
                        if (assres.strAssState != "0")
                        {
                            MessageBox.Show("该会员已经失效,卡号:" + chs.strCardID + ",现处于“" + strAssState + "”状态,请核查!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                            return;
                        }
                    }

                    err = null;
                    DataTable dtFillFee = cs.GetAssFillLast(assres.strCardID, out err);
                    if (dtFillFee == null || err != null)
                    {
                        MessageBox.Show(err.Message, "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                        return;
                    }
                    else
                    {
                        txtAssID.Text     = assres.strAssID;
                        txtCurCharge.Text = dtFillFee.Rows[0]["nFeeCur"].ToString();
                        txtCardID.Text    = assres.strCardID;
                        txtAssName.Text   = assres.strAssName;

                        this.txtFillSerial.Text = dtFillFee.Rows[0]["iSerial"].ToString();
                        this.txtFillFee.Text    = dtFillFee.Rows[0]["nFillFee"].ToString();
                        this.txtFillDate.Text   = dtFillFee.Rows[0]["dtFillDate"].ToString();
                        this.txtPromFee.Text    = dtFillFee.Rows[0]["nFillProm"].ToString();
                        strOldDate = dtFillFee.Rows[0]["dtFillDate"].ToString();

                        btnRead.Enabled        = false;
                        this.btnRemove.Enabled = true;
                    }
                }
                else
                {
                    MessageBox.Show("无会员资料,请与管理员联系!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                    if (err != null)
                    {
                        clog.WriteLine(err);
                    }
                    return;
                }
            }
        }