public ActionResult Edit(tbl_AssetMaster user) { if (ModelState.IsValid == true) { //Ims.Entry(user).State = EntityState.Modified; //int a = Ims.SaveChanges(); //if (a > 0) //{ // TempData["UpdateMesage"] = " <script>alert('Asset Update SuccessFull')</Script>"; // return RedirectToAction("AssetMasterList"); //} //else //{ // TempData["UpdateMessage"] = " <script>alert('Asset Not Update')</Script>"; //} using (IMSEntities obj = new IMSEntities()) { tbl_AssetMaster asset = (from m in obj.tbl_AssetMaster where m.AssetId == user.AssetId select m).FirstOrDefault(); asset.UserName = user.UserName; asset.LocationId = user.LocationId; asset.Ram = user.Ram; asset.WarrantyStatus = user.WarrantyStatus; asset.WindowKey = user.WindowKey; int e = obj.SaveChanges(); if (e > 0) { TempData["UpdateMesage"] = " <script>alert('Asset Update SuccessFull')</Script>"; return(RedirectToAction("AssetMasterList")); } else { TempData["UpdateMessage"] = " <script>alert('Asset Not Update')</Script>"; } } } // return View("AssetMasterList"); return(RedirectToAction("AssetMasterList")); }
public ActionResult AssetMaster() { if (Session["UserName"] == null) // This Syntax For Restriction to go without login on AssetMaster Page { return(RedirectToAction("Login", "Admin")); } tbl_AssetMaster asset = new tbl_AssetMaster(); using (IMSEntities db = new IMSEntities()) { // asset.AssetTypeCollection = db.tbl_AssetType.ToList<tbl_AssetType>(); } // ViewBag.AssetTypeId = new SelectList(Ims.tbl_AssetType, "AssetTypeId", "AssetTypeName"); return(View()); }
public ActionResult AssetMaster(tbl_AssetMaster user) { try { if (ModelState.IsValid == true) { tbl_AssetMaster add = new tbl_AssetMaster(); //add.AssetTypeId = user.AssetTypeId.Value; // add.LocationId = user.LocationId.Value; add.AssetTypeId = 1; add.LocationId = 1; add.UserName = user.UserName; add.SerialNo = user.SerialNo; // add.AssetsCode = user.AssetsCode; add.Ram = user.Ram; add.PurchaseDate = user.PurchaseDate; add.WarrantyStatus = user.WarrantyStatus; add.WindowKey = user.WindowKey; add.Model = user.Model.ToString(); // add.CreatedBy = Convert.ToInt32(Session["UserId"].ToString()); add.CreatedBy = 1; add.CreatedOn = DateTime.Now; // add.UpdatedBy = Convert.ToInt32(Session["UserId"].ToString()); add.UpdatedBy = 1; add.UpdatedOn = DateTime.Now; Ims.tbl_AssetMaster.Add(add); Ims.SaveChanges(); ViewBag.Message = "Asset Added Successfully"; } ModelState.Clear(); return(View()); } catch (Exception ex) { throw ex; } }