/// <summary>
        /// 显示查询结果
        /// </summary>
        private void ShowRecord()
        {
            _showList = new List<ViewInfo>();

            try
            {
                this.lblRecordAmount.Text = "0";
                this.lvList.Items.Clear();

                DateTime startTime = DateTime.Parse(dtpDateFrom.Value.ToString("yyyy/MM/dd"));
                DateTime endTime = DateTime.Parse(dtpDateTo.Value.ToString("yyyy/MM/dd"));

                if (startTime > endTime)
                {
                    base.MessageDialog("提示", "开始时间要小于结束时间!");
                    return;
                }

                System.TimeSpan ts = endTime.Subtract(startTime);//TimeSpan得到dt1和dt2的时间间隔
                int countDays = ts.Days;//相隔天数
                if (countDays > 60)
                {
                    base.MessageDialog("提示", "最多只能查询前后60天的记录!");
                    startTime = startTime.AddDays(60);
                    this.dtpDateTo.Value = startTime;
                    return;
                }

                CardUserAccount_cua_Info cuaInfo = new CardUserAccount_cua_Info();
                cuaInfo.cua_cCUSID = _userID;
                cuaInfo = _icuaBL.SearchRecords(cuaInfo).FirstOrDefault() as CardUserAccount_cua_Info;

                CardUserAccountDetail_cuad_Info cuadInfo = new CardUserAccountDetail_cuad_Info();
                cuadInfo.cuad_cCUAID = cuaInfo.cua_cRecordID;
                cuadInfo.OptTime_From = startTime;
                cuadInfo.OptTime_To = endTime.AddDays(1);

                List<CardUserAccountDetail_cuad_Info> infoList = _icuadBL.SearchRecords(cuadInfo);

                if (infoList != null)
                {
                    infoList = infoList.OrderByDescending(x => x.cuad_dOptTime).ToList();

                    int rowNo = 1;

                    for (int index = 0; index < infoList.Count; index++)
                    {
                        cuadInfo = infoList[index] as CardUserAccountDetail_cuad_Info;

                        ViewInfo vi = new ViewInfo();
                        vi.index = rowNo;
                        vi.times = cuadInfo.cuad_dOptTime.ToString("yyyy/MM/dd");
                        vi.cost = cuadInfo.cuad_fFlowMoney.ToString();
                        vi.type = cuadInfo.cuad_cFlowType;

                        try
                        {
                            //PreConsumeRecord_pcs_Info pcsinfo = new PreConsumeRecord_pcs_Info();
                            //pcsinfo.pcs_cRecordID = (Guid)cuadInfo.cuad_cConsumeID;
                            //pcsinfo = _ipcrBL.DisplayRecord(pcsinfo);

                            //if (pcsinfo != null)
                            //{
                            //    vi.mealTime = pcsinfo.pcs_dConsumeDate.ToString("yyyy/MM/dd HH:mm:ss");
                            //}
                            //else
                            //{
                            //    vi.mealTime = cuadInfo.cuad_dOptTime.ToString("yyyy/MM/dd HH:mm:ss");
                            //}

                            ConsumeRecord_csr_Info csrInfo = new ConsumeRecord_csr_Info();
                            csrInfo.csr_cRecordID = (Guid)cuadInfo.cuad_cConsumeID;
                            csrInfo = _IConsumeRecordBL.DisplayRecord(csrInfo);
                            if (csrInfo != null)
                            {
                                vi.mealTime = csrInfo.csr_dConsumeDate.ToString("yyyy/MM/dd HH:mm:ss");
                            }
                            else
                            {
                                PreConsumeRecord_pcs_Info pcsinfo = new PreConsumeRecord_pcs_Info();
                                pcsinfo.pcs_cRecordID = (Guid)cuadInfo.cuad_cConsumeID;
                                pcsinfo = _ipcrBL.DisplayRecord(pcsinfo);

                                if (pcsinfo != null)
                                {
                                    vi.mealTime = pcsinfo.pcs_dConsumeDate.ToString("yyyy/MM/dd HH:mm:ss");
                                }
                                else
                                {
                                    vi.mealTime = cuadInfo.cuad_dOptTime.ToString("yyyy/MM/dd HH:mm:ss");
                                }
                            }
                        }
                        catch
                        {

                        }
                        if (cuadInfo.MacNo != null)
                        {
                            vi.CostType = cuadInfo.MacNo.ToString() + "号机";
                        }
                        else
                        {
                            vi.CostType = "系统补扣";
                        }

                        SetShowViewInfo(vi, _showList);
                        //_showList.Add(vi);

                        rowNo = _showList.Count + 1;
                    }
                }

                if (_showList.Count == 0)
                {
                    if (startTime == endTime && startTime == DateTime.Parse(System.DateTime.Now.ToString("yyyy/MM/dd")))
                    {
                        base.MessageDialog("提示", "今天内无消费记录!");
                    }
                    else
                    {
                        base.MessageDialog("提示", "查找时间内无消费记录!");
                    }
                }

                this.lblRecordAmount.Text = _showList.Count.ToString();
            }
            catch
            {

            }
            finally
            {
                //計算最大頁數
                if (_showList != null)
                {
                    _MaxPage = _showList.Count / _PageSize;

                    if (_showList.Count % _PageSize != 0)
                    {
                        _MaxPage++;
                    }

                    if (_MaxPage == 0)
                    {
                        _PageIndex = 0;
                    }
                    else
                    {
                        if (_PageIndex == 0)
                        {
                            _PageIndex = 1;
                        }
                    }

                    ShowList();//顯示內容
                }
                SetUpDownBtnStatus();
            }
        }
        public ReturnValueInfo UpdateRecord(CardUserAccountDetail_cuad_Info infoObject)
        {
            ReturnValueInfo rvInfo = new ReturnValueInfo();
            try
            {
                if (infoObject != null)
                {
                    using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                    {
                        CardUserAccountDetail_cuad record = db.CardUserAccountDetail_cuad.Where(x => x.cuad_cRecordID == infoObject.cuad_cRecordID).FirstOrDefault();

                        if (record != null)
                        {
                            record.cuad_cCUAID = infoObject.cuad_cCUAID;
                            record.cuad_fFlowMoney = infoObject.cuad_fFlowMoney;
                            record.cuad_cFlowType = infoObject.cuad_cFlowType;
                            if (infoObject.cuad_cConsumeID != null)
                            {
                                record.cuad_cConsumeID = infoObject.cuad_cConsumeID.Value;
                            }
                            record.cuad_cOpt = infoObject.cuad_cOpt;
                            record.cuad_dOptTime = infoObject.cuad_dOptTime;

                            db.SubmitChanges();
                            rvInfo.boolValue = true;
                        }
                        else
                        {
                            rvInfo.messageText = "GetEntity is null";
                        }
                    }
                }
                else
                {
                    rvInfo.messageText = Common.DefineConstantValue.SystemMessageText.strMessageText_E_ObjectNull;
                }
            }
            catch (Exception ex)
            {
                rvInfo.isError = true;
                rvInfo.messageText = ex.Message;
            }
            return rvInfo;
        }
