Esempio n. 1
0
 public PosSelectViewModel(PosTicket currentTicket)
 {
     Edit = true;
     this.currentTicket = currentTicket;
     ticketType         = currentTicket.ticketType;
     Numero             = currentTicket.Numero;
 }
Esempio n. 2
0
        public PayeTicketViewModel(PosTicket ticket, Client client)
        {
            settings = PosSettings.getInstance();
            if (ticket == null)
            {
                throw new Exception("Selectionner un TICKET a payé");
            }


            this.ticket = ticket;

            if (this.ticket.MontantPaye > 0)
            {
                MontantRecu = this.ticket.Reste;
            }
            else
            {
                MontantRecu = this.ticket.Total;
            }

            LoadData();

            IsAnonym = true;
            var settingsUser = PosSettings.getInstance();

            if (client != null)
            {
                SelectedClient = client;
            }

            PrintPdf      = settingsUser.EstImprimer;
            PrintKitchen  = settingsUser.EstImprimerCuisine;
            CreateFacture = settingsUser.EstFacturer;


            NotifyOfPropertyChange("IsAnonym");
            NotifyOfPropertyChange("SelectedClient");
            NotifyOfPropertyChange("MontantTotal");
        }
Esempio n. 3
0
 public PosSelectViewModel(PosTicket currentTicket, BindableCollection <PosTicket> tickets) : this(currentTicket)
 {
     this.tickets = tickets;
 }
        public void OpenPaiementDialog()
        {
            try
            {
                var Client = PosSettings.getInstance().DefaultClient.GetObject("Client");
                var paye   = new PayeTicketViewModel(CurrentTicket, Client);
                //var view = DataHelpers.container.Get<ViewManager>().CreateAndBindViewForModelIfNecessary(paye);
                var doDelete = DataHelpers.windowManager.ShowDialog(paye);



                if (doDelete == true)
                {
                    CurrentTicket.isHandled = 1;
                    CurrentTicket.Save();
                    var index = Tickets.IndexOf(CurrentTicket); // * * * *
                    Tickets.Remove(CurrentTicket);              //  * * |*| *

                    if (Tickets.Count > index)                  // 3
                    {
                        CurrentTicket = Tickets[index];
                    }
                    else if (Tickets.Count > 0)
                    {
                        CurrentTicket = Tickets[--index];
                    }
                    else
                    {
                        CurrentTicket = null;
                    }



                    // Automatic create new ticket
                    if (!Tickets.Any())
                    {
                        var ticket = new PosTicket()
                        {
                            Date       = DateTime.Now,
                            ticketType = TicketType.PREPAYE,
                            Numero     = SesssionIndex++
                        };
                        Tickets.Add(ticket);
                        CurrentTicket = ticket;
                    }

                    NotifyOfPropertyChange("Tickets");
                    NotifyOfPropertyChange("CurrentTicket");
                    //CurrentTicket?.Refresh();
                    //Tickets?.Refresh();
                    CreateCartLines();
                    MessageQueue.Enqueue("Vente terminé");
                }
                //else if (paye.MontantRecu < CurrentTicket.Total)
                //{
                //    CurrentTicket.MontantPaye += paye.MontantRecu;
                //    MessageQueue.Enqueue("PAIEMENT PARTIEL ENREGISTRÉ");

                //}

                CreateCartLines();
                if (ShowTicketsVisible)
                {
                    ShowTickets();
                }
            }
            catch (Exception s)
            {
                MessageBox.Show(s.Message);
            }
        }
        //public PosSettings settings { get; set; } = PosSettings.getInstance();
        public void AddTicket()
        {
            if (CurrentTicket != null && settings.PrintCuisineAlways && CmdStatus == "")
            {
                MessageBox.Show("ENVOYER/IMPRIMER TICKET CUISINE");
                return;
            }


            if (_EstPrepayeOnly)
            {
                CurrentTicket          = new PosTicket();
                CurrentTicket.Position = this.Position;
                this.Position++;
                CurrentTicket.ticketType = TicketType.PREPAYE;
                CurrentTicket.Numero     = SesssionIndex++;
                CurrentTicket.Date       = DateTime.Now;

                Tickets.Add(CurrentTicket);
                CreateCartLines();
                NotifyOfPropertyChange("Tickets");
                NotifyOfPropertyChange("CurrentTicket");
                NotifyOfPropertyChange("Total");

                MessageQueue.Enqueue("NOUVEAU TICKET");
                return;
            }



            var ticketType = new PosSelectViewModel();

            var view = DataHelpers.container.Get <ViewManager>().CreateAndBindViewForModelIfNecessary(ticketType);

            DataHelpers.windowManager.ShowDialog(ticketType);
            bool IsJumler = false;

            if (ticketType.ticketType == TicketType.TABLE)
            {
                if (Tickets.Where(a => a.ticketType == TicketType.TABLE && a.Numero == ticketType.Numero).Count() > 0)
                {
                    MessageBox.Show($"Mode jumeler\nUne table avec le méme numéro <TABLE-{ticketType.Numero}> existe/ouverte! ");


                    var existedTicket = Tickets.First(a => a.ticketType == TicketType.TABLE && a.Numero == ticketType.Numero);
                    CurrentTicket = existedTicket;
                    //CurrentTicket?.Refresh();
                    //Tickets?.Refresh();
                    NotifyOfPropertyChange("CurrentTicket");
                    NotifyOfPropertyChange("Tickets");

                    IsJumler = true;
                }
                else
                {
                    CurrentTicket          = new PosTicket();
                    CurrentTicket.Position = this.Position;
                    this.Position++;

                    CurrentTicket.ticketType = ticketType.ticketType;
                    CurrentTicket.Numero     = ticketType.Numero;
                }
            }
            else
            {
                CurrentTicket          = new PosTicket();
                CurrentTicket.Position = this.Position;
                this.Position++;
                CurrentTicket.ticketType = ticketType.ticketType;
                CurrentTicket.Numero     = SesssionIndex++;
            }
            CartData.Add(view);
            //CartData.Refresh();
            NotifyOfPropertyChange("CartData");

            if (settings.ListPrixParDefault != ObjectId.Empty && settings.ListPrixParDefault != null)
            {
                CurrentTicket.ListePrix = settings.ListPrixParDefault;
            }

            CurrentTicket.Date = DateTime.Now;
            if (!IsJumler)
            {
                Tickets.Add(CurrentTicket);
            }

            CreateCartLines();
            NotifyOfPropertyChange("Tickets");
            NotifyOfPropertyChange("CurrentTicket");
            NotifyOfPropertyChange("Total");
            if (ShowTicketsVisible)
            {
                ShowTickets();
            }
        }