public AddEndOfShiftUserControl() { endOfShiftViewModel = new EndOfShiftViewModel(); _endOfShiftBusiness = new EndOfShiftBusiness(); InitializeComponent(); this.DataContext = endOfShiftViewModel; InitializeData(); }
public bool Update(EndOfShiftViewModel entity) { var endOfShift = entity.MapToEndOfShift(); endOfShift.CreatedDate = DateTime.Now; endOfShift.EndOfShiftId = StaffGlobal.CurrentStaff.StaffId; DateTime fromDatetime = new DateTime(endOfShift.CreatedDate.Year, endOfShift.CreatedDate.Month, endOfShift.CreatedDate.Day, entity.From, 0, 0); DateTime toDatetime = new DateTime(endOfShift.CreatedDate.Year, endOfShift.CreatedDate.Month, endOfShift.CreatedDate.Day, entity.To, 0, 0); //hanlder money var totalMoney = _saleBillRepository.GetAll().Where(s => !s.IsAprroved && s.CreatedDate >= fromDatetime && s.CreatedDate <= toDatetime) .Sum(s => s.TotalMoney); endOfShift.TotalMoney = totalMoney; return(_endOfShiftRepository.Update(endOfShift)); }
private void Add_Click(object sender, RoutedEventArgs e) { if (endOfShiftViewModel.IsValidModel()) { var isSuccess = _endOfShiftBusiness.Add(endOfShiftViewModel); if (isSuccess) { MessageBox.Show("Đã thêm thành công!", "Add", MessageBoxButton.OK, MessageBoxImage.Information); endOfShiftViewModel = new EndOfShiftViewModel(); } else { MessageBox.Show("Thêm không thành công!", "Add", MessageBoxButton.OK, MessageBoxImage.Error); } } }