Ejemplo n.º 1
0
        private void ReadCard()
        {
            ClearControl();

            WaitForCardReader wfcrFrm = new WaitForCardReader(this._strPwd);
            if (wfcrFrm.ShowDialog() == DialogResult.OK)
            {
                _cardInfo = wfcrFrm.CardInfo;
                ShowCardMessage();
            }
            else
            {
                this.btnSearch.Enabled = false;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 初始化读卡信息
        /// </summary>
        void InitReadCard()
        {
            labCardNo.Text = string.Empty.PadLeft(8, '0');
            labName.Text = string.Empty;
            labPreCost.Text = "0.00";
            labRecharge.Text = "0.00";
            labTotalRecharge.Text = "0.00";
            labCardBalance.Text = "0.00";
            lvRechargeList.SetDataSource<RechargeInfo>(new List<RechargeInfo>());
            ListViewSorter sorter = new ListViewSorter(1, SortOrder.Ascending);
            lvRechargeList.ListViewItemSorter = sorter;
            lvRechargeList.Sorting = SortOrder.Ascending;

            WaitForCardReader wfcrFrm = new WaitForCardReader(this._strPwd);

            GlobalVar.OpenFormList.Add(wfcrFrm);

            if (wfcrFrm.ShowDialog() == DialogResult.OK)
            {
                this._CardInfo = wfcrFrm.CardInfo;
                if (this._CardInfo != null)
                {
                    string strCardID = this._CardInfo.CardSourceID;
                    labCardBalance.Text = this._CardInfo.CardBalance.ToString();

                    UserCardPair_ucp_Info cardPair = this._IUserCardPairBL.SearchRecords(new UserCardPair_ucp_Info()
                    {
                        ucp_iCardNo = Convert.ToInt16(this._CardInfo.CardNo),
                        ucp_cCardID = strCardID,
                        ucp_cUseStatus = Common.DefineConstantValue.ConsumeCardStatus.Normal.ToString()
                    }).FirstOrDefault();

                    if (cardPair != null)
                    {
                        if (cardPair.CardOwner != null && cardPair.CardOwner.AccountInfo != null)
                        {
                            ucMealBookingDetail.ShowData(cardPair.CardOwner);
                            labName.Text = cardPair.CardOwner.cus_cChaName;
                            labCardNo.Text = this._CardInfo.CardNo.PadLeft(8, '0');
                            this._UserInfo = cardPair.CardOwner;

                            //预充值表
                            List<PreRechargeRecord_prr_Info> listPreRechargeRecord = this._IPreRechargeRecordBL.SearchRecords(new PreRechargeRecord_prr_Info()
                            {
                                prr_cUserID = cardPair.ucp_cCUSID,
                                prr_cStatus = Common.DefineConstantValue.ConsumeMoneyFlowStatus.WaitForAcceptTransfer.ToString()
                            });
                            if (listPreRechargeRecord == null && (listPreRechargeRecord != null && listPreRechargeRecord.Count > 0))
                            {
                                base.MessageDialog("提示", "没有可用的预充值的记录。");
                                return;
                            }

                            //转账列表
                            List<RechargeRecord_rcr_Info> listRechargeRecord = new List<RechargeRecord_rcr_Info>();
                            foreach (PreRechargeRecord_prr_Info item in listPreRechargeRecord)
                            {
                                RechargeRecord_rcr_Info rechrageInfo = new RechargeRecord_rcr_Info();
                                rechrageInfo.rcr_cAdd = "tqs";
                                rechrageInfo.rcr_cCardID = this._CardInfo.CardSourceID;
                                rechrageInfo.rcr_cLast = "tqs";
                                rechrageInfo.rcr_cRechargeType = item.prr_cRechargeType;
                                rechrageInfo.rcr_cRecordID = Guid.NewGuid();
                                rechrageInfo.rcr_cStatus = Common.DefineConstantValue.ConsumeMoneyFlowStatus.Finished.ToString();
                                rechrageInfo.rcr_cUserID = item.prr_cUserID;
                                rechrageInfo.rcr_dLastDate = DateTime.Now;
                                rechrageInfo.rcr_dRechargeTime = item.prr_dRechargeTime;
                                rechrageInfo.rcr_fBalance = 0;
                                rechrageInfo.rcr_fRechargeMoney = item.prr_fRechargeMoney;

                                item.prr_cRCRID = rechrageInfo.rcr_cRecordID;

                                listRechargeRecord.Add(rechrageInfo);
                            }
                            this._ListPreRechargeRecord = listPreRechargeRecord;
                            this._ListRechargeRecord = listRechargeRecord;

                            List<RechargeInfo> listRechargeInfo = getRechargeInfo(listRechargeRecord);
                            if (listRechargeInfo != null)
                            {
                                listRechargeInfo = listRechargeInfo.OrderByDescending(x => x.RechargeTime).ToList();
                                lvRechargeList.SetDataSource<RechargeInfo>(listRechargeInfo);
                                decimal dRecharge = listRechargeInfo.Sum(x => x.RechargeMoney);
                                if (dRecharge != 0)
                                {
                                    labRecharge.Text = dRecharge.ToString();
                                }
                            }

                            //未结算的预消费列表
                            List<PreConsumeRecord_pcs_Info> listPreCost = this._IPreConsumeRecordBL.SearchRecords(new PreConsumeRecord_pcs_Info() { pcs_cAccountID = cardPair.CardOwner.AccountInfo.cua_cRecordID });
                            if (listPreCost != null)
                            {
                                listPreCost = listPreCost.Where(x =>
                                    x.pcs_cConsumeType != Common.DefineConstantValue.ConsumeMoneyFlowType.IndeterminateCost.ToString()
                                    && x.pcs_cConsumeType != Common.DefineConstantValue.ConsumeMoneyFlowType.AdvanceMealCost.ToString()
                                    && x.pcs_cConsumeType != Common.DefineConstantValue.ConsumeMoneyFlowType.HedgeFund.ToString()
                                    && x.pcs_lIsSettled == false
                                    && x.pcs_cUserID == cardPair.CardOwner.cus_cRecordID
                                    ).ToList();
                                labPreCost.Text = Math.Round(listPreCost.Sum(x => x.pcs_fCost), 2).ToString();
                            }
                            else
                            {
                                labPreCost.Text = "0.00";
                            }

                            decimal fTotalRecharge = decimal.Parse(labRecharge.Text) + decimal.Parse(labPreCost.Text);
                            decimal fActualRecharge = decimal.Parse(labRecharge.Text) + decimal.Parse(labPreCost.Text) + decimal.Parse(labCardBalance.Text);
                            labTotalRecharge.Text = fTotalRecharge.ToString();
                            if (fActualRecharge >= decimal.Zero)
                                btnRecharge.Enabled = true;
                            else
                                btnRecharge.Enabled = false;
                        }
                        else
                        {
                            base.MessageDialog("提示", "本卡持卡人信息异常!");
                            return;
                        }
                    }
                    else
                    {
                        base.MessageDialog("提示", "未找到此卡或此卡不能進行充值!");
                        return;
                    }
                }
                else
                {
                    base.MessageDialog("提示", "读卡失败,请重试。" + Environment.NewLine + "(如多次失败,卡片有可能已损坏,请及时申请更换)");
                    return;
                }
            }
        }