protected override void ResetFields() { OnSafeChanging = true; dtpOutDate.Reset(); dtpInDate.Reset(); _current = null; ChangesHappened = OnSafeChanging = false; }
protected override void LoadWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { var results = e.Result as IList <object>; if (results == null || results.Count == 0 || (results[0] as Prop) == null) { tbNoResults.Visibility = btnSearch.Visibility = Visibility.Visible; spDetails.Visibility = spType.Visibility = spInputs.Visibility = Visibility.Collapsed; } else { OnSafeChanging = true; spDetails.Visibility = spType.Visibility = spInputs.Visibility = Visibility.Visible; btnCancelChanges.IsEnabled = true; tbNoResults.Visibility = btnSearch.Visibility = Visibility.Collapsed; var prop = results[0] as Prop; if (prop != null) { tbName.Text = prop.Name; tbPropNo.Text = prop.PropNo.ToString(); if (string.IsNullOrWhiteSpace(tbPropNo.Text)) { tbPropNo.Text = PropStatusResources.Unknown; } tbSerialNo.Text = prop.SerialNo; if (string.IsNullOrWhiteSpace(tbSerialNo.Text)) { tbSerialNo.Text = PropStatusResources.Unknown; } tbCreateDate.Text = prop.StringCreatedOn; } _current = results[1] as PropStatusChange; if (_current != null) { cmbStatus.SelectedIndex = -1; cmbStatus.SelectedIndex = _current.Type; tbDescription.Text = _current.Description; } OnSafeChanging = false; } btnSubmit.IsEnabled = btnCancelChanges.IsEnabled = false; aiLoader.Visibility = Visibility.Collapsed; OnReloading = false; }
public static string PropStatusChangeDetailer(PropStatusChange propStatusChange, ActionType actionType) { switch (actionType) { case ActionType.Created: return(string.Format("برای اموالی با شناسه {0} تعیین وضعیت (پیشفرض سیستم: آزاد) انجام شد.", propStatusChange.PropID)); case ActionType.Modified: return(string.Format("وضعیت تعیین شده ({1}) اموالی با شناسه {0} بروز شد.", propStatusChange.PropID, ((ReportType)propStatusChange.Type).ToUIString())); case ActionType.Removed: return(string.Format("وضعیت ({1}) اموالی با شناسه {0} حذف شد.", propStatusChange.PropID, ((ReportType)propStatusChange.Type).ToUIString())); default: return(null); } }
protected override void SaveWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (ValidateFields()) { var result = MessageBoxResult.Yes; var type = (ReportType)cmbStatus.SelectedIndex; if (type == ReportType.Used || type == ReportType.DeliveredToRepository) { result = MessageWindowHelpers.Show(this, PropStatusResources.Attention, MessageBoxButton.YesNo, MessageBoxImage.Question); } if (result == MessageBoxResult.Yes) { if (_current.Type == (short)cmbStatus.SelectedIndex) { switch (_current.Type) { case 1: case 2: _current.ChangedOn = dtpOutDate.Value; _current.ResolveDate = dtpInDate.Value; break; case 3: case 5: _current.ChangedOn = dtpOutDate.Value; break; } _current.Description = tbDescription.Text; if (PropStatusChangesService.Instanse.Insert(_current)) { Global.SubmissionSuceeded(this); ResetFields(); if ( MessageWindowHelpers.Show(this, PropStatusResources.SelectAnotherProp, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { TryToLoad(true); } else { Close(); } } else { Global.SubmissionFailed(this); } } else { _current.IsAlive = false; if (PropStatusChangesService.Instanse.Insert(_current)) { var newPropStatusChange = new PropStatusChange { PropID = _current.PropID, Type = (short)cmbStatus.SelectedIndex }; switch (newPropStatusChange.Type) { case 1: case 2: newPropStatusChange.ChangedOn = dtpOutDate.Value; newPropStatusChange.ResolveDate = dtpInDate.Value; break; case 3: case 5: newPropStatusChange.ChangedOn = dtpOutDate.Value; break; } newPropStatusChange.Description = tbDescription.Text; if (PropStatusChangesService.Instanse.Insert(newPropStatusChange)) { Global.SubmissionSuceeded(this); ResetFields(); if ( MessageWindowHelpers.Show(this, PropStatusResources.SelectAnotherProp, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { TryToLoad(true); } else { Close(); } } else { Global.SubmissionFailed(this); } } else { Global.SubmissionFailed(this); } } } } aiLoader.Visibility = Visibility.Collapsed; OnSaving = false; }