Exemplo n.º 1
0
        /// <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();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 確定換卡
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                bool resUkey = base.CheckUKey();
                if (!resUkey)
                {
                    return;
                }

                #region 添加换卡前对收数情况的判断,若收数未成功,则不能进行换卡操作

                ConsumeMachineMaster_cmm_Info searchMacInfo = new ConsumeMachineMaster_cmm_Info();
                searchMacInfo.cmm_cStatus = Common.DefineConstantValue.ConsumeMachineStatus.Using.ToString();
                List<ConsumeMachineMaster_cmm_Info> listMacInfos = this._IConsumeMachineBL.SearchRecords(searchMacInfo);
                listMacInfos = listMacInfos.Where(x => x.cmm_lIsActive).ToList();
                if (listMacInfos == null && listMacInfos.Count > 0)
                {
                    base.ShowErrorMessage("获取消费数据同步信息时出现异常,请重试。");
                    return;
                }
                //消费机最后同步时间
                DateTime dtMacSync = listMacInfos[0].cmm_dLastAccessTime;
                //List<ConsumeMachineMaster_cmm_Info> listUnSyncMachineInfos = listMacInfos.Where(x =>
                //          x.cmm_dLastAccessTime.Hour != dtMacSync.Hour).ToList();
                List<ConsumeMachineMaster_cmm_Info> listUnSyncMachineInfos = new List<ConsumeMachineMaster_cmm_Info>();
                foreach (ConsumeMachineMaster_cmm_Info macItem in listMacInfos)
                {
                    if (macItem != null)
                    {
                        DateTime dtAccess = macItem.cmm_dLastAccessTime;
                        if (Math.Abs((dtAccess - dtMacSync).TotalMinutes) > 30)
                        {
                            listUnSyncMachineInfos.Add(macItem);
                        }
                    }
                    else
                        continue;
                }
                List<ConsumeMachineMaster_cmm_Info> listUnConnMachineInfos = listMacInfos.Where(x =>
                        !x.cmm_lLastAccessRes).ToList();
                if ((listUnSyncMachineInfos != null && listUnSyncMachineInfos.Count > 0) || (listUnConnMachineInfos != null && listUnConnMachineInfos.Count > 0))
                {
                    if (base.ShowQuestionMessage("暂时不能进行换卡操作,因检测到有断线现象的消费机,请在恢复收集数据正常后重试。" + Environment.NewLine + "需要立即查看【消费数据收集情况】吗?"))
                    {
                        MenuItem menuClick = new MenuItem();
                        Sys_FormMaster_fom_Info formClick = new Sys_FormMaster_fom_Info();
                        formClick.fom_cExePath = "WindowUI.HHZX.ConsumerDevice.frmConsumptionRecordCollect";
                        menuClick.Tag = formClick;
                        base.ShowSubForm(menuClick, base.BaseDockPanel);
                    }
                    this.btnSave.Enabled = false;
                    this.lblReadNo.Text = "请读卡";
                    return;
                }

                #endregion

                this.btnSave.Enabled = false;
                this.lblReadNo.Text = "请读卡";

                UserCardPair_ucp_Info userPairInfo = new UserCardPair_ucp_Info();
                userPairInfo.ucp_cCardID = _CardInfo.CardSourceID;
                userPairInfo.ucp_iCardNo = int.Parse(_CardInfo.CardNo);
                //查询用户是否已拥有正常的消费卡
                List<UserCardPair_ucp_Info> listResUserPair = _IUserCardPairBL.SearchRecords(userPairInfo);
                if (userPairInfo != null)
                {
                    listResUserPair = listResUserPair.Where(x => x.ucp_cUseStatus != Common.DefineConstantValue.ConsumeCardStatus.Returned.ToString()).ToList();
                }

                if (listResUserPair != null && listResUserPair.Count > 0)
                {
                    string strMessage = string.Empty;

                    userPairInfo = listResUserPair[0] as UserCardPair_ucp_Info;

                    userPairInfo = _IUserCardPairBL.DisplayRecord(userPairInfo);

                    if (userPairInfo.CardOwner != null)
                    {
                        strMessage += userPairInfo.CardOwner.cus_cChaName + " " + userPairInfo.CardOwner.ClassName + " 卡号:" + userPairInfo.ucp_iCardNo;
                    }

                    base.ShowErrorMessage("该卡已在使用中。使用者:" + strMessage);
                    return;
                }

                if (!ShowQuestionMessage("是否确认换卡?"))
                {
                    return;
                }
                if (ShowQuestionMessage("是否需要重新设置【换卡工本费】?" + Environment.NewLine + "当前【换卡工本费】为:" + _ReplaceCost.ToString()))
                {
                    btnSetCost_Click(null, null);
                    if (!ShowQuestionMessage("【换卡工本费】更新完毕,是否需要继续进行换卡操作?"))
                    {
                        return;
                    }
                }

                userPairInfo = _CurrentUserInfo.PairInfo;
                int iOldCardNo = userPairInfo.ucp_iCardNo;
                userPairInfo.ucp_cUseStatus = DefineConstantValue.ConsumeCardStatus.Returned.ToString();
                userPairInfo.ucp_dReturnTime = System.DateTime.Now;

                if (!_IUserCardPairBL.Save(userPairInfo, DefineConstantValue.EditStateEnum.OE_Update).isError)
                {
                    ConsumeCardMaster_ccm_Info ccmInfo = new ConsumeCardMaster_ccm_Info();
                    ccmInfo.ccm_cCardID = _CardInfo.CardSourceID;

                    ccmInfo.ccm_cCardState = DefineConstantValue.CardUseState.InUse.ToString();
                    ccmInfo.ccm_lIsActive = true;
                    ccmInfo.ccm_cAdd = this.UserInformation.usm_cUserLoginID;
                    ccmInfo.ccm_dAddDate = System.DateTime.Now;
                    ccmInfo.ccm_cLast = this.UserInformation.usm_cUserLoginID;
                    ccmInfo.ccm_dLastDate = System.DateTime.Now;
                    ///如果新卡沒錄入系統,則先錄入新卡
                    if (_IConsumeCardMasterBL.DisplayRecord(ccmInfo) != null)
                    {
                        //如果新卡已在系統,則設為已使用
                        if (_IConsumeCardMasterBL.Save(ccmInfo, DefineConstantValue.EditStateEnum.OE_Update).isError)
                        {

                        }
                    }
                    else
                    {
                        //添加新卡信息
                        if (_IConsumeCardMasterBL.Save(ccmInfo, DefineConstantValue.EditStateEnum.OE_Insert).isError)
                        {
                            base.ShowErrorMessage("卡信息录入时发生错误,请再次尝试。");
                        }
                    }

                    //如果存在舊卡,將舊卡設為未使用
                    if (_CurrentUserInfo.PairInfo != null)
                    {
                        ConsumeCardMaster_ccm_Info oldCardInfo = new ConsumeCardMaster_ccm_Info();
                        oldCardInfo.ccm_cCardID = _CurrentUserInfo.PairInfo.ucp_cCardID;
                        oldCardInfo = _IConsumeCardMasterBL.DisplayRecord(oldCardInfo) as ConsumeCardMaster_ccm_Info;
                        if (oldCardInfo != null)
                        {
                            oldCardInfo.ccm_cCardState = DefineConstantValue.CardUseState.NotUsed.ToString();
                            _IConsumeCardMasterBL.Save(oldCardInfo, DefineConstantValue.EditStateEnum.OE_Update);
                        }
                    }

                    userPairInfo.ucp_cRecordID = Guid.NewGuid();
                    userPairInfo.ucp_cCardID = ccmInfo.ccm_cCardID;
                    userPairInfo.ucp_cAdd = this.UserInformation.usm_cUserLoginID;
                    userPairInfo.ucp_cLast = this.UserInformation.usm_cUserLoginID;
                    userPairInfo.ucp_dPairTime = DateTime.Now;
                    userPairInfo.ucp_dAddDate = DateTime.Now;
                    userPairInfo.ucp_dLastDate = DateTime.Now;
                    userPairInfo.ucp_cUseStatus = DefineConstantValue.ConsumeCardStatus.Normal.ToString();
                    userPairInfo.ucp_lIsActive = true;
                    userPairInfo.ucp_dReturnTime = null;

                    ReturnValueInfo returnInfo = _IUserCardPairBL.InsertExchargeCard(userPairInfo, _ReplaceCost);

                    userPairInfo = returnInfo.ValueObject as UserCardPair_ucp_Info;

                    if (returnInfo.isError)
                    {
                        base.ShowErrorMessage("换卡失败,请再次尝试。");
                        return;
                    }
                    else
                    {
                        //換卡成功,將新卡設為已使用
                        initValue();

                        UserCardPair_ucp_Info currentPair = this._IUserCardPairBL.DisplayRecord(new UserCardPair_ucp_Info() { ucp_cRecordID = userPairInfo.ucp_cRecordID }) as UserCardPair_ucp_Info;

                        string strCardName = string.Empty;

                        //抽取用户信息写入卡显示名称
                        if (currentPair.CardOwner != null)
                        {
                            CardUserMaster_cus_Info userSearch = new CardUserMaster_cus_Info() { cus_cRecordID = currentPair.CardOwner.cus_cRecordID };
                            CardUserMaster_cus_Info userInfo = this._ICardUserMasterBL.DisplayRecord(userSearch) as CardUserMaster_cus_Info;
                            if (userInfo != null)
                            {
                                if (userInfo.cus_cIdentityNum == DefineConstantValue.CodeMasterDefine.KEY2_SIOT_CardUserIdentity_Student)//学生
                                {
                                    if (userInfo.ClassInfo != null)
                                    {
                                        if (userInfo.ClassInfo.GradeInfo == null)
                                        {
                                            strCardName += userInfo.ClassInfo.csm_cClassName.Substring(0, 1) == "高" ? "G" : "C";
                                            strCardName += userInfo.ClassInfo.csm_cClassName.Substring(1, 1);
                                        }
                                        else
                                        {
                                            strCardName += userInfo.ClassInfo.GradeInfo.gdm_cAbbreviation;
                                        }

                                        string strTmpName = userInfo.cus_cChaName;
                                        if (userInfo.cus_cChaName.Length > 3)
                                        {
                                            strTmpName = userInfo.cus_cChaName.Substring(1, 3);
                                        }
                                        strCardName += strTmpName;
                                    }
                                    else
                                    {
                                        this.Cursor = Cursors.Default;
                                        base.ShowWarningMessage("用户班级信息不全,请重试。");
                                        return;
                                    }
                                }
                                else//老师
                                {
                                    string strTmpName = userInfo.cus_cChaName;
                                    if (userInfo.cus_cChaName.Length > 6)
                                    {
                                        strTmpName = strTmpName.Substring(0, 6);
                                    }
                                    strCardName = strTmpName;
                                }
                            }
                        }

                        CardUserAccount_cua_Info cuaInfo = new CardUserAccount_cua_Info();
                        cuaInfo.cua_cCUSID = userPairInfo.ucp_cCUSID;

                        cuaInfo = _ICardUserAccountBL.SearchRecords(cuaInfo).FirstOrDefault() as CardUserAccount_cua_Info;
                        _CardInfo.CardNo = userPairInfo.ucp_iCardNo.ToString();
                        _CardInfo.Name = strCardName;
                        _CardInfo.CardPwd = this._PayPwd;
                        //_cardInfo.CardBalance = cuaInfo.cua_fCurrentBalance;

                        decimal Balance = cuaInfo.cua_fCurrentBalance;

                        if (this._CurrentUserInfo != null)
                        {
                            if (this._CurrentUserInfo.cus_cIdentityNum == Common.DefineConstantValue.CodeMasterDefine.KEY2_SIOT_CardUserIdentity_Student)
                            {
                                CodeMaster_cmt_Info codeInfo = this._ICodeMasterBL.SearchRecords(new CodeMaster_cmt_Info() { cmt_cKey1 = Common.DefineConstantValue.CodeMasterDefine.KEY1_ConstantExpenses, cmt_cKey2 = Common.DefineConstantValue.CodeMasterDefine.KEY2_AdvanceCost }).FirstOrDefault() as CodeMaster_cmt_Info;
                                if (codeInfo != null)
                                {
                                    Balance = Balance + codeInfo.cmt_fNumber;
                                }
                            }
                        }

                        if (Balance < 0)
                        {
                            Balance = 0;
                        }

                        _CardInfo.CardBalance = Balance;

                        this._Reader.WriteCardInfo(this._CardInfoSection, this._SectionPwd, _CardInfo);

                        this.lblReadNo.Text = "已换卡";

                        userPairInfo = returnInfo.ValueObject as UserCardPair_ucp_Info;

                        _CurrentUserInfo.PairInfo = userPairInfo;

                        _CardInfo = null;

                        initValue();

                        ShowInformationMessage("换卡成功。");

                        ReturnValueInfo rvRemoveOld = RemoveOldCardFromWList(iOldCardNo);
                        ReturnValueInfo rvAddNew = AddNewCardToWList(userPairInfo.ucp_iCardNo);
                        if (rvRemoveOld.boolValue && rvAddNew.boolValue)
                        {
                            ShowInformationMessage("旧卡自动添加到黑名单列表成功,原卡已不能继续使用。");
                        }
                        else
                        {
                            ShowErrorMessage("旧卡自动添加到黑名单列表失败,可等待停餐服务收集名单添加或联系管理员手动添加。");
                        }
                    }
                }
            }
            catch
            {

            }
        }
