private void GotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { Stores_PartGrid.DataContext = null; this.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { PickList_PartComboBox.Text = ""; PickList_PartComboBox.SelectedItem = null; PickList_QtyTextBox.Clear(); PickList_SUNTextBox.Clear(); Line_PartComboBox.Text = ""; Line_PartComboBox.SelectedItem = null; Line_ReleaseQtyTextBox.Clear(); Line_TrackingCodeTextBox.Clear(); Line_ReturnQtyTextBox.Clear(); Scrap_PartNoCombobox.Text = ""; Scrap_PartNoCombobox.SelectedItem = null; Scrap_QtyTextBox.Clear(); Scrap_ReasonTextBox.Clear(); })); }
private void PickList_UpdateButton_Click(object sender, RoutedEventArgs e) { CurrentPart = PickList_PartComboBox.SelectedItem as Part; if (CurrentPart == null) { return; } using (var db = new MTSDB()) { var parts = from p in db.Parts where p.PartNo == CurrentPart.PartNo select p; var fs = from s in db.FromStores select s; Part P = parts.SingleOrDefault(); if (P == null) { MessageBox.Show("Part Not Found !! Please Verify", "Database Error", MessageBoxButton.OK, MessageBoxImage.Error); } if (PickList_SUNTextBox.Text == String.Empty && P.Kanban == false) { MessageBox.Show("Please Scan/Enter SUN", "Alert", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } if (PickList_SUNTextBox.Text.Length != 10 && (PickList_SUNTextBox.Text.Length != 14)) { MessageBox.Show("SUN Not Equal to expected number of characters. Please Veifry ", "Alert", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } int qty = 0; if (int.TryParse(PickList_QtyTextBox.Text, out qty) == false || (qty == 0)) { MessageBox.Show("Please Verify Quantity", "Alert", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } FromStores f = new FromStores(); f.SUN = PickList_SUNTextBox.Text; f.Part = P; f.Quantity = qty; f.Balance = qty; f.Timestamp = DateTime.Now; db.FromStores.Add(f); P.Quantity += f.Quantity.Value; P.LastUpdated = DateTime.Now; P.LastActivity = "Stores Inward Entry"; P.FromStoresRecords.Add(f); db.SaveChanges(); DisplayParts.Clear(); DisplayParts.Add(P); Stores_PartGrid.DataContext = null; Stores_PartGrid.DataContext = DisplayParts; MessageBox.Show("Part Added To Inventory", "Alert", MessageBoxButton.OK, MessageBoxImage.Information); this.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { //PickList_PartComboBox.SelectedIndex = -1; PickList_QtyTextBox.Clear(); PickList_SUNTextBox.Clear(); DisplayParts.Clear(); PickList_SUNTextBox.Focus(); })); } }