Esempio n. 1
0
        private void btnRemove_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;
            }

            if (chs.strCardID != txtCardID.Text.Trim())
            {
                MessageBox.Show("充值撤消卡与首次刷卡不是同一张卡,充值撤消失败,请重试!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                this.ClearText();
                btnRead.Enabled = true;
                return;
            }
            else
            {
                #region 开始充值撤消
                if (this.txtFillSerial.Text.Trim() == "")
                {
                    MessageBox.Show("没有任何可以进行撤消的充值记录!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
                    return;
                }

                CMSMData.CMSMStruct.FillFeeStruct refill = new CMSMData.CMSMStruct.FillFeeStruct();
                refill.strAssID    = this.txtAssID.Text.Trim();
                refill.strCardID   = this.txtCardID.Text.Trim();
                refill.dFillFee    = Math.Round(-double.Parse(this.txtFillFee.Text.Trim()), 2);
                refill.dFillProm   = Math.Round(-double.Parse(this.txtPromFee.Text.Trim()), 2);
                refill.dFeeLast    = Math.Round(double.Parse(this.txtCurCharge.Text.Trim()), 2);
                refill.dFeeCur     = refill.dFillFee + refill.dFeeLast + refill.dFillProm;
                refill.strFillDate = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString();
                refill.strComments = "充值撤消,原流水号:" + this.txtFillSerial.Text.Trim();
                refill.strOperName = SysInitial.CurOps.strOperName;
                refill.strDeptID   = SysInitial.LocalDept;
                refill.strSerial   = this.txtFillSerial.Text.Trim();
                if (refill.dFeeCur < 0)
                {
                    MessageBox.Show("撤消后余额已经小于0,充值撤消失败,请检查是否已经有消费,再重试!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                    return;
                }

                chs.dCurCharge = refill.dFeeCur;
                double dCurChargeBak = System.Math.Round(double.Parse(txtCurCharge.Text.Trim()) - double.Parse(this.txtFillFee.Text.Trim()) - double.Parse(this.txtPromFee.Text.Trim()), 2);

                if (chs.dCurCharge != dCurChargeBak)
                {
                    MessageBox.Show("充值撤消失败,请重试!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                    clog.WriteLine("充值撤消备份值与计算值不等:备份值-- " + dCurChargeBak.ToString() + " 计算值-- " + chs.dCurCharge.ToString());
                    return;
                }

                err       = null;
                strresult = "";
                strresult = cs.AssFillRemove(refill, chs.iCurIg, dCurChargeBak, strOldDate, out err);
                if (strresult.Equals(CardCommon.CardDef.ConstMsg.RFOK) || strresult.Substring(0, 3) == "CMT")
                {
                    MessageBox.Show("充值撤消成功!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
                    clog.WriteLine(strresult);
                }
                else
                {
                    MessageBox.Show("充值撤消失败,本次充值撤消无效,请检查余额是否正确!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                    clog.WriteLine(err + "\n" + strresult);
                }
                this.ClearText();
                btnRead.Enabled        = true;
                this.btnRemove.Enabled = false;
                #endregion
            }
        }