//su kien khi click table(single or double) private async void btnTableAdded_Click(object sender, MouseButtonEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { FrameworkElement ctrl = (FrameworkElement)sender; ClickAttach.SetClicks(ctrl, (int)e.ClickCount); await Task.Delay(300); DoClickSingleOrDouble(ctrl, sender as Rectangle); } }
//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); } } } }