private void btnConfirmRefund_Click(object sender, EventArgs e) { bool resUkey = base.CheckUKey(); if (!resUkey) { return; } if (base._CurrentCardInfo == null) { this.ShowWarningMessage("请重新读卡。"); btnRead.Focus(); return; } if (string.IsNullOrEmpty(tbxRefundMoney.Text.Trim())) { this.ShowWarningMessage("请输入退款金额。"); tbxRefundMoney.Focus(); tbxRefundMoney.SelectAll(); return; } decimal fRefund; #region 处理退款金额 bool res = decimal.TryParse(tbxRefundMoney.Text.Trim(), out fRefund); if (!res) { this.ShowWarningMessage("请检查退款金额的格式。"); tbxRefundMoney.Focus(); tbxRefundMoney.SelectAll(); return; } if (fRefund <= 0) { this.ShowWarningMessage("退款金额需大于0,请重新输入。"); tbxRefundMoney.Focus(); tbxRefundMoney.SelectAll(); return; } else if (fRefund > Common.DefineConstantValue.MaxRechargeVal) { this.ShowWarningMessage("充值金额不能大于" + Common.DefineConstantValue.MaxRechargeVal.ToString() + ",请重新输入。"); tbxRefundMoney.Focus(); tbxRefundMoney.SelectAll(); return; } #endregion if (string.IsNullOrEmpty(tbxDesc.Text)) { ShowWarningMessage("请先输入退款原因。"); tbxDesc.Focus(); tbxDesc.SelectAll(); return; } decimal fPreCost = decimal.Zero; if (ckbPreCost.Checked) { fPreCost = decimal.Parse(labPreCost.Text); } dlgConfirmInfo dlg = new dlgConfirmInfo(); dlg.CardInfo = base._CurrentCardInfo; dlg.IsPrinted = cbxPrint.Checked; dlg.RefundMoney = fRefund; dlg.UserInfo = base._CurrentCardUserInfo; dlg.PreCostMoney = fPreCost; dlg.IsPrinted = cbxPrint.Checked; if (dlg.ShowDialog() == DialogResult.OK) { //卡信息再次验证 ConsumeCardInfo chkCardInfo = this._Reader.ReadCardInfo(base._CardInfoSection, base._SectionPwd); if (chkCardInfo == null || (chkCardInfo != null && chkCardInfo.CardSourceID != base._CurrentCardInfo.CardSourceID)) { this.ShowWarningMessage("卡片信息已变更,请重新读卡后操作。"); resetAllControls(); return; } this.Cursor = Cursors.WaitCursor; try { fRefund = fRefund - Math.Abs(fPreCost);//实际退款金额 = 用户键入的退款额 - 需交付的欠款额 //先进行物理卡充值 ReturnValueInfo rvInfo = this._Reader.Recharge(base._CardInfoSection, base._SectionPwd, fRefund); if (rvInfo.boolValue && !rvInfo.isError) { RechargeRecord_rcr_Info rechargeRecord = new RechargeRecord_rcr_Info(); #region 填充实体 rechargeRecord.rcr_cRecordID = Guid.NewGuid(); rechargeRecord.rcr_cUserID = this._CurrentCardUserInfo.cus_cRecordID; rechargeRecord.rcr_cCardID = chkCardInfo.CardSourceID; rechargeRecord.rcr_cRechargeType = DefineConstantValue.ConsumeMoneyFlowType.Refund_CardPersonalRealTime.ToString(); rechargeRecord.rcr_cStatus = DefineConstantValue.ConsumeMoneyFlowStatus.Finished.ToString(); rechargeRecord.rcr_dRechargeTime = DateTime.Now; rechargeRecord.rcr_fRechargeMoney = fRefund; rechargeRecord.rcr_fBalance = base._CurrentCardInfo.CardBalance + fRefund;//退款后卡余额 = 当前卡余额 + 退款金额 rechargeRecord.PreCostMoney = fPreCost;//未结算的欠款 rechargeRecord.rcr_cDesc = tbxDesc.Text; rechargeRecord.rcr_cAdd = this.UserInformation.usm_cUserLoginID; rechargeRecord.rcr_cLast = rechargeRecord.rcr_cAdd; rechargeRecord.rcr_dLastDate = rechargeRecord.rcr_dRechargeTime; rechargeRecord.IsNeedSyncAccount = ckbPreCost.Checked; #endregion //卡退款成功后,将退款信息写入充值记录表 rvInfo = this._IRechargeRecordBL.InsertRechargeRecord(rechargeRecord); if (rvInfo.boolValue && !rvInfo.isError) { //成功录入退款记录后提示成功 this.Cursor = Cursors.Default; this.ShowInformationMessage("退款成功。" + Environment.NewLine + "退款用户:" + this._CurrentCardUserInfo.cus_cChaName + ",退款金额:" + fRefund.ToString() + "元"); if (cbxPrint.Checked) { RechargeDetail rdInfo = new RechargeDetail(); //rdInfo.CardNo = Int32.Parse(this.labCardNo.Text); rdInfo.OperationTime = System.DateTime.Now; rdInfo.Operator = this.UserInformation.usm_cUserLoginID; rdInfo.RechargeValue = fRefund; rdInfo.UserName = this.labUserName.Text; rdInfo.ClassName = this.labClassName.Text; //打印小票 PrintTicket(rdInfo); } resetAllControls(); btnRead.Focus(); return; } else { ShowErrorMessage("上传充值记录失败,需要进行回滚扣费,请摆放好卡片后,点击确定。"); ConsumeCardInfo cardInfoRollback = this._Reader.ReadCardInfo(base._CardInfoSection, base._SectionPwd); if (cardInfoRollback.CardSourceID != chkCardInfo.CardSourceID) { ShowWarningMessage("卡片信息不符合,请核对后重新放卡,原卡片卡号为:" + chkCardInfo.CardNo.ToString() + ",卡信息为:" + chkCardInfo.Name); cardInfoRollback = this._Reader.ReadCardInfo(base._CardInfoSection, base._SectionPwd); if (cardInfoRollback.CardSourceID == chkCardInfo.CardSourceID) { //录入退款记录失败,则需要将原先充入的卡金额扣除,如果卡已被取走,则需等待后台自动同步金额 rvInfo = this._Reader.Recharge(base._CardInfoSection, base._SectionPwd, fRefund * -1); if (rvInfo.boolValue && !rvInfo.isError) { ShowInformationMessage("回滚扣费成功,可重新进行充值。"); return; } else { ShowWarningMessage("回滚扣费失败,请联系系统管理员处理问题卡片。"); } } else { ShowWarningMessage("核对信息失败,请联系系统管理员处理问题卡片。"); } } else { rvInfo = this._Reader.Recharge(base._CardInfoSection, base._SectionPwd, fRefund * -1); if (rvInfo.boolValue && !rvInfo.isError) { ShowInformationMessage("回滚扣费成功,可重新进行充值。"); return; } else { ShowWarningMessage("回滚扣费失败,请联系系统管理员处理问题卡片。"); } } resetAllControls(); this.Cursor = Cursors.Default; this.ShowInformationMessage("实时卡退款失败。" + rvInfo.messageText); btnRead.Focus(); return; } } else { resetAllControls(); this.Cursor = Cursors.Default; this.ShowInformationMessage("实时卡退款失败。" + rvInfo.messageText); btnRead.Focus(); return; } } catch (Exception ex) { this.Cursor = Cursors.Default; this.ShowErrorMessage("退款失败。" + Environment.NewLine + ex); btnRead.Focus(); return; } } }
private void btnConfirmRefund_Click(object sender, EventArgs e) { bool resUkey = base.CheckUKey(); if (!resUkey) { return; } if (string.IsNullOrEmpty(tbxRefundMoney.Text.Trim())) { this.ShowWarningMessage("请输入退款金额。"); tbxRefundMoney.Focus(); return; } decimal fRefund; bool res = decimal.TryParse(tbxRefundMoney.Text.Trim(), out fRefund); if (!res) { this.ShowWarningMessage("请检查退款金额的格式。"); tbxRefundMoney.Focus(); return; } if (fRefund <= 0) { this.ShowWarningMessage("退款金额需大于0,请重新输入。"); tbxRefundMoney.Focus(); return; } else if (fRefund > Common.DefineConstantValue.MaxRechargeVal) { this.ShowWarningMessage("退款金额不能大于" + Common.DefineConstantValue.MaxRechargeVal.ToString() + ",请重新输入。"); tbxRefundMoney.Focus(); tbxRefundMoney.SelectAll(); return; } //帐号余额 ConsumeCardInfo ccInfo = new ConsumeCardInfo(); ccInfo.CardBalance = decimal.Parse(this.labAccountBalance.Text); //查卡号 UserCardPair_ucp_Info ucpInfo = new UserCardPair_ucp_Info(); ucpInfo.ucp_cCUSID = this._CurrentUser.cus_cRecordID; List<UserCardPair_ucp_Info> ucpList = _IUserCardPairBL.SearchRecords(ucpInfo); if (ucpList != null && ucpList.Count > 0) { ucpList = ucpList.OrderBy(p => p.ucp_dAddDate).ToList(); ccInfo.CardNo = ucpList[0].ucp_iCardNo.ToString(); } else { if (MessageBox.Show("该用户未发卡,确认继续进行操作?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { } else { return; } } dlgConfirmInfo dlg = new dlgConfirmInfo(); dlg.RefundMoney = fRefund; dlg.UserInfo = this._CurrentUser; dlg.PreCostMoney = computePreCost(this._CurrentUser.cus_cRecordID); dlg.CardInfo = ccInfo; dlg.IsPrinted = cbxPrint.Checked; dlg.IsSkipPreCost = true; if (dlg.ShowDialog() == DialogResult.OK) { this.Cursor = Cursors.WaitCursor; try { PreRechargeRecord_prr_Info preRechargeInfo = new PreRechargeRecord_prr_Info(); preRechargeInfo.prr_cAdd = base.UserInformation.usm_cUserLoginID; preRechargeInfo.prr_cLast = base.UserInformation.usm_cUserLoginID; preRechargeInfo.prr_cRechargeType = Common.DefineConstantValue.ConsumeMoneyFlowType.Refund_PersonalTransfer.ToString(); preRechargeInfo.prr_cRecordID = Guid.NewGuid(); preRechargeInfo.prr_cStatus = Common.DefineConstantValue.ConsumeMoneyFlowStatus.WaitForAcceptTransfer.ToString(); preRechargeInfo.prr_cUserID = this._CurrentUser.cus_cRecordID; preRechargeInfo.prr_dRechargeTime = DateTime.Now; preRechargeInfo.prr_fRechargeMoney = fRefund; ReturnValueInfo rvInfo = this._IPreRechargeRecordBL.Save(preRechargeInfo, Common.DefineConstantValue.EditStateEnum.OE_Insert); if (rvInfo.boolValue && !rvInfo.isError) { base.ShowInformationMessage("转账成功,请通知卡用户进行退款确认。"); if (cbxPrint.Checked) { RechargeDetail rdInfo = new RechargeDetail(); //rdInfo.CardNo = Int32.Parse(this.labCardNo.Text); rdInfo.OperationTime = System.DateTime.Now; rdInfo.Operator = this.UserInformation.usm_cUserLoginID; rdInfo.RechargeValue = fRefund; rdInfo.UserName = this.labUserName.Text; rdInfo.ClassName = this.labClassName.Text; //打印小票 PrintTicket(rdInfo); } } else { base.ShowErrorMessage("转账失败。" + rvInfo.messageText); } } catch (Exception ex) { this.Cursor = Cursors.Default; this.ShowErrorMessage(ex); } ResetAllControls(); this.Cursor = Cursors.Default; } }
/// <summary> /// 打印小票 /// </summary> /// <param name="rdInfo"></param> private void PrintTicket(RechargeDetail rdInfo) { List<RechargeDetail> rdList = new List<RechargeDetail>(); rdList.Add(rdInfo); LocalReport lr = new LocalReport(); ReportDataSource rds = new ReportDataSource("RechargeDetail", rdList); lr.ReportPath = DefineConstantValue.ReportFileBasePath + @"RechargeTicket.rdlc"; lr.DataSources.Add(rds); string printName = ConfigurationSettings.AppSettings["TicketPrintName"]; TicketPrint tp = new TicketPrint(); tp.PrintTicket(lr, printName); }
private void btnConfirmRecharge_Click(object sender, EventArgs e) { bool resUkey = base.CheckUKey(); if (!resUkey) { return; } if (base._CurrentCardInfo == null) { this.ShowWarningMessage("请重新读卡。"); btnRead.Focus(); return; } if (string.IsNullOrEmpty(tbxRechargeMoney.Text.Trim())) { this.ShowWarningMessage("请输入充值金额。"); tbxRechargeMoney.Focus(); tbxRechargeMoney.SelectAll(); return; } decimal fRecharge;//实际充值金额 #region 检查实际充值金额 bool res = decimal.TryParse(tbxRechargeMoney.Text.Trim(), out fRecharge); if (!res) { this.ShowWarningMessage("请检查充值金额的格式。"); tbxRechargeMoney.Focus(); tbxRechargeMoney.SelectAll(); return; } if (fRecharge <= 0) { this.ShowWarningMessage("充值金额需大于0,请重新输入。"); tbxRechargeMoney.Focus(); tbxRechargeMoney.SelectAll(); return; } else if (fRecharge > Common.DefineConstantValue.MaxRechargeVal) { this.ShowWarningMessage("充值金额不能大于" + Common.DefineConstantValue.MaxRechargeVal.ToString() + ",请重新输入。"); tbxRechargeMoney.Focus(); tbxRechargeMoney.SelectAll(); return; } #endregion decimal fPreCost;//当次欠费,显示为负数 #region 检查当次欠费 bool resPreCost = decimal.TryParse(labPreCost.Text, out fPreCost); if (!resPreCost) { this.ShowWarningMessage("充值金额需大于0,请重新输入。"); btnRead.Focus(); return; } #endregion if (base._CurrentCardInfo == null) { ShowWarningMessage("原卡信息异常,请重新读卡确认。"); btnRead.Focus(); return; } if (this._CurrentPairInfo == null) { ShowWarningMessage("卡信息异常,请重新读卡确认。"); btnRead.Focus(); return; } if (base._CurrentCardUserInfo == null) { ShowWarningMessage("卡用户信息异常,请重新读卡确认"); btnRead.Focus(); return; } decimal fAdvanceMoney = decimal.Zero; RechargeRecord_rcr_Info searchAdvance = new RechargeRecord_rcr_Info(); //searchAdvance.rcr_cCardID = this._CurrentCardInfo.CardSourceID; searchAdvance.rcr_cUserID = this._CurrentCardUserInfo.cus_cRecordID; searchAdvance.rcr_cRechargeType = Common.DefineConstantValue.ConsumeMoneyFlowType.Recharge_AdvanceMoney.ToString(); RechargeRecord_rcr_Info advanceRecharge = this._IRechargeRecordBL.SearchRecords(searchAdvance).FirstOrDefault(); if (advanceRecharge != null) { fAdvanceMoney = advanceRecharge.rcr_fRechargeMoney; } //确认页面 dlgConfirmInfo dlg = new dlgConfirmInfo(); dlg.CardInfo = base._CurrentCardInfo; dlg.UserInfo = base._CurrentCardUserInfo; dlg.IsPrinted = cbxPrint.Checked; dlg.RechargeMoney = fRecharge; dlg.AdvanceMoney = fAdvanceMoney; if (ckbIsSyncUnPay.Checked) { dlg.PreCostMoney = fPreCost; } else { dlg.PreCostMoney = decimal.Zero; } if (dlg.ShowDialog() == DialogResult.OK) { this.Cursor = Cursors.WaitCursor; decimal fRechargeDeduct = decimal.Zero; if (ckbIsSyncUnPay.Checked) { fRechargeDeduct = fRecharge + fPreCost;//已经扣除的预付款数据 if (fRechargeDeduct < fRecharge) fPreCost = Math.Abs(fPreCost); else fPreCost = 0; } else { fRechargeDeduct = fRecharge; fPreCost = 0; } //卡信息再次验证 ConsumeCardInfo cardInfo = this._Reader.ReadCardInfo(base._CardInfoSection, base._SectionPwd); #region 卡片信息再次验证 if (cardInfo == null) { ShowWarningMessage("充值失败。" + Environment.NewLine + "无法确认充值卡信息,请重新读卡再试。"); this.Cursor = Cursors.Default; return; } if (cardInfo.CardSourceID != dlg.CardInfo.CardSourceID) { ShowWarningMessage("充值失败。" + Environment.NewLine + "充值卡信息已变更,请重新读卡再试。"); this.Cursor = Cursors.Default; return; } #endregion //修正卡显示资料 #region 修正卡显示资料 try { string strOldCardName = cardInfo.Name.Trim(); string strCurrentCardName = (this._CurrentPairInfo.CardOwner.ClassInfo.GradeInfo.gdm_cAbbreviation + this._CurrentPairInfo.CardOwner.cus_cChaName).Trim(); if (strOldCardName != strCurrentCardName) { ConsumeCardInfo changeCardInfo = new ConsumeCardInfo(); changeCardInfo.CardBalance = this._CurrentCardInfo.CardBalance; changeCardInfo.CardNo = this._CurrentCardInfo.CardNo; changeCardInfo.CardPwd = this._CurrentCardInfo.CardPwd; changeCardInfo.CardSourceID = this._CurrentCardInfo.CardSourceID; changeCardInfo.CardBalance = this._CurrentCardInfo.CardBalance; changeCardInfo.Name = strCurrentCardName; //年级信息发生变更,修改对应信息 ReturnValueInfo rvChangeCardInfo = this._Reader.WriteCardInfo(base._CardInfoSection, base._SectionPwd, changeCardInfo); } } catch (Exception) { } #endregion //先进行【卡物理充值】 ReturnValueInfo rvInfo = this._Reader.Recharge(base._CardInfoSection, base._SectionPwd, fRechargeDeduct); if (rvInfo.boolValue && !rvInfo.isError) { //卡物理充值成功,继续进行充值记录上传操作 RechargeRecord_rcr_Info rechargeRecord = new RechargeRecord_rcr_Info(); #region 实体赋值 rechargeRecord.rcr_cRecordID = Guid.NewGuid(); rechargeRecord.rcr_cCardID = cardInfo.CardSourceID; rechargeRecord.rcr_cRechargeType = DefineConstantValue.ConsumeMoneyFlowType.Recharge_PersonalRealTime.ToString(); rechargeRecord.rcr_cStatus = DefineConstantValue.ConsumeMoneyFlowStatus.Finished.ToString(); rechargeRecord.rcr_cUserID = this._CurrentCardUserInfo.cus_cRecordID; rechargeRecord.rcr_dRechargeTime = DateTime.Now;//TODO:应该修改为跟服务器时间 rechargeRecord.rcr_fRechargeMoney = fRechargeDeduct;//扣减欠费得到的当次实际充值金额 rechargeRecord.PreCostMoney = fPreCost;//需要缴付的欠款金额 //<--卡实际充值后余额=卡当前余额+实际充值金额 rechargeRecord.rcr_fBalance = base._CurrentCardInfo.CardBalance + fRechargeDeduct; //---> rechargeRecord.IsNeedSyncAccount = ckbIsSyncUnPay.Checked;//是否需要同步账户,主要用以分别透支金额这些系统额外金额的记录登记 rechargeRecord.rcr_cAdd = this.UserInformation.usm_cUserLoginID; rechargeRecord.rcr_cLast = rechargeRecord.rcr_cAdd; rechargeRecord.rcr_dLastDate = rechargeRecord.rcr_dRechargeTime; #endregion //卡充值成功后,将充值信息写入充值记录表 rvInfo = this._IRechargeRecordBL.InsertRechargeRecord(rechargeRecord); ComputePreCost(this._CurrentPairInfo); if (rvInfo.boolValue && !rvInfo.isError) { //成功录入充值记录后提示成功 this.Cursor = Cursors.Default; this.ShowInformationMessage("充值成功。"); if (cbxPrint.Checked) { RechargeDetail rdInfo = new RechargeDetail(); rdInfo.CardNo = Int32.Parse(this.labCardNo.Text); rdInfo.OperationTime = System.DateTime.Now; rdInfo.Operator = this.UserInformation.usm_cUserLoginID; rdInfo.RechargeValue = fRecharge; rdInfo.UserName = this.labUserName.Text; rdInfo.ClassName = this.labClassName.Text; //打印小票 PrintTicket(rdInfo); } resetAllControls(); this.Invoke(new DLG_GetRechargeHistory(BindRechargeList)); DateTime? dtSysNow = DateTime.Now;//使用系统时间作准,避免因客户机时间不同步造成操作异常 if (rvInfo.ValueObject != null) { dtSysNow = Convert.ToDateTime(rvInfo.ValueObject); } if (dtSysNow == null) { dtSysNow = DateTime.Now; } ResetMealPlanning(base._CurrentCardUserInfo, dtSysNow); btnRead.Focus(); return; } else { ShowErrorMessage("上传充值记录失败,需要进行回滚扣费,请摆放好卡片后,点击确定。"); ConsumeCardInfo cardInfoRollback = this._Reader.ReadCardInfo(base._CardInfoSection, base._SectionPwd); if (cardInfoRollback.CardSourceID != cardInfo.CardSourceID) { ShowWarningMessage("卡片信息不符合,请核对后重新放卡,原卡片卡号为:" + cardInfo.CardNo.ToString() + ",卡信息为:" + cardInfo.Name); cardInfoRollback = this._Reader.ReadCardInfo(base._CardInfoSection, base._SectionPwd); if (cardInfoRollback.CardSourceID == cardInfo.CardSourceID) { //录入充值记录失败,则需要将原先充入的卡金额扣除,如果卡已被取走,则需等待后台自动同步金额 rvInfo = this._Reader.Recharge(base._CardInfoSection, base._SectionPwd, fRechargeDeduct * -1); if (rvInfo.boolValue && !rvInfo.isError) { ShowInformationMessage("回滚扣费成功,可重新进行充值。"); return; } else { ShowWarningMessage("回滚扣费失败,请联系系统管理员处理问题卡片。"); } } else { ShowWarningMessage("核对信息失败,请联系系统管理员处理问题卡片。"); } } else { rvInfo = this._Reader.Recharge(base._CardInfoSection, base._SectionPwd, fRechargeDeduct * -1); if (rvInfo.boolValue && !rvInfo.isError) { ShowInformationMessage("回滚扣费成功,可重新进行充值。"); return; } else { ShowWarningMessage("回滚扣费失败,请联系系统管理员处理问题卡片。"); } } resetAllControls(); this.Cursor = Cursors.Default; this.ShowInformationMessage("充值失败。" + rvInfo.messageText); btnRead.Focus(); return; } } else { resetAllControls(); this.Cursor = Cursors.Default; this.ShowInformationMessage("充值失败。" + rvInfo.messageText); btnRead.Focus(); return; } } }