/// <summary> /// Sets the modification review date and reviewer and updates the database with the new information /// Should be surrounded by a try catch /// </summary> /// <param name="mod"></param> private void updateModification(EngineeredModification mod) { mod.ReviewedDate = DateTime.Now; mod.Reviewer = string.Format("{0} {1}", _navigationService.user.FirstName, _navigationService.user.LastName); _serviceProxy.updateEngineeredModification(mod); }
/// <summary> /// Submits each of the component modifications to the database /// </summary> private void submit() { informationText = ""; if (componentsFound.Count <= 0) { informationText = "No components selected to update."; } else if (checkComplete()) { try { informationText = "Submitting component modifications..."; //Create a new modification for each component in the list foreach (Component component in componentsFound) { EngineeredModification modifiedComponent = new EngineeredModification() { RequestDate = DateTime.Now, ReviewedDate = new DateTime(1900, 1, 1), Description = string.IsNullOrWhiteSpace(description) ? "no description entered" : description, State = 0, Sender = string.Format("{0} {1}", _navigationService.user.FirstName, _navigationService.user.LastName), Reviewer = "", IsNew = false, ComponentName = component.ComponentName, EnclosureSize = component.EnclosureSize, EnclosureType = "", NewTime = (decimal)newTime, OldTime = component.Time, Gauge = "", NewTimePercentage = 0, OldTimePercentage = 0 }; _serviceProxy.addEngineeredModificationRequest(modifiedComponent); } //Clear input boxes _component = ""; RaisePropertyChanged("component"); _enclosureSize = ""; RaisePropertyChanged("enclosureSize"); componentsFound = new ObservableCollection <Component>(); newTime = null; description = ""; informationText = "Component modifications have been submitted. Waiting for manager approval."; } catch (Exception e) { informationText = "There was a problem accessing the database"; Console.WriteLine(e); } } }
/// <summary> /// Submits the wire guage modification to the database /// </summary> private void submit() { informationText = ""; if (wireGaugesFound.Count <= 0) { informationText = "No wire guages selected to update."; } else if (checkComplete()) { try { informationText = "Submitting wire gauge modifications..."; //Create a new modification for each wire gauge in the list //Should only be one foreach (WireGauge gauge in wireGaugesFound) { EngineeredModification modifiedGauge = new EngineeredModification() { RequestDate = DateTime.Now, ReviewedDate = new DateTime(1900, 1, 1), Description = string.IsNullOrWhiteSpace(description) ? "no description entered" : description, State = 0, Sender = string.Format("{0} {1}", _navigationService.user.FirstName, _navigationService.user.LastName), Reviewer = "", IsNew = false, ComponentName = "", EnclosureSize = "", EnclosureType = "", NewTime = 0, OldTime = 0, Gauge = gauge.Gauge, NewTimePercentage = (decimal)newTimePercentage, OldTimePercentage = gauge.TimePercentage }; _serviceProxy.addEngineeredModificationRequest(modifiedGauge); } //Clear input boxes _wireGauge = null; RaisePropertyChanged("wireGauge"); wireGaugesFound = new ObservableCollection <WireGauge>(); newTimePercentage = null; description = ""; informationText = "Wire gauge modification has been submitted. Waiting for manager approval."; } catch (Exception e) { informationText = "There was a problem accessing the database"; Console.WriteLine(e); } } }
/// <summary> /// Creates the new component modifications for each enclosure size and adds them to the modifications to submit list /// Calls checkValid and newEnclosureSizeTimes /// </summary> private void addComponent() { informationText = ""; if (checkValid()) { informationText = "Adding components..."; foreach (Component component in enclosureSizeTimes) { EngineeredModification mod = new EngineeredModification() { RequestDate = DateTime.Now, ReviewedDate = new DateTime(1900, 1, 1), Description = string.IsNullOrWhiteSpace(description) ? "no description entered" : description, State = 0, Sender = string.Format("{0} {1}", _navigationService.user.FirstName, _navigationService.user.LastName), Reviewer = "", IsNew = true, ComponentName = component.ComponentName, EnclosureSize = component.EnclosureSize, EnclosureType = "", NewTime = component.Time, OldTime = 0, Gauge = "", NewTimePercentage = 0, OldTimePercentage = 0 }; // Since the observable collection was created on the UI thread // we have to add the override to the list using a delegate function. App.Current.Dispatcher.Invoke(delegate { modificationsToSubmit.Add(mod); }); } //Clear input boxes componentName = ""; newEnclosureSizeTimes(); informationText = "Components added"; } }