private void button1_Click(object sender, RoutedEventArgs e) { Button button = sender as Button; //this.parent.SelfHelpInfo.SaleTime = DateTime.Now.ToString("MM月dd日"); //this.parent.SelfHelpInfo.TicketType = button.Tag.ToString(); string configValue = ConfigHelper.GetConfigValue("ticket", "t" + button.Tag.ToString(), "price"); this.parent.mSelfHelpClass.SaleTime = DateTime.Now.ToString("MM月dd日"); if ((Convert.ToInt32(button.Tag) - 2) == 0) { this.parent.mSelfHelpClass.BoxNumber = "A"; //票箱 this.parent.mSelfHelpClass.TicketTypeID = M_Configuration.TicketTypeID_1; //默认A票箱的票种就是TicketTypeID_1 } else if ((Convert.ToInt32(button.Tag) - 2) == 1) { this.parent.mSelfHelpClass.BoxNumber = "B"; this.parent.mSelfHelpClass.TicketTypeID = M_Configuration.TicketTypeID_2;//默认B票箱的票种就是TicketTypeID_2 } //********************验证下票数是否已报警************* if (T_SellTicketRecord.Judge_TicketAlarmCount(this.parent.mSelfHelpClass.TicketTypeID, 0)) { MessageBox.Show("余票不足!", T_SellTicketRecord.str_Apption, MessageBoxButton.OK, MessageBoxImage.Information); return; } //********************验证下票数是否已报警************* //***预售期价格 Int64 ticketprice = -1; //预售期票价 ticketprice = T_SellTicketRecord.Get_sl_period_Price(this.parent.mSelfHelpClass.TicketTypeID); //获取预售期票价 this.parent.mSelfHelpClass.OriginalPrice = T_SellTicketRecord.GetTicketInfo(this.parent.mSelfHelpClass.TicketTypeID).Price; //T_GetCurTicketInfo.GetCurTicketTypeIDInfo(M_Configuration.TicketTypeID_1, M_TicketTypeList.listTicketType).Price;//原票价 自助售票类 //this.parent.mSelfHelpClass.TicketTypeID = M_Configuration.TicketTypeID_1;//票种 自助售票类 if (ticketprice != -1) { this.parent.mSelfHelpClass.SalePrice = ticketprice;//预售期票价 自助售票类 } else { this.parent.mSelfHelpClass.SalePrice = this.parent.mSelfHelpClass.OriginalPrice;//原票价 } //if (this.parent.mSelfHelpClass.BoxNumber == "A")//箱号1中的票种 //{ // ticketprice = T_SellTicketRecord.Get_sl_period_Price(M_Configuration.TicketTypeID_1);//获取预售期票价 // this.parent.mSelfHelpClass.OriginalPrice = T_SellTicketRecord.GetTicketInfo(M_Configuration.TicketTypeID_1).Price; //T_GetCurTicketInfo.GetCurTicketTypeIDInfo(M_Configuration.TicketTypeID_1, M_TicketTypeList.listTicketType).Price;//原票价 自助售票类 // this.parent.mSelfHelpClass.TicketTypeID = M_Configuration.TicketTypeID_1;//票种 自助售票类 // if (ticketprice != -1) // { // this.parent.mSelfHelpClass.SalePrice = ticketprice;//预售期票价 自助售票类 // } // else // { // this.parent.mSelfHelpClass.SalePrice = this.parent.mSelfHelpClass.OriginalPrice;//原票价 // } //} //else if (this.parent.mSelfHelpClass.BoxNumber == "B")//箱号2中的票种 //{ // ticketprice = T_SellTicketRecord.Get_sl_period_Price(M_Configuration.TicketTypeID_2); // this.parent.mSelfHelpClass.TicketTypeID = M_Configuration.TicketTypeID_2;//票种 自助售票类 // this.parent.mSelfHelpClass.OriginalPrice = T_SellTicketRecord.GetTicketInfo(M_Configuration.TicketTypeID_2).Price; //T_GetCurTicketInfo.GetCurTicketTypeIDInfo(M_Configuration.TicketTypeID_2, M_TicketTypeList.listTicketType).Price;//原票价 自助售票类 // if (ticketprice != -1) // { // this.parent.mSelfHelpClass.SalePrice = ticketprice;//预售期票价 自助售票类 // } // else // { // this.parent.mSelfHelpClass.SalePrice = this.parent.mSelfHelpClass.OriginalPrice;//原票价 // } //} //*********************获取下票价---还有预售期价格************** //this.parent.SelfHelpInfo.TicketPrice = decimal.Parse(configValue); this.parent.Operation("gp3"); }
//****写票函数 private bool WriteTicket() { bool isok = false; try { //具体写票操作 bool hasTicket = rfidReader.WaitForTicketPresent(1000); #region try { if (hasTicket) { //读取发行信息 TicketPublishInfo tpInfo = rfidReader.readTicketPublishInfo(); _log.Debug("已读取到门票,票号:" + tpInfo.ID.ToString()); CurTicketID = tpInfo.ID.ToString(); //票号 上传时用到 //读取销售信息 TicketSaleInfo?tsInfo = rfidReader.readTicketSaleInfo(); if (!tsInfo.HasValue) //未做过销售的 { #region //验证出票与购票的票种是否相同 if ((tpInfo.TicketClass.ToString() == M_Configuration.TicketTypeID_1) || (tpInfo.TicketClass.ToString() == M_Configuration.TicketTypeID_2)) { //获到票种实体 mticketType = D_TicketType.GetTicketTypeInfo(tpInfo.TicketClass.ToString()); #region //首先判断票种是否存在 if (mticketType.TICKET_TYPE_ID != null) //当前票票种存在的 { #region //两个票箱票种互换的情况 if ((this.parent.mSelfHelpClass.BoxNumber == "A" && tpInfo.TicketClass.ToString() != M_Configuration.TicketTypeID_1) || (this.parent.mSelfHelpClass.BoxNumber == "B" && tpInfo.TicketClass.ToString() != M_Configuration.TicketTypeID_2)) { // 票箱设置的票种与实际所放票种不一致 //TPU_OUT(1);//回收票据 _log.Error("票箱设置票种与实际出票票种不符!"); this.parent.ticketbox_isErr = 1;//票种放反 rfidReader.LongBeep(); isok = false; return(isok); } #endregion Yu_Price = T_SellTicketRecord.Get_sl_period_Price(tpInfo.TicketClass.ToString()); //获取预售期票价 #region //是否团体票 if (mticketType.TEAM_FLAG == "Y") //团体票 { BeginDate = DateTime.Now; EndDate = DateTime.Now.AddMinutes(M_Configuration.Teamtickettime);//从参数表中取出结束时间//Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 16:00:00")); _log.Error("此门票为团体票,不能在此销售!"); rfidReader.LongBeep(); return(false); } else { if (mticketType.DAY_VALIDATE_FLAG == "Y")//当日有效 { BeginDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00")); EndDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 23:59:59")); } else //非当日有效 { BeginDate = DateTime.Now; EndDate = DateTime.Now.AddYears(2); } } #endregion //真正写票 并保存到数据库中 #region if (rfidReader.writeTicketSaleInfo(BeginDate, EndDate, 1)) { _log.Debug("写票成功!"); if (this.parent.mSelfHelpClass.OperType == "0")//购票时生成销售明细单号 { XiaoMX = T_SellTicketRecord.CreateTableUID(M_Configuration.CLIENTID, T_SellTicketRecord.LocalTicketMX_Prefix_ZG, this.cardCount); } //保存数据 #region if (T_SellTicketRecord.Insert_SL_ORDER_DETAIL(mticketType, tpInfo.ID.ToString(), Convert.ToInt32(this.parent.mSelfHelpClass.OperType), this.parent.mSelfHelpClass, XiaoMX, this.cardCount)) { _log.Debug("本地缓存写入成功!"); isok = true; } else { _log.Warn("本地缓存写入失败!"); } #endregion } else { _log.Warn("写入票据信息失败!"); } #endregion } else//该票的票种不存在 { _log.Error("系统中不存在当前票种!票种:" + tpInfo.TicketClass.ToString()); rfidReader.LongBeep(); } #endregion } else//购票与出票 票种不符 { _log.Error("当前门票同所购门票的票种不符!票种:" + tpInfo.TicketClass.ToString()); rfidReader.LongBeep(); } #endregion } else//已做过销售的 { _log.Error("当前门票已做过销售处理!票号:" + CurTicketID.ToString()); rfidReader.LongBeep(); } } else { return(false); } } catch (Exception ex) { _log.Error("门票读取错误!", ex); rfidReader.LongBeep(); } #endregion } catch (Exception ex) { _log.Error("读卡器异常!", ex); rfidReader.LongBeep(); } finally { //rfidReader.WaitForTicketRemoval(0); } return(isok); }