private void DeleteItemCommandExecute() { try { if (WarehouseItem != null) { MessageBoxResult result = MessageBox.Show("Are you sure you want to delete warehouse item?", "Delete Record", MessageBoxButton.OKCancel); switch (result) { case MessageBoxResult.OK: int itemId = warehouseItem.ID; dataBaseService.DeleteWarehouseItem(itemId); string logMessage = string.Format("Warehouse Item: {0}, Item number: {1}, Item amount: {2}, was deleted from database.", WarehouseItem.ProductName, WarehouseItem.ProductNumber, WarehouseItem.Amount); actionEventObject.OnActionPerformed(logMessage); WarehouseItemList = dataBaseService.GetAllWarehouseItems().ToList(); MessageBox.Show("Item deleted!", "Delete Record"); break; case MessageBoxResult.Cancel: break; } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void DeleteWorkerExecute() { try { if (Worker != null) { MessageBoxResult result = MessageBox.Show("Are you sure you want to delete employee record?", "Delete Record", MessageBoxButton.OKCancel); switch (result) { case MessageBoxResult.OK: int _workerID = _worker.WorkerID; _dataBaseService.DeleteWorker(_workerID); string logMessage = string.Format("Worker {0} {1} - JMBG:{2}, was deleted from database.", _worker.FirstName, _worker.LastName, _worker.JMBG); actionEventObject.OnActionPerformed(logMessage); WorkerList = _dataBaseService.GetAllWorkerRecords().ToList(); MessageBox.Show("Record deleted!", "Delete Record"); break; case MessageBoxResult.Cancel: break; } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void SaveExecute() { try { if (EntryValidation.ValidateName(Worker.FirstName) == false) { MessageBox.Show("First Name can only contain letters. Please try again", "Invalid input"); return; } if (EntryValidation.ValidateName(Worker.LastName) == false) { MessageBox.Show("Last Name can only contain letters. Please try again", "Invalid input"); return; } if (EntryValidation.ValidateDate(Worker.DateOfBirth) == false) { MessageBox.Show("Person Must be at least 16 years of age. Please try again", "Invalid input"); return; } if (EntryValidation.ValidatePersonalIDNumber(Worker.PersonalIDNumber) == false) { MessageBox.Show("Personal ID nubmer you entered is not valid. Please try again", "Invalid input"); return; } if (EntryValidation.ValidateJmbg(Worker.JMBG) == false) { MessageBox.Show("JMBG you entered is not valid. Please try again", "Invalid input"); return; } if (EntryValidation.ValidatePhone(Worker.PhoneNumber) == false) { MessageBox.Show("Phone number you entered is not in correct format. Please try again", "Invalid input"); return; } Worker.GenderID = Gender.GenderID; Worker.SectorID = Sector.SectorID; if (Manager != null) { Worker.ManagerID = Manager.WorkerID; } Worker.LocationID = Location.LocationID; _dbService.AddWorker(Worker); IsUpdateWorker = true; string logMessage = string.Format("Worker {0} {1} - JMBG:{2}, was added to database.", _worker.FirstName, _worker.LastName, _worker.JMBG); actionEventObject.OnActionPerformed(logMessage); MessageBox.Show("New Worker Added Successfully!", "Info"); _addWorker.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void EditCommandExecute() { try { if (EntryValidation.ValidateProductName(WarehouseItem.ProductName) == false) { MessageBox.Show("Product name can only contain letters and numbers. Please try again", "Invalid input"); return; } if (EntryValidation.ValidateProductNumber(WarehouseItem.ProductNumber) == false) { MessageBox.Show("Product number can only contain numbers. Please try again", "Invalid input"); return; } if (EntryValidation.ValidateAmount((int)WarehouseItem.Amount) == false) { MessageBox.Show("Amount must be greated than 0 and less or equat to 100. Please try again", "Invalid input"); return; } if (EntryValidation.ValidatePriceFormat(WarehouseItem.Price) == false) { MessageBox.Show("Price can contain only decimal numbers (numbers, comma and dot is allowed). Please try again", "Invalid input"); return; } if (EntryValidation.ValidatePriceAmount(WarehouseItem.Price) == false) { MessageBox.Show("Price must be a positive number. Please try again", "Invalid input"); return; } dataBaseService.EditWarehouseItem(WarehouseItem); IsUpdateWarehouseItem = true; string logMessage = string.Format("Warehouse Item: {0}, Item number: {1}, Item amount: {2}, Item price: {3} was edited to new Item Name:{4}," + " Item Number: {5}, Item Amount: {6}, Item Price: {7}.", ProductNameBeforeEdit, ProductNumberBeforeEdit, AmountBeforeEdit, PriceBeforeEdit, WarehouseItem.ProductName, WarehouseItem.ProductNumber, WarehouseItem.Amount, WarehouseItem.Price); actionEventObject.OnActionPerformed(logMessage); MessageBox.Show("New Warehouse Item Edited Successfully!", "Info"); editItem.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }