public string InsertTicket(TTicket ticket, string userId)
        {
            try
            {
                //------------------------------------------------------------//
                // check a valid of Ticket
                //------------------------------------------------------------//
                TicketSaleDateBusiness saleDatebusines = new TicketSaleDateBusiness();
                Ticket newTicket = ThriftUtil.ConvertToEntityObject(ticket) as Ticket;

                string errorMessage = CheckTicketInfo(newTicket);
                errorMessage += saleDatebusines.ValidateDateTime(newTicket.departure_time);

                if (string.IsNullOrEmpty(errorMessage) == false)
                {
                    return(errorMessage);
                }

                TicketBusiness business  = new TicketBusiness();
                string         resultMsg = business.Insert(newTicket);

                ////notify to the others client station
                //ticket.TicketId = ticketId;
                //BroadcastToClient(ClientAction.SellTicket,ticket);

                return(resultMsg);
            }
            catch (Exception exc)
            {
                ServerLogger.logError("[InsertTicket]", exc);
                return(exc.Message);
            }
        }
示例#2
0
        public ActionResult Create(Ticket tk, FormCollection collection)
        {
            tk.CustomerId = CustomerBusiness.SelectIdbyName(collection["SearchCustomer"]);
            IFormatProvider iFP = new System.Globalization.CultureInfo("vi-VN", true);

            tk.StartTime      = DateTime.Parse(collection["StartTime"], iFP);
            tk.EndTime        = DateTime.Parse(collection["EndTime"], iFP);
            tk.Price          = 0;
            tk.MotorbikePlate = collection["SearchPlate"];
            tk.TypeId         = Int64.Parse(collection["ticketType"]);
            TicketBusiness.Insert(tk);
            IEnumerable <SelectListItem> sList = new SelectList(TicketTypeBusiness.ListTicketTypes(), "Id", "Description");

            ViewBag.TicketType = sList;
            return(PartialView("Create"));
        }
        public override bool HandleSaveTask()
        {
            bool isSuccess = false;

            try
            {
                string errorMsg = string.Empty;
                errorMsg = ValidateData();
                var confirmView = new TicketPaymentView();
                var tickets     = new List <Ticket>();

                if (string.IsNullOrEmpty(errorMsg))
                {
                    if (_isUpdating == false)
                    {
                        foreach (var seatNo in _selectedSeatNumbers)
                        {
                            tickets.Add(CreateUpdateTicket(seatNo: seatNo));
                        }

                        if (tickets.Count > 1)
                        {
                            int index = 1;
                            tickets.ForEach(x =>
                            {
                                x.id += index.ToString("D2");
                                index++;
                            });
                        }

                        confirmView.ConfirmTickets = tickets;
                        //confirmView.SellTicket = new TicketPaymentView.SellTicketDelegate(SellTicket);
                        confirmView.ShowDialog();
                        if (confirmView.DialogResult == System.Windows.Forms.DialogResult.OK ||
                            confirmView.DialogResult == System.Windows.Forms.DialogResult.Yes)
                        {
                            foreach (var ticket in tickets)
                            {
                                errorMsg = _ticketBusiness.Insert(ticket);
                            }
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        var ticket = CreateUpdateTicket(_ticketBusiness.Get(lblTicketId.Text));
                        errorMsg = _ticketBusiness.Update(ticket);
                    }
                }

                // print receipt
                if (string.IsNullOrEmpty(errorMsg) && confirmView.DialogResult == System.Windows.Forms.DialogResult.Yes)
                {
                    var tour = _tourBusiness.Get(_tourId);
                    var bus  = _busBusiness.Get(_busId);

                    Exporter <EntityObject> exporter = new Exporter <EntityObject>(Constants.PRINT_TICKET_RECIEPT, tickets, new List <EntityObject>()
                    {
                        tour
                    }, new List <EntityObject>()
                    {
                        bus
                    });
                    exporter.Run();
                }

                // output result
                if (string.IsNullOrEmpty(errorMsg))
                {
                    ShowInformationMessage(_isUpdating ? Constants.Messages.MSG_TICKET_UPDATE_TICKET_SUCCESS_MSG : Constants.Messages.MSG_TICKET_INSERT_TICKET_SUCCESS_MSG);
                    isSuccess = true;

                    LoadSeatMapData();
                    ChangeStatusControl(false);
                }
                else
                {
                    ShowErrorMessageBox(errorMsg);
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                AppLogger.logError(this.ToString(), Constants.Messages.MSG_TICKET_UPDATE_TICKET_EXCEPTION_MSG, ex);
                ShowErrorMessageBox(Constants.Messages.MSG_TICKET_UPDATE_TICKET_FAIL_MSG);
            }

            return(isSuccess);
        }