Esempio n. 1
0
        private static Export extractData(SQLiteDataReader reader)
        {
            Export ticket = new Export();

            ticket.Id      = reader.GetInt32(0);
            ticket.Staff   = StaffDAL.GetById(reader.GetInt32(1));
            ticket.Date    = reader.GetString(2);
            ticket.Receipt = ReceiptDAL.GetById(reader.GetInt32(3));

            string        detailsQuery   = $"SELECT * FROM {subTable} WHERE ticketId = @ticketId";
            SQLiteCommand detailsCommand = new SQLiteCommand(detailsQuery, DAL.Conn);

            detailsCommand.Parameters.AddWithValue("@ticketId", ticket.Id);

            SQLiteDataReader detailsReader = detailsCommand.ExecuteReader();

            while (detailsReader.HasRows)
            {
                while (detailsReader.Read())
                {
                    TicketDetails details = new TicketDetails();
                    details.Ticket  = ticket;
                    details.Product = ProductDAL.GetById(detailsReader.GetInt32(1));
                    details.Amount  = detailsReader.GetInt32(2);

                    ticket.Details.Add(details);
                }

                detailsReader.NextResult();
            }

            return(ticket);
        }
Esempio n. 2
0
        public static void CreateExportTicket(Receipt receipt, int staffId)
        {
            Export ticket = new Export();

            ticket.Receipt = receipt;
            ticket.Staff   = StaffDAL.GetById(staffId);

            foreach (ReceiptDetails detail in receipt.Details)
            {
                TicketDetails ticketDetails = new TicketDetails()
                {
                    Ticket  = ticket,
                    Product = detail.Product,
                    Amount  = detail.Amount
                };

                ticket.Details.Add(ticketDetails);
            }

            foreach (ReceiptCombos detail in receipt.Combos)
            {
                foreach (ComboDetails comboDetails in detail.Combo.Details)
                {
                    TicketDetails ticketDetails = new TicketDetails()
                    {
                        Ticket  = ticket,
                        Product = comboDetails.Product,
                        Amount  = comboDetails.Amount
                    };

                    ticket.Details.Add(ticketDetails);
                }
            }

            ExportDAL.Create(ticket);
        }