private void DataGridHyperlinkColumnClick(object sender, RoutedEventArgs e) { var material = dgResults.SelectedItem as Material; if (material != null) { var amount = 0; object returnValue; int temp; if (InputWindowHelpers.Show(this, x => int.TryParse(x as string, out temp) && temp > 0, MaterialsResources.IncreaseAmountDescription, MaterialsResources.IncreaseAmount, out returnValue, 0)) { amount = int.Parse(returnValue.ToString()); } if (amount != 0) { if ( RepositoryMaterialsService.Instanse.Insert(new RepositoryMaterial { MaterialID = material.MaterialID, Amount = amount, TargetApplicant = AppContext.User.UserName })) { TryToLoad(); Global.SubmissionSuceeded(this); } else { Global.SubmissionFailed(this); } } } }
protected override void SaveWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (ValidateFields()) { var initialAmount = 0; Material material = null; if (EditMode) { material = _current; } if (material == null) { object returnValue; uint temp; if (InputWindowHelpers.Show(this, x => uint.TryParse(x.ToString(), out temp), MaterialsResources.InitialAmountDescription, MaterialsResources.InitialAmount, out returnValue, 0)) { initialAmount = int.Parse(returnValue.ToString()); } material = new Material(); } material.Name = cmbNames.Text.Trim(); material.Unit = (short)cmbMesureUnit.SelectedIndex; material.LowestAmount = int.Parse(tbLowestAmount.Text); material.Formula = tbFormula.Text; material.MolecularMass = tbMolecularMass.Text; material.Description = tbDescription.Text.Trim(); if (cmbCategories.SelectedValue != null) { material.CategoryID = (Guid)cmbCategories.SelectedValue; } if (MaterialsService.Insert(material, initialAmount)) { Global.SubmissionSuceeded(this); EditMode = btnCancelChanges.IsEnabled = ChangesHappened = false; btnDelete.IsEnabled = cutTextBox.IsEnabled = true; cmbNames.ItemsSource = MaterialsService.Instanse.GetAll(); ResetFields(); TryToLoad(); } else { Global.SubmissionFailed(this); } } aiLoader.Visibility = Visibility.Collapsed; OnSaving = false; }
protected override void SaveWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (ValidateFields()) { var initialCount = 0; Item item = null; if (EditMode) { item = _current; } if (item == null) { object returnValue; uint temp; if (InputWindowHelpers.Show(this, x => uint.TryParse(x.ToString(), out temp), ItemsResources.InitialCountDescription, ItemsResources.InitialCount, out returnValue, 0)) { initialCount = int.Parse(returnValue.ToString()); } item = new Item(); } item.Name = cmbNames.Text.Trim(); item.LowestCount = int.Parse(tbLowestCount.Text); item.Description = tbDescription.Text.Trim(); if (cmbCategories.SelectedValue != null) { item.CategoryID = (Guid)cmbCategories.SelectedValue; } if (ItemsService.Insert(item, initialCount)) { Global.SubmissionSuceeded(this); EditMode = btnCancelChanges.IsEnabled = ChangesHappened = false; btnDelete.IsEnabled = cutTextBox.IsEnabled = true; cmbNames.ItemsSource = ItemsService.Instanse.GetAll(); ResetFields(); TryToLoad(); } else { Global.SubmissionFailed(this); } } aiLoader.Visibility = Visibility.Collapsed; OnSaving = false; }
private void BtnStartClick(object sender, RoutedEventArgs e) { while (true) { var backupFileName = ""; switch (Settings.Default.BackupFileNamingFormat) { case 0: object returnValue; if (InputWindowHelpers.Show(this, x => !string.IsNullOrWhiteSpace(x as string), BackupResources.BackupFileNameDescription, BackupResources.BackupFileName, out returnValue, backupFileName)) { backupFileName = returnValue.ToString(); } if (string.IsNullOrWhiteSpace(backupFileName)) { return; } break; case 1: backupFileName = DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss"); break; case 2: backupFileName = Guid.NewGuid().ToString(); break; } _pathAndFileName = Settings.Default.BackupPath + "\\" + backupFileName + ".bak"; if (backupFileName.IndexOfAny(Path.GetInvalidFileNameChars()) > -1 || Settings.Default.BackupPath.IndexOfAny(Path.GetInvalidPathChars()) > -1) { MessageWindowHelpers.Show(this, BackupResources.InvalidPathAndFileName, MessageBoxButton.OK, MessageBoxImage.Hand); } else if (File.Exists(_pathAndFileName) && Settings.Default.BackupFileNamingFormat == 0) { MessageWindowHelpers.Show(this, BackupResources.FileExists, MessageBoxButton.OK, MessageBoxImage.Hand); } else { break; } } TryToSave(); }
protected override void SaveWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (ValidateFields()) { Prop prop = null; if (EditMode) { prop = _current; } var initialLabID = Guid.Empty; if (prop == null) { prop = new Prop(); object returnValue; Guid temp; if (InputWindowHelpers.Show(this, x => Guid.TryParse(x != null ? x.ToString() : "", out temp), PropsResources.InitialLabID, PropsResources.LabName, out returnValue, null, LabsService.Instanse.GetAll(cmbCategories.SelectedValue as Guid?), "Name", "LabID")) { initialLabID = Guid.Parse(returnValue.ToString()); } } prop.Name = cmbNames.Text.Trim(); if (!string.IsNullOrEmpty(tbPropNo.Text)) { prop.PropNo = int.Parse(tbPropNo.Text); } else { prop.PropNo = null; } prop.SerialNo = tbSerialNo.Text.Trim(); prop.PurchasingDate = dtpPurchasingDate.Value; prop.WarrantyExpirationDate = dtpWarrantyExpirationDate.Value; prop.Description = tbDescription.Text.Trim(); if (cmbCategories.SelectedValue != null) { prop.CategoryID = (Guid)cmbCategories.SelectedValue; } if (PropsService.Instanse.Insert(prop)) { if (initialLabID != Guid.Empty) { LabPropsService.Instanse.Insert(new LabProp { LabID = initialLabID, PropID = prop.PropID }); } Global.SubmissionSuceeded(this); EditMode = btnCancelChanges.IsEnabled = ChangesHappened = false; btnDelete.IsEnabled = cutTextBox.IsEnabled = true; cmbNames.ItemsSource = PropsService.Instanse.GetAll(); ResetFields(); TryToLoad(); } else { Global.SubmissionFailed(this); } } aiLoader.Visibility = Visibility.Collapsed; OnSaving = false; }