Exemplo n.º 1
0
 /// <summary>
 /// Add a device.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnAddDevice_Click(object sender, EventArgs e)
 {
     try
     {
         if (CoreSystem.SelectedOrder.ETypeDevice == eType && !(CoreSystem.ListAssembly is null) && this.pressButton == true)
         {
             if (CoreSystem.PreviewDevices.Count < CoreSystem.SelectedOrder.CountDevice || MessageBox.Show($"The quantity requested in the order has already been reached. Do you want to assemble the device anyway?", "LIMIT DEVICES", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes)
             {
                 if (Stock.ThereIsStock(CoreSystem.ListAssembly, out string component))
                 {
                     CoreSystem.LoadDevices(eType, eValidation);
                     CoreSystem.PreviewDevices.Add(CoreSystem.DeviceAssembly);
                     this.pgbStatusOrder.Value = (int)((float)CoreSystem.PreviewDevices.Count / CoreSystem.SelectedOrder.CountDevice * 100);
                     Device.SaveLogDevices(CoreSystem.DeviceAssembly, "Assembly");
                     CoreSystem.DeviceAssembly = null;
                     SerialsNumbers.SaveSerialsNumbers();
                     DAO.ModifyListComponents(Stock.ComponentsStock);
                     PressButton();
                     LoadListAssembly();
                     TrasparentButtonsSubPanel();
                     HideSubMenu();
                     this.lblSerialNumber.Text = "--";
                 }
                 else
                 {
                     MessageBox.Show($"The missing materials are:\n\n{component}", "NO STOCK COMPONENTS!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
         }
         else
         {
             MessageBox.Show("The device to be assembled must be of the same type as the order", "TYPE ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "NO ADD DEVICE!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }