/// <summary> /// NAME: Jesse Tomash /// DATE: 4/26/2020 /// /// Approver: Brandyn T. Coverdill /// /// Inserts a new Order-Item Line /// </summary> /// <remarks> /// UPDATED BY: /// UPDATE DATE: /// WHAT WAS CHANGED: /// <returns>1 if successful, 0 if not</returns> public bool InsertSpecialOrderItemLine(SpecialOrderItemLine newLine) { bool isInserted = false; var conn = DBConnection.GetConnection(); var cmdText = @"sp_insert_special_order_item_line"; var cmd = new SqlCommand(cmdText, conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@SpecialOrderID", newLine.SpecialOrderID); cmd.Parameters.AddWithValue("@ItemID", newLine.ItemID); cmd.Parameters.AddWithValue("@Quantity", newLine.Quantity); try { conn.Open(); isInserted = 1 == cmd.ExecuteNonQuery(); } catch (Exception ex) { throw ex; } finally { conn.Close(); } return(isInserted); }
/// <summary> /// NAME: Jesse Tomash /// DATE: 4/26/2020 /// /// Approver: /// Approver: /// /// Action on item click to add item to order and create order line /// </summary> /// /// <remarks> /// UPDATED BY: Brandyn T. Coverdill /// UPDATE DATE: 4/28/2020 /// WHAT WAS CHANGED: When the user clicks add item for the order, it makes the quantity empty. /// </remarks> /// <returns></returns> private void btnAddOrderItem_Click(object sender, RoutedEventArgs e) { if (dgItems.SelectedItem == null) { "You must have an item selected.".ErrorMessage(); } if (txtQty == null || txtQty.Text == "0") { "You must enter a quantity".ErrorMessage(); } else { try { Int32.Parse(txtQty.Text); if (Int32.Parse(txtQty.Text) < 20) { try { _item = (Item)dgItems.SelectedItem; _orderItemLine = new SpecialOrderItemLine { SpecialOrderID = _order.SpecialOrderID, ItemID = _item.ItemID, Quantity = Int32.Parse(txtQty.Text) }; _orderItemLineManager.AddSpecialOrderItemLine(_orderItemLine); // After the item has been added to the OrderItem Datagrid, remove it from the item datagrid. Item item = new Item(); item = _item; item.ItemQuantity = Int32.Parse(txtQty.Text); _orderItems.Add(item); dgItems.Items.Refresh(); dgOrderItems.Items.Refresh(); } catch { "Could not Add Item to Order".ErrorMessage(); } } else { "Cannot be greater than 20".ErrorMessage(); } } catch { "Not a number".ErrorMessage(); } txtQty.Text = ""; } }
/// <summary> /// NAME: Jesse Tomash /// DATE: 4/26/2020 /// /// Approver: Brandyn T. Coverdill /// /// This is the method that handles logic between InsertOrderitemline() and the presentation /// </summary> /// <remarks> /// UPDATED BY: /// UPDATE DATE: /// WHAT WAS CHANGED: /// </remarks> /// <param name="newLine"></param> /// <returns></returns> public bool AddSpecialOrderItemLine(SpecialOrderItemLine newLine) { bool result; try { result = _orderItemLineAccessor.InsertSpecialOrderItemLine(newLine); } catch (Exception ex) { throw ex; } return(result); }