forked from E-menu/E_Menu_Personel_App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddWindow.xaml.cs
57 lines (51 loc) · 1.99 KB
/
AddWindow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
namespace E_Menu_Personel_App
{
using Models;
using Interfaces;
using Repositories;
using System;
using System.Windows;
using Table = Models.Table;
/// <summary>
/// Interaction logic for AddWindow.xaml
/// </summary>
public partial class AddWindow : Window
{
public AddWindow()
{
InitializeComponent();
ITableRepository repoTable = new TableRepository();
var tableNames = repoTable.GetTables();
string[] tables = new string[tableNames.Length];
int i = 0;
foreach (var x in tableNames)
{
tables[i] = tableNames[i].TableID.ToString();
i++;
}
tableSelect.ItemsSource = tables;
IDishRepository repoDish = new DishRepository();
string[] dishNames = repoDish.GetDishNames();
dishSelect.ItemsSource = dishNames;
}
private void Add_Table_Click(object sender, RoutedEventArgs e)
{
Table table = new Table() { TableInfo = TableInfoBox.Text };
ITableRepository repository = new TableRepository();
repository.CreateTable(table);
}
private void Add_Dish_Click(object sender, RoutedEventArgs e)
{
Dish dish = new Dish() { Name = DishNameBox.Text, DishPrice = Convert.ToInt32(DishPriceBox.Text) };
IDishRepository repository = new DishRepository();
repository.CreateDish(dish);
}
private void Add_Order_Click(object sender, RoutedEventArgs e)
{
IDishRepository dishRepo = new DishRepository();
Order order = new Order() { DishID = Convert.ToInt32(dishRepo.GetDish(dishSelect.Text).DishID), TableID = Convert.ToInt32(tableSelect.Text), TimeStamp = DateTime.Now.ToString("HH:mm:ss") };
IOrderRepository repository = new OrderRepository();
repository.CreateOrder(order);
}
}
}