public JsonResult CreateData(string HD, string RD)
        {
            tblholiday tblholiday     = new tblholiday();
            DateTime   Var            = Convert.ToDateTime(HD).Date;
            var        duplicateEntry = db.tblholidays.Where(m => m.IsDeleted == 0 && m.HolidayDate == Var).ToList();

            if (duplicateEntry.Count > 0)
            {
                TempData["Error"] = "Record already exists";
            }
            else
            {
                tblholiday.CreatedBy   = 1;
                tblholiday.CreatedOn   = DateTime.Now;
                tblholiday.IsDeleted   = 0;
                tblholiday.HolidayDate = Convert.ToDateTime(HD).Date;
                tblholiday.Reason      = RD;
                {
                    db.tblholidays.Add(tblholiday);
                    db.SaveChanges();
                }
            }

            return(Json(tblholiday.HolidayId, JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        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();
            //Getting all the details of that particular id in PMCheckPoint table
            configuration_tblpmcheckpoint tblmc = condb.configuration_tblpmcheckpoint.Find(id);

            using (i_facility_shaktiEntities1 condb = new i_facility_shaktiEntities1())
            {
                //Getting all the details of that particular id in PMCheckList table
                var data = condb.configuration_tblpmcheckpoint.Where(m => m.pmcpID == id && m.Isdeleted == 0).ToList();
                foreach (var row in data)
                {
                    //deleting the perticular row of that id in tblPMCheckList table
                    row.Isdeleted = 1;
                    condb.SaveChanges();
                }
                //And deleting the row present in tblPMCheckPoint table
            }
            tblmc.Isdeleted = 1;
            condb.SaveChanges();
            TempData["toaster_success"] = "Data Deleted successfully";
            return(RedirectToAction("Index"));
        }
        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"]);
            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"));
        }
Beispiel #5
0
        //public string Getdata(int cellid, int machineid)
        //{
        //    List<PMSEntry> pmslist = new List<PMSEntry>();
        //    string res = "";
        //    var checkpointdata = condb.configuration_tblpmcheckpoint.Where(m => m.Isdeleted == 0 && m.CellID == cellid).ToList();
        //    var pmsdet = condb.tblpmsdetails.Where(m => m.IsDeleted == 0 && m.IsCompleted == 0 && m.MachineID == machineid).ToList();
        //    int count = pmsdet.Count;
        //    if (count == 0)
        //    {

        //        foreach (var checkpointdet in checkpointdata)
        //        {
        //            PMSEntry obj = new PMSEntry();
        //            obj.checkpointid = checkpointdet.pmcpID;
        //            obj.checkpointname = checkpointdet.TypeofCheckpoint;
        //            var checklistdata = condb.configuration_tblpmchecklist.Where(m => m.Isdeleted == 0 && m.pmcpID == checkpointdet.pmcpID).ToList();
        //            List<pmchecklistdata> pmclist = new List<pmchecklistdata>();
        //            foreach (var checklistdet in checklistdata)
        //            {
        //                pmchecklistdata obj1 = new pmchecklistdata();
        //                obj1.checklistname = checklistdet.CheckList;
        //                obj1.Frequency = checklistdet.Frequency;
        //                obj1.Value = checklistdet.Value;
        //                obj1.How = checklistdet.How;
        //                pmclist.Add(obj1);
        //            }
        //            obj.checklistdata = pmclist;
        //            pmslist.Add(obj);
        //        }
        //        res = JsonConvert.SerializeObject(pmslist);
        //    }
        //    else
        //    {
        //        foreach (var checkpointdet in checkpointdata)
        //        {
        //            var histpms = condb.tblhistpms.Where(m => m.Pmcheckpointid == checkpointdet.pmcpID).ToList();
        //            foreach (var histpmsdet in histpms)
        //            {
        //                if (checkpointdet.pmcpID == histpmsdet.Pmcheckpointid)
        //                {
        //                    PMSEntry obj = new PMSEntry();
        //                    obj.checkpointid = histpmsdet.Pmcheckpointid;
        //                    var checkpointname = condb.configuration_tblpmcheckpoint.Where(m => m.pmcpID == histpmsdet.Pmcheckpointid).Select(m => m.TypeofCheckpoint).FirstOrDefault();
        //                    obj.checkpointname = checkpointname;
        //                    var checklistdata = condb.configuration_tblpmchecklist.Where(m => m.Isdeleted == 0 && m.pmcpID == histpmsdet.Pmcheckpointid).ToList();
        //                    List<pmchecklistdata> pmclist = new List<pmchecklistdata>();
        //                    foreach (var checklistdet in checklistdata)
        //                    {
        //                        pmchecklistdata obj1 = new pmchecklistdata();
        //                        obj1.checklistname = checklistdet.CheckList;
        //                        obj1.Frequency = checklistdet.Frequency;
        //                        obj1.Value = checklistdet.Value;
        //                        obj1.How = checklistdet.How;
        //                        pmclist.Add(obj1);
        //                    }
        //                    obj.checklistdata = pmclist;
        //                    pmslist.Add(obj);
        //                    res = JsonConvert.SerializeObject(pmslist);
        //                }
        //                else
        //                {
        //                    PMSEntry obj = new PMSEntry();
        //                    obj.checkpointid = checkpointdet.pmcpID;
        //                    obj.checkpointname = checkpointdet.TypeofCheckpoint;
        //                    var checklistdata = condb.configuration_tblpmchecklist.Where(m => m.Isdeleted == 0 && m.pmcpID == histpmsdet.Pmcheckpointid).ToList();
        //                    List<pmchecklistdata> pmclist = new List<pmchecklistdata>();
        //                    foreach (var checklistdet in checklistdata)
        //                    {
        //                        pmchecklistdata obj1 = new pmchecklistdata();
        //                        obj1.checklistname = checklistdet.CheckList;
        //                        obj1.Frequency = checklistdet.Frequency;
        //                        obj1.Value = checklistdet.Value;
        //                        obj1.How = checklistdet.How;
        //                        pmclist.Add(obj1);
        //                    }
        //                    obj.checklistdata = pmclist;
        //                    pmslist.Add(obj);
        //                    res = JsonConvert.SerializeObject(pmslist);
        //                }
        //            }
        //        }
        //    }
        //    return res;
        //}
        public string insertdata(int machineid, string Startdate)
        {
            string res    = "";
            var    pmsdet = condb.tblpmsdetails.Where(m => m.IsDeleted == 0 && m.IsCompleted == 0 && m.MachineID == machineid && m.PMStartDate == Startdate).ToList();
            int    count  = pmsdet.Count;

            if (count == 0)
            {
                tblpmsdetail obj1 = new tblpmsdetail();
                obj1.MachineID = machineid;
                //obj1.CellID = cellid;
                obj1.PMEndDate   = null;
                obj1.PMStartDate = Startdate;
                obj1.IsCompleted = 0;
                obj1.IsSubmitted = 1;
                obj1.CreatedOn   = System.DateTime.Now;
                obj1.CreatedBy   = 1;
                obj1.IsDeleted   = 0;
                condb.tblpmsdetails.Add(obj1);
                condb.SaveChanges();
                res = JsonConvert.SerializeObject(obj1.pmsid);
            }
            else
            {
            }
            return(res);
        }
        //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 InsertDatawithio(int channelnum, string memoryadd, int sid, string sensordesc, int modeltype,
                                       decimal scalingfac, int uid, int sdlid)
        {
            string res = "";
            //var doesThisExist = db.configurationtblsensormasters.Where(m => m.IsDeleted == 0 && m.ChannelNo == channelnum && m.MemoryAddress == memoryadd && m.Sid == sid && m.SensorDesc == sensordesc && m.IsAnalog == modeltype && m.scalingFactor == scalingfac && m.Unitid == uid && m.parametertypeid == sdlid).ToList();
            //if (doesThisExist.Count == 0)
            //{

            configurationtblsensormaster tblpc = new configurationtblsensormaster();

            tblpc.CreatedBy       = 1;
            tblpc.CreatedOn       = DateTime.Now;
            tblpc.IsDeleted       = 0;
            tblpc.IsAnalog        = modeltype;
            tblpc.ChannelNo       = channelnum;
            tblpc.MemoryAddress   = Convert.ToInt32(memoryadd);
            tblpc.Sid             = sid;
            tblpc.SensorDesc      = sensordesc;
            tblpc.scalingFactor   = scalingfac;
            tblpc.Unitid          = uid;
            tblpc.parametertypeid = sdlid;
            db.configurationtblsensormasters.Add(tblpc);
            db.SaveChanges();
            res = "success";
            // }
            //else
            // {
            //     TempData["Message"] = "This Record is already Exists";
            //     return res;
            // }
            return(res);
        }
