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"]; int UserID1 = id; //ViewBag.IsConfigMenu = 0; tbl_autoreportsetting tee = db.tbl_autoreportsetting.Find(id); tee.IsDeleted = 1; tee.ModifiedBy = UserID1; tee.ModifiedOn = System.DateTime.Now; //start Logging int UserID = Convert.ToInt32(Session["UserId"]); String Username = Session["Username"].ToString(); //string CompleteModificationdetail = "Deleted Parts/Item"; //ActiveLogStorage Obj = new ActiveLogStorage(); //Obj.SaveActiveLog(Action, Controller, Username, UserID, CompleteModificationdetail); //End db.Entry(tee).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(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(); tbl_autoreportsetting tee = db.tbl_autoreportsetting.Find(id); ViewBag.RL1 = new SelectList(db.tbl_reportmaster.Where(m => m.IsDeleted == 0), "ReportID", "ReportDispName", tee.ReportID); ViewBag.RL2 = new SelectList(db.tbl_autoreportbasedon.Where(m => m.IsDeleted == 0), "BasedOnID", "BasedOn", tee.BasedOn); ViewBag.RL3 = new SelectList(db.tbl_autoreporttime.Where(m => m.IsDeleted == 0), "AutoReportTimeID", "AutoReportTime", tee.AutoReportTimeID); ViewBag.Plant = new SelectList(db.tblplants.Where(m => m.IsDeleted == 0), "PlantID", "PlantName", tee.PlantID); ViewBag.Shop = new SelectList(db.tblshops.Where(m => m.IsDeleted == 0 && m.PlantID == tee.PlantID), "ShopID", "ShopName", tee.ShopID); ViewBag.Cell = new SelectList(db.tblcells.Where(m => m.IsDeleted == 0 && m.ShopID == tee.ShopID), "CellID", "CellName", tee.CellID); ViewBag.WorkCenter = new SelectList(db.tblmachinedetails.Where(m => m.IsDeleted == 0 && m.PlantID == tee.PlantID && m.ShopID == tee.ShopID && m.CellID == tee.CellID), "MachineID", "MachineDisplayName", tee.MachineID); return(View(tee)); }
public ActionResult Create(tbl_autoreportsetting tee) { 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 //Email validation string RL1 = Convert.ToString(tee.ReportID); string RL2 = Convert.ToString(tee.BasedOn); string RL3 = Convert.ToString(tee.AutoReportTimeID); string ValidEscalation = null; //ValidEscalation = IsItValidEscalation(RL1, RL2, RL3); if (tee.AutoReportTimeID == 1) //day { tee.NextRunDate = Convert.ToDateTime("2018-12-27 17:35:00"); //tee.NextRunDate = DateTime.Now.AddDays(1); } else if (tee.AutoReportTimeID == 2) //week { DateTime begining, end; GetWeek(DateTime.Now, new CultureInfo("fr-FR"), out begining, out end); tee.NextRunDate = end.AddDays(1); } else if (tee.AutoReportTimeID == 3) //month { DateTime Temp2 = new DateTime(DateTime.Now.Year, DateTime.Now.AddMonths(1).Month, 01, 00, 00, 01); tee.NextRunDate = Temp2; } else if (tee.AutoReportTimeID == 4) //year { DateTime Temp2 = new DateTime(DateTime.Now.AddYears(1).Year, 01, 01, 00, 00, 01); tee.NextRunDate = Temp2; } var DupData = db.tbl_autoreportsetting.Where(m => m.ReportID == tee.ReportID && m.BasedOn == tee.BasedOn && m.AutoReportTimeID == tee.AutoReportTimeID && m.PlantID == tee.PlantID && m.ShopID == tee.ShopID && m.CellID == tee.CellID && m.MachineID == tee.MachineID).FirstOrDefault(); if (DupData != null) { ValidEscalation += " Duplicate Entry "; } if (ValidEscalation == null) { tee.CreatedBy = UserID; tee.CreatedOn = DateTime.Now; tee.IsDeleted = 0; db.tbl_autoreportsetting.Add(tee); db.SaveChanges(); } else { Session["Error"] = ValidEscalation; ViewBag.RL1 = new SelectList(db.tbl_reportmaster.Where(m => m.IsDeleted == 0), "ReportID", "ReportDispName", tee.ReportID); ViewBag.RL2 = new SelectList(db.tbl_autoreportbasedon.Where(m => m.IsDeleted == 0), "BasedOnID", "BasedOn", tee.BasedOn); ViewBag.RL3 = new SelectList(db.tbl_autoreporttime.Where(m => m.IsDeleted == 0), "AutoReportTimeID", "AutoReportTime", tee.AutoReportTimeID); ViewBag.Plant = new SelectList(db.tblplants.Where(m => m.IsDeleted == 0), "PlantID", "PlantName", tee.PlantID); ViewBag.Shop = new SelectList(db.tblshops.Where(m => m.IsDeleted == 0 && m.PlantID == tee.PlantID), "ShopID", "ShopName", tee.ShopID); ViewBag.Cell = new SelectList(db.tblcells.Where(m => m.IsDeleted == 0 && m.PlantID == tee.ShopID), "CellID", "CellName", tee.CellID); ViewBag.WorkCenter = new SelectList(db.tblmachinedetails.Where(m => m.IsDeleted == 0 && m.IsNormalWC == 0 && m.PlantID == tee.PlantID && m.ShopID == tee.ShopID && m.CellID == tee.CellID), "MachineID", "MachineInvNo", tee.MachineID); return(View(tee)); } return(RedirectToAction("Index")); }