示例#3
0
        public ReturnValueInfo Save(IModelObject itemEntity, DefineConstantValue.EditStateEnum EditMode)
        {
            ReturnValueInfo rvInfo = new ReturnValueInfo();
            try
            {
                RechargeRecord_rcr_Info sourceInfo = itemEntity as RechargeRecord_rcr_Info;
                if (sourceInfo == null)
                {
                    rvInfo.messageText = DefineConstantValue.SystemMessageText.strMessageText_E_ObjectNull;
                    rvInfo.isError = true;
                    return rvInfo;
                }

                //检查充值用户的账户ID,如还未创建账户,则自动创建,如创建失败,则不给予充值
                Guid? accountID = GetAccountID(sourceInfo);
                if (accountID == null)
                {
                    rvInfo.messageText = "用户账户信息缺失,自动添加账户失败。";
                    rvInfo.isError = true;
                    return rvInfo;
                }

                //判断是否为需要录入用户账户中的记录
                bool isUserDetail = IsUserAccountRecord(sourceInfo);
                // 判断是否为需要录入到系统账户中的记录
                bool isSysDetail = IsSysAccountRecord(sourceInfo);

                switch (EditMode)
                {
                    case DefineConstantValue.EditStateEnum.OE_Insert:
                        {
                            /*插入充值记录时,判断是否需要同步一条卡用户账户资金流记录及系统账户资金流记录,
                             * 如需要,则在新增充值记录后同步插入一条资金流记录及系统账户资金流记录,
                             * 如插入失败,则需要在运行资金同步服务时重新新增*/
                            #region Insert Record

                            sourceInfo.rcr_dRechargeTime = DateTime.Now;
                            sourceInfo.rcr_dLastDate = sourceInfo.rcr_dRechargeTime;

                            rvInfo = this._IRechargeRecordDA.InsertRecord(sourceInfo);

                            if (rvInfo.boolValue && !rvInfo.isError)
                            {
                                if (isUserDetail)
                                {
                                    //同步插入一条用户资金流动记录
                                    #region 同步用户资金流动记录

                                    CardUserAccountDetail_cuad_Info accountDetail = new CardUserAccountDetail_cuad_Info();
                                    accountDetail.cuad_cConsumeID = sourceInfo.rcr_cRecordID;
                                    accountDetail.cuad_cCUAID = accountID.Value;
                                    accountDetail.cuad_fFlowMoney = sourceInfo.rcr_fRechargeMoney;
                                    accountDetail.cuad_cFlowType = sourceInfo.rcr_cRechargeType;
                                    accountDetail.cuad_cOpt = sourceInfo.rcr_cAdd;
                                    accountDetail.cuad_cRecordID = Guid.NewGuid();
                                    accountDetail.cuad_dOptTime = sourceInfo.rcr_dRechargeTime;
                                    ReturnValueInfo res = this._ICardUserAccountDetailDA.InsertRecord(accountDetail);
                                    rvInfo.messageText += res.messageText;

                                    #endregion
                                }
                                if (isSysDetail)
                                {
                                    //同步插入一条系统资金现金流
                                    #region 同步系统资金流动记录

                                    SystemAccountDetail_sad_Info sysAccountInfo = new SystemAccountDetail_sad_Info();
                                    sysAccountInfo.sad_cConsumeID = sourceInfo.rcr_cRecordID;
                                    sysAccountInfo.sad_cDesc = string.Empty;
                                    sysAccountInfo.sad_cFLowMoney = sourceInfo.rcr_fRechargeMoney;
                                    sysAccountInfo.sad_cFlowType = sourceInfo.rcr_cRechargeType;
                                    sysAccountInfo.sad_cOpt = sourceInfo.rcr_cAdd;
                                    sysAccountInfo.sad_cRecordID = Guid.NewGuid();
                                    sysAccountInfo.sad_dOptTime = sourceInfo.rcr_dRechargeTime;
                                    ReturnValueInfo res = this._ISystemAccountDetailDA.InsertRecord(sysAccountInfo);
                                    rvInfo.messageText += res.messageText;

                                    #endregion
                                }
                            }
                            break;

                            #endregion
                        }
                    case DefineConstantValue.EditStateEnum.OE_Update:
                        {
                            /*更新充值记录时,需检查是否有相应的资金流记录,
                             * 如有,则需同步更新
                             */
                            #region Update Record

                            sourceInfo.rcr_dLastDate = DateTime.Now;

                            rvInfo = this._IRechargeRecordDA.UpdateRecord(sourceInfo);

                            if (rvInfo.boolValue && !rvInfo.isError)
                            {
                                if (isUserDetail)
                                {
                                    //同步更新对应用户资金流记录
                                    #region 同步用户资金流记录

                                    CardUserAccountDetail_cuad_Info accountDetail = this._ICardUserAccountDetailDA.SearchRecords(new CardUserAccountDetail_cuad_Info() { cuad_cConsumeID = sourceInfo.rcr_cRecordID }).FirstOrDefault();
                                    if (accountDetail == null)
                                    {
                                        //如无对应资金流记录,则添加
                                        accountDetail = new CardUserAccountDetail_cuad_Info();
                                        accountDetail.cuad_cConsumeID = sourceInfo.rcr_cRecordID;
                                        accountDetail.cuad_cCUAID = accountID.Value;
                                        accountDetail.cuad_fFlowMoney = sourceInfo.rcr_fRechargeMoney;
                                        accountDetail.cuad_cFlowType = sourceInfo.rcr_cRechargeType;
                                        accountDetail.cuad_cOpt = sourceInfo.rcr_cAdd;
                                        accountDetail.cuad_cRecordID = Guid.NewGuid();
                                        accountDetail.cuad_dOptTime = sourceInfo.rcr_dRechargeTime;
                                        ReturnValueInfo res = this._ICardUserAccountDetailDA.InsertRecord(accountDetail);
                                        rvInfo.messageText += res.messageText;
                                    }
                                    else
                                    {
                                        //如存在对应资金流记录,则更新金额、流类型、操作人、最后操作时间
                                        accountDetail.cuad_cFlowType = sourceInfo.rcr_cRechargeType;
                                        accountDetail.cuad_cOpt = sourceInfo.rcr_cLast;
                                        accountDetail.cuad_dOptTime = sourceInfo.rcr_dLastDate;
                                        accountDetail.cuad_fFlowMoney = sourceInfo.rcr_fRechargeMoney;
                                        ReturnValueInfo res = this._ICardUserAccountDetailDA.UpdateRecord(accountDetail);
                                        rvInfo.messageText += res.messageText;
                                    }

                                    #endregion
                                }
                                if (isSysDetail)
                                {
                                    //同步更新对应系统资金流记录
                                    #region 同步系统资金流记录

                                    SystemAccountDetail_sad_Info sysAccountInfo = this._ISystemAccountDetailDA.SearchRecords(new SystemAccountDetail_sad_Info() { sad_cConsumeID = sourceInfo.rcr_cRecordID }).FirstOrDefault();
                                    if (sysAccountInfo == null)
                                    {
                                        sysAccountInfo.sad_cConsumeID = sourceInfo.rcr_cRecordID;
                                        sysAccountInfo.sad_cDesc = string.Empty;
                                        sysAccountInfo.sad_cFLowMoney = sourceInfo.rcr_fRechargeMoney;
                                        sysAccountInfo.sad_cFlowType = sourceInfo.rcr_cRechargeType;
                                        sysAccountInfo.sad_cOpt = sourceInfo.rcr_cAdd;
                                        sysAccountInfo.sad_cRecordID = Guid.NewGuid();
                                        sysAccountInfo.sad_dOptTime = sourceInfo.rcr_dRechargeTime;
                                        ReturnValueInfo res = this._ISystemAccountDetailDA.InsertRecord(sysAccountInfo);
                                        rvInfo.messageText += res.messageText;
                                    }
                                    else
                                    {
                                        sysAccountInfo.sad_cDesc = string.Empty;
                                        sysAccountInfo.sad_cFLowMoney = sourceInfo.rcr_fRechargeMoney;
                                        sysAccountInfo.sad_cFlowType = sourceInfo.rcr_cRechargeType;
                                        sysAccountInfo.sad_cOpt = sourceInfo.rcr_cAdd;
                                        sysAccountInfo.sad_cRecordID = Guid.NewGuid();
                                        sysAccountInfo.sad_dOptTime = sourceInfo.rcr_dRechargeTime;
                                        ReturnValueInfo res = this._ISystemAccountDetailDA.UpdateRecord(sysAccountInfo);
                                        rvInfo.messageText += res.messageText;
                                    }

                                    #endregion
                                }
                            }
                            break;

                            #endregion
                        }
                    case DefineConstantValue.EditStateEnum.OE_Delete:
                        {
                            /*需要删除充值记录时,不能做真正的删除记录操作,
                             * 只能添加一条交易金额为原金额*1的充值记录作为充数只用,充值类型也相应为对冲类型
                             * 同时也需要检查是否有资金流记录,进行同步操作
                             */
                            #region Delete Record

                            RechargeRecord_rcr_Info OldRechargeInfo = this._IRechargeRecordDA.DisplayRecord(sourceInfo);
                            if (OldRechargeInfo != null)
                            {
                                //插入一条金额对冲记录代替删除原充值记录
                                RechargeRecord_rcr_Info NewRechargeInfo = new RechargeRecord_rcr_Info();
                                NewRechargeInfo.rcr_fRechargeMoney = OldRechargeInfo.rcr_fRechargeMoney * -1;
                                NewRechargeInfo.rcr_dRechargeTime = DateTime.Now;
                                NewRechargeInfo.rcr_cUserID = OldRechargeInfo.rcr_cUserID;
                                NewRechargeInfo.rcr_cStatus = DefineConstantValue.ConsumeMoneyFlowStatus.Finished.ToString();
                                NewRechargeInfo.rcr_cRecordID = Guid.NewGuid();
                                NewRechargeInfo.rcr_cRechargeType = DefineConstantValue.ConsumeMoneyFlowType.HedgeFund.ToString();
                                NewRechargeInfo.rcr_cLast = sourceInfo.rcr_cLast;
                                NewRechargeInfo.rcr_dLastDate = NewRechargeInfo.rcr_dRechargeTime;

                                rvInfo = this._IRechargeRecordDA.InsertRecord(NewRechargeInfo);

                                if (rvInfo.boolValue && !rvInfo.isError)
                                {
                                    if (isUserDetail)
                                    {
                                        //同步插入用户账户资金流
                                        #region 同步用户资金流记录

                                        CardUserAccountDetail_cuad_Info accountDetail = new CardUserAccountDetail_cuad_Info();
                                        accountDetail.cuad_cConsumeID = sourceInfo.rcr_cRecordID;
                                        accountDetail.cuad_cCUAID = accountID.Value;
                                        accountDetail.cuad_fFlowMoney = sourceInfo.rcr_fRechargeMoney;
                                        accountDetail.cuad_cFlowType = sourceInfo.rcr_cRechargeType;
                                        accountDetail.cuad_cOpt = sourceInfo.rcr_cAdd;
                                        accountDetail.cuad_cRecordID = Guid.NewGuid();
                                        accountDetail.cuad_dOptTime = sourceInfo.rcr_dRechargeTime;
                                        ReturnValueInfo res = this._ICardUserAccountDetailDA.InsertRecord(accountDetail);

                                        #endregion
                                    }
                                    if (isSysDetail)
                                    {
                                        //同步插入系统资金现金流
                                        #region 同步系统资金流动记录

                                        SystemAccountDetail_sad_Info sysAccountInfo = new SystemAccountDetail_sad_Info();
                                        sysAccountInfo.sad_cConsumeID = sourceInfo.rcr_cRecordID;
                                        sysAccountInfo.sad_cDesc = string.Empty;
                                        sysAccountInfo.sad_cFLowMoney = sourceInfo.rcr_fRechargeMoney;
                                        sysAccountInfo.sad_cFlowType = sourceInfo.rcr_cRechargeType;
                                        sysAccountInfo.sad_cOpt = sourceInfo.rcr_cAdd;
                                        sysAccountInfo.sad_cRecordID = Guid.NewGuid();
                                        sysAccountInfo.sad_dOptTime = sourceInfo.rcr_dRechargeTime;
                                        ReturnValueInfo res = this._ISystemAccountDetailDA.InsertRecord(sysAccountInfo);
                                        rvInfo.messageText += res.messageText;

                                        #endregion
                                    }
                                }

                            }
                            else
                            {
                                rvInfo.messageText = "找不到原充值记录。";
                                rvInfo.isError = true;
                            }

                            break;

                            #endregion
                        }
                    default:
                        break;
                }
            }
            catch (Exception ex)
            {
                rvInfo.isError = true;
                rvInfo.messageText = ex.Message;
            }
            return rvInfo;
        }
 public ReturnValueInfo InsertRecord(CardUserAccountDetail_cuad_Info infoObject)
 {
     ReturnValueInfo rvInfo = new ReturnValueInfo();
     try
     {
         if (infoObject != null)
         {
             using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
             {
                 CardUserAccountDetail_cuad record = Common.General.CopyObjectValue<CardUserAccountDetail_cuad_Info, CardUserAccountDetail_cuad>(infoObject);
                 if (record != null)
                 {
                     db.CardUserAccountDetail_cuad.InsertOnSubmit(record);
                     db.SubmitChanges();
                     rvInfo.boolValue = true;
                     rvInfo.ValueObject = infoObject;
                 }
                 else
                 {
                     rvInfo.messageText = "TransEntity is null";
                 }
             }
         }
         else
         {
             rvInfo.messageText = Common.DefineConstantValue.SystemMessageText.strMessageText_E_ObjectNull;
         }
     }
     catch (Exception ex)
     {
         rvInfo.isError = true;
         rvInfo.messageText = ex.Message;
     }
     return rvInfo;
 }
 /// <summary>
 /// 绑定当天充值流水账信息
 /// </summary>
 void BindRechargeList()
 {
     CardUserAccountDetail_cuad_Info rechargeInfo = new CardUserAccountDetail_cuad_Info();
     List<CardUserAccountDetail_cuad_Info> listRechargeDetail = this._ICardUserAccountDetailBL.SearchRecords(rechargeInfo, DateTime.Now, DateTime.Now);
     if (listRechargeDetail != null && listRechargeDetail.Count >= 0)
     {
         listRechargeDetail = listRechargeDetail.Where(x => x.cuad_cFlowType != Common.DefineConstantValue.ConsumeMoneyFlowType.Recharge_AdvanceMoney.ToString()).ToList();
         labRechargeAmount.Text = listRechargeDetail.Sum(x => x.FlowMoney).ToString();
         gbxAmount.Text = "现金充值记录:" + listRechargeDetail.Count.ToString() + " 条";
     }
     lvRechargeAmount.SetDataSource<CardUserAccountDetail_cuad_Info>(listRechargeDetail);
 }