Exemplo n.º 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 != "")
                {
                    strresult = this.GetColCh(strresult, "ERR");
                }
                MessageBox.Show("刷卡失败,请重试!", "系统提示", 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)
                {
                    string strAssState = assres.strAssState;
                    if (strAssState != "0")
                    {
                        MessageBox.Show("该会员已经失效,卡号:" + chs.strCardID + ",请核查!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                        return;
                    }

                    err = null;
                    DataSet dsout = cs.GetAssConsLast(assres.strCardID, out err);
                    if (dsout == null || err != null)
                    {
                        MessageBox.Show(err.Message, "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                        return;
                    }
                    else
                    {
#if !DEBUG
                        if (chs.dCurCharge != Math.Round(double.Parse(dsout.Tables["CurCharge"].Rows[0]["nFeeCur"].ToString()), 2))
                        {
                            MessageBox.Show("会员卡上当前余额与上次消费后余额不相符,不能撤消!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                            return;
                        }
                        else
                        {
#endif
                        txtAssID.Text     = assres.strAssID;
                        txtCurCharge.Text = chs.dCurCharge.ToString();
                        txtCardID.Text    = assres.strCardID;
                        txtAssName.Text   = assres.strAssName;

                        this.txtBillNo.Text   = dsout.Tables["Bill"].Rows[0]["iSerial"].ToString();
                        this.txtConsFee.Text  = dsout.Tables["Bill"].Rows[0]["nPay"].ToString();
                        this.txtConsDate.Text = dsout.Tables["Bill"].Rows[0]["dtTime"].ToString();

                        this.dataGrid1.SetDataBinding(dsout.Tables["ConsItem"], "");
                        this.EnToCh("商品编号,商品名称,单价,数量,折扣金额,实收金额", "80,130,70,50,60,70", dsout.Tables["ConsItem"], this.dataGrid1);

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