예제 #1
0
        public static bool UpdateItem(Dictionary <string, string> dto)
        {
            var item = Item.Create(Convert.ToInt32(dto["itemId"]));

            item.Name          = dto["name"];
            item.Description   = dto["description"];
            item.Price         = Convert.ToDecimal(dto["price"]);
            item.Quantity      = Convert.ToInt32(dto["quantity"]);
            item.Justification = dto["justification"];
            item.Source        = dto["source"];
            return(ItemCUD.Update(Convert.ToInt32(HttpContext.Current.Session["EmployeeId"]), item));
        }
예제 #2
0
        private void btnRemoveItem_Click(object sender, EventArgs e)
        {
            var command = (Button)sender;

            try
            {
                if (orderList != null)
                {
                    if (gdvItems.SelectedRows.Count > 0)
                    {
                        var orderIndex = gdvOrders.CurrentRow.Index;
                        var itemIndex  = gdvItems.CurrentRow.Index;
                        if (command.Text == "SAVE CHANGES")
                        {
                            ItemCUD.Update(employee.EmployeeId, (Item)itemList[itemIndex]);
                        }
                        else if (command.Text == "NO LONGER REQUIRED")
                        {
                            itemList[itemIndex].Description = "No longer needed.";
                            itemList[itemIndex].Price       = 0;
                            itemList[itemIndex].Quantity    = 0;

                            ItemCUD.Update(employee.EmployeeId, (Item)itemList[itemIndex]);
                        }
                        gdvItems.Refresh();
                    }
                }
            }
            catch (Exception ex)
            {
                var itemIndex = gdvItems.CurrentRow.Index;
                var items     = ItemLists.GetItemsByOrderId(orderList[gdvItems.CurrentRow.Index].OrderId);
                itemList.Clear();
                foreach (var item in items)
                {
                    itemList.Add(item);
                }
                MessageBox.Show(ex.Message, "Bismark", MessageBoxButtons.OK, MessageBoxIcon.Error);
                gdvItems.Refresh();
            }
        }