public ActionResult Delete(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            UserID1          = id;
            int            UserID           = Convert.ToInt32(Session["UserId"]);
            tblshiftmethod tblmc            = condb.tblshiftmethods.Find(id);
            var            shiftdetailsList = condb.tblshiftdetails.Where(m => m.IsDeleted == 0 && m.ShiftMethodID == id).ToList();

            foreach (var shiftdetailsrow in shiftdetailsList)
            {
                shiftdetailsrow.IsDeleted          = 1;
                condb.Entry(shiftdetailsrow).State = EntityState.Modified;
                condb.SaveChanges();
            }

            tblmc.IsDeleted          = 1;
            condb.Entry(tblmc).State = EntityState.Modified;
            condb.SaveChanges();
            TempData["toaster_success"] = "Data Deleted successfully";
            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        //Delete Plant
        public ActionResult Delete(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    UserID1  = id;

            ViewBag.IsConfigMenu = 0;
            tblplant tblmc   = db.tblplants.Find(id);
            int      plantid = tblmc.PlantID;

            tblmc.IsDeleted       = 1;
            db.Entry(tblmc).State = EntityState.Modified;
            db.SaveChanges();


            //Delete corresponding shops cells & machines.

            var shopdata = db.tblshops.Where(m => m.IsDeleted == 0 && m.PlantID == plantid).ToList();

            foreach (var shoprow in shopdata)
            {
                shoprow.IsDeleted       = 1;
                db.Entry(shoprow).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                int shopid = shoprow.ShopID;

                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.PlantID == id).ToList();

            foreach (var machinerow in machinedata1)
            {
                machinerow.IsDeleted       = 1;
                db.Entry(machinerow).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
        //Update IsDeleted = 1 to mark it as Deleted Role.
        public ActionResult Delete(int id)
        {
            if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
            {
                return(RedirectToAction("Login", "Login", null));
            }

            int UserID1 = Convert.ToInt32(Session["UserID"].ToString());

            using (i_facility_shaktiEntities1 db = new i_facility_shaktiEntities1())
            {
                tblmodule tblModule = db.tblmodules.Find(id);
                tblModule.IsDeleted       = 1;
                tblModule.ModifiedBy      = UserID1;
                tblModule.ModifiedOn      = System.DateTime.Now;
                db.Entry(tblModule).State = EntityState.Modified;
                db.SaveChanges();

                //Updating in module helper
                int ID = Convert.ToInt32(tblModule.ModuleId);
                tblrolemodulelink module = db.tblrolemodulelinks.Where(m => m.ModuleID == ID).FirstOrDefault();
                module.IsDeleted       = 1;
                module.ModifiedBy      = UserID1;
                module.ModifiedOn      = System.DateTime.Now;
                db.Entry(module).State = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
        }
        public string UpdateData(int smid, int channelnum, string memoryadd, int sid, string sensordesc, int modeltype, int countlow, int counthigh, int sensorlimithigh, int sensorlimitlow, int uid, int sdlid)
        {
            string res = "";
            //var doesThissensorExist = db.configurationtblsensormasters.Where(m => m.IsDeleted == 0 && m.ChannelNo == channelnum && m.CountHigh == counthigh && m.CountLow == countlow && m.MemoryAddress == memoryadd && m.IsAnalog == modeltype && m.SensorDesc == sensordesc && m.sensorlimitHigh == sensorlimithigh && m.sensorlimitLow == sensorlimitlow && m.SMID != smid).ToList();
            //if (doesThissensorExist.Count == 0)
            //{
            var sensor = db.configurationtblsensormasters.Find(smid);

            sensor.ChannelNo       = channelnum;
            sensor.CountHigh       = counthigh;
            sensor.CountLow        = countlow;
            sensor.MemoryAddress   = Convert.ToInt32(memoryadd);
            sensor.IsAnalog        = modeltype;
            sensor.SensorDesc      = sensordesc;
            sensor.sensorlimitHigh = sensorlimithigh;
            sensor.sensorlimitLow  = sensorlimitlow;
            sensor.Sid             = sid;
            sensor.parametertypeid = sdlid;
            sensor.Unitid          = uid;
            sensor.ModifiedBy      = ViewBag.roleid;
            sensor.ModifiedOn      = DateTime.Now;
            db.Entry(sensor).State = EntityState.Modified;
            db.SaveChanges();
            res = "success";
            // }
            //else
            //{
            //    TempData["Message"] = "parameter Name already Exists";
            //    res = "failure";
            //    return res;
            //}
            return(res);
            //return Json(tblpc.SdlID, JsonRequestBehavior.AllowGet);
        }
        //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(tbluser tbluser)
        {
            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"]);
            int    roleid   = Convert.ToInt32(Session["RoleID"]);

            tbluser.ModifiedBy = UserID;
            tbluser.ModifiedOn = System.DateTime.Now;
            var dupUserData = db.tblusers.Where(m => m.IsDeleted == 0 && m.UserName == tbluser.UserName && m.UserID != tbluser.UserID).ToList();

            if (dupUserData.Count == 0)
            {
                #region Active Log Code
                //tblUser OldData = db.tblUsers.Find(tbluser.UserID);
                //IEnumerable<string> FullData = ActiveLog.EnumeratePropertyDifferences<tblUser>(OldData, tbluser);
                //ICollection<tblUser> c = FullData as ICollection<tblUser>;
                //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

                int primaryrole = Convert.ToInt32(tbluser.PrimaryRole);
                if (primaryrole != 3)
                {
                    tbluser.MachineID = Convert.ToInt32(System.DBNull.Value);
                }
                db.Entry(tbluser).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            else
            {
                Session["Error"]      = "User Name Exists.";
                ViewBag.PrimaryRole   = new SelectList(db.tblroles.Where(m => m.IsDeleted == 0 && m.Role_ID >= roleid), "Role_ID", "RoleDesc", tbluser.PrimaryRole);
                ViewBag.SecondaryRole = new SelectList(db.tblroles.Where(m => m.IsDeleted == 0 && m.Role_ID >= roleid), "Role_ID", "RoleDesc", tbluser.SecondaryRole);
                ViewBag.MachineID     = new SelectList(db.tblmachinedetails.Where(m => m.IsDeleted == 0), "MachineID", "MachineDispName", tbluser.MachineID);
                return(View(tbluser));
            }
        }
        public JsonResult DeleteData(int id = 0)
        {
            tblholiday tblholiday = db.tblholidays.Find(id);

            tblholiday.IsDeleted  = 1;
            tblholiday.ModifiedBy = 1;
            tblholiday.ModifiedOn = DateTime.Now;
            {
                db.Entry(tblholiday).State = EntityState.Modified;
                db.SaveChanges();
            }
            return(Json(tblholiday.HolidayId, JsonRequestBehavior.AllowGet));
        }
 public ActionResult Edit(tblplannedbreak tblplannedbreak)
 {
     if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
     {
         return(RedirectToAction("Login", "Login", null));
     }
     ViewBag.Logout                  = Session["Username"].ToString().ToUpper();
     ViewBag.roleid                  = Session["RoleID"];
     tblplannedbreak.ModifiedBy      = 1;
     tblplannedbreak.ModifiedOn      = DateTime.Now;
     tblplannedbreak.IsDeleted       = 0;
     db.Entry(tblplannedbreak).State = EntityState.Modified;
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
        public string update1(int plant, int shop, int cell, string value, string frequency, int pmcpid, int pmcid, string checklist, string How)
        {
            string res = "";

            using (i_facility_shaktiEntities1 condb = new i_facility_shaktiEntities1())
            {
                var tblpc = condb.configuration_tblpmchecklist.Find(pmcid);

                tblpc.Isdeleted          = 0;
                tblpc.PlantID            = plant;
                tblpc.ShopID             = shop;
                tblpc.CellID             = cell;
                tblpc.pmcpID             = pmcpid;
                tblpc.Value              = value;
                tblpc.How                = How;
                tblpc.Frequency          = frequency;
                tblpc.CheckList          = checklist;
                tblpc.ModifiedBy         = 1;
                tblpc.ModifiedOn         = DateTime.Now;
                condb.Entry(tblpc).State = EntityState.Modified;
                condb.SaveChanges();
                res = "Success";
                return(res);
            }
        }
        public string DeleteOperatorDetails(int id)
        {
            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())
            {
                tblOperatorLoginDetail obj = db.tblOperatorLoginDetails.Find(id);
                obj.isDeleted       = 1;
                db.Entry(obj).State = EntityState.Modified;
                db.SaveChanges();
            }

            var mac = db.tblOperatorMachineDetails.Where(m => m.operatorLoginId == id).ToList();

            if (mac.Count != 0)
            {
                foreach (var ec in mac)
                {
                    ec.isDeleted = 1;
                    db.SaveChanges();
                }
            }
            return("Deleted");
        }
        public ActionResult Delete(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    UserID1  = id;
            int    UserID   = Convert.ToInt32(Session["UserId"]);

            using (i_facility_shaktiEntities1 db = new i_facility_shaktiEntities1())
            {
                var tblpm = db.configuration_tblsensorgroup.Where(m => m.SID == id).FirstOrDefault();
                //tblpmchecklist tblpm = db.tblpmchecklists.Find(id);
                tblpm.IsDeleted       = 1;
                tblpm.ModifiedBy      = UserID;
                tblpm.ModifiedOn      = DateTime.Now;
                db.Entry(tblpm).State = EntityState.Modified;
                db.SaveChanges();
                TempData["toaster_success"] = "Data Deleted successfully";
                return(RedirectToAction("IndexSensorGroup"));
            }
        }
        public ActionResult EditSensorGroup(sensormodel tblmc)
        {
            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"]);
            string sensorName = tblmc.sensorgroup.SensorGroupName.ToString();
            int    sid        = tblmc.sensorgroup.SID;

            using (i_facility_shaktiEntities1 db = new i_facility_shaktiEntities1())
            {
                var doesThisPlantExist = db.configuration_tblsensorgroup.Where(m => m.IsDeleted == 0 && m.SensorGroupName == sensorName && m.SID != sid).ToList();
                if (doesThisPlantExist.Count == 0)
                {
                    var sensor = db.configuration_tblsensorgroup.Find(tblmc.sensorgroup.SID);
                    sensor.SensorDesc      = tblmc.sensorgroup.SensorDesc;
                    sensor.SensorGroupName = sensorName;
                    sensor.ModifiedBy      = ViewBag.roleid;
                    sensor.ModifiedOn      = DateTime.Now;
                    db.Entry(sensor).State = EntityState.Modified;
                    db.SaveChanges();
                    TempData["toaster_success"] = "Data Updated successfully";
                    return(RedirectToAction("IndexSensorGroup"));
                }
                else
                {
                    TempData["toaster_warning"] = "This Record Already Exists";
                    return(View(tblmc));
                }
            }
        }
        public string UpdateDat(string UserName, string Password, string DisplayName, int RoleID1, int RoleID2, int userid)
        {
            string res           = "";
            var    doesThisExist = condb.tblusers.Where(m => m.IsDeleted == 0 && m.UserName == UserName && m.Password == Password && m.DisplayName == DisplayName && m.UserID != userid && m.PrimaryRole == RoleID1 && m.SecondaryRole == RoleID2).ToList();

            if (doesThisExist.Count == 0)
            {
                using (i_facility_shaktiEntities1 condb = new i_facility_shaktiEntities1())
                {
                    var UserData = condb.tblusers.Find(userid);

                    UserData.UserName           = UserName;
                    UserData.Password           = Password;
                    UserData.DisplayName        = DisplayName;
                    UserData.PrimaryRole        = RoleID1;
                    UserData.ModifiedBy         = userid;
                    UserData.SecondaryRole      = RoleID2;
                    UserData.ModifiedOn         = DateTime.Now;
                    condb.Entry(UserData).State = EntityState.Modified;
                    condb.SaveChanges();
                    res = "Success";
                }
            }
            return(res);
        }
Exemplo n.º 14
0
        //delete machine category
        public ActionResult DeleteCells(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    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
            using (i_facility_shaktiEntities1 db = new i_facility_shaktiEntities1())
            {
                tblcell tblmc     = db.tblcells.Find(id);
                int     mcahineid = tblmc.CellID;
                tblmc.IsDeleted       = 1;
                tblmc.ModifiedBy      = 1;
                tblmc.ModifiedOn      = DateTime.Now;
                db.Entry(tblmc).State = EntityState.Modified;
                db.SaveChanges();

                //delete corresponding machines
                var machinedata = db.tblmachinedetails.Where(m => m.IsDeleted == 0 && m.CellID == mcahineid).ToList();
                foreach (var machinerow in machinedata)
                {
                    machinerow.IsDeleted       = 1;
                    db.Entry(machinerow).State = EntityState.Modified;
                    db.SaveChanges();
                }
            }


            return(RedirectToAction("CellsList"));
        }
        public ActionResult Delete(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"];
            int               UserID   = Convert.ToInt32(Session["UserId"]);
            String            Username = Session["Username"].ToString();
            tbloperatordetail OpTDet   = db.tbloperatordetails.Find(id);

            OpTDet.isDeleted       = 1;
            OpTDet.ModifiedBy      = UserID;
            OpTDet.ModifiedOn      = DateTime.Now;
            db.Entry(OpTDet).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public JsonResult DeleteData(int id = 0)
        {
            var tblpm = condb.configuration_tblpmchecklist.Where(m => m.pmcid == id).FirstOrDefault();

            tblpm.Isdeleted          = 1;
            tblpm.ModifiedBy         = 1;
            tblpm.ModifiedOn         = DateTime.Now;
            condb.Entry(tblpm).State = EntityState.Modified;
            condb.SaveChanges();
            return(Json(tblpm.pmcid, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Edit(ModulesModel tblModule)
        {
            if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
            {
                return(RedirectToAction("Login", "Login", null));
            }
            ViewBag.UserName = Session["Username"];
            ViewBag.roleid   = Session["RoleID"];
            String Username = Session["Username"].ToString();

            int UserID1 = Convert.ToInt32(Session["UserID"].ToString());

            ViewBag.IsEmailEscalation = 0;


            if (ModelState.IsValid)
            {
                using (i_facility_shaktiEntities1 db = new i_facility_shaktiEntities1())
                {
                    var DupModule = db.tblmodules.Where(m => m.IsDeleted == 0 && m.Module == tblModule.Modules.Module && m.ModuleId != tblModule.Modules.ModuleId).FirstOrDefault();
                    if (DupModule == null)
                    {
                        var ModuleData = db.tblmodules.Find(tblModule.Modules.ModuleId);
                        ModuleData.Module         = tblModule.Modules.Module;
                        ModuleData.ModuleDesc     = tblModule.Modules.ModuleDesc;
                        ModuleData.ModuleDispName = tblModule.Modules.ModuleDispName;
                        ModuleData.ModifiedBy     = 1;
                        ModuleData.ModifiedOn     = DateTime.Now;


                        db.Entry(ModuleData).State = EntityState.Modified;
                        db.SaveChanges();

                        ////Updating in module helper not necessary as we are not changing the ModuleID.
                        //int ID = Convert.ToInt32(Session["ID"]);
                        //masterrolemodulehelper module = db.masterrolemodulehelpers.Find(ID);
                        //module.ModuleID = tblModule.ModuleId;
                        //db.Entry(tblModule).State = EntityState.Modified;
                        //db.SaveChanges();

                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        Session["Error"] = "Duplicate ModuleName: " + tblModule.Modules.Module;
                        return(View(tblModule));
                    }
                }
            }
            else
            {
                return(View(tblModule));
            }
        }
        public ActionResult Edit(TblPMSNotification_Master tee)
        {
            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();

            #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 Plantidstring      = Convert.ToString(tee.PlantID);
            string Shopidstring       = Convert.ToString(tee.ShopID);
            string Cellidstring       = Convert.ToString(tee.CellID);
            string WorkCenteridstring = Convert.ToString(tee.WorkCenterID);
            string days        = tee.NoOfDaysPrior;
            string cclist      = tee.CcList;
            string tolist      = tee.ToList;
            string contactlist = tee.SMSContactList;



            tee.ModifiedBy = UserID;
            tee.ModifiedOn = (DateTime)DateTime.Now;
            tee.IsDeleted  = 0;

            db.Entry(tee).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Exemplo n.º 19
0
        public ActionResult Edit(tblunit tblunit)
        {
            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"]);

            tblunit.ModifiedBy = UserID;
            tblunit.ModifiedOn = System.DateTime.Now;
            {
                //Section related to storing data in ActiveLog
                //#region Active Log Code
                //tblunit OldData = db.tblunits.Find(tblunit.U_ID);
                //IEnumerable<string> FullData = ActiveLog.EnumeratePropertyDifferences<tblunit>(OldData, tblunit);
                //ICollection<tblunit> c = FullData as ICollection<tblunit>;
                //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
                if (ModelState.IsValid)
                {
                    db.Entry(tblunit).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            return(View(tblunit));
        }
Exemplo n.º 20
0
        public string update(int plant, int shop, int cell, string typeofcheckpoint, string value, string frequency, int pmcpid, string checklist, string How)
        {
            string res   = "";
            var    tblpc = condb.configuration_tblpmcheckpoint.Find(pmcpid);

            tblpc.Isdeleted          = 0;
            tblpc.PlantID            = plant;
            tblpc.ShopID             = shop;
            tblpc.CellID             = cell;
            tblpc.pmcpID             = pmcpid;
            tblpc.frequency          = frequency;
            tblpc.Value              = value;
            tblpc.How                = How;
            tblpc.CheckList          = checklist;
            tblpc.TypeofCheckpoint   = typeofcheckpoint;
            tblpc.ModifiedBy         = ViewBag.roleid;
            tblpc.ModifiedOn         = DateTime.Now;
            condb.Entry(tblpc).State = EntityState.Modified;
            condb.SaveChanges();
            res = "Success";
            return(res);
        }
        //Delete Machine
        public ActionResult DeleteMachine(int id)
        {
            //ViewBag.Logout = Session["Username"].ToString().ToUpper();
            //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
            tblmachinedetail tblmc = db.tblmachinedetails.Find(id);
            int mcahineid          = tblmc.MachineID;

            tblmc.IsDeleted         = 1;
            tblmc.ModifiedBy        = 1;
            tblmc.ServerTabFlagSync = 1;
            tblmc.ServerTabCheck    = 2;
            tblmc.ModifiedOn        = DateTime.Now;
            db.Entry(tblmc).State   = EntityState.Modified;
            db.SaveChanges();

            //delete corresponding machines
            var machinedata = db.tblcells.Where(m => m.IsDeleted == 0 && m.CellID == mcahineid).ToList();

            foreach (var machinerow in machinedata)
            {
                machinerow.IsDeleted       = 1;
                db.Entry(machinerow).State = EntityState.Modified;
                db.SaveChanges();
            }

            return(RedirectToAction("MachineList"));
        }
Exemplo n.º 22
0
        public string Setfalg(string Enddate)
        {
            string res        = "";
            var    pmsdetails = condb.tblpmsdetails.Where(m => m.IsDeleted == 0 && m.IsSubmitted == 1).ToList();

            foreach (var pmsdet1 in pmsdetails)
            {
                pmsdet1.IsCompleted        = 1;
                pmsdet1.PMEndDate          = Enddate;
                condb.Entry(pmsdet1).State = EntityState.Modified;
                condb.SaveChanges();
            }
            res = "Success";
            return(res);
        }
        public ActionResult EditSensorDataLink(SensorDataLink tblmc)
        {
            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"]);
            string parameterName = tblmc.sensordatalink.ParameterName.ToString();
            var    parameterid   = tblmc.sensordatalink.ParameterTypeID;

            using (i_facility_shaktiEntities1 db = new i_facility_shaktiEntities1())
            {
                var doesThissensorExist = db.configurationtblsensordatalinks.Where(m => m.IsDeleted == 0 && m.ParameterName == parameterName && m.ParameterDesc == tblmc.sensordatalink.ParameterDesc && m.LSL == tblmc.sensordatalink.LSL && m.LogFrequency == tblmc.sensordatalink.LogFrequency && m.IsAxis == tblmc.sensordatalink.IsAxis && m.IsSensor == tblmc.sensordatalink.IsSensor && m.USL == tblmc.sensordatalink.USL && m.LogFrequency == tblmc.sensordatalink.LogFrequency && m.ParameterTypeID != parameterid && m.Element == tblmc.sensordatalink.Element && m.SubElement == tblmc.sensordatalink.SubElement && m.Deterioration == tblmc.sensordatalink.Deterioration).ToList();
                if (doesThissensorExist.Count == 0)
                {
                    var sensor = db.configurationtblsensordatalinks.Find(tblmc.sensordatalink.ParameterTypeID);
                    sensor.ParameterName   = tblmc.sensordatalink.ParameterName;
                    sensor.ParameterDesc   = tblmc.sensordatalink.ParameterDesc;
                    sensor.IsCycle         = tblmc.sensordatalink.IsCycle;
                    sensor.LSL             = tblmc.sensordatalink.LSL;
                    sensor.USL             = tblmc.sensordatalink.USL;
                    sensor.IsAxis          = tblmc.sensordatalink.IsAxis;
                    sensor.IsSensor        = tblmc.sensordatalink.IsSensor;
                    sensor.LogFrequency    = tblmc.sensordatalink.LogFrequency;
                    sensor.LogFreqUnitID   = tblmc.sensordatalink.LogFreqUnitID;
                    sensor.AxisID          = tblmc.sensordatalink.AxisID;
                    sensor.Element         = tblmc.sensordatalink.Element;
                    sensor.SubElement      = tblmc.sensordatalink.SubElement;
                    sensor.Deterioration   = tblmc.sensordatalink.Deterioration;
                    sensor.ModifiedBy      = ViewBag.roleid;
                    sensor.ModifiedOn      = DateTime.Now;
                    db.Entry(sensor).State = EntityState.Modified;
                    db.SaveChanges();
                    TempData["toaster_success"] = "Data Updated successfully";
                    return(RedirectToAction("Index"));
                }
                else
                {
                    TempData["toaster_warning"] = "This Record Already Exists";
                    return(View(tblmc));
                }
            }
        }
 public ActionResult EditRoleModule(IEnumerable <tblrolemodulelink> rolemodule)
 {
     if (rolemodule != null)
     {
         if (ModelState.IsValid)
         {
             foreach (var b in rolemodule)
             {
                 b.ModifiedBy      = 1;
                 b.ModifiedOn      = DateTime.Now;
                 db.Entry(b).State = System.Data.Entity.EntityState.Modified;
                 db.SaveChanges();
             }
             return(RedirectToAction("Index"));
         }
     }
     return(View(rolemodule));
 }
        public ActionResult EditMachineSensor(sensormachinemodel tblmc)
        {
            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"]);
            string sensorName = db.configuration_tblsensorgroup.Where(m => m.SID == tblmc.machinesensor.Sid).Select(m => m.SensorGroupName).FirstOrDefault();
            string macname    = db.tblmachinedetails.Where(m => m.MachineID == tblmc.machinesensor.MachineId).Select(m => m.MachineName).FirstOrDefault();
            int    msid       = tblmc.machinesensor.MSID;

            using (i_facility_shaktiEntities1 db = new i_facility_shaktiEntities1())
            {
                var doesThisExist = db.configurationtblmachinesensors.Where(m => m.IsDeleted == 0 && m.MSID != msid && m.Sid == tblmc.machinesensor.Sid && m.MachineId == tblmc.machinesensor.MachineId && m.Sid == tblmc.machinesensor.Sid).ToList();
                if (doesThisExist.Count == 0)
                {
                    var sensor = db.configurationtblmachinesensors.Find(tblmc.machinesensor.MSID);
                    sensor.MachineId = tblmc.machinesensor.MachineId;
                    sensor.Sid       = tblmc.machinesensor.Sid;
                    sensor.IPAddress = tblmc.machinesensor.IPAddress;
                    if (sensor.IPAddress == null)
                    {
                        sensor.IPAddress = "0";
                    }
                    sensor.PortNo          = tblmc.machinesensor.PortNo;
                    sensor.MachineId       = tblmc.machinesensor.MachineId;
                    sensor.ModifiedBy      = ViewBag.roleid;
                    sensor.ModifiedOn      = DateTime.Now;
                    db.Entry(sensor).State = EntityState.Modified;
                    db.SaveChanges();
                    TempData["toaster_success"] = "Data Updated successfully";
                    return(RedirectToAction("IndexMachineSensor"));
                }
                else
                {
                    TempData["toaster_error"] = "Sensor Group Name already exists";
                    return(View(tblmc));
                }
            }
        }
        public ActionResult Edit(RolesModel tblrole)
        {
            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"]);

            // Update Role data with other required fields.
            //tblrole.ModifiedBy = UserID;
            //tblrole.ModifiedOn = System.DateTime.Now;
            var DuplicateRole = db.tblroles.Where(m => m.IsDeleted == 0 && m.RoleName == tblrole.Role.RoleName && m.Role_ID != tblrole.Role.Role_ID).FirstOrDefault();

            if (DuplicateRole == null)
            {
                if (ModelState.IsValid)
                {
                    using (i_facility_shaktiEntities1 db = new i_facility_shaktiEntities1())
                    {
                        var RoleData = db.tblroles.Find(tblrole.Role.Role_ID);
                        RoleData.RoleName        = tblrole.Role.RoleName;
                        RoleData.RoleDesc        = tblrole.Role.RoleDesc;
                        RoleData.RoleDisplayName = tblrole.Role.RoleDisplayName;
                        RoleData.ModifiedBy      = 1;
                        RoleData.ModifiedOn      = DateTime.Now;
                        db.Entry(RoleData).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                    return(RedirectToAction("Index"));
                }
            }
            else
            {
                Session["Error"] = "Duplicate Role : " + tblrole.Role.RoleName;
                return(View(tblrole));
            }
            return(View(tblrole));
        }
        //0: upload failed,
        //1: Successfull.
        public JsonResult CheckEndStatus()
        {
            string retValue = "";

            using (i_facility_shaktiEntities1 dbpupload = new i_facility_shaktiEntities1())
            {
                int macID       = Convert.ToInt32(Session["MachineID"]);
                int pthistroyID = 0;
                Int32.TryParse(Convert.ToString(Session["pthID"]), out pthistroyID);

                if (pthistroyID == 0)
                {
                    pthistroyID = dbpupload.tblprogramtransferhistories.Where(m => m.MachineID == macID).OrderByDescending(m => m.UploadedTime).Select(m => m.PTHID).FirstOrDefault();
                }

                var RetStatusData = dbpupload.tblprogramtransferhistories.Where(m => m.PTHID == pthistroyID).FirstOrDefault();
                if (RetStatusData != null && RetStatusData.IsCompleted == 0)
                {
                    int retStatusInt = 0;
                    if (int.TryParse(Convert.ToString(RetStatusData.ReturnStatus), out retStatusInt))
                    {
                        if (retStatusInt == 0)
                        {
                            retValue         = RetStatusData.ReturnDesc;
                            Session["pthID"] = null;
                        }
                        else
                        {
                            retValue         = "Upload Successfull.";
                            Session["pthID"] = null;
                        }

                        //RetStatusData.IsCompleted = 1;
                        dbpupload.Entry(RetStatusData).State = System.Data.Entity.EntityState.Modified;
                        dbpupload.SaveChanges();
                    }
                    // else return null
                }
            }
            return(Json(retValue, JsonRequestBehavior.AllowGet));
        }
        //[HttpPost]
        //public ActionResult Create(UserModel user, int PrimaryRoleID, int SecondaryRoleID)
        //{
        //    if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
        //    {
        //        return RedirectToAction("Login", "Login", null);
        //    }

        //    ViewBag.Logout = Session["Username"].ToString().ToUpper();
        //    ViewBag.roleid = Session["RoleID"];
        //    int roleid = Convert.ToInt32(Session["RoleID"]);
        //    String Username = Session["Username"].ToString();

        //    //Update user data with other required fields.
        //    user.Users.PrimaryRole = PrimaryRoleID;
        //    user.Users.SecondaryRole = SecondaryRoleID;
        //    user.Users.CreatedBy = roleid;
        //    user.Users.CreatedOn = System.DateTime.Now;
        //    user.Users.IsDeleted = 0;
        //    var dupUserData = condb.tblusers.Where(m => m.IsDeleted == 0 && m.UserName == user.Users.UserName).ToList();
        //    if (dupUserData.Count == 0)
        //    {
        //        condb.tblusers.Add(user.Users);
        //        condb.SaveChanges();
        //        return RedirectToAction("Index");
        //    }
        //    else // Duplicate UserName Exists so show error message.
        //    {
        //        Session["Error"] = "Duplicate UserName : "******"RoleID", "RoleDesc", user.Users.PrimaryRole);
        //        ViewBag.SecondaryRoleID = new SelectList(condb.tblroles.Where(m => m.IsDeleted == 0 && m.Role_ID >= roleid).ToList(), "RoleID", "RoleDesc", user.Users.SecondaryRole);
        //        return View(user);
        //    }
        //}

        //[HttpPost]
        //public ActionResult Edit(UserModel user, int PrimaryRoleID, int SecondaryRoleID)
        //{
        //    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"]);
        //    int roleid = Convert.ToInt32(Session["RoleID"]);

        //    //user.ModifiedBy = UserID;
        //    //user.ModifiedOn = System.DateTime.Now;

        //    var dupUserData = condb.tblusers.Where(m => m.IsDeleted == 0 && m.UserName == user.Users.UserName && m.UserID != user.Users.UserID).ToList();
        //    if (dupUserData.Count == 0)
        //    {
        //        var UserData = condb.tblusers.Find(user.Users.UserID);

        //        UserData.UserName = user.Users.UserName;
        //        UserData.Password = user.Users.Password;
        //        UserData.DisplayName = user.Users.DisplayName;
        //        UserData.PrimaryRole = PrimaryRoleID;
        //        UserData.SecondaryRole = SecondaryRoleID;
        //        UserData.ModifiedBy = UserID;
        //        UserData.ModifiedOn = DateTime.Now;

        //        int primaryrole = Convert.ToInt32(user.Users.PrimaryRole);

        //        condb.Entry(UserData).State = EntityState.Modified;
        //        condb.SaveChanges();
        //        return RedirectToAction("Index");
        //    }
        //    else
        //    {
        //        Session["Error"] = "Duplicate User Name : " + user.Users.UserName;
        //        ViewBag.PrimaryRoleID = new SelectList(condb.tblroles.Where(m => m.IsDeleted == 0 && m.Role_ID >= roleid).ToList(), "Role_ID", "RoleDesc", user.Users.PrimaryRole);
        //        ViewBag.SecondaryRoleID = new SelectList(condb.tblroles.Where(m => m.IsDeleted == 0 && m.Role_ID >= roleid).ToList(), "Role_ID", "RoleDesc", user.Users.SecondaryRole);
        //        return View(user);
        //    }
        //}

        public ActionResult Delete(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;
            tbluser tblusers = condb.tblusers.Find(id);

            tblusers.IsDeleted          = 1;
            tblusers.ModifiedBy         = UserID;
            tblusers.ModifiedOn         = System.DateTime.Now;
            condb.Entry(tblusers).State = EntityState.Modified;
            condb.SaveChanges();
            TempData["toaster_success"] = "Data Deleted successfully";
            return(RedirectToAction("Index"));
        }
        public ActionResult EditShops(ShopModel shop)
        {
            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"]);
            //shop name validation
            string deptname = shop.Shops.ShopName.ToString();
            int    shopid   = shop.Shops.ShopID;

            using (i_facility_shaktiEntities1 db = new i_facility_shaktiEntities1())
            {
                var doesThisdeptExists = db.tblshops.Where(m => m.IsDeleted == 0 && m.PlantID == shop.Shops.PlantID && m.ShopName == deptname && m.ShopID != shopid).ToList();
                if (doesThisdeptExists.Count == 0)
                {
                    var Department = db.tblshops.Find(shop.Shops.ShopID);

                    Department.ShopName        = shop.Shops.ShopName;
                    Department.ShopDesc        = shop.Shops.ShopDesc;
                    Department.Shopdisplayname = shop.Shops.Shopdisplayname;
                    Department.ModifiedBy      = UserID;
                    Department.ModifiedOn      = DateTime.Now;
                    //dept.ModifiedBy = 1;
                    //dept.ModifiedOn = DateTime.Now;
                    db.Entry(Department).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("ShopList"));
                }
                else
                {
                    Session["Error"] = "Department Name already exists for this Plant:" + shop.Shops.tblplant.PlantDisplayName;
                    ViewBag.PlantID  = new SelectList(db.tblshops.Where(m => m.IsDeleted == 0), "PlantID", "PlantName", shop.Shops.PlantID);
                    return(View(shop));
                }
            }
        }
        public void insertProdlosses(int WOID, int LossID, decimal LossDuration, DateTime CorrectedDate, int MachineID)
        {
            var Presentloss = db.tbl_ProdOrderLosses.Where(m => m.WOID == WOID && m.LossID == LossID).FirstOrDefault();

            if (Presentloss == null)
            {
                tbl_ProdOrderLosses PRA = new tbl_ProdOrderLosses();
                PRA.LossID = LossID;
                if (LossID != 0)
                {
                    var GetLossDet = db.tbllossescodes.Find(LossID);
                    if (GetLossDet.LossCodesLevel1ID == null)
                    {
                        PRA.LossCodeL1ID = LossID;
                    }
                    else
                    {
                        PRA.LossCodeL1ID = (int)GetLossDet.LossCodesLevel1ID;
                        PRA.LossID       = (int)GetLossDet.LossCodesLevel1ID;
                    }
                    if (GetLossDet.LossCodesLevel2ID != null)
                    {
                        PRA.LossCodeL2ID = (int)GetLossDet.LossCodesLevel2ID;
                    }
                }
                //PRA.MachineID = MachineID;
                PRA.WOID          = WOID;
                PRA.CorrectedDate = CorrectedDate.Date;
                PRA.LossDuration  = (int)LossDuration;
                PRA.MachineID     = MachineID;
                db.tbl_ProdOrderLosses.Add(PRA);
                db.SaveChanges();
            }
            else
            {
                Presentloss.LossDuration    = (int)(Presentloss.LossDuration + LossDuration);
                db.Entry(Presentloss).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
            }
        }