public void TestEditBatchType() { TestAddBatchType(); bool success1 = BatchTypeController.EditBatchType(type2.Name, type1.VariableA, type1.VariableB, type1.TemperatureRequirement, type1.ViscosityRequirement, type1.SpeedRequirement, type1.TimeRequirement); Assert.IsTrue(success1); }
public void TestAddBatchType() { bool success1 = BatchTypeController.AddBatchType(type1); bool success2 = BatchTypeController.AddBatchType(type2); bool success3 = BatchTypeController.AddBatchType(type3); bool success4 = BatchTypeController.AddBatchType(type4); Assert.IsTrue(success1 && success2 && success3 && success4); }
public void TestGetBachType() { TestAddBatchType(); BatchType test = BatchTypeController.GetBatchType(type1.Name); BatchType emptyTest = BatchTypeController.GetBatchType(""); Assert.IsTrue(test.Equals(test, type1)); Assert.AreEqual(null, emptyTest); }
public void TestGetAllBatchTypes() { TestAddBatchType(); List <BatchType> tests = BatchTypeController.GetAllBatchTypes(); CleanUp(); List <BatchType> emptyTests = BatchTypeController.GetAllBatchTypes(); Assert.IsTrue(type1.Equals(tests[0], type1)); Assert.IsTrue(type1.Equals(tests[1], type2)); Assert.IsTrue(type1.Equals(tests[2], type3)); Assert.IsTrue(type1.Equals(tests[3], type4)); Assert.AreEqual(null, emptyTests); }
/// <summary> /// Initializes a new instance of the <see cref="HistoryWindow"/> class. /// </summary> public HistoryWindow() { InitializeComponent(); try { _machineIDs = MachineController.GetMachineIDs(); } catch { MessageBox.Show("Error getting Machine IDs.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error); return; } try { _batches = BatchController.GetAllBatches(); } catch { MessageBox.Show("Error getting Batches.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error); return; } try { _batchTypes = BatchTypeController.GetAllBatchTypes(); } catch { MessageBox.Show("Error getting Batch Types.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error); return; } cboMachines.ItemsSource = _machineIDs; cboMachines.SelectedIndex = 0; cboBatchTypes.ItemsSource = _batchTypes; cboBatchTypes.SelectedIndex = 0; dgHistory.ItemsSource = _batches; }
/// <summary> /// Initializes a new instance of the <see cref="EditBatchTypeWindow"/> class. /// </summary> public EditBatchTypeWindow() { InitializeComponent(); try { _batchTypes = BatchTypeController.GetAllBatchTypes(); } catch { MessageBox.Show("Error retrieving batch types from the database. Please Try again.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error); Close(); } if (_batchTypes.Count > 0) { cboBatchTypes.ItemsSource = _batchTypes; cboBatchTypes.SelectedIndex = 0; } }
/// <summary> /// Handles the Click event of the btnAdd control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param> private void btnAdd_Click(object sender, RoutedEventArgs e) { BatchType newType = new BatchType(); AddBatchTypeWindow newWindow = new AddBatchTypeWindow(newType); if (newWindow.ShowDialog().Value) { try { BatchTypeController.AddBatchType(newType); } catch { MessageBox.Show("Error adding batch type.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error); return; } _batchTypes.Add(newType); MessageBox.Show("Added batch type!"); } }
/// <summary> /// Initializes a new instance of the <see cref="NewBatchWindow"/> class. /// </summary> public NewBatchWindow() { InitializeComponent(); _machine = MachineController.InitializeMachine(); _lblStatus1Dispatcher = lblStatus1.Dispatcher; _lblStatus2Dispatcher = lblStatus2.Dispatcher; _lblStatus3Dispatcher = lblStatus3.Dispatcher; _lblStatus4Dispatcher = lblStatus4.Dispatcher; _lblStatus5Dispatcher = lblStatus5.Dispatcher; _lblStatus6Dispatcher = lblStatus6.Dispatcher; _worker = new BackgroundWorker(); _worker.WorkerReportsProgress = true; _worker.WorkerSupportsCancellation = true; _worker.DoWork += worker_MakeBatch; _worker.ProgressChanged += new ProgressChangedEventHandler(worker_ProgressChanged); _worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted); //Load batch types into combo box try { _batchTypes = BatchTypeController.GetAllBatchTypes(); } catch { MessageBox.Show("Error retrieving batch types from database.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (_batchTypes.Count <= 0) { MessageBox.Show("No batch types found.", "Notice!", MessageBoxButton.OK, MessageBoxImage.Asterisk); return; } cboBatchTypes.ItemsSource = _batchTypes; cboBatchTypes.SelectedIndex = 0; }
/// <summary> /// Handles the Click event of the btnEdit control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param> private void btnEdit_Click(object sender, RoutedEventArgs e) { double variableA, variableB, temp; double?tempReq = null; double?viscosityReq = null; double?timeReq = null; double?speedReq = null; bool success = true; if (!double.TryParse(txtVariableA.Text, out variableA)) { success = false; } if (!double.TryParse(txtVariableB.Text, out variableB)) { success = false; } if (txtTemperatureRequirement.Text != "" && txtViscosityRequirement.Text == "" && txtSpeedRequirement.Text == "" && txtTimeRequirement.Text == "") { if (!double.TryParse(txtTemperatureRequirement.Text, out temp)) { success = false; } else { tempReq = temp; } } else if (txtTemperatureRequirement.Text == "" && txtViscosityRequirement.Text != "" && txtSpeedRequirement.Text == "" && txtTimeRequirement.Text == "") { if (!double.TryParse(txtViscosityRequirement.Text, out temp)) { success = false; } else { viscosityReq = temp; } } else if (txtTemperatureRequirement.Text == "" && txtViscosityRequirement.Text == "" && txtSpeedRequirement.Text != "" && txtTimeRequirement.Text != "") { if (!double.TryParse(txtTimeRequirement.Text, out temp)) { success = false; } else { timeReq = temp; } if (!double.TryParse(txtSpeedRequirement.Text, out temp)) { success = false; } else { speedReq = temp; } } else { MessageBox.Show("Invalid requirements. Please specify either Temperature, Viscosity, or Speed and Time.", "Error", MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (success) { try { BatchTypeController.EditBatchType(cboBatchTypes.SelectedItem.ToString(), variableA, variableB, tempReq, viscosityReq, speedReq, timeReq); } catch { MessageBox.Show("Error editing batch", "Error!", MessageBoxButton.OK, MessageBoxImage.Error); return; } } else { MessageBox.Show("Invalid data entered.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error); return; } MessageBox.Show("Batch edited succesfully!"); }
public void TestAddBatchError() { BatchTypeController.AddBatchType(null); }