private void btnSave_Click(object sender, EventArgs e) { if (this.txtBox_ItemName.Text.Trim() == "") { MessageBox.Show("Please insert 'Item Name' ", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); this.txtBox_ItemName.Focus(); } else if (this.txtBox_Quantity.Text.Trim() == "") { MessageBox.Show("Please insert 'Quantity' ", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); this.txtBox_Quantity.Focus(); } else { if (editMode == true) { dao.EditItem(GetTxtBoxData(), itm); } else { dao.AddNewItem(GetTxtBoxData()); } this.Close(); } }
public ActionResult Edit([Bind(Include = "ID,Name,Description,Quantity,Price,Image")] Item item) { try { if (ModelState.IsValid) { dao.EditItem(item); return(RedirectToAction("Index")); } } catch (Exception e) { ViewBag.Message = $"Something went wrong: {e.Message}"; } return(View(item)); }
public ActionResult EditItem(string itemid, Item item) { ItemDAO itemDAO = new ItemDAO(); CategoryDAO categoryDAO = new CategoryDAO(); Category category = new Category(); List <Category> categoreyList = categoryDAO.GetAll(); int length = categoreyList.Count; for (int i = 0; i < length; i++) { if (item.CategoryName == categoreyList[i].Name) { item.CategoryId = categoreyList[i].Id; } } itemDAO.EditItem(item, itemid); ViewData["itemId"] = itemid; return(RedirectToAction("ViewItems", "StoreClerk")); }