コード例 #1
0
 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());
     }
 }