/// <summary> /// Carlos Arzu /// Created: 2019/04/05 /// /// Saves the new Input by user, as a new Item in orderline in our DB. /// /// </summary> private void EditSaveItem_Btn_Click(object sender, RoutedEventArgs e) { if (EditSaveItem_Btn.Content == "Add") { try { if (InputUser()) { try { if (true == _specialOrderLogic.CreateSpecialOrderLine(_specialOrderLine)) { MessageBox.Show("New Item Added Succesfully"); this.Close(); refreshBrowse.updateList(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Unable to add New Item to Data Base"); } } } catch (NullReferenceException ex) { MessageBox.Show("Processor Usage" + ex.Message); } } else if (EditSaveItem_Btn.Content == "Edit") { setAddUpdate(); EditSaveItem_Btn.Content = "Save"; this.DeleteItem_Btn.Visibility = Visibility.Hidden; } else if (EditSaveItem_Btn.Content == "Save") { InputUser(); try { _specialOrderLogic.EditSpecialOrderLine(_selected, _specialOrderLine); this.DialogResult = true; MessageBox.Show("Update was Successful"); this.Close(); } 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(); }