private void checkWorkingAction(EmpLoginList currentEmp, OrderTemp ordertempcurrenttable) { ((MainWindow)Window.GetWindow(this)).b.isTablesDataChange = true; if (currentEmp.Emp.EmpId.Equals(ordertempcurrenttable.EmpId)) { return; } if (ordertempcurrenttable.SubEmpId != null) { string[] subemplist = ordertempcurrenttable.SubEmpId.Split(','); for (int i = 0; i < subemplist.Count(); i++) { if (subemplist[i].Equals("")) { continue; } if (currentEmp.Emp.EmpId.Equals(subemplist[i])) { return; } } ordertempcurrenttable.SubEmpId += currentEmp.Emp.EmpId + ","; _unitofwork.OrderTempRepository.Update(ordertempcurrenttable); _unitofwork.Save(); return; } ordertempcurrenttable.SubEmpId += currentEmp.Emp.EmpId + ","; _unitofwork.OrderTempRepository.Update(ordertempcurrenttable); _unitofwork.Save(); }
private void BtnCodeLogin_Click(object sender, RoutedEventArgs e) { DependencyObject dep = (DependencyObject)e.OriginalSource; while ((dep != null) && !(dep is ListViewItem)) { dep = VisualTreeHelper.GetParent(dep); } if (dep == null) { if (this.Width == 500) { IsShow = false; LoadForm.Start(); } spLoginAnother.Visibility = Visibility.Visible; loginNormal.Visibility = Visibility.Collapsed; loginCode.Visibility = Visibility.Visible; lvLoginList.UnselectAll(); txbLabel.Text = "Login Another"; setControl(true); } else { if (_typeshow == 1) { return; } int index = lvLoginList.ItemContainerGenerator.IndexFromContainer(dep); EmpLoginList emp = EmpLoginListData.emploglist[index]; if (emp == null) { MessageBox.Show("Please choose employee to continue!"); return; } if (this.Width == 500) { IsShow = false; LoadForm.Start(); } _emplog = emp; spLoginAnother.Visibility = Visibility.Visible; loginNormal.Visibility = Visibility.Collapsed; loginCode.Visibility = Visibility.Visible; lvLoginList.UnselectAll(); txbLabel.Text = "Login Another"; setControl(true); } }
//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(); }
private void btnView_Click(object sender, RoutedEventArgs e) { _emplog = lvLoginList.SelectedItem as EmpLoginList; if (_emplog == null) { MessageBox.Show("Please choose one employee want to view details!"); return; } if (this.Width == 500) { IsShow = false; LoadForm.Start(); } spLoginAnother.Visibility = Visibility.Visible; loginNormal.Visibility = Visibility.Visible; loginCode.Visibility = Visibility.Collapsed; lvLoginList.UnselectAll(); txbLabel.Text = "View Details"; setControl(false); txtUsername.Text = _emplog.Emp.Username; }
//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); } } } }
private async Task Async(string username, string pass, string code, EmpLoginList empout) { try { await Task.Run(() => { if (empout != null) { if (EmpLoginListData.emploglist.Count == 1) { var orderedTable = _unitofwork.TableRepository.Get(x => x.IsOrdered == 1).ToList(); if (orderedTable.Count != 0) { MessageBox.Show("You can not logout because still have Tables that in the ordering state out there. Please check again!"); return; } } if ((empout.Emp.Username.Equals(username) && (empout.Emp.DecryptedPass.Equals(pass)) || empout.Emp.DecryptedCode.Equals(code))) { empout.EmpWH.EndTime = DateTime.Now; _cloudPosUnitofwork.WorkingHistoryRepository.Insert(empout.EmpWH); _cloudPosUnitofwork.Save(); var workH = empout.EmpWH.EndTime - empout.EmpWH.StartTime; empout.EmpSal = _cloudPosUnitofwork.SalaryNoteRepository.Get(sle => sle.EmpId.Equals(empout.Emp.EmpId) && sle.ForMonth.Equals(DateTime.Now.Month) && sle.ForYear.Equals(DateTime.Now.Year)).First(); empout.EmpSal.WorkHour += workH.Hours + (workH.Minutes / 60.0) + (workH.Seconds / 3600.0); empout.EmpSal.SalaryValue = (decimal)(empout.EmpSal.WorkHour *empout.Emp.HourWage); _cloudPosUnitofwork.SalaryNoteRepository.Update(empout.EmpSal); _cloudPosUnitofwork.Save(); EmpLoginListData.emploglist.Remove(empout); Dispatcher.Invoke(() => { checkEmployeeCount(); }); return; } else { MessageBox.Show("Fail! Please try again!"); return; } } bool isFound = false; foreach (Employee emp in _employee) { if ((emp.Username.Equals(username) && (emp.DecryptedPass.Equals(pass)) || emp.DecryptedCode.Equals(code))) { var chemp = EmpLoginListData.emploglist.Where(x => x.Emp.EmpId.Equals(emp.EmpId)).ToList(); if (chemp.Count != 0) { MessageBox.Show("This employee is already login!"); return; } try { SalaryNote empSalaryNote = _cloudPosUnitofwork.SalaryNoteRepository.Get(sle => sle.EmpId.Equals(emp.EmpId) && sle.ForMonth.Equals(DateTime.Now.Month) && sle.ForYear.Equals(DateTime.Now.Year)).First(); App.Current.Properties["EmpSN"] = empSalaryNote; WorkingHistory empWorkHistory = new WorkingHistory { ResultSalary = empSalaryNote.SnId, EmpId = empSalaryNote.EmpId }; App.Current.Properties["EmpWH"] = empWorkHistory; } catch (Exception ex) { SalaryNote empSalary = new SalaryNote { EmpId = emp.EmpId, SalaryValue = 0, WorkHour = 0, ForMonth = DateTime.Now.Month, ForYear = DateTime.Now.Year, IsPaid = 0 }; _cloudPosUnitofwork.SalaryNoteRepository.Insert(empSalary); _cloudPosUnitofwork.Save(); WorkingHistory empWorkHistory = new WorkingHistory { ResultSalary = empSalary.SnId, EmpId = empSalary.EmpId }; App.Current.Properties["EmpWH"] = empWorkHistory; App.Current.Properties["EmpSN"] = empSalary; } Dispatcher.Invoke(() => { EmpLoginListData.emploglist.Add(new EmpLoginList { Emp = emp, EmpSal = App.Current.Properties["EmpSN"] as SalaryNote, EmpWH = App.Current.Properties["EmpWH"] as WorkingHistory, TimePercent = 0 }); checkEmployeeCount(); setControl(true); }); isFound = true; //end create break; } } if (!isFound) { MessageBox.Show("incorrect username or password"); return; } }); } catch (Exception ex) { } }