////check file tableRuntimeHistory isExist //public static bool checkTableRuntimeHistoryFileExist() //{ // return File.Exists(startupProjectPath + "\\SerializedData\\tableRuntimeHistory.bin"); //} //write khi add new public static Entities.Table writeOnAddNew(EmployeewsOfLocalPOS _unitofwork, Rectangle rec, Entities.Employee emp) { Entities.Table newTable = new Entities.Table() { TableId = 0, TableNumber = int.Parse(rec.Name.Substring(5)), ChairAmount = 0, PosX = Convert.ToInt32(rec.Margin.Left), PosY = Convert.ToInt32(rec.Margin.Top), IsPinned = 0, IsOrdered = 0, IsLocked = 0, TableRec = rec }; _unitofwork.TableRepository.Insert(newTable); _unitofwork.Save(); Entities.OrderTemp newOrderTemp = new Entities.OrderTemp() { CusId = "CUS0000001", EmpId = emp.EmpId, TableOwned = _unitofwork.TableRepository.Get(x => x.TableNumber.Equals(newTable.TableNumber)).First().TableId, Ordertime = DateTime.Now, TotalPrice = 0, CustomerPay = 0, PayBack = 0 }; _unitofwork.OrderTempRepository.Insert(newOrderTemp); _unitofwork.Save(); return(_unitofwork.TableRepository.Get(x => x.TableNumber.Equals(newTable.TableNumber)).First()); }
//method tao popup menu cho table private void initcmRec(string cmType, Entities.Table t) { ContextMenu cmRec = new ContextMenu(); MenuItem pinTable = new MenuItem(); pinTable.Name = "pinTable"; pinTable.Header = "Pin Table"; pinTable.Click += pinTable_Click; MenuItem moveTable = new MenuItem(); moveTable.Name = "moveTable"; moveTable.Header = "Move Table"; moveTable.Click += moveTable_Click; MenuItem changeChairTable = new MenuItem(); changeChairTable.Name = "changeChairTable"; changeChairTable.Header = "Change Table Chair Amount"; changeChairTable.Click += changeChairTable_Click; MenuItem removeTable = new MenuItem(); removeTable.Name = "removeTable"; removeTable.Header = "Remove Table"; removeTable.Click += removeTable_Click; //demo payed //MenuItem payedTable = new MenuItem(); //payedTable.Name = "payedTable"; //payedTable.Header = "Payed Table"; //payedTable.Click += payedTable_Click; if (cmType.Equals("pinned")) { if (t.IsOrdered == 1) { cmRec.Items.Add(changeChairTable); cmRec.Items.Add(removeTable); //cmRec.Items.Add(payedTable); } else if (t.IsPinned == 1) { cmRec.Items.Add(moveTable); cmRec.Items.Add(changeChairTable); cmRec.Items.Add(removeTable); } } if (cmType.Equals("moved")) { cmRec.Items.Add(pinTable); cmRec.Items.Add(changeChairTable); cmRec.Items.Add(removeTable); } cmRec.PlacementTarget = currentRec; cmRec.IsOpen = true; }
// Methods protected void GetListOfDbTables() { //if (_logtables != null) //{ // records = _logtables; //} //else //{ using (SqlConnection cnn = new SqlConnection(property.CONNECTION_STRING)) { using (SqlCommand cmd = new SqlCommand(_command.Replace("{dbname}", property.DATABASE), cnn)) { cmd.CommandType = CommandType.Text; cmd.CommandTimeout = 0; records = new List <Entities.Table>(); IDataReader drResult = null; try { if (cnn.State == ConnectionState.Closed) { cnn.Open(); } drResult = cmd.ExecuteReader(); while (drResult.Read()) { Entities.Table record = new Entities.Table(); record.PROCESS = false; record.TABLE_CATALOG = (string)(drResult["TABLE_CATALOG"]); record.TABLE_SCHEMA = (string)(drResult["TABLE_SCHEMA"]); record.TABLE_NAME = (string)(drResult["TABLE_NAME"]); record.TABLE_TYPE = (string)(drResult["TABLE_TYPE"]); records.Add(record); } Session["tables"] = records; } catch (SqlException exception) { records = null; string Error = exception.Message; } finally { if (cnn.State == ConnectionState.Open) { cnn.Close(); } } } } //} }
public static void UpdateTable(Context context, Entities.Table table) { context.Tables.AddOrUpdate( t => t.TableID, new Entities.Table { TableID = table.TableID, TableLabel = table.TableLabel, TableLocation = table.TableLocation, TablePlaces = table.TablePlaces } ); context.SaveChanges(); }
public TableSettingDialog(EmployeewsOfLocalPOS unitofwork, Entities.Table table) { InitializeComponent(); _uniofwork = unitofwork; curTable = table; this.Loaded += TableSettingDialog_Loaded; this.ResizeMode = ResizeMode.NoResize; this.WindowStyle = WindowStyle.SingleBorderWindow; }
public ConfirmMergeDialog(EmployeewsOfLocalPOS unitofwork, Entities.Table first, Entities.Table second) { _unitofwork = unitofwork; _first = first; _second = second; InitializeComponent(); initTableData(); this.WindowStyle = WindowStyle.SingleBorderWindow; this.ResizeMode = ResizeMode.NoResize; }
//su kien khi lua chon move tu popup menu cua table private void moveTable_Click(object sender, RoutedEventArgs e) { bool pass = false; if (currentRec.Opacity == 1) { if (App.Current.Properties["AdLogin"] == null) { MessageBoxResult mess = MessageBox.Show("You must have higher permission for this action? Do you want to continue?", "Warning!", MessageBoxButton.YesNo); if (mess == MessageBoxResult.Yes) { PermissionRequired pr = new PermissionRequired(_cloudPosUnitofwork, ((MainWindow)Window.GetWindow(this)).cUser); pr.ShowDialog(); if (App.Current.Properties["AdLogin"] != null) { pass = true; } } else { return; } } else { pass = true; } if (pass) { currentRec.MouseLeftButtonDown += btnTableAdded_StartDrag; currentRec.MouseMove += btnTableAdded_MoveDrag; currentRec.Opacity = 0.65; currentRec.Cursor = Cursors.SizeAll; Entities.Table t = currentTableList.Where(x => x.TableNumber.Equals(int.Parse(currentRec.Name.Substring(5)))).First(); t.IsPinned = 0; currentRec.ClearValue(BitmapEffectProperty); _unitofwork.TableRepository.Update(t); _unitofwork.Save(); currentRec.ToolTip = SetTooltip(currentRec); } } }
private void buttonChair_Unchecked(object sender, RoutedEventArgs e) { ToggleButton cur = sender as ToggleButton; int id = int.Parse(cur.Name.Substring(2)); if (first == null || second == null) { return; } if (first.TableId.Equals(id)) { first = null; } if (second.TableId.Equals(id)) { second = null; } }
//su kien khi lua chon pin tu popup menu cua table private void pinTable_Click(object sender, RoutedEventArgs e) { if (currentRec.Opacity == 0.65) { currentRec.MouseLeftButtonDown -= btnTableAdded_StartDrag; currentRec.MouseMove -= btnTableAdded_MoveDrag; currentRec.Opacity = 1; currentRec.Cursor = Cursors.Arrow; Entities.Table t = currentTableList.Where(x => x.TableNumber.Equals(int.Parse(currentRec.Name.Substring(5)))).First(); t.IsPinned = 1; currentRec.SetValue(BitmapEffectProperty, recShadow); _unitofwork.TableRepository.Update(t); _unitofwork.Save(); currentRec.ToolTip = SetTooltip(currentRec); } }
private void buttonChair_Checked(object sender, RoutedEventArgs e) { int i = 0; ToggleButton cur = sender as ToggleButton; int id = int.Parse(cur.Name.Substring(2)); foreach (ToggleButton chTable in wpTableContainer.Children) { if (chTable.IsChecked == true) { i++; } } if (i == 1) { first = _unitofwork.TableRepository.Get(x => x.TableId.Equals(id)).First(); } else if (i == 2) { if (second == null) { second = _unitofwork.TableRepository.Get(x => x.TableId.Equals(id)).First(); } else { first = _unitofwork.TableRepository.Get(x => x.TableId.Equals(id)).First(); } } else if (i > 2) { cur.Checked -= buttonChair_Checked; cur.Unchecked -= buttonChair_Unchecked; cur.IsChecked = false; cur.Checked += buttonChair_Checked; cur.Unchecked += buttonChair_Unchecked; return; } }
/// <summary> /// Convert data of OrderTemp object to OrderForPrint /// </summary> /// <param name="table">target table that contain order</param> public OrderForPrint GetAndConvertOrder(Entities.Table targetTable, EmployeewsOfLocalPOS unitofwork) { TableOwned = targetTable; var targetOrder = unitofwork.OrderTempRepository.Get(x => x.TableOwned == targetTable.TableId).First(); No = targetOrder.OrdertempId.ToString(); Casher = targetOrder.EmpId; Customer = targetOrder.CusId; Table = targetTable.TableNumber; Pax = targetOrder.Pax; Date = targetOrder.Ordertime; TotalPriceNonDisc = targetOrder.TotalPriceNonDisc; TotalPrice = targetOrder.TotalPrice; Svc = targetOrder.Svc; Vat = targetOrder.Vat; SaleValue = targetOrder.SaleValue; CustomerPay = targetOrder.CustomerPay; PayBack = targetOrder.PayBack; return(this); }
//method kiem tra sau khi start employee -> order private void checkCurrentEmp(EmpLoginList currentEmp, Rectangle rec, Entities.Table founded, OrderTemp ordertempcurrenttable) { if (App.Current.Properties["CurrentEmpWorking"] == null) { return; } currentEmp = App.Current.Properties["CurrentEmpWorking"] as EmpLoginList; if (currentEmp != null) { if (ordertempcurrenttable != null) { ordertempcurrenttable.EmpId = currentEmp.Emp.EmpId; _unitofwork.OrderTempRepository.Update(ordertempcurrenttable); _unitofwork.Save(); } navigateToOrder(currentEmp, rec, founded); return; } }
//method navigate to entry page private void navigateToOrder(EmpLoginList currentEmp, Rectangle rec, Entities.Table founded) { rec.MouseLeftButtonDown -= btnTableAdded_StartDrag; rec.MouseMove -= btnTableAdded_MoveDrag; rec.Opacity = 1; rec.Cursor = Cursors.Arrow; rec.SetValue(BitmapEffectProperty, recShadowOrdered); founded.IsPinned = 1; //pass ((MainWindow)Window.GetWindow(this)).currentTable = founded; var orderControl = (Entry)((MainWindow)Window.GetWindow(this)).en; ((MainWindow)Window.GetWindow(this)).myFrame.Navigate(orderControl); //orderControl.ucOrder.RefreshControl(_unitofwork, founded); thừa ((MainWindow)Window.GetWindow(this)).bntTable.IsEnabled = true; ((MainWindow)Window.GetWindow(this)).bntDash.IsEnabled = true; ((MainWindow)Window.GetWindow(this)).bntEntry.IsEnabled = false; _unitofwork.TableRepository.Update(founded); _unitofwork.Save(); }
/// <summary> /// Convert the list of OrderDetailsTemp's data to OrderDetailForPrint /// </summary> /// <param name="targetTable"></param> /// <param name="unitofwork"></param> /// <returns></returns> public OrderForPrint GetAndConverOrderDetails(Entities.Table targetTable, EmployeewsOfLocalPOS unitofwork, EmployeewsOfCloudPOS cloudPosUnitofwork, int printType) { // get Chairs data from target Table var targetChairs = unitofwork.ChairRepository.Get(x => x.TableOwned == targetTable.TableId); // get OrderDetailsTemp data from target Table List <OrderDetailsTemp> targetOrderDetails = new List <OrderDetailsTemp>(); foreach (var chair in targetChairs) { targetOrderDetails.AddRange(unitofwork.OrderDetailsTempRepository.Get(x => x.ChairId == chair.ChairId)); } // convert foreach (var orderDetailsTemp in targetOrderDetails) { if (orderDetailsTemp.IsPrinted == 1 && (DoPrintHelper.Bar_Printing == printType || printType == DoPrintHelper.Kitchen_Printing)) { // ignore the printed orderDetails is only available when bar printing and kitchen printing continue; } OrderDetails.Add(new OrderDetailsForPrint() { Quan = orderDetailsTemp.Quan, ProductName = cloudPosUnitofwork.ProductRepository.Get(p => p.ProductId == orderDetailsTemp.ProductId).First().Name, ProductPrice = cloudPosUnitofwork.ProductRepository.Get(p => p.ProductId == orderDetailsTemp.ProductId).First().Price, ProductId = orderDetailsTemp.ProductId, ProductType = cloudPosUnitofwork.ProductRepository.Get(p => p.ProductId == orderDetailsTemp.ProductId).First().Type, ChairNumber = unitofwork.ChairRepository.Get(c => c.ChairId == orderDetailsTemp.ChairId).First().ChairNumber, Note = orderDetailsTemp.Note, SelectedStats = orderDetailsTemp.SelectedStats, }); } return(this); }
//ToDo: Need to update the contain in Warehouse database when new order occur private void lvCategory_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (App.Current.Properties["CurrentEmpWorking"] == null) { return; } orderingTable = ((MainWindow)Window.GetWindow(this)).currentTable; orderingChair = ((MainWindow)Window.GetWindow(this)).currentChair; ListBox lbSelected = sender as ListBox; if (orderingTable == null || orderingChair == null) { MessageBox.Show("Chair must be choice!"); return; } orderTempCurrentTable = _unitofwork.OrderTempRepository.Get(x => x.TableOwned.Equals(orderingTable.TableId)).First(); if (orderTempCurrentTable == null) { return; } var item = lbSelected.SelectedItem; if (item != null) { if (orderingTable.IsOrdered == 0) { orderTempCurrentTable.Ordertime = DateTime.Now; orderingTable.IsOrdered = 1; _unitofwork.TableRepository.Update(orderingTable); } OrderDetailsTemp o = new OrderDetailsTemp(); Product it = (Product)lbSelected.SelectedItem; //order for each chair if (orderingChair != null) { var chairorderdetailstemp = _unitofwork.OrderDetailsTempRepository.Get(x => x.ChairId.Equals(orderingChair.ChairId)).ToList(); var foundinchairorderdetailstemp = chairorderdetailstemp.Where(x => x.ProductId.Equals(it.ProductId)).ToList(); // go to warehouse, check and get the ingredient to make product if (!TakeFromWareHouseData(o, it)) { return; } // add a product to order if (foundinchairorderdetailstemp.Count == 0) { o.ChairId = orderingChair.ChairId; o.OrdertempId = orderTempCurrentTable.OrdertempId; o.ProductId = it.ProductId; o.SelectedStats = it.StandardStats; o.Note = ""; o.Quan = 1; o.IsPrinted = 0; o.Discount = it.Discount; _unitofwork.OrderDetailsTempRepository.Insert(o); _unitofwork.Save(); } else { foreach (var order in foundinchairorderdetailstemp) { if (!order.SelectedStats.Equals(it.StandardStats) || !order.Note.Equals("") || order.IsPrinted != 0) { o.ChairId = orderingChair.ChairId; o.OrdertempId = orderTempCurrentTable.OrdertempId; o.ProductId = it.ProductId; o.SelectedStats = it.StandardStats; o.Note = ""; o.Quan = 1; o.IsPrinted = 0; o.Discount = it.Discount; _unitofwork.OrderDetailsTempRepository.Insert(o); _unitofwork.Save(); break; } if (order.SelectedStats.Equals(it.StandardStats) && order.Note.Equals("") && order.IsPrinted == 0) { order.ProductId = it.ProductId; order.Quan++; _unitofwork.OrderDetailsTempRepository.Update(order); _unitofwork.Save(); break; } } } } lbSelected.UnselectAll(); checkWorkingAction(App.Current.Properties["CurrentEmpWorking"] as EmpLoginList, orderTempCurrentTable); ((MainWindow)Window.GetWindow(this)).initProgressTableChair(); ((MainWindow)Window.GetWindow(this)).en.ucOrder.RefreshControl(_unitofwork, orderingTable); ((MainWindow)Window.GetWindow(this)).en.ucOrder.txtDay.Text = orderTempCurrentTable.Ordertime.ToString("dd/MM/yyyy H:mm:ss"); } }
public static void DeleteTable(Context context, Entities.Table table) { context.Tables.Add(table); context.SaveChanges(); }
private void btnSwap_Click(object sender, RoutedEventArgs e) { if (first == null || second == null) { MessageBox.Show("You must be choose two table to swap!"); return; } loadData(); //swap ordertemp orderOfFirst.TableOwned = second.TableId; orderOfSecond.TableOwned = first.TableId; _unitofwork.OrderTempRepository.Update(orderOfFirst); _unitofwork.OrderTempRepository.Update(orderOfSecond); _unitofwork.Save(); _currentChairList = _unitofwork.ChairRepository.Get().ToList(); _orderTempList = _unitofwork.OrderTempRepository.Get().ToList(); _orderDetailsTempList = _unitofwork.OrderDetailsTempRepository.Get().ToList(); loadData(); var chairOfFirst = _currentChairList.Where(x => x.TableOwned.Equals(first.TableId)).ToList(); var chairOfSecond = _currentChairList.Where(x => x.TableOwned.Equals(second.TableId)).ToList(); first.ChairAmount = chairOfSecond.Count; second.ChairAmount = chairOfFirst.Count; _unitofwork.TableRepository.Update(first); _unitofwork.TableRepository.Update(second); foreach (var ch in chairOfFirst) { ch.TableOwned = second.TableId; _unitofwork.ChairRepository.Update(ch); } foreach (var ch in chairOfSecond) { ch.TableOwned = first.TableId; _unitofwork.ChairRepository.Update(ch); } //temporary first table to swap Entities.Table tempFirst = new Entities.Table { TableId = first.TableId, TableNumber = first.TableNumber, ChairAmount = first.ChairAmount, PosX = first.PosX, PosY = first.PosY, IsPinned = first.IsPinned, IsOrdered = first.IsOrdered, IsLocked = first.IsLocked, IsPrinted = first.IsPrinted, TableRec = first.TableRec, }; //temporary second table to swap Entities.Table tempSecond = new Entities.Table { TableId = second.TableId, TableNumber = second.TableNumber, ChairAmount = second.ChairAmount, PosX = second.PosX, PosY = second.PosY, IsPinned = second.IsPinned, IsOrdered = second.IsOrdered, IsLocked = second.IsLocked, IsPrinted = second.IsPrinted, TableRec = second.TableRec, }; //setting new first table first.IsOrdered = tempSecond.IsOrdered; first.IsLocked = tempSecond.IsLocked; first.IsPrinted = tempSecond.IsPrinted; //setting new second table second.IsOrdered = tempFirst.IsOrdered; second.IsLocked = tempFirst.IsLocked; second.IsPrinted = tempFirst.IsPrinted; _unitofwork.TableRepository.Update(first); _unitofwork.TableRepository.Update(second); _unitofwork.Save(); MessageBox.Show("Swapped Successful!"); }
//mothod kiem tra single or double private void DoClickSingleOrDouble(FrameworkElement ctrl, Rectangle rec) { int clicks = ClickAttach.GetClicks(ctrl); ClickAttach.SetClicks(ctrl, 0); if (clicks == 2) { if (App.Current.Properties["AdLogin"] != null) { return; } EmpLoginList currentEmp = App.Current.Properties["CurrentEmpWorking"] as EmpLoginList; AllEmployeeLogin ael; Entities.Table founded = currentTableList.Where(x => x.TableNumber.Equals(int.Parse(rec.Name.Substring(5)))).First(); if (founded == null) { return; } var ordertempcurrenttable = _unitofwork.OrderTempRepository.Get(x => x.TableOwned.Equals(founded.TableId)).First(); if (founded.IsPinned == 0) { MessageBoxResult mess = MessageBox.Show("You must be pin this table before you want to create new order. Do you want to pin now?", "Warning!", MessageBoxButton.YesNo); if (mess == MessageBoxResult.Yes) { if (founded.ChairAmount == 0) { MessageBox.Show("You must be set Chair Amount greater than 0!"); return; } if (currentEmp != null) { if (ordertempcurrenttable != null) { ordertempcurrenttable.EmpId = currentEmp.Emp.EmpId; _unitofwork.OrderTempRepository.Update(ordertempcurrenttable); _unitofwork.Save(); } navigateToOrder(currentEmp, founded.TableRec, founded); return; } ael = new AllEmployeeLogin((MainWindow)Window.GetWindow(this), _unitofwork, _cloudPosUnitofwork, ((MainWindow)Window.GetWindow(this)).cUser, 4); ael.ShowDialog(); checkCurrentEmp(currentEmp, founded.TableRec, founded, ordertempcurrenttable); } } else { if (founded.ChairAmount == 0) { MessageBox.Show("You must be set Chair Amount greater than 0!"); return; } if (founded.IsOrdered == 1) { currentEmp = App.Current.Properties["CurrentEmpWorking"] as EmpLoginList; if (currentEmp != null) { if (currentEmp.Emp.EmpId.Equals(ordertempcurrenttable.EmpId)) { navigateToOrder(currentEmp, founded.TableRec, founded); return; } else { navigateToOrder(currentEmp, founded.TableRec, founded); return; } } ael = new AllEmployeeLogin((MainWindow)Window.GetWindow(this), _unitofwork, _cloudPosUnitofwork, ((MainWindow)Window.GetWindow(this)).cUser, 4); ael.ShowDialog(); checkCurrentEmp(currentEmp, founded.TableRec, founded, ordertempcurrenttable); } else { currentEmp = App.Current.Properties["CurrentEmpWorking"] as EmpLoginList; if (currentEmp != null) { if (ordertempcurrenttable != null) { ordertempcurrenttable.EmpId = currentEmp.Emp.EmpId; _unitofwork.OrderTempRepository.Update(ordertempcurrenttable); _unitofwork.Save(); } checkCurrentEmp(currentEmp, founded.TableRec, founded, ordertempcurrenttable); return; } ael = new AllEmployeeLogin((MainWindow)Window.GetWindow(this), _unitofwork, _cloudPosUnitofwork, ((MainWindow)Window.GetWindow(this)).cUser, 4); ael.ShowDialog(); checkCurrentEmp(currentEmp, founded.TableRec, founded, ordertempcurrenttable); } } } }