Exemplo n.º 3
0
 public ReturnValueInfo InsertRecord(CardUserAccount_cua_Info infoObject)
 {
     ReturnValueInfo rvInfo = new ReturnValueInfo();
     try
     {
         if (infoObject != null)
         {
             using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
             {
                 CardUserAccount_cua record = Common.General.CopyObjectValue<CardUserAccount_cua_Info, CardUserAccount_cua>(infoObject);
                 if (record != null)
                 {
                     db.CardUserAccount_cua.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;
 }
Exemplo n.º 4
0
        public ReturnValueInfo UpdateRecord(CardUserAccount_cua_Info infoObject)
        {
            ReturnValueInfo rvInfo = new ReturnValueInfo();
            try
            {
                if (infoObject != null)
                {
                    using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                    {
                        CardUserAccount_cua record = db.CardUserAccount_cua.Where(x => x.cua_cRecordID == infoObject.cua_cRecordID).FirstOrDefault();

                        if (record != null)
                        {
                            record.cua_cCUSID = infoObject.cua_cCUSID;
                            record.cua_dLastSyncTime = infoObject.cua_dLastSyncTime;
                            record.cua_fCurrentBalance = infoObject.cua_fCurrentBalance;
                            record.cua_fOriginalBalance = infoObject.cua_fOriginalBalance;
                            record.cua_lIsActive = infoObject.cua_lIsActive;
                            record.cua_cAdd = infoObject.cua_cAdd;
                            record.cua_dAddDate = infoObject.cua_dAddDate;

                            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;
        }
Exemplo n.º 5
0
 /// <summary>
 /// 获取账户ID
 /// </summary>
 /// <param name="UserID"></param>
 /// <returns></returns>
 Guid? GetAccountID(RechargeRecord_rcr_Info rechargeRecord)
 {
     if (rechargeRecord == null)
     {
         return null;
     }
     Guid UserID = rechargeRecord.rcr_cUserID;
     CardUserAccount_cua_Info accountInfo = this._ICardUserAccountDA.SearchRecords(new CardUserAccount_cua_Info() { cua_cCUSID = UserID }).FirstOrDefault();
     if (accountInfo == null)
     {
         accountInfo = new CardUserAccount_cua_Info();
         accountInfo.cua_cAdd = rechargeRecord.rcr_cLast;
         accountInfo.cua_cCUSID = UserID;
         accountInfo.cua_cRecordID = Guid.NewGuid();
         accountInfo.cua_dAddDate = DateTime.Now;
         accountInfo.cua_dLastSyncTime = DateTime.Now;
         accountInfo.cua_fCurrentBalance = 0;
         accountInfo.cua_fOriginalBalance = 0;
         ReturnValueInfo rvInfo = this._ICardUserAccountDA.InsertRecord(accountInfo);
         if (!rvInfo.boolValue || rvInfo.isError)
         {
             return null;
         }
     }
     return accountInfo.cua_cRecordID;
 }
 /// <summary>
 /// 获取账户信息
 /// </summary>
 private void GetAccountInfos()
 {
     CardUserAccount_cua_Info searchInfo = new CardUserAccount_cua_Info();
     searchInfo.cua_cCUSID = base._CurrentCardUserInfo.cus_cRecordID;
     List<CardUserAccount_cua_Info> listAccountInfo = this._ICardUserAccountBL.SearchRecords(searchInfo);
     if (listAccountInfo != null && listAccountInfo.Count > 0)
     {
         labAccountBalance.Text = listAccountInfo[0].cua_fCurrentBalance.ToString();
         labAccountSyncTime.Text = listAccountInfo[0].cua_dLastSyncTime.ToString("yyyy-MM-dd HH:mm:ss");
     }
 }