Esempio n. 1
0
        private void sbtnFill_Click(object sender, System.EventArgs e)
        {
            string strCardID = txtCardID.Text.Trim();

            if (strCardID == "")
            {
                MessageBox.Show("会员卡号不可为空且小于10位,请重新填写会员卡号!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                txtCardID.Focus();
                return;
            }
            if (txtFillFee.Text.Trim() == "")
            {
                MessageBox.Show("充值金额不可为空,请重新输入!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                return;
            }
            double dFee = Double.Parse(txtFillFee.Text.Trim());

            if (dFee <= 0)
            {
                MessageBox.Show("充值金额应大于0,请重新输入!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                return;
            }
            else
            {
                System.Windows.Forms.DialogResult diaRes = MessageBox.Show("是否确定充值" + dFee.ToString() + "元?", "请确认", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question);
                if (diaRes.Equals(System.Windows.Forms.DialogResult.Yes))
                {
                    err = null;
                    double dFeeLast = Double.Parse(txtCharge.Text.Trim());
                    CMSMStruct.FillFeeStruct ffs = new CMSMData.CMSMStruct.FillFeeStruct();
                    ffs.strAssID  = txtAssID.Text.Trim();
                    ffs.strCardID = strCardID;
                    ffs.dFillFee  = dFee;
                    string promrate = "0";
                    ffs.dFillProm = (double.Parse(txtFillFee.Text.Trim()) * (double.Parse(promrate)) / 100);
                    ffs.dFeeLast  = dFeeLast;
                    ffs.dFeeCur   = System.Math.Round((dFee + ffs.dFillProm + dFeeLast), 2);
                    ffs.strDeptID = SysInitial.CurOps.strDeptID;
                    DateTime dtNow = DateTime.Now;
                    ffs.iSerial     = Int64.Parse(dtNow.ToString("yyyyMMddHHmmss"));
                    ffs.strFillDate = dtNow.ToShortDateString() + " " + dtNow.ToLongTimeString();
                    double dChargeBak = Double.Parse(txtCharge.Text.Trim()) + Double.Parse(txtFillFee.Text.Trim()) + Double.Parse(txtPromFee.Text.Trim());
                    if (ffs.dFeeCur != dChargeBak)
                    {
                        MessageBox.Show("充值失败,请重试!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                        clog.WriteLine("充值备份值与计算值不等:备份值-" + dChargeBak.ToString() + " 计算值" + ffs.dFeeCur.ToString());
                        return;
                    }

                    string strresult = cs.FillFeeError(ffs, chs.iCurIg, dChargeBak, 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);
                        lblerr.Text    = "充值失败,本次充值无效,请检查余额是否正确!";
                        lblerr.Visible = true;
                        clog.WriteLine(err);
                        clog.WriteLine(strresult);
                    }
                    this.ClearText();
                    txtCardID.ReadOnly    = true;
                    this.sbtnFill.Enabled = false;
                    this.sbtnRead.Enabled = true;
                }
            }
        }