Esempio n. 1
0
        private void Line_TrackingCodeTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            TextBox tb = (TextBox)sender;

            if (tb.Text.Length == 13)
            {
                using (var db = new MTSDB())
                {
                    var tl = (from t in db.ToLine
                              where t.SMN == Line_TrackingCodeTextBox.Text
                              select t).SingleOrDefault();

                    if (tl == null)
                    {
                        MessageBox.Show("Part Not Found!! Please Verify", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        Line_TrackingCodeTextBox.Clear();
                        return;
                    }


                    CurrentPart = tl.Part;
                    CurrentPart.ImageReference = "./Images/" + CurrentPart.PartNo + ".png";
                }

                this.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                                            new Action(() =>
                {
                    DisplayParts.Clear();
                    DisplayParts.Add(CurrentPart);
                    Stores_PartGrid.DataContext = null;
                    Stores_PartGrid.DataContext = DisplayParts;
                    Line_ReturnQtyTextBox.Focus();
                }));
            }
        }
Esempio n. 2
0
        private void Line_UpdateButton_Click(object sender, RoutedEventArgs e)
        {
            using (var db = new MTSDB())
            {
                var tl = (from t in db.ToLine
                          where t.SMN == Line_TrackingCodeTextBox.Text
                          select t).SingleOrDefault();

                if (tl == null)
                {
                    MessageBox.Show("Part Not Found!! Please Verify", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    Line_TrackingCodeTextBox.Clear();
                    return;
                }

                CurrentPart = tl.Part;

                int qty = 0;
                if (int.TryParse(Line_ReturnQtyTextBox.Text, out qty) == false || (qty == 0))
                {
                    MessageBox.Show("Please Verify Quantity", "Alert", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    return;
                }

                FromLine fl = new FromLine();
                fl.ToLineRecord   = tl;
                fl.Quantity       = qty;
                fl.Part           = tl.Part;
                fl.Timestamp      = DateTime.Now;
                tl.Balance       -= qty;
                tl.Part.Quantity += qty;
                tl.Part.FromLineRecords.Add(fl);
                db.SaveChanges();

                MessageBox.Show("Inventory Updated", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                this.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                                            new Action(() =>
                {
                    Line_ReturnQtyTextBox.Clear();
                    Line_TrackingCodeTextBox.Clear();
                    DisplayParts.Clear();
                    Stores_PartGrid.DataContext = null;
                    Stores_PartGrid.DataContext = DisplayParts;
                }));
            }
        }
Esempio n. 3
0
        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();
            }));
        }
Esempio n. 4
0
        private void Scrap_UpdateButton_Click(object sender, RoutedEventArgs e)
        {
            if (Scrap_PartNoCombobox.SelectedItem == null)
            {
                return;
            }
            CurrentPart = (Part)Scrap_PartNoCombobox.SelectedItem;



            int qty = 0;

            if (int.TryParse(Scrap_QtyTextBox.Text, out qty) == false || (qty == 0))
            {
                MessageBox.Show("Please Verify Quantity", "Alert", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }
            using (var db = new MTSDB())
            {
                var part = db.Parts.Where(p => p.PartID == CurrentPart.PartID).SingleOrDefault();


                if (part == null)
                {
                    MessageBox.Show("Part Not Found!! Please Verify", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    Line_TrackingCodeTextBox.Clear();
                    return;
                }

                var tl = db.ToLine.Include("Part").Where(t => t.Part.PartID == part.PartID && t.Balance > 0).OrderBy(t => t.Timestamp).ToList();

                int lineQty = 0;
                foreach (ToLine t in tl)
                {
                    lineQty += t.Balance.Value;
                }
                if (lineQty < qty)
                {
                    MessageBox.Show("Line Quantity less than Scrap Quantity. Please Verify", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    Line_TrackingCodeTextBox.Clear();
                    return;
                }


                LineRejection fl = new LineRejection();
                fl.Part      = part;
                fl.Reason    = Scrap_ReasonTextBox.Text;
                fl.Timestamp = DateTime.Now;

                foreach (ToLine t in tl)
                {
                    if (qty > 0)
                    {
                        if (t.Balance > qty)
                        {
                            t.Balance   -= qty;
                            fl.Quantity += qty;
                            fl.ToLines.Add(t);
                            break;
                        }
                        else
                        {
                            qty         -= t.Balance.Value;
                            fl.Quantity += t.Balance.Value;
                            t.Balance    = 0;
                            fl.ToLines.Add(t);
                        }
                    }
                }



                db.LineRejections.Add(fl);
                db.SaveChanges();

                MessageBox.Show("Scrap Updated", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                this.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                                            new Action(() =>
                {
                    Scrap_PartNoCombobox.Text         = "";
                    Scrap_PartNoCombobox.SelectedItem = null;
                    Scrap_QtyTextBox.Clear();
                    Scrap_ReasonTextBox.Clear();
                }));
            }
        }