Beispiel #8
0
        private bool InsertOEEDetails(string CorrectedDate, int MachineID, decimal AvailabilityPercentage, decimal QualityPercentage, decimal PerformancePercentage, decimal OEEPercentage,
                                      int TotalPartsCount, decimal OperatingTime, decimal TotalIdleTimeInMin, decimal PerformanceFactor)
        {
            bool res    = false;
            var  oeedet = db.tbl_OEEDetails.Where(m => m.CorrectedDate == CorrectedDate && m.MachineID == MachineID).FirstOrDefault();

            if (oeedet == null)
            {
                tbl_OEEDetails oee = new tbl_OEEDetails();
                oee.MachineID          = MachineID;
                oee.Availability       = AvailabilityPercentage;
                oee.IsDeleted          = 0;
                oee.OEE                = OEEPercentage;
                oee.Performance        = PerformancePercentage;
                oee.Quality            = QualityPercentage;
                oee.TotalPartsCount    = TotalPartsCount;
                oee.CreatedOn          = DateTime.Now;
                oee.CreatedBy          = 1;
                oee.CorrectedDate      = CorrectedDate;
                oee.OperatingTimeinMin = OperatingTime;
                oee.TotalIDLETimeinMin = TotalIdleTimeInMin;
                oee.PerformanceFactor  = PerformanceFactor;
                db.tbl_OEEDetails.Add(oee);
                db.SaveChanges();
                res = true;
            }
            return(res);
        }
