public static void printOrder( Order o ) { PrintDialog printDlg = new PrintDialog(); String textToPrint = ""; textToPrint += "\t\t Τραπέζι "+o.Table_id+"\n\n"; textToPrint += "Παραγγελία : \n"; String orderName = ""; foreach (Items i in DBController.LoadItems()) { if (i.Id == o.Items_id) orderName = i.Name; } orderName += o.CharacteristicsInfo; textToPrint += "\t1 "+orderName+"\n"; textToPrint += "\n\n"; String waiterName = ""; foreach (User u in DBController.LoadUsers()) { if (u.User_id == o.User_id) waiterName = u.Name; } textToPrint += "Σερβιτόρος : "+waiterName+"\n"; textToPrint += "Ώρα : " + DateTime.Now.ToString("dd/MM/yyyy h:mm:ss tt"); FlowDocument doc = new FlowDocument(new Paragraph(new Run(textToPrint))); doc.Name = "FlowDoc"; IDocumentPaginatorSource idpSource = doc; printDlg.PrintDocument(idpSource.DocumentPaginator, "smart order"); }
/// <summary> /// sinartisi pou fortonei apo tin basi ola ta orders /// </summary> public static List<Order> LoadOrders() { List<Order> orders = new List<Order>(); DBOpenClose(() => { string sql = "select * from orders"; SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection); SQLiteDataReader reader = command.ExecuteReader(); try { while (reader.Read()) { int order_id = reader.GetInt32(0); Order o = new Order(order_id, reader.GetInt32(1), reader.GetInt32(2), reader.GetInt32(3), reader.GetBoolean(4), reader.GetString(5), LoadCharacteristicsInOrder(order_id)); orders.Add(o); } } catch (Exception ex) { Console.WriteLine("LoadOrders " + ex.Message); } }); return orders; }