public string InsertData(int channelnum, string memoryadd, int sid, string sensordesc, int countlow, int counthigh, int sensorlimithigh, int sensorlimitlow, int uid, int sdlid, int modeltype)
        {
            string res = "";
            //var doesThisExist = db.configurationtblsensormasters.Where(m => m.IsDeleted == 0 && m.ChannelNo == channelnum && m.MemoryAddress == memoryadd && m.Sid == sid && m.SensorDesc == sensordesc && m.CountLow == countlow && m.CountHigh == counthigh  && m.sensorlimitLow == sensorlimitlow && m.sensorlimitHigh == sensorlimithigh && m.IsAnalog == modeltype).ToList();
            //if (doesThisExist.Count == 0)
            //{

            configurationtblsensormaster tblpc = new configurationtblsensormaster();

            tblpc.CreatedBy       = 1;
            tblpc.CreatedOn       = DateTime.Now;
            tblpc.IsDeleted       = 0;
            tblpc.ChannelNo       = channelnum;
            tblpc.MemoryAddress   = Convert.ToInt32(memoryadd);
            tblpc.Sid             = sid;
            tblpc.SensorDesc      = sensordesc;
            tblpc.Unitid          = uid;
            tblpc.CountLow        = countlow;
            tblpc.IsAnalog        = modeltype;
            tblpc.CountHigh       = counthigh;
            tblpc.sensorlimitHigh = sensorlimithigh;
            tblpc.sensorlimitLow  = sensorlimitlow;
            tblpc.parametertypeid = sdlid;
            db.configurationtblsensormasters.Add(tblpc);
            db.SaveChanges();
            res = "success";
            // }
            //else
            //{
            //    TempData["Message"] = "Sensor Name already Exists";
            //    res = "failure";
            //    return res;
            //}
            return(res);
        }
        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);
        }
        public ActionResult EditSensorMaster(int id)
        {
            if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
            {
                return(RedirectToAction("Login", "Login", null));
            }
            ViewBag.Logout = Session["Username"].ToString().ToUpper();
            ViewBag.roleid = Session["RoleID"];
            String Username = Session["Username"].ToString();

            using (i_facility_shaktiEntities1 db = new i_facility_shaktiEntities1())
            {
                configurationtblsensormaster tblmc = db.configurationtblsensormasters.Find(id);
                if (tblmc == null)
                {
                    return(HttpNotFound());
                }
                ViewBag.Unit            = new SelectList(db.tblunits.Where(m => m.IsDeleted == 0), "U_id", "Unit", tblmc.Unitid).ToList();
                ViewBag.SensorGroupName = new SelectList(db.configuration_tblsensorgroup.ToList().Where(m => m.IsDeleted == 0), "SID", "SensorGroupName", tblmc.Sid).ToList();
                ViewBag.SensorDataLink  = new SelectList(db.configurationtblsensordatalinks.Where(m => m.IsDeleted == 0 && m.IsSensor == 1), "ParameterTypeID", "parametername", tblmc.parametertypeid).ToList();
                SensorMaster sd = new SensorMaster();
                sd.sensormaster = tblmc;
                return(View(sd));
            }
        }
        // GET: SensorMaster
        public ActionResult Index()
        {
            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();
            SensorMaster pa                 = new SensorMaster();
            configurationtblsensormaster mp = new configurationtblsensormaster();

            pa.sensormaster     = mp;
            pa.sensormasterList = db.configurationtblsensormasters.Where(m => m.IsDeleted == 0).ToList();
            return(View(pa));
        }