public ActionResult Delete(int id) { if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty)) { return(RedirectToAction("Login", "Login", null)); } ViewBag.Logout = Session["Username"]; ViewBag.roleid = Session["RoleID"]; String Username = Session["Username"].ToString(); int UserID1 = id; //ViewBag.IsConfigMenu = 0; //start Logging int UserID = Convert.ToInt32(Session["UserId"]); string CompleteModificationdetail = "Deleted Role"; Action = "Delete"; // ActiveLogStorage Obj = new ActiveLogStorage(); //Obj.SaveActiveLog(Action, Controller, Username, UserID, CompleteModificationdetail); //End tblshop tblmc = db.tblshops.Find(id); tblmc.IsDeleted = 1; tblmc.ModifiedBy = UserID; int shopId = tblmc.ShopID; tblmc.ModifiedOn = DateTime.Now; db.Entry(tblmc).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); //delete corresponding cells & machines also. var cellsdata = db.tblcells.Where(m => m.IsDeleted == 0 && m.ShopID == shopId).ToList(); foreach (var cellrow in cellsdata) { cellrow.IsDeleted = 1; db.Entry(cellrow).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); int cellid = cellrow.CellID; var machinedata = db.tblmachinedetails.Where(m => m.IsDeleted == 0 && m.CellID == cellid).ToList(); foreach (var machinerow in machinedata) { machinerow.IsDeleted = 1; db.Entry(machinerow).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } } var machinedata1 = db.tblmachinedetails.Where(m => m.IsDeleted == 0 && m.ShopID == shopId).ToList(); foreach (var machinerow in machinedata1) { machinerow.IsDeleted = 1; db.Entry(machinerow).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("Index")); }
//Delete Department public ActionResult DeleteShops(int id) { if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty)) { return(RedirectToAction("Login", "Login", null)); } ViewBag.Logout = Session["Username"].ToString().ToUpper(); ViewBag.roleid = Session["RoleID"]; String Username = Session["Username"].ToString(); int UserID = Convert.ToInt32(Session["UserID"]); //ViewBag.IsConfigMenu = 0; using (i_facility_shaktiEntities1 db = new i_facility_shaktiEntities1()) { tblshop shop = db.tblshops.Find(id); shop.IsDeleted = 1; shop.ModifiedBy = UserID; int shopid = shop.ShopID; shop.ModifiedOn = DateTime.Now; db.Entry(shop).State = EntityState.Modified; db.SaveChanges(); } //delete corresponding cells & machines also. var cellsdata = db.tblcells.Where(m => m.IsDeleted == 0 && m.ShopID == id).ToList(); foreach (var cellrow in cellsdata) { cellrow.IsDeleted = 1; db.Entry(cellrow).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); int cellid = cellrow.CellID; var machinedata = db.tblmachinedetails.Where(m => m.IsDeleted == 0 && m.CellID == cellid).ToList(); foreach (var machinerow in machinedata) { machinerow.IsDeleted = 1; db.Entry(machinerow).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } } var machinedata1 = db.tblmachinedetails.Where(m => m.IsDeleted == 0 && m.ShopID == id).ToList(); foreach (var machinerow in machinedata1) { machinerow.IsDeleted = 1; db.Entry(machinerow).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("ShopList")); }
public ActionResult Edit(tblshop tblmc, int Plant = 0) { if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty)) { return(RedirectToAction("Login", "Login", null)); } ViewBag.Logout = Session["Username"]; ViewBag.roleid = Session["RoleID"]; String Username = Session["Username"].ToString(); int UserID = Convert.ToInt32(Session["UserID"]); //shop name validation string shopname = tblmc.ShopName.ToString(); int shopid = tblmc.ShopID; var doesThisShopExists = db.tblshops.Where(m => m.IsDeleted == 0 && m.PlantID == Plant && m.ShopName == shopname && m.ShopID != shopid).ToList(); if (doesThisShopExists.Count == 0) { #region Active Log Code //tblmachinecategory OldData = db.tblmachinecategories.Find(tblmc.ID); //IEnumerable<string> FullData = ActiveLog.EnumeratePropertyDifferences<tblmachinecategory>(OldData, tblmc); //ICollection<tblmachinecategory> c = FullData as ICollection<tblmachinecategory>; //int Count = c.Count; //if (Count != 0) //{ // string CompleteModificationdetail = null; // for (int i = 0; i < Count; i++) // { // CompleteModificationdetail = CompleteModificationdetail + "-" + FullData.Take(i).ToArray(); // } // Action = "Edit"; // ActiveLogStorage Obj = new ActiveLogStorage(); // Obj.SaveActiveLog(Action, Controller, Username, UserID, CompleteModificationdetail); //} #endregion //End Active Log tblmc.ModifiedBy = UserID; tblmc.PlantID = Plant; tblmc.ModifiedOn = DateTime.Now; db.Entry(tblmc).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } else { Session["Error"] = "Shop Name already exists for this Plant."; ViewBag.Plant = new SelectList(db.tblplants.Where(m => m.IsDeleted == 0), "PlantID", "PlantName", Plant); return(View(tblmc)); } }
public ActionResult Edit(int id) { if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty)) { return(RedirectToAction("Login", "Login", null)); } ViewBag.Logout = Session["Username"]; ViewBag.roleid = Session["RoleID"]; String Username = Session["Username"].ToString(); tblshop tblmc = db.tblshops.Find(id); if (tblmc == null) { return(HttpNotFound()); } ViewBag.Plant = new SelectList(db.tblplants.Where(m => m.IsDeleted == 0), "PlantID", "PlantName", tblmc.PlantID); //ViewBag.unit = new SelectList(db.tblunits.Where(m => m.IsDeleted == 0), "U_ID", "Unit", tblpart.UnitDesc); return(View(tblmc)); }
public ActionResult ShopList() { if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty)) { return(RedirectToAction("Login", "Login", null)); } ViewBag.Logout = Session["Username"].ToString().ToUpper(); ViewBag.roleid = Session["RoleID"]; String Username = Session["Username"].ToString(); ShopModel de = new ShopModel(); tblshop da = new tblshop(); ViewBag.PlantID = new SelectList(db.tblplants.Where(m => m.IsDeleted == 0), "PlantID", "PlantName", da.PlantID).ToList(); de.Shops = da; de.Shopslist = db.tblshops.Where(m => m.IsDeleted == 0).ToList(); ViewBag.Plant = new SelectList(db.tblplants.Where(m => m.IsDeleted == 0), "PlantID", "PlantName").ToList(); return(View(de)); //var dept = db.masterdepartment_tbl.Where(x => x.IsDeleted == 0); //return View(dept.ToList()); }
public ActionResult EditShops(int Id) { if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty)) { return(RedirectToAction("Login", "Login", null)); } ViewBag.Logout = Session["Username"].ToString().ToUpper(); ViewBag.roleid = Session["RoleID"]; String Username = Session["Username"].ToString(); using (i_facility_shaktiEntities1 db = new i_facility_shaktiEntities1()) { tblshop dept = db.tblshops.Find(Id); if (dept == null) { return(HttpNotFound()); } ViewBag.PlantID = new SelectList(db.tblplants.Where(m => m.IsDeleted == 0), "PlantID", "PlantName", dept.PlantID).ToList(); return(View(dept)); } }
public ActionResult Create(tblshop tblp, int Plant = 0) { if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty)) { return(RedirectToAction("Login", "Login", null)); } ViewBag.Logout = Session["Username"]; ViewBag.roleid = Session["RoleID"]; String Username = Session["Username"].ToString(); #region//ActiveLog Code int UserID = Convert.ToInt32(Session["UserId"]); string CompleteModificationdetail = "New Creation"; Action = "Create"; // ActiveLogStorage Obj = new ActiveLogStorage(); // Obj.SaveActiveLog(Action, Controller, Username, UserID, CompleteModificationdetail); //End #endregion //shop name validation string shopname = tblp.ShopName.ToString(); var doesThisShopExists = db.tblshops.Where(m => m.IsDeleted == 0 && m.PlantID == Plant && m.ShopName == shopname).ToList(); if (doesThisShopExists.Count == 0) { tblp.CreatedBy = UserID; tblp.CreatedOn = DateTime.Now; tblp.PlantID = Plant; db.tblshops.Add(tblp); db.SaveChanges(); } else { Session["Error"] = "Shop Name already exists for this Plant."; } return(RedirectToAction("Index")); }