Beispiel #9
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"));
        }
        //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"));
        }
Beispiel #11
0
        public ActionResult Create(tblmailid tmi)
        {
            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

            //MailID Details validation
            string name            = tmi.EmployeeName.ToString();
            string emailid         = tmi.EmailID.ToString();
            string contactNo       = tmi.EmployeeContactNum.ToString();
            var    doesTheseExists = db.tblmailids.Where(m => m.IsDeleted == 0 && (m.EmployeeName == name || m.EmailID == emailid || m.EmployeeContactNum == contactNo)).ToList();
            if (doesTheseExists.Count() == 0)
            {
                tmi.IsDeleted = 0;
                tmi.CreatedBy = UserID;
                tmi.CreatedOn = DateTime.Now;
                db.tblmailids.Add(tmi);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            else
            {
                Session["Error"] = null;
                var doesNameExists = db.tblmailids.Where(m => m.IsDeleted == 0 && m.EmployeeName == name).ToList();
                if (doesNameExists.Count() > 0)
                {
                    Session["Error"] += "Duplicate Name. ";
                }
                var doesMailIdExists = db.tblmailids.Where(m => m.EmailID == emailid).ToList();
                if (doesMailIdExists.Count() > 0)
                {
                    Session["Error"] += " Duplicate Email ID. ";
                }
                var doesCnoExists = db.tblmailids.Where(m => m.IsDeleted == 0 && m.EmployeeContactNum == contactNo).ToList();
                if (doesCnoExists.Count() > 0)
                {
                    Session["Error"] += " Duplicate Contact Number. ";
                }
                return(View(tmi));
            }
        }
        //[HttpPost]
        //public ActionResult Create(OperatorModule OPTDet)
        //{
        //    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 Dept = OPTDet.OPDetails.Dept;
        //    string OperatorName = OPTDet.OPDetails.OperatorName;
        //    int OperatorID = OPTDet.OPDetails.OperatorID;
        //    bool check = ValidationCheckForInsertion(OperatorID);
        //    if (check == true)
        //    {
        //        OPTDet.OPDetails.CreatedOn = DateTime.Now;
        //        OPTDet.OPDetails.CorrectedDate = DateTime.Now.Date;
        //        OPTDet.OPDetails.CreatedBy = UserID;
        //        OPTDet.OPDetails.isDeleted = 0;
        //        db.tbloperatordetails.Add(OPTDet.OPDetails);
        //        db.SaveChanges();
        //    }
        //    return RedirectToAction("Index");
        //}

        public string CreateOperator(string dept, string operatorId, string operatorName, int OperatorDesc)
        {
            string res    = "";
            int    UserID = Convert.ToInt32(Session["UserId"]);
            bool   check  = ValidationCheckForInsertion(operatorId);

            if (check == true)
            {
                tbloperatordetail OPTDet = new tbloperatordetail();
                OPTDet.CreatedOn     = DateTime.Now;
                OPTDet.CorrectedDate = DateTime.Now.Date;
                OPTDet.CreatedBy     = UserID;
                OPTDet.isDeleted     = 0;
                OPTDet.Dept          = dept;
                OPTDet.OperatorID    = Convert.ToString(operatorId);
                OPTDet.OperatorName  = operatorName;
                OPTDet.OperatorDesc  = OperatorDesc;
                db.tbloperatordetails.Add(OPTDet);
                db.SaveChanges();
                res = "Success";
            }
            else
            {
                res = "failure";
            }
            return(res);
        }
        public string CreateOperatorLogin(OperatorLoginDetails OperatorLogin)
        {
            ViewBag.Logout = Session["Username"].ToString().ToUpper();
            ViewBag.roleid = Session["RoleID"];
            String Username = Session["Username"].ToString();

            //shop name validation
            using (i_facility_shaktiEntities1 db = new i_facility_shaktiEntities1())
            {
                var operatorCheck = db.tblOperatorLoginDetails.Where(m => m.operatorId == OperatorLogin.operatorId).FirstOrDefault();
                if (operatorCheck == null)
                {
                    string[] machineName       = OperatorLogin.machineids.Split(',');
                    tblOperatorLoginDetail obj = new tblOperatorLoginDetail();
                    obj.operatorUserName = OperatorLogin.operatorUserName;
                    obj.operatorPwd      = OperatorLogin.operatorPwd;
                    obj.operatorEmailId  = OperatorLogin.operatorEmailId;
                    obj.operatorMobileNo = OperatorLogin.operatorMobileNo;
                    obj.roleId           = OperatorLogin.roleId;
                    obj.operatorId       = OperatorLogin.operatorId;
                    obj.operatorName     = OperatorLogin.operatorName;
                    obj.NumOfMachines    = OperatorLogin.NumOfMachines;
                    obj.createdOn        = DateTime.Now;
                    obj.isDeleted        = 0;
                    db.tblOperatorLoginDetails.Add(obj);
                    db.SaveChanges();

                    if (machineName != null)
                    {
                        foreach (var i in machineName)
                        {
                            tblOperatorMachineDetail obj1 = new tblOperatorMachineDetail();
                            var machineId = db.tblmachinedetails.Where(m => m.MachineName == i).Select(m => m.MachineID).FirstOrDefault();
                            obj1.machineId       = machineId;
                            obj1.operatorLoginId = obj.operatorLoginId;
                            obj1.isDeleted       = 0;
                            obj1.createdOn       = DateTime.Now;
                            db.tblOperatorMachineDetails.Add(obj1);
                            db.SaveChanges();
                        }
                    }
                }
                else
                {
                    Session["Error"] = "Operator User Name: " + OperatorLogin.operatorUserName + " already exists ";
                    return("Operator Name already exists ");
                }
                return("Created");
            }
        }
        public string InsertData(string ip, int machineid, int sid, int portno)
        {
            string res = "";

            //var doesThisdataExist = db.configurationtblmachinesensors.Where(m => m.IsDeleted == 0 && m.Sid == sid && m.MachineId == machineid).ToList();
            //if (doesThisdataExist.Count == 0)
            //{
            configurationtblmachinesensor tblpc = new configurationtblmachinesensor();

            tblpc.CreatedBy = 1;
            tblpc.CreatedOn = DateTime.Now;
            tblpc.IsDeleted = 0;
            tblpc.IPAddress = ip;
            tblpc.MachineId = machineid;
            tblpc.Sid       = sid;
            tblpc.PortNo    = portno;
            db.configurationtblmachinesensors.Add(tblpc);
            db.SaveChanges();
            TempData["toaster_success"] = "Data Saved successfully";
            res = "success";
            return(res);
            //}
            //else
            //{
            //    TempData["toaster_error"] = "Sensor Group Name already Exists";
            //    res = "success";

            //}
            //return Json(tblpc.SdlID, JsonRequestBehavior.AllowGet);
        }
        public ActionResult Create(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();
            var    DuplicateRole = db.tblroles.Where(m => m.IsDeleted == 0 && m.RoleName == tblrole.Role.RoleName).FirstOrDefault();

            if (DuplicateRole == null)
            {
                //  Update Role data with other required fields.
                int UserID = Convert.ToInt32(Session["UserId"]);
                tblrole.Role.CreatedBy = UserID;
                tblrole.Role.CreatedOn = System.DateTime.Now;
                tblrole.Role.IsDeleted = 0;

                using (i_facility_shaktiEntities1 db = new i_facility_shaktiEntities1())
                {
                    db.tblroles.Add(tblrole.Role);
                    db.SaveChanges();
                }
            }
            else
            {
                Session["Error"] = "Duplicate Role : " + tblrole.Role.RoleName;
                return(View(tblrole));
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult CreateSensorGroup(sensormodel tblp)
        {
            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();
            string sensorName = tblp.sensorgroup.SensorGroupName.ToString();

            using (i_facility_shaktiEntities1 db = new i_facility_shaktiEntities1())
            {
                var doesThisExist = db.configuration_tblsensorgroup.Where(m => m.IsDeleted == 0 && m.SensorGroupName == sensorName).ToList();
                if (doesThisExist.Count == 0)
                {
                    tblp.sensorgroup.CreatedBy = ViewBag.roleid;
                    tblp.sensorgroup.CreatedOn = DateTime.Now;
                    tblp.sensorgroup.IsDeleted = 0;
                    db.configuration_tblsensorgroup.Add(tblp.sensorgroup);
                    db.SaveChanges();
                    TempData["toaster_success"] = "Data Saved successfully";
                    return(RedirectToAction("IndexSensorGroup"));
                }
                else
                {
                    TempData["toaster_warning"] = "This Record Already Exists";
                    return(View(tblp));
                }
            }
        }
        public string InsertData(string ParameterName, string ParameterDesc, int IsAxis, int IsSensor, decimal LSL, decimal USL, int LogFrequency, int axisid, int logfreqid, int unit, string element, string subelement, string Deterioration, int IsCycle)
        {
            string res = "";
            var    doesThisPlantExist = db.configurationtblsensordatalinks.Where(m => m.IsDeleted == 0 && m.ParameterName == ParameterName && m.AxisID != axisid).ToList();

            if (doesThisPlantExist.Count == 0)
            {
                configurationtblsensordatalink tblpc = new configurationtblsensordatalink();
                tblpc.CreatedBy     = 1;
                tblpc.CreatedOn     = DateTime.Now;
                tblpc.IsDeleted     = 0;
                tblpc.ParameterName = ParameterName;
                tblpc.ParameterDesc = ParameterDesc;
                tblpc.IsCycle       = IsCycle;
                tblpc.IsAxis        = IsAxis;
                tblpc.IsSensor      = IsSensor;
                tblpc.Element       = element;
                tblpc.Unit          = unit;
                tblpc.SubElement    = subelement;
                tblpc.Deterioration = Deterioration;
                tblpc.LSL           = LSL;
                tblpc.LogFreqUnitID = logfreqid;
                tblpc.USL           = USL;
                tblpc.LogFrequency  = LogFrequency;
                tblpc.AxisID        = axisid;
                db.configurationtblsensordatalinks.Add(tblpc);
                db.SaveChanges();
                res = "success";
            }
            return(res);
        }
        public JsonResult CreateData(string st, string br, string et)
        {
            tblplannedbreak tblplannedbreak = new tblplannedbreak();

            tblplannedbreak.CreatedBy   = 1;
            tblplannedbreak.CreatedOn   = DateTime.Now;
            tblplannedbreak.IsDeleted   = 0;
            tblplannedbreak.StartTime   = Convert.ToDateTime(st).TimeOfDay;
            tblplannedbreak.EndTime     = Convert.ToDateTime(et).TimeOfDay;
            tblplannedbreak.BreakReason = br;
            {
                db.tblplannedbreaks.Add(tblplannedbreak);
                db.SaveChanges();
            }
            return(Json(tblplannedbreak.BreakID, JsonRequestBehavior.AllowGet));
        }
Beispiel #19
0
        public ActionResult Create(PlantModel tblp)
        {
            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();
            string plantName = tblp.Plant.PlantName.ToString();

            using (i_facility_shaktiEntities1 db = new i_facility_shaktiEntities1())
            {
                var doesThisPlantExist = db.tblplants.Where(m => m.IsDeleted == 0 && m.PlantName == plantName).ToList();
                if (doesThisPlantExist.Count == 0)
                {
                    tblp.Plant.CreatedBy = 1;
                    tblp.Plant.CreatedOn = DateTime.Now;
                    tblp.Plant.IsDeleted = 0;
                    db.tblplants.Add(tblp.Plant);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                else
                {
                    Session["Error"] = "Plant Name" + " " + tblp.Plant.PlantName + " already Exists.";
                    return(View(tblp));
                }
            }
        }
        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 ActionResult CreateShops(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();

            //shop name validation
            using (i_facility_shaktiEntities1 db = new i_facility_shaktiEntities1())
            {
                string shopname           = shop.Shops.ShopName.ToString();
                var    doesThisShopExists = db.tblshops.Where(m => m.IsDeleted == 0 && m.PlantID == shop.Shops.PlantID && m.ShopName == shopname).ToList();
                if (doesThisShopExists.Count == 0)
                {
                    shop.Shops.CreatedBy = 1;
                    shop.Shops.CreatedOn = DateTime.Now;
                    shop.Shops.IsDeleted = 0;
                    db.tblshops.Add(shop.Shops);
                    db.SaveChanges();
                }
                else
                {
                    ViewBag.PlantID  = new SelectList(db.tblplants.Where(m => m.IsDeleted == 0), "PlantID", "PlantName", shop.Shops.PlantID).ToList();
                    Session["Error"] = "Shop Name: " + shop.Shops.ShopName + " already exists for this Plant :" + db.tblplants.Where(m => m.PlantID == shop.Shops.PlantID && m.IsDeleted == 0).Select(m => m.PlantDisplayName).FirstOrDefault();
                    return(View(shop));
                }
                return(RedirectToAction("ShopList"));
            }
        }
        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);
        }
        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 ActionResult Create(ShiftMethodModel objtblshiftMethod)
        {
            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 var_shiftmethod = objtblshiftMethod.ShiftMethod.ShiftMethodName;

            using (i_facility_shaktiEntities1 condb = new i_facility_shaktiEntities1())
            {
                var does_shiftmethod_name_Exists = condb.tblshiftmethods.Where(m => m.IsDeleted == 0 && m.ShiftMethodName == var_shiftmethod).ToList();
                if (does_shiftmethod_name_Exists.Count == 0)
                {
                    objtblshiftMethod.ShiftMethod.CreatedBy = UserID;
                    objtblshiftMethod.ShiftMethod.IsDeleted = 0;
                    objtblshiftMethod.ShiftMethod.CreatedOn = DateTime.Now;
                    condb.tblshiftmethods.Add(objtblshiftMethod.ShiftMethod);
                    condb.SaveChanges();
                }
                else
                {
                    TempData["Error"] = "Shift Method Exists.";
                    return(View(objtblshiftMethod));
                }
                TempData["toaster_success"] = "Data Saved successfully";
                return(RedirectToAction("Index"));
            }
        }
        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 Create(tbluser tbluser)
        {
            if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
            {
                return(RedirectToAction("Login", "Login", null));
            }
            ViewBag.Logout = Session["Username"];
            ViewBag.roleid = Session["RoleID"];
            int    roleid   = Convert.ToInt32(Session["RoleID"]);
            String Username = Session["Username"].ToString();

            //ViewBag.PrimaryRole = new SelectList(db.tblroles.Where(m => m.IsDeleted == 0), "Role_ID", "RoleDesc");
            //ViewBag.SecondaryRole = new SelectList(db.tblroles.Where(m => m.IsDeleted == 0), "Role_ID", "RoleDesc");
            tbluser.CreatedBy = roleid;
            tbluser.CreatedOn = System.DateTime.Now;
            tbluser.IsDeleted = 0;
            ////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
            var dupUserData = db.tblusers.Where(m => m.IsDeleted == 0 && m.UserName == tbluser.UserName).ToList();

            if (dupUserData.Count == 0)
            {
                int primaryrole = Convert.ToInt32(tbluser.PrimaryRole);
                if (primaryrole != 3)
                {
                    // tbluser.MachineID =  ;
                }
                db.tblusers.Add(tbluser);
                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 ActionResult CreateMachine(MachineModel tblmachine, int dept = 0, int Plant = 0, int cell = 0, int Machnecategory = 0)
        {
            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 machinename    = tblmachine.Machine.MachineName;
            var    duplicateEntry = db.tblmachinedetails.Where(m => m.IsDeleted == 0 && m.PlantID == Plant && m.ShopID == dept && m.CellID == Machnecategory && m.MachineName == machinename).ToList();

            if (duplicateEntry.Count == 0)
            {
                tblmachine.Machine.InsertedBy = 1; //Convert.ToInt32(Session["UserId"]);
                var Datevar = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                tblmachine.Machine.InsertedOn        = Datevar.ToString();
                tblmachine.Machine.IsDeleted         = 0;
                tblmachine.Machine.ServerTabFlagSync = 0;
                tblmachine.Machine.ServerTabCheck    = 1;
                tblmachine.Machine.PlantID           = Plant;
                tblmachine.Machine.ShopID            = dept;
                tblmachine.Machine.CellID            = cell;
                //var shopname = db.tblshops.Where(m => m.IsDeleted == 0 && m.ShopID == Shop).Select(m => m.ShopName).FirstOrDefault();
                //tblmachine.ShopNo = shopname.ToString();

                //if (Cell != 0)
                //{
                //    tblmachine.CellID = Cell;
                //}

                db.tblmachinedetails.Add(tblmachine.Machine);
                db.SaveChanges();
            }
            else
            {
                Session["Error"]          = "Duplicate Machine Name";
                ViewBag.plant             = new SelectList(db.tblplants.Where(p => p.IsDeleted == 0), "PlantID", "PlantName", tblmachine.Machine.PlantID);
                ViewBag.dept              = new SelectList(db.tblshops.Where(d => d.IsDeleted == 0), "ShopId", "ShopName", tblmachine.Machine.ShopID);
                ViewBag.MachineCategoryID = new SelectList(db.tblcells.Where(m => m.IsDeleted == 0), "CellID", "CellName", tblmachine.Machine.CellID);
                return(View(tblmachine));
            }
            return(RedirectToAction("MachineList"));
        }
Beispiel #28
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 Create(TblPMSNotification_Master tee, int hdnSaveNContinue = 0)
        {
            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;
            int    Frequency   = Convert.ToInt32(tee.Frequency);
            string Unit        = tee.Unit;
            if (hdnSaveNContinue == 0)
            {
                tee.CreatedBy = UserID;
                tee.CreatedOn = DateTime.Now;
                tee.IsDeleted = 0;

                db.TblPMSNotification_Master.Add(tee);
                db.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }
        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));
            }
        }