// GET: Layouts/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DevLayout devLayout = db.DevLayout.Find(id); List <LayoutSettings> set = db.LayoutSettings.Where(sl => sl.ltSDevLayoutId == devLayout.dvLtAutoId).ToList(); string res = ""; if (set.Count > 0) { for (int i = 0; i < set.Count; i++) { res += "id:" + (i + 2) + ";type:" + set[i].ltSType + ";" + set[i].ItSPosition + "dbid:" + set[i].ItSdbid; //res = res.Remove(res.Length - 1, 1); res += "#"; } } ViewLayout veilout = new ViewLayout { Devlayout = devLayout, result = res }; if (devLayout == null) { return(HttpNotFound()); } return(View(veilout)); }
public ActionResult DeleteConfirmed(int id) { DevLayout devLayout = db.DevLayout.Find(id); db.DevLayout.Remove(devLayout); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "dvLtAutoId,dvLtName,dvLtVersion,dvLtDescription,dvLtLastUpdate")] DevLayout devLayout) { if (ModelState.IsValid) { devLayout.dvLtLastUpdate = DateTime.Now.ToString(); devLayout.dvLtVersion = (Convert.ToInt32(devLayout.dvLtVersion) + 1).ToString(); db.Entry(devLayout).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(devLayout)); }
// GET: Layouts/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DevLayout devLayout = db.DevLayout.Find(id); if (devLayout == null) { return(HttpNotFound()); } return(View(devLayout)); }
public ActionResult Settings(int id, ViewLayoutSettings LayoutSetting) { DevLayout getDevlayout = db.DevLayout.Find(id); getDevlayout.dvLtVersion = (Convert.ToInt32(getDevlayout.dvLtVersion) + 1).ToString(); db.SaveChanges(); if (LayoutSetting.LayoutSettingsList != null) { for (int i = 0; i < LayoutSetting.LayoutSettingsList.Count; i++) { LayoutSettings data = db.LayoutSettings.Find(LayoutSetting.LayoutSettingsList[i].ltSId); data.ltSContent = LayoutSetting.LayoutSettingsList[i].ltSContent; db.SaveChanges(); } } return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { List <LayoutSettings> getloutseting = db.LayoutSettings.Where(x => x.ltSDevLayoutId == id).ToList(); if (getloutseting.Count > 0) { foreach (var data in getloutseting) { db.LayoutSettings.Remove(data); db.SaveChanges(); } } DevLayout devLayout = db.DevLayout.Find(id); db.DevLayout.Remove(devLayout); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(int?id, ViewLayout ViewdevLayout) { if (id != null) { List <LayoutSettings> getloutseting = db.LayoutSettings.Where(x => x.ltSDevLayoutId == id.Value).ToList(); DevLayout getDevlayout = db.DevLayout.Find(id.Value); if (getDevlayout != null) { /*foreach (var data in getloutseting) * { * db.LayoutSettings.Attach(data); * db.LayoutSettings.Remove(data); * db.SaveChanges(); * }*/ getDevlayout.dvLtLastUpdate = DateTime.Now.ToString(); db.SaveChanges(); string[] sett = ViewdevLayout.result.Split('#'); foreach (string s in sett) { if (s != "") { string[] data = s.Split(';'); string[] getguid = data[6].Split(':'); string guid = getguid[1]; LayoutSettings layouteset = db.LayoutSettings.Where(x => x.ItSdbid == guid).SingleOrDefault(); if (layouteset == null) { layouteset = new LayoutSettings(); } else { layouteset.ItSPosition = ""; } if (layouteset == null) { layouteset = new LayoutSettings(); } foreach (string v in data) { string[] val = v.Split(':'); if (val[0] == "type") { layouteset.ltSType = val[1]; } else if (val[0] == "left") { layouteset.ItSPosition += val[0] + ":" + val[1] + ";"; } else if (val[0] == "top") { layouteset.ItSPosition += val[0] + ":" + val[1] + ";"; } else if (val[0] == "width") { layouteset.ItSPosition += val[0] + ":" + val[1] + ";"; } else if (val[0] == "height") { layouteset.ItSPosition += val[0] + ":" + val[1] + ";"; } } layouteset.ltSDevLayoutId = getDevlayout.dvLtAutoId; if (layouteset.ItSdbid == null) { layouteset.ItSdbid = Guid.NewGuid().ToString(); db.LayoutSettings.Add(layouteset); } var getset = getloutseting.Where(x => x.ItSdbid == layouteset.ItSdbid).SingleOrDefault(); if (getset != null) { getloutseting.Remove(getset); } db.SaveChanges(); } } foreach (var data in getloutseting) { db.LayoutSettings.Attach(data); db.LayoutSettings.Remove(data); db.SaveChanges(); } string subPath = getDevlayout.dvLtAutoId.ToString(); Directory.CreateDirectory(Server.MapPath("~/files/" + subPath)); return(RedirectToAction("Settings", new { id = getDevlayout.dvLtAutoId })); //if (getDevlayout.dvLtType == 1) //{ // if (ViewdevLayout.result != null) // { // string[] sett = ViewdevLayout.result.Split('#'); // foreach (string s in sett) // { // if (s != "") // { // //LayoutSettings layouteset = new LayoutSettings(); // string[] data = s.Split(';'); // string[] getguid = data[6].Split(':'); // string guid = getguid[1]; // LayoutSettings layouteset = db.LayoutSettings.Where(x => x.ItSdbid == guid).SingleOrDefault(); // if (layouteset == null) // { // layouteset = new LayoutSettings(); // } // else // { // layouteset.ItSPosition = ""; // } // foreach (string v in data) // { // string[] val = v.Split(':'); // if (val[0] == "type") // layouteset.ltSType = val[1]; // else if (val[0] == "left") // layouteset.ItSPosition += val[0] + ":" + val[1] + ";"; // else if (val[0] == "top") // layouteset.ItSPosition += val[0] + ":" + val[1] + ";"; // else if (val[0] == "width") // layouteset.ItSPosition += val[0] + ":" + val[1] + ";"; // else if (val[0] == "height") // layouteset.ItSPosition += val[0] + ":" + val[1] + ";"; // } // layouteset.ltSDevLayoutId = getDevlayout.dvLtAutoId; // if (layouteset.ItSdbid == null) // { // layouteset.ItSdbid = Guid.NewGuid().ToString(); // db.LayoutSettings.Add(layouteset); // } // var getset = getloutseting.Where(x => x.ItSdbid == layouteset.ItSdbid).SingleOrDefault(); // if (getset != null) // { // getloutseting.Remove(getset); // } // db.SaveChanges(); // } // } // string subPath = getDevlayout.dvLtAutoId.ToString(); // Directory.CreateDirectory(Server.MapPath("~/files/" + subPath)); // } // DeviceIO addnew; // for (int i = 0; i < ViewdevLayout.inputCount; i++) // { // addnew = new DeviceIO // { // ioType = "1", // ioDeviceId = ViewdevLayout.Devlayout.dvLtAutoId, // ioValType = "bit" // }; // db.DeviceIO.Add(addnew); // } // for (int i = 0; i < ViewdevLayout.outputCount; i++) // { // addnew = new DeviceIO // { // ioType = "2", // ioDeviceId = ViewdevLayout.Devlayout.dvLtAutoId, // ioValType = "bit" // }; // db.DeviceIO.Add(addnew); // } // for (int i = 0; i < ViewdevLayout.virtualCount; i++) // { // addnew = new DeviceIO // { // ioType = "3", // ioDeviceId = ViewdevLayout.Devlayout.dvLtAutoId, // ioValType = "string" // }; // db.DeviceIO.Add(addnew); // } // db.SaveChanges(); // foreach (var data in getloutseting) // { // db.LayoutSettings.Attach(data); // db.LayoutSettings.Remove(data); // db.SaveChanges(); // } // return RedirectToAction("Settings", new { id = getDevlayout.dvLtAutoId }); //} //else if (getDevlayout.dvLtType == 2) //{ // string[] sett = ViewdevLayout.result.Split('#'); // foreach (string s in sett) // { // if (s != "") // { // string[] data = s.Split(';'); // string[] getguid = data[6].Split(':'); // string guid = getguid[1]; // LayoutSettings layouteset = db.LayoutSettings.Where(x => x.ItSdbid == guid).SingleOrDefault(); // if (layouteset == null) // { // layouteset = new LayoutSettings(); // } // else // { // layouteset.ItSPosition = ""; // } // if (layouteset == null) // { // layouteset = new LayoutSettings(); // } // foreach (string v in data) // { // string[] val = v.Split(':'); // if (val[0] == "type") // layouteset.ltSType = val[1]; // else if (val[0] == "left") // layouteset.ItSPosition += val[0] + ":" + val[1] + ";"; // else if (val[0] == "top") // layouteset.ItSPosition += val[0] + ":" + val[1] + ";"; // else if (val[0] == "width") // layouteset.ItSPosition += val[0] + ":" + val[1] + ";"; // else if (val[0] == "height") // layouteset.ItSPosition += val[0] + ":" + val[1] + ";"; // } // layouteset.ltSDevLayoutId = getDevlayout.dvLtAutoId; // if (layouteset.ItSdbid == null) // { // layouteset.ItSdbid = Guid.NewGuid().ToString(); // db.LayoutSettings.Add(layouteset); // } // var getset = getloutseting.Where(x => x.ItSdbid == layouteset.ItSdbid).SingleOrDefault(); // if (getset != null) // { // getloutseting.Remove(getset); // } // db.SaveChanges(); // } // } // foreach (var data in getloutseting) // { // db.LayoutSettings.Attach(data); // db.LayoutSettings.Remove(data); // db.SaveChanges(); // } // string subPath = getDevlayout.dvLtAutoId.ToString(); // System.IO.Directory.CreateDirectory(Server.MapPath("~/files/" + subPath)); // return RedirectToAction("Settings", new { id = getDevlayout.dvLtAutoId }); //} //else if (getDevlayout.dvLtType == 3) //{ // //db.DevLayout.Add(ViewdevLayout.Devlayout); // //db.SaveChanges(); // DeviceIO addnew; // for (int i = 0; i < ViewdevLayout.inputCount; i++) // { // addnew = new DeviceIO // { // ioType = "1", // ioDeviceId = ViewdevLayout.Devlayout.dvLtAutoId, // ioValType = "bit" // }; // db.DeviceIO.Add(addnew); // } // for (int i = 0; i < ViewdevLayout.outputCount; i++) // { // addnew = new DeviceIO // { // ioType = "2", // ioDeviceId = ViewdevLayout.Devlayout.dvLtAutoId, // ioValType = "bit" // }; // db.DeviceIO.Add(addnew); // } // for (int i = 0; i < ViewdevLayout.virtualCount; i++) // { // addnew = new DeviceIO // { // ioType = "3", // ioDeviceId = getDevlayout.dvLtAutoId, // ioValType = "string" // }; // db.DeviceIO.Add(addnew); // } // db.SaveChanges(); // foreach (var data in getloutseting) // { // db.LayoutSettings.Attach(data); // db.LayoutSettings.Remove(data); // db.SaveChanges(); // } // return RedirectToAction("Settings", new { id = getDevlayout.dvLtAutoId }); //} } } return(View()); /*if (ModelState.IsValid) * { * devLayout.Devlayout.dvLtLastUpdate = DateTime.Now.ToString(); * devLayout.Devlayout.dvLtVersion = (Convert.ToInt32(devLayout.Devlayout.dvLtVersion) + 1).ToString(); * * db.Entry(devLayout).State = EntityState.Modified; * db.SaveChanges(); * return RedirectToAction("Index"); * } * return View(devLayout);*/ }