public IActionResult EditAccessories(Equipment_Accessories editAccessories) { if (!ModelState.IsValid) { ViewData["Message"] = "Please fill up all the blanks"; ViewData["MsgTye"] = "warning"; return(View()); } string update = @"UPDATE Equipment_accessories SET Accessories_details='{1}', Quantity = '{2}',Storage_location='{3}' WHERE Equipment_accessories_id ='{0}'"; int res = DBUtl.ExecSQL(update, editAccessories.Equipment_accessories_id, editAccessories.Accessories_details, editAccessories.Quantity, editAccessories.Storage_location); if (res == 1) { TempData["Message"] = "Successfully updated Accessory"; TempData["MsgType"] = "success"; } else { TempData["Message"] = DBUtl.DB_Message; TempData["MsgType"] = "danger"; } return(RedirectToAction("Index")); }
public IActionResult AddAccessories(Equipment_Accessories newAccessories) { if (!ModelState.IsValid) { ViewData["Message"] = "Invalid Input"; ViewData["MsgType"] = "warning"; return(View("AddAccessories")); } else { string insert = @"INSERT INTO Equipment_accessories(Accessories_details,Storage_location,Quantity) VALUES('{0}','{1}','{2}')"; int result = DBUtl.ExecSQL(insert, newAccessories.Accessories_details, newAccessories.Storage_location, newAccessories.Quantity); if (result == 1) { TempData["Message"] = "Accessory Created"; TempData["MsgType"] = "success"; } else { TempData["Message"] = DBUtl.DB_Message; TempData["MsgType"] = "danger"; } return(RedirectToAction("Index")); } }