Esempio n. 1
0
        /// <summary>
        /// 根据票种编号返回一个票种实体
        /// </summary>
        /// <param name="ticket_type_id">票种编号</param>
        /// <returns>票种实体</returns>
        public static M_TicketType GetTicketTypeInfo(string ticket_type_id)
        {
            M_TicketType mticketype = new M_TicketType();

            #region //具体操作
            if (ticket_type_id != "")
            {
                string        strsel = "select * from SYS_TICKET_TYPE where TICKET_TYPE_ID='" + ticket_type_id + "'";
                SQLiteCommand cmdsel = new SQLiteCommand(strsel);
                DataSet       ds     = new DataSet();
                ds = SQLiteHelper.ExecuteDataSet(SQLiteHelper.LocalDbConnectionString, cmdsel);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    mticketype.TICKET_TYPE_ID   = ds.Tables[0].Rows[0]["ticket_type_id"].ToString();   //票种编号
                    mticketype.TICKET_TYPE_NAME = ds.Tables[0].Rows[0]["ticket_type_name"].ToString(); //票种名称
                    mticketype.TEAM_FLAG        = ds.Tables[0].Rows[0]["team_flag"].ToString();        //是否团体
                    if (ds.Tables[0].Rows[0]["validate_times"].ToString() != "")
                    {
                        mticketype.VALIDATE_TIMES = Convert.ToInt32(ds.Tables[0].Rows[0]["validate_times"]);//可用次数
                    }
                    else
                    {
                        mticketype.VALIDATE_TIMES = 0;
                    }
                    mticketype.LESS_FLAG         = ds.Tables[0].Rows[0]["LESS_FLAG"].ToString();         //是否优惠
                    mticketype.DAY_NIGHT_FLAG    = ds.Tables[0].Rows[0]["DAY_NIGHT_FLAG"].ToString();    //日夜场
                    mticketype.DAY_VALIDATE_FLAG = ds.Tables[0].Rows[0]["DAY_VALIDATE_FLAG"].ToString(); //是否销售日当日有效(Y是N否)
                    if (ds.Tables[0].Rows[0]["PRICE"].ToString() != "")
                    {
                        mticketype.PRICE = Convert.ToInt32(ds.Tables[0].Rows[0]["PRICE"]);//票价
                    }
                    else
                    {
                        mticketype.PRICE = 0;
                    }
                    mticketype.OPE_USER_ID = ds.Tables[0].Rows[0]["OPE_USER_ID"].ToString();//操作人
                    if (ds.Tables[0].Rows[0]["OPE_TIME"].ToString() != "")
                    {
                        mticketype.OPE_TIME = Convert.ToDateTime(ds.Tables[0].Rows[0]["OPE_TIME"]);//操作时间
                    }
                    else
                    {
                        mticketype.OPE_TIME = DateTime.Now;
                    }
                    if (ds.Tables[0].Rows[0]["version_no"].ToString() != "")
                    {
                        mticketype.VERSION = Convert.ToDateTime(ds.Tables[0].Rows[0]["version_no"]);//版本
                    }
                    else
                    {
                        mticketype.VERSION = DateTime.Now;
                    }
                }
            }
            #endregion

            return(mticketype);
        }
Esempio n. 2
0
        /// <summary>
        /// 将售票信息写入SL_ORDER_DETAIL_表中
        /// </summary>
        /// <param name="ticketType">票种实体</param>
        /// <param name="ticketid">票号</param>
        /// <param name="selltype">0自助购票 1自助取票</param>
        /// <param name="selfhelpclass">自助售票类</param>
        /// <param name="index">取票时表示明细的序号</param>
        /// <returns></returns>
        public static bool Insert_SL_ORDER_DETAIL(M_TicketType ticketType, string ticketid, int selltype, M_SelfHelpClass selfhelpclass, string XiaoMX, int index)
        {
            bool isok = false;

            try
            {
                string strIn = "";
                if (selltype == 0)                                                                 //购票
                {
                    string strOutLet = Convert.ToString(M_Configuration.CLIENTID).Substring(1, 3); //网点编号
                    strIn = "insert into SL_ORDER_DETAIL(order_detail_id,order_id,ticket_class,ticket_id," +
                            "ticket_type_id,validate_times,remain_times,original_price,sale_price," +
                            "check_flag,useless_flag,ope_user_id,ope_time,version_no,SellType,OUTLET_ID,CLIENT_ID,EJECT_USER_ID,EJECT_TICKET_STAT,EJECT_TICKET_TIME)" +
                            " values('" + XiaoMX + "','" + selfhelpclass.OrderID + "','1','" + ticketid + "','" + selfhelpclass.TicketTypeID + "','"
                            + ticketType.VALIDATE_TIMES.ToString() + "'," + ticketType.VALIDATE_TIMES.ToString() + ",'" + selfhelpclass.OriginalPrice.ToString() + "','" + selfhelpclass.SalePrice.ToString() + "'," +
                            " 'N','N','" + M_Configuration.CLIENTID.ToString() + "',DateTime('now','localtime'),DateTime('now','localtime'),'" + selltype.ToString() + "','" + strOutLet + "','" +
                            M_Configuration.CLIENTID.ToString() + "','" + M_Configuration.CLIENTID.ToString() + "','2','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "') ";
                }
                else if (selltype == 1)//取票
                {
                    strIn = "insert into SL_ORDER_DETAIL(order_detail_id,order_id,ticket_class,ticket_id," +
                            "ticket_type_id,validate_times,remain_times,original_price,sale_price," +
                            "check_flag,useless_flag,ope_user_id,ope_time,version_no,SellType,OUTLET_ID,CLIENT_ID,EJECT_USER_ID,EJECT_TICKET_STAT,EJECT_TICKET_TIME)" +
                            " values('" + selfhelpclass.listorderdetail[index - 1].OrderDetailId + "','" + selfhelpclass.listorderdetail[index - 1].OrderId + "','2','" + ticketid + "','" + selfhelpclass.listorderdetail[index - 1].TicketTypeId + "','"
                            + ticketType.VALIDATE_TIMES.ToString() + "'," + ticketType.VALIDATE_TIMES.ToString() + ",'" + selfhelpclass.OriginalPrice.ToString() + "','" + selfhelpclass.SalePrice.ToString() + "'," +
                            " 'N','N','" + M_Configuration.CLIENTID.ToString() + "',DateTime('now','localtime'),DateTime('now','localtime'),'" + selltype.ToString() + "','" + selfhelpclass.OrderID + "','" +
                            M_Configuration.CLIENTID.ToString() + "','" + M_Configuration.CLIENTID.ToString() + "','2','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "') ";
                }
                SQLiteCommand cmd = new SQLiteCommand(strIn);
                SQLiteHelper.ExecuteNonQuery(SQLiteHelper.LocalDbConnectionString, cmd);
                isok = true;
            }
            catch (Exception ex)
            {
                _log.Error(typeof(T_SellTicketRecord), ex);
            }
            return(isok);
        }
Esempio n. 3
0
        //****写票函数
        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);
        }