Esempio n. 1
0
 private void btnAddOrder_Click(object sender, RoutedEventArgs e)
 {
     if (btnAddOrder.Content == "Add")
     {
         try
         {
             if (InputUser())
             {
                 try
                 {
                     if (true == _specialOrderLogic.CreateSpecialOrder(_completespecialOrder))
                     {
                         MessageBox.Show("New Order Added Succesfully");
                         ID = _specialOrderLogic.retrieveSpecialOrderID(_completespecialOrder);
                         Items order = new Items(ID);
                         order.Show();
                         this.Close();
                         refreshBrowse.updateList();
                     }
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show(ex.Message, "Unable to add New Order to Data Base");
                 }
             }
         }
         catch (NullReferenceException ex)
         {
             MessageBox.Show("Processor Usage" + ex.Message);
         }
     }
     else if (btnAddOrder.Content == "Edit")
     {
         setAddUpdate();
         btnAddOrder.Content = "Save";
     }
     else if (btnAddOrder.Content == "Save")
     {
         if (InputUser())
         {
             try
             {
                 _specialOrderLogic.EditSpecialOrder(_selected, _completespecialOrder);
                 this.DialogResult = true;
                 MessageBox.Show("Update was Successful");
                 refreshBrowse.updateList();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, "Update Failed!");
             }
         }
     }
 }
        /// <summary>
        /// Author: Kevin Broskow
        /// Created : 3/25/2019
        /// Handles the event of the submit button being clicked
        ///
        /// </summary>
        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            if (this.btnSubmit.Content.Equals("Submit"))
            {
                ticket.SupplierOrderID             = order.SupplierOrderID;
                ticket.ReceivingTicketExceptions   = this.txtException.Text;
                ticket.ReceivingTicketCreationDate = DateTime.Now;
                for (int i = 0; i < dgOrderRecieving.Items.Count - 1; i++)
                {
                    dgOrderRecieving.SelectedIndex = i;
                    SupplierOrderLine temp = (SupplierOrderLine)dgOrderRecieving.SelectedItem;
                    var _tempLine          = supplierOrderLine.Find(x => x.ItemID == temp.ItemID);
                    _tempLine.QtyReceived = temp.QtyReceived;
                    if (_tempLine.OrderQty != temp.QtyReceived)
                    {
                        orderComplete = false;
                    }
                    supplierOrderLine.Find(x => x.ItemID == temp.ItemID).QtyReceived = temp.QtyReceived;
                }

                try
                {
                    order.OrderComplete = orderComplete;

                    _supplierManager.UpdateSupplierOrder(order, supplierOrderLine);

                    _receivingManager.createReceivingTicket(ticket);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else if (this.btnSubmit.Content.Equals("Save"))
            {
                ticket.ReceivingTicketExceptions   = this.txtException.Text;
                ticket.ReceivingTicketCreationDate = DateTime.Now;
                for (int i = 0; i < dgOrderRecieving.Items.Count - 1; i++)
                {
                    dgOrderRecieving.SelectedIndex = i;
                    SupplierOrderLine temp = (SupplierOrderLine)dgOrderRecieving.SelectedItem;
                    var _tempLine          = supplierOrderLine.Find(x => x.ItemID == temp.ItemID);
                    _tempLine.QtyReceived = temp.QtyReceived;
                    if (_tempLine.OrderQty != temp.QtyReceived)
                    {
                        orderComplete = false;
                    }
                    supplierOrderLine.Find(x => x.ItemID == temp.ItemID).QtyReceived = temp.QtyReceived;
                }

                try
                {
                    order.OrderComplete = orderComplete;

                    _supplierManager.UpdateSupplierOrder(order, supplierOrderLine);

                    _receivingManager.updateReceivingTicket(originalTicket, ticket);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else if (this.btnSubmit.Content.Equals("Complete"))
            {
                ticket.SupplierOrderID             = _specialOrder.SpecialOrderID;
                ticket.ReceivingTicketExceptions   = this.txtException.Text;
                ticket.ReceivingTicketCreationDate = DateTime.Now;
                for (int i = 0; i < dgOrderRecieving.Items.Count - 1; i++)
                {
                    dgOrderRecieving.SelectedIndex = i;
                    SpecialOrderLine temp = (SpecialOrderLine)dgOrderRecieving.SelectedItem;
                    var _tempLine         = specialOrderLines.Find(x => x.NameID == temp.NameID);
                    _tempLine.QtyReceived = temp.QtyReceived;
                    if (_tempLine.OrderQty != temp.QtyReceived)
                    {
                        orderComplete = false;
                    }
                    specialOrderLines.Find(x => x.NameID == temp.NameID).QtyReceived = temp.QtyReceived;
                }

                try
                {
                    if (orderComplete)
                    {
                        _specialManager.EditSpecialOrder(_specialOrder, _specialOrder);
                    }
                    int i = 0;
                    foreach (var item in specialOrderLines)
                    {
                        _specialManager.EditSpecialOrderLine(originalSpecialOrderLine[i], item);
                        i++;
                    }

                    //_receivingManager.createReceivingTicket(ticket);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

            this.Close();
        }