public ActionResult Edit(int id) { try { DT_WebGISEntities MyContext = new DT_WebGISEntities(); CMS_Categories_DAO objDAO = new CMS_Categories_DAO(); var Partial = objDAO.GetCategoriesByID(id); List <SubSelectBox> listTree = new List <SubSelectBox>(); SubSelectBox sc; var listData = MyContext.CMS_Categories.ToList(); var listData0 = listData.Where(x => x.PARENTCATE == 0).OrderBy(x => x.ORDERS).ToList(); string tag = ""; foreach (var item in listData0) { sc = new SubSelectBox(); sc.id = item.ID; sc.name = item.NAME; listTree.Add(sc); BuildSubTree(listTree, item.ID, listData, tag); } TempData["PARENTCATE"] = listTree; TempData.Keep("PARENTCATE"); return(View(Partial)); } catch (Exception ex) { SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error); Logs.WriteLog(ex); return(View()); } }
public JsonResult GetParentID() { try { DT_WebGISEntities MyContext = new DT_WebGISEntities(); List <SubSelectBox> listTree = new List <SubSelectBox>(); SubSelectBox sc; var listData = MyContext.CMS_Organization.ToList(); var listData0 = listData.Where(x => x.ParentID == 0).ToList(); string tag = ""; foreach (var item in listData0) { sc = new SubSelectBox(); sc.id = item.ID; sc.name = item.Name; listTree.Add(sc); BuildSubTree(listTree, item.ID, listData, tag); } var jsonResults = new { listTree, state = true }; return(Json(jsonResults, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { state = false, message = ex }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Create() { try { CMS_News_DAO objDAO = new CMS_News_DAO(); DT_WebGISEntities MVCContext = new DT_WebGISEntities(); //var listData = MVCContext.CMS_Categories.Where(x => x.PUBLISH == true).AsQueryable().Select(new x SubSelectBox { }).ToList(); List <SubSelectBox> listTree = new List <SubSelectBox>(); SubSelectBox sc; var listData = (from a in MVCContext.CMS_Categories where a.PUBLISH == true select new SubSelectBox() { id = a.ID, name = a.NAME, parentid = (int)a.PARENTCATE }).ToList(); var listData0 = listData.Where(x => x.parentid == 0).ToList(); string tag = ""; foreach (var item in listData0) { sc = new SubSelectBox(); sc.id = item.id; sc.name = item.name; listTree.Add(sc); BuildSubTree(listTree, item.id, listData, tag); } TempData["categories"] = listTree; TempData.Keep("categories"); return(View()); } catch (Exception ex) { SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error); Logs.WriteLog(ex); return(View()); } }
public ActionResult Edit(int id) { try { CMS_Organization_DAO objDAO = new CMS_Organization_DAO(); var Partial = objDAO.GetOrganizationByID(id); DT_WebGISEntities MyContext = new DT_WebGISEntities(); List <SubSelectBox> listTree = new List <SubSelectBox>(); SubSelectBox sc; var listData = MyContext.CMS_Organization.ToList(); var listData0 = listData.Where(x => x.ParentID == 0).ToList(); string tag = ""; foreach (var item in listData0) { sc = new SubSelectBox(); sc.id = item.ID; sc.name = item.Name; listTree.Add(sc); BuildSubTree(listTree, item.ID, listData, tag); } TempData["Organization"] = listTree; TempData.Keep("Organization"); return(View(Partial)); } catch (Exception ex) { SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error); Logs.WriteLog(ex); return(View()); } }
public JsonResult GetPageParent(string isadmin) { try { DT_WebGISEntities MyContext = new DT_WebGISEntities(); bool IsAdmin = isadmin == "true" ? true : false; List <SubSelectBox> listTree = new List <SubSelectBox>(); SubSelectBox sc; //var listData = MyContext.CSF_Pages.Where(x => x.IsAdmin == IsAdmin).ToList(); var listData = MyContext.CSF_Pages .Join(MyContext.CSF_Modules, pg => pg.ModuleID, md => md.ID, (pg, md) => new { CSF_Pages = pg, CSF_Modules = md }) .Where(md => md.CSF_Modules.IsActive == true) .Select(mdp => mdp.CSF_Pages) .Where(x => x.IsAdmin == IsAdmin).ToList(); var listData0 = listData.Where(x => x.ParentID == 0).OrderBy(x => x.Order).ToList(); string tag = ""; foreach (var item in listData0) { sc = new SubSelectBox(); sc.id = item.ID; sc.name = item.Name; listTree.Add(sc); BuildSubTree(listTree, item.ID, listData, tag); } var jsonResults = new { listTree, state = true }; return(Json(jsonResults, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { state = false, message = ex }, JsonRequestBehavior.AllowGet)); } }
protected void SetTempData2SelectList(int moduleid, int pageid, bool IsAdmin) { DT_WebGISEntities MyContext = new DT_WebGISEntities(); var listModules = MyContext.CSF_Modules; TempData["module"] = new SelectList(listModules, "ID", "Name", moduleid); TempData.Keep("module"); List <SubSelectBox> listTree = new List <SubSelectBox>(); SubSelectBox sc; //var listData = MyContext.CSF_Pages.Where(x => x.IsAdmin == IsAdmin).ToList(); var listData = MyContext.CSF_Pages .Join(MyContext.CSF_Modules, pg => pg.ModuleID, md => md.ID, (pg, md) => new { CSF_Pages = pg, CSF_Modules = md }) .Where(md => md.CSF_Modules.IsActive == false) .Select(mdp => mdp.CSF_Pages) .Where(x => x.IsAdmin == IsAdmin).ToList(); var listData0 = listData.Where(x => x.ParentID == 0).OrderBy(x => x.Order).ToList(); string tag = ""; foreach (var item in listData0) { sc = new SubSelectBox(); sc.id = item.ID; sc.name = item.Name; listTree.Add(sc); BuildSubTree(listTree, item.ID, listData, tag); } TempData["page"] = listTree; TempData.Keep("page"); }
public JsonResult GetPageParent(string isadmin) { try { CSF_MVCEntities MyContext = new CSF_MVCEntities(); bool IsAdmin = isadmin == "true" ? true : false; List <SubSelectBox> listTree = new List <SubSelectBox>(); SubSelectBox sc; var listData = MyContext.CSF_Pages.Where(x => x.IsAdmin == IsAdmin).ToList(); var listData0 = listData.Where(x => x.ParentID == 0).OrderBy(x => x.Order).ToList(); string tag = ""; foreach (var item in listData0) { sc = new SubSelectBox(); sc.id = item.ID; sc.name = item.Name; listTree.Add(sc); BuildSubTree(listTree, item.ID, listData, tag); } var jsonResults = new { listTree, state = true }; return(Json(jsonResults, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { state = false, message = ex }, JsonRequestBehavior.AllowGet)); } }
public JsonResult GetPARENTCATE() { try { CSF_MVCEntities MyContext = new CSF_MVCEntities(); List <SubSelectBox> listTree = new List <SubSelectBox>(); SubSelectBox sc; var listData = MyContext.CMS_Categories.ToList(); var listData0 = listData.Where(x => x.PARENTCATE == 0).OrderBy(x => x.ORDERS).ToList(); string tag = ""; foreach (var item in listData0) { sc = new SubSelectBox(); sc.id = item.ID; sc.name = item.NAME; listTree.Add(sc); BuildSubTree(listTree, item.ID, listData, tag); } var jsonResults = new { listTree, state = true }; return(Json(jsonResults, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { state = false, message = ex }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Create() { try { //if (!this.HasPermission) return RedirectToAction("Unauthorized", "Home"); TempData["listController"] = GetControllerNames(); TempData.Keep("listController"); DT_WebGISEntities MyContext = new DT_WebGISEntities(); List <SubSelectBox> listTree = new List <SubSelectBox>(); SubSelectBox sc; var listData = MyContext.CSF_Functions .Join(MyContext.CSF_Modules, fc => fc.ModuleID, md => md.ID, (fc, md) => new { CSF_Functions = fc, CSF_Modules = md }) .Where(md => md.CSF_Modules.IsActive == true) .Select(mdp => mdp.CSF_Functions).ToList(); var listData0 = listData.Where(x => x.ParentID == 0).OrderBy(x => x.Name).ToList(); string tag = ""; foreach (var item in listData0) { sc = new SubSelectBox(); sc.id = item.ID; sc.name = item.Name; listTree.Add(sc); BuildSubTree(listTree, item.ID, listData, tag); } TempData["functions"] = listTree.ToList(); TempData.Keep("functions"); CSF_Modules_DAO objModulesDAO = new CSF_Modules_DAO(); var modules = objModulesDAO.GetAll(); TempData["modules"] = modules.ToList(); TempData.Keep("modules"); //ParentFunctionDropDownList(); ModulesDropDownList(); return(View()); } catch (Exception ex) { SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error); Logs.WriteLog(ex); return(View()); } }
public JsonResult GetDataPageSetup(string pageid) { try { DT_WebGISEntities ett = new DT_WebGISEntities(); var modules = from a in ett.CSF_Modules where a.IsActive == false select new { a.ID, a.Name }; int PAGEID = Convert.ToInt32(pageid); CSF_Pages_DAO dao = new CSF_Pages_DAO(); List <CSF_Pages_GetPartial_Result> lData = dao.GetPartialByPageID(PAGEID, -1); var lDataBox = (from a in lData where a.IsBox == true select new { a.ID, a.Title }).ToList(); List <PagePartialBox> listPPB = new List <PagePartialBox>(); PagePartialBox ppb; foreach (var item in lData.Where(x => x.IsBox == true)) { ppb = new PagePartialBox(); ppb.box = item; ppb.boxChild = lData.Where(x => x.BoxParent == item.ID).ToList(); listPPB.Add(ppb); } //get list all page to copy //var listPage = (from a in ett.CSF_Pages where a.IsActive == true && a.IsAdmin == false orderby a.Name select new { a.ID, a.Name }).ToList(); List <SubSelectBox> listPage = new List <SubSelectBox>(); SubSelectBox sc; var listData = ett.CSF_Pages.Where(x => x.IsAdmin == false).ToList(); var listData0 = listData.Where(x => x.ParentID == 0).OrderBy(x => x.Order).ToList(); string tag = ""; foreach (var item in listData0) { sc = new SubSelectBox(); sc.id = item.ID; sc.name = item.Name; listPage.Add(sc); BuildSubTree(listPage, item.ID, listData, tag); } var jsonResults = new { modules, lData, lDataBox, listPPB, listPage, state = true }; return(Json(jsonResults, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { state = false, message = ex }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Edit(int id) { try { ViewBag.URLIMAGE = System.Configuration.ConfigurationManager.AppSettings["UrlImage"]; DT_WebGISEntities entity = new DT_WebGISEntities(); TempData["TypeOfDocumentID"] = entity.CMS_TypeOfDocument.ToList(); TempData.Keep("TypeOfDocumentID"); TempData["AreaOfDocument"] = entity.CMS_AreaOfDocument.ToList(); TempData.Keep("AreaOfDocument"); TempData["OrganizationID"] = entity.CMS_Organization.ToList(); TempData.Keep("OrganizationID"); DT_WebGISEntities MyContext = new DT_WebGISEntities(); List <SubSelectBox> listTree = new List <SubSelectBox>(); SubSelectBox sc; var listData = MyContext.CMS_Organization.ToList(); var listData0 = listData.Where(x => x.ParentID == 0).ToList(); string tag = ""; foreach (var item in listData0) { sc = new SubSelectBox(); sc.id = item.ID; sc.name = item.Name; listTree.Add(sc); BuildSubTree(listTree, item.ID, listData, tag); } TempData["Organization"] = listTree; TempData.Keep("Organization"); var doc = entity.CMS_Documents.Find(id); if (doc != null) { return(View(doc)); } return(View()); } catch (Exception ex) { SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error); Logs.WriteLog(ex); return(View()); } }
public PartialViewResult TimKiem(string title, string category, string key, string type, int?page) { try { ViewBag.TITLE = title; ViewBag.CATE = category; int typeID = type != null?Convert.ToInt32(type) : 0; key = key != null ? key : ""; CMS_News_DAO objDAO = new CMS_News_DAO(); var data = objDAO.Search(key, typeID, 5); int pageSize = 10; int pageNumber = (page ?? 1); DT_WebGISEntities MyContext = new DT_WebGISEntities(); var listData = MyContext.CMS_Categories.Where(x => x.PUBLISH == true).ToList(); List <SubSelectBox> listCate = new List <SubSelectBox>(); SubSelectBox sc; var listData0 = listData.Where(x => x.PARENTCATE == 0).OrderBy(x => x.ORDERS); string tag = ""; foreach (var item in listData0) { sc = new SubSelectBox(); sc.id = item.ID; sc.name = item.NAME; listCate.Add(sc); BuildSubCate(listCate, item.ID, listData, tag); } TempData["category"] = listCate; TempData.Keep("category"); ViewBag.KEY = key; ViewBag.TYPE = typeID; return(PartialView(data.ToPagedList(pageNumber, pageSize))); } catch (Exception ex) { Logs.WriteLog(ex); return(PartialView()); } }
public ActionResult Edit(int id) { try { ViewBag.URLIMAGE = System.Configuration.ConfigurationManager.AppSettings["UrlImage"]; DT_WebGISEntities entity = new DT_WebGISEntities(); List <SubSelectBox> listTree = new List <SubSelectBox>(); SubSelectBox sc; var listData = (from a in entity.CMS_Categories where a.PUBLISH == true select new SubSelectBox() { id = a.ID, name = a.NAME, parentid = (int)a.PARENTCATE }).ToList(); var listData0 = listData.Where(x => x.parentid == 0).ToList(); string tag = ""; foreach (var item in listData0) { sc = new SubSelectBox(); sc.id = item.id; sc.name = item.name; listTree.Add(sc); BuildSubTree(listTree, item.id, listData, tag); } TempData["categories"] = listTree; TempData.Keep("categories"); var news = entity.CMS_News.Find(id); if (news != null && (news.ID_NEWS_STATUS == 1 || news.ID_NEWS_STATUS == 6 || news.ID_NEWS_STATUS == 3)) { return(View(news)); } return(RedirectToAction("Index", "CMS_News")); } catch (Exception ex) { SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error); Logs.WriteLog(ex); return(View()); } }
public void BuildSubTree(List <SubSelectBox> listTree, int ParentID, List <CMS_Organization> listData, string tag) { try { SubSelectBox sc; var listChild = listData.Where(x => x.ParentID == ParentID); if (listChild != null && listChild.Count() > 0) { tag += "--- "; foreach (var item in listChild) { sc = new SubSelectBox(); sc.id = item.ID; sc.name = tag + item.Name; listTree.Add(sc); BuildSubTree(listTree, item.ID, listData, tag); } } } catch (Exception ex) { throw ex; } }
public void BuildSubCate(List <SubSelectBox> listCate, int ParentID, List <CMS_Categories> listData, string tag) { try { SubSelectBox sc; var listChild = listData.Where(x => x.PARENTCATE == ParentID); if (listChild != null && listChild.Count() > 0) { tag += "--- "; foreach (var item in listChild) { sc = new SubSelectBox(); sc.id = item.ID; sc.name = tag + item.NAME; listCate.Add(sc); BuildSubCate(listCate, item.ID, listData, tag); } } } catch (Exception ex) { throw ex; } }
protected void SetTempData2SelectList(int moduleid, int pageid, bool IsAdmin) { CSF_MVCEntities MyContext = new CSF_MVCEntities(); var listModules = MyContext.CSF_Modules; TempData["module"] = new SelectList(listModules, "ID", "Name", moduleid); TempData.Keep("module"); List <SubSelectBox> listTree = new List <SubSelectBox>(); SubSelectBox sc; var listData = MyContext.CSF_Pages.Where(x => x.IsAdmin == IsAdmin).ToList(); var listData0 = listData.Where(x => x.ParentID == 0).OrderBy(x => x.Order).ToList(); string tag = ""; foreach (var item in listData0) { sc = new SubSelectBox(); sc.id = item.ID; sc.name = item.Name; listTree.Add(sc); BuildSubTree(listTree, item.ID, listData, tag); } TempData["page"] = listTree; TempData.Keep("page"); }