Exemple #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.txtBillNo.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.txtConsFee.Text.Trim()), 2);
                refill.dFillProm = 0;
                refill.dFeeLast  = Math.Round(double.Parse(this.txtCurCharge.Text.Trim()), 2);
                refill.dFeeCur   = refill.dFillFee + refill.dFeeLast;
                DateTime dtNow = DateTime.Now;
                refill.iSerial     = Int64.Parse(dtNow.ToString("yyyyMMddHHmmss"));
                refill.strFillDate = dtNow.ToShortDateString() + " " + dtNow.ToLongTimeString();
                refill.strComments = "消费撤消,原小票号:" + this.txtBillNo.Text.Trim();
                refill.strOperName = SysInitial.CurOps.strOperName;
                refill.strDeptID   = SysInitial.LocalDept;


                chs.dCurCharge = refill.dFeeCur;
                double dCurChargeBak = System.Math.Round((double.Parse(txtConsFee.Text.Trim()) + double.Parse(txtCurCharge.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.AssConsRemove(this.txtBillNo.Text.Trim(), refill, chs.iCurIg, dCurChargeBak, 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;
                DataTable dtConsItem = new DataTable();
                dtConsItem.Columns.Add("GoodsID");
                dtConsItem.Columns.Add("GoodsName");
                dtConsItem.Columns.Add("Price");
                dtConsItem.Columns.Add("Count");
                dtConsItem.Columns.Add("Rate");
                dtConsItem.Columns.Add("Fee");
                dtConsItem.Columns.Add("Comments");
                dtConsItem.Columns["Comments"].DefaultValue = "";
                this.dataGrid1.SetDataBinding(dtConsItem, "");
                this.EnToCh("商品编号,商品名称,单价,数量,折扣金额,应收金额", "80,130,70,50,60,70", dtConsItem, this.dataGrid1);
                #endregion
            }
        }