public int CreateSYS_PageLayoutGet(SYS_PageLayout sys_PageLayout) { int i = 0; using (SqlConnection connection = GetConnection()) { SqlCommand command = new SqlCommand("_SYS_PageLayoutInsert", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@Type", 0); command.Parameters.AddWithValue("@Id", 0); command.Parameters.AddWithValue("@PageName", sys_PageLayout.PageName); command.Parameters.AddWithValue("@SlugPageName", sys_PageLayout.SlugPageName); command.Parameters.AddWithValue("@TemplateId", sys_PageLayout.TemplateId); command.Parameters.AddWithValue("@Orders", sys_PageLayout.Orders); command.Parameters.AddWithValue("@Language", sys_PageLayout.Language); SqlParameter parameter = new SqlParameter("@ReturnId", SqlDbType.Int); parameter.Direction = ParameterDirection.ReturnValue; command.Parameters.Add(parameter); connection.Open(); if (command.ExecuteNonQuery() <= 0) { throw new DataAccessException("Khong them duoc"); } else { i = (int)parameter.Value; command.Dispose(); } } return(i); }
private SYS_PageLayout SYS_PageLayoutReader(SqlDataReader reader) { SYS_PageLayout sys_PageLayout = new SYS_PageLayout(); sys_PageLayout.Id = (int)reader["Id"]; sys_PageLayout.PageName = (string)reader["PageName"]; sys_PageLayout.SlugPageName = (string)reader["SlugPageName"]; sys_PageLayout.TemplateId = (int)reader["TemplateId"]; sys_PageLayout.Orders = (int)reader["Orders"]; sys_PageLayout.Language = (string)reader["Language"]; return(sys_PageLayout); }
private void GetRegion() { List <ControlData> _list = new List <ControlData>(); try { int PageLayoutId = TypeHelper.ToInt32(ddlPageLayout.SelectedValue); SYS_PageLayoutBSO _pageLayoutBSO = new SYS_PageLayoutBSO(); SYS_PageLayout _pageLayout = _pageLayoutBSO.GetSYS_PageLayoutById(PageLayoutId); SYS_TemplatePageBSO _templateBSO = new SYS_TemplatePageBSO(); SYS_TemplatePage _template = _templateBSO.GetSYS_TemplatePageById(_pageLayout.TemplateId); Control objControl = (Control)this.LoadControl(ResolveUrl("~/") + "Client/Skins/Templates/" + _template.TemplateControl); ControlCollection _controls = objControl.Controls; foreach (Control obj1 in _controls) { Type objType = obj1.GetType(); if (obj1 != null) { if (obj1.ID != null) { ControlData objData = new ControlData(); objData.Control = obj1.ID; if (obj1 != null) { objData.Text = obj1.ID; _list.Add(objData); } } } } ddlRegion.Items.Clear(); ddlRegion.DataSource = _list; ddlRegion.DataTextField = "Text"; ddlRegion.DataValueField = "Control"; ddlRegion.DataBind(); } catch { ddlRegion.Items.Clear(); ddlRegion.DataSource = _list; ddlRegion.DataTextField = "Text"; ddlRegion.DataValueField = "Control"; ddlRegion.DataBind(); } }
public static string LoadMasterPage(string urlRoot, string strSlugPage, HttpRequest request, Page pageContainer, PlaceHolder placeHolderMainContent, string lang) { //IList<SYS_PageLayout> list = new List<SYS_PageLayout>(); string strMaster = "MasterPage.master"; if (strSlugPage != string.Empty) { SYS_PageLayoutBSO _pageLayoutBSO = new SYS_PageLayoutBSO(); SYS_PageLayout _pageLayout = new SYS_PageLayout(); if (!AspNetCache.CheckCache("PageLayout_" + strSlugPage + "_" + lang.Replace("-", "_"))) { _pageLayout = _pageLayoutBSO.GetSYS_PageLayoutBySlug(strSlugPage, lang); if (_pageLayout == null) { _pageLayout = _pageLayoutBSO.GetSYS_PageLayoutBySlug("home", lang); } AspNetCache.SetCache("PageLayout_" + strSlugPage + "_" + lang.Replace("-", "_"), _pageLayout); } else { _pageLayout = (SYS_PageLayout)AspNetCache.GetCache("PageLayout_" + strSlugPage + "_" + lang.Replace("-", "_")); } if (_pageLayout != null) { SYS_TemplatePageBSO _templateBSO = new SYS_TemplatePageBSO(); SYS_TemplatePage _template = new SYS_TemplatePage(); if (!AspNetCache.CheckCache("Template_" + _pageLayout.TemplateId)) { _template = _templateBSO.GetSYS_TemplatePageById(_pageLayout.TemplateId); AspNetCache.SetCache("Template_" + _pageLayout.TemplateId, _template); } else { _template = (SYS_TemplatePage)AspNetCache.GetCache("Template_" + _pageLayout.TemplateId); } if (_template != null) { strMaster = _template.MasterControl; } } } return(strMaster); }
public static void AddWidgetPage(string urlRoot, string strSlugPage, HttpRequest request, Page pageContainer, PlaceHolder placeHolderMainContent) { //IList<SYS_PageLayout> list = new List<SYS_PageLayout>(); if (strSlugPage != string.Empty) { SYS_PageLayoutBSO _pageLayoutBSO = new SYS_PageLayoutBSO(); SYS_PageLayout _pageLayout = new SYS_PageLayout(); if (!AspNetCache.CheckCache("PageLayout_" + strSlugPage + "_" + Language.language.Replace("-", "_"))) { _pageLayout = _pageLayoutBSO.GetSYS_PageLayoutBySlug(strSlugPage, Language.language); if (_pageLayout == null) { _pageLayout = _pageLayoutBSO.GetSYS_PageLayoutBySlug("home", Language.language); } AspNetCache.SetCache("PageLayout_" + strSlugPage + "_" + Language.language.Replace("-", "_"), _pageLayout); } else { _pageLayout = (SYS_PageLayout)AspNetCache.GetCache("PageLayout_" + strSlugPage + "_" + Language.language.Replace("-", "_")); } if (_pageLayout != null) { SYS_TemplatePageBSO _templateBSO = new SYS_TemplatePageBSO(); SYS_TemplatePage _template = new SYS_TemplatePage(); if (!AspNetCache.CheckCache("Template_" + _pageLayout.TemplateId)) { _template = _templateBSO.GetSYS_TemplatePageById(_pageLayout.TemplateId); AspNetCache.SetCache("Template_" + _pageLayout.TemplateId, _template); } else { _template = (SYS_TemplatePage)AspNetCache.GetCache("Template_" + _pageLayout.TemplateId); } if (_template != null) { string _path = urlRoot + "Client/Skins/Templates/" + _template.TemplateControl; Control objControl = (Control)pageContainer.LoadControl(_path); placeHolderMainContent.Controls.Add(objControl); AddWidgetPageLayout(objControl, _pageLayout.Id, urlRoot, pageContainer); } } } }
private SYS_PageLayout ReceiveHtml() { SYS_PageLayout _pageLayout = new SYS_PageLayout(); _pageLayout.Id = (hddID.Value != "") ? Convert.ToInt32(hddID.Value) : 0; _pageLayout.PageName = txtName.Text; _pageLayout.SlugPageName = txtSlug.Text; _pageLayout.Orders = (txtOrder.Text != "") ? Convert.ToInt32(txtOrder.Text) : 0; if (ddlTemplate.SelectedIndex > 0) { _pageLayout.TemplateId = Convert.ToInt32(ddlTemplate.SelectedValue); } _pageLayout.Language = Language.language; return(_pageLayout); }
protected void btn_edit_Click(object sender, EventArgs e) { try { SYS_PageLayout _pageLayout = new SYS_PageLayout(); _pageLayout = ReceiveHtml(); SYS_PageLayoutBSO _pageLayoutBSO = new SYS_PageLayoutBSO(); _pageLayoutBSO.UpdateSYS_PageLayout(_pageLayout); ViewPageLayout(); clientview.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Cập nhật thành công !</div>"; initControl(_pageLayout.Id); } catch (Exception ex) { clientview.Text = ex.Message.ToString(); } }
protected void btn_add_Click_more(object sender, EventArgs e) { try { SYS_PageLayout _pageLayout = new SYS_PageLayout(); _pageLayout = ReceiveHtml(); SYS_PageLayoutBSO _pageLayoutBSO = new SYS_PageLayoutBSO(); int id = _pageLayoutBSO.CreateSYS_PageLayoutGet(_pageLayout); ViewPageLayout(); clientview.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Thêm mới thành công !</div>"; } catch (Exception ex) { clientview.Text = ex.Message.ToString(); } }
private void initControl(int Id) { if (Id > 0) { btn_add.Visible = false; btn_edit.Visible = true; btn_add1.Visible = false; btn_add2.Visible = false; btn_edit1.Visible = true; try { SYS_PageLayoutBSO _pageLayoutBSO = new SYS_PageLayoutBSO(); SYS_PageLayout _pageLayout = _pageLayoutBSO.GetSYS_PageLayoutById(Id); hddID.Value = Convert.ToString(_pageLayout.Id); txtName.Text = _pageLayout.PageName; txtSlug.Text = _pageLayout.SlugPageName; txtOrder.Text = _pageLayout.Orders.ToString(); BindDropDownList(); ddlTemplate.SelectedValue = Convert.ToString(_pageLayout.TemplateId); } catch (Exception ex) { clientview.Text = ex.Message.ToString(); } } else { BindDropDownList(); btn_edit.Visible = false; btn_add.Visible = true; btn_edit1.Visible = false; btn_add1.Visible = true; btn_add2.Visible = true; } }
public SYS_PageLayout GetSYS_PageLayoutById(int Id) { SYS_PageLayout sys_PageLayout = null; using (SqlConnection connection = GetConnection()) { SqlCommand command = new SqlCommand("_SYS_PageLayoutGetById", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@Id", Id); connection.Open(); using (SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection)) { if (reader.Read()) { sys_PageLayout = SYS_PageLayoutReader(reader); } //else // throw new DataAccessException("Khong tim thay gia tri sys_PageLayout"); command.Dispose(); } } return(sys_PageLayout); }
public void UpdateSYS_PageLayout(SYS_PageLayout sys_PageLayout) { using (SqlConnection connection = GetConnection()) { SqlCommand command = new SqlCommand("_SYS_PageLayoutUpdate", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@Type", 1); command.Parameters.AddWithValue("@ID", sys_PageLayout.Id); command.Parameters.AddWithValue("@PageName", sys_PageLayout.PageName); command.Parameters.AddWithValue("@SlugPageName", sys_PageLayout.SlugPageName); command.Parameters.AddWithValue("@TemplateId", sys_PageLayout.TemplateId); command.Parameters.AddWithValue("@Orders", sys_PageLayout.Orders); command.Parameters.AddWithValue("@Language", sys_PageLayout.Language); connection.Open(); if (command.ExecuteNonQuery() <= 0) { throw new DataAccessException("khong cap nhat duoc sys_PageLayout"); } else { command.Dispose(); } } }
public SYS_PageLayout GetSYS_PageLayoutBySlug(string slug, string _lang) { SYS_PageLayout sys_PageLayout = null; using (SqlConnection connection = GetConnection()) { SqlCommand command = new SqlCommand("_SYS_PageLayoutGetBySlug", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@Slug", String.IsNullOrEmpty(slug)?"":slug); command.Parameters.AddWithValue("@Language", string.IsNullOrEmpty(_lang) ? "" : _lang); connection.Open(); using (SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection)) { if (reader.Read()) { sys_PageLayout = SYS_PageLayoutReader(reader); } //else // throw new DataAccessException("Khong tim thay gia tri sys_PageLayout"); command.Dispose(); } } return(sys_PageLayout); }
public void UpdateSYS_PageLayout(SYS_PageLayout sys_PageLayout) { SYS_PageLayoutDAO sys_PageLayoutDAO = new SYS_PageLayoutDAO(); sys_PageLayoutDAO.UpdateSYS_PageLayout(sys_PageLayout); }
public int CreateSYS_PageLayoutGet(SYS_PageLayout sys_PageLayout) { SYS_PageLayoutDAO sys_PageLayoutDAO = new SYS_PageLayoutDAO(); return(sys_PageLayoutDAO.CreateSYS_PageLayoutGet(sys_PageLayout)); }
public static void GetNavigation(string strSlugPage, string g, string cId, string Id, string urlRoot) { if (strSlugPage != string.Empty) { SYS_PageLayoutBSO _pageLayoutBSO = new SYS_PageLayoutBSO(); SYS_PageLayout _pageLayout = new SYS_PageLayout(); if (!AspNetCache.CheckCache("PageLayout_" + strSlugPage + "_" + Language.language.Replace("-", "_"))) { _pageLayout = _pageLayoutBSO.GetSYS_PageLayoutBySlug(strSlugPage, Language.language); if (_pageLayout == null) { _pageLayout = _pageLayoutBSO.GetSYS_PageLayoutBySlug("home", Language.language); } AspNetCache.SetCache("PageLayout_" + strSlugPage + "_" + Language.language.Replace("-", "_"), _pageLayout); } else { _pageLayout = (SYS_PageLayout)AspNetCache.GetCache("PageLayout_" + strSlugPage + "_" + Language.language.Replace("-", "_")); } Navigation.TitleName = _pageLayout.PageName; Navigation.TitleCate = "<li><a href='" + urlRoot + "'>Trang chủ</a></li>"; CateNewsGroupBSO cateNewsgroupBSO = new CateNewsGroupBSO(); NewsGroupBSO newsgroupBSO = new NewsGroupBSO(); CateNewsBSO catenewsBSO = new CateNewsBSO(); if (strSlugPage == "du-an") { if (!String.IsNullOrEmpty(Id)) { Navigation.TitleName = "Thông tin dự án"; string cate = "<li><a href='" + urlRoot + "c2/du-an-c/du-an-1.aspx'>Dự án"; cate += "</a></li>"; Navigation.TitleCate = "<li><a href='" + urlRoot + "Default.aspx'>" + Resources.resource.T_home + "</a></li>"; Navigation.TitleCate += cate; } } else if (strSlugPage == "detailvideos") { if (!String.IsNullOrEmpty(cId)) { VideosCateBSO videosCateBSO = new VideosCateBSO(); VideosCate videoCate = videosCateBSO.GetVideosCateById(Convert.ToInt32(cId)); Navigation.TitleName = "<a href='" + urlRoot + "thu-vien-video" + "-" + videoCate.VideosCateID + ".aspx'>" + videoCate.VideosCateName + "</a>"; string cate = "<li><a href='" + urlRoot + "thu-vien-video.aspx'>Thư viện Video"; string s1 = ""; while (videoCate.ParentCateID != 0) { int pId = videoCate.ParentCateID; videoCate = videosCateBSO.GetVideosCateById(pId); s1 = "<li><a href='" + urlRoot + "thu-vien-video/" + videoCate.VideosCateName + "-" + videoCate.VideosCateID + ".aspx'>" + videoCate.VideosCateName + "</a></li>" + s1; } // cate += "Video"; //Sửa lại cate += "</a></li>"; cate += s1; Navigation.TitleCate = "<li><a href='" + urlRoot + "Default.aspx'>" + Resources.resource.T_home + "</a></li>"; Navigation.TitleCate += cate; } } else if (strSlugPage == "detailalbums") { if (!String.IsNullOrEmpty(cId)) { AlbumsCateBSO albumsCateBSO = new AlbumsCateBSO(); AlbumsCate videoCate = albumsCateBSO.GetAlbumsCateById(Convert.ToInt32(cId)); Navigation.TitleName = "<a href='" + urlRoot + "thu-vien-video" + "-" + videoCate.AlbumsCateID + ".aspx'>" + videoCate.AlbumsCateName + "</a>"; string cate = "<li><a href='" + urlRoot + "thu-vien-video.aspx'>Thư viện Video"; string s1 = ""; while (videoCate.ParentCateID != 0) { int pId = videoCate.ParentCateID; videoCate = albumsCateBSO.GetAlbumsCateById(pId); s1 = "<li><a href='" + urlRoot + "thu-vien-video/" + videoCate.AlbumsCateName + "-" + videoCate.AlbumsCateID + ".aspx'>" + videoCate.AlbumsCateName + "</a></li>" + s1; } // cate += "Video"; //Sửa lại cate += "</a></li>"; cate += s1; Navigation.TitleCate = "<li><a href='" + urlRoot + "Default.aspx'>" + Resources.resource.T_home + "</a></li>"; Navigation.TitleCate += cate; } } else if (strSlugPage == "dh") { if (!String.IsNullOrEmpty(g)) { Navigation.TitleName = "<a href='" + urlRoot + "tim-truong/0-0-0-0-0-0-0/search.aspx'>Thông tin trường</a>"; Navigation.TitleCate = "<li><a href='" + urlRoot + "Default.aspx'>" + Resources.resource.T_home + "</a></li>"; } } else if (strSlugPage == "dang-ky-ts") { if (!String.IsNullOrEmpty(g)) { Navigation.TitleName = "<a href='" + urlRoot + "c2/dh-dk/Dang-ky-tuyen-sinh-truc-tuyen-20.aspx'>Trang Đăng ký tuyển sinh</a>"; Navigation.TitleCate = "<li><a href='" + urlRoot + "Default.aspx'>" + Resources.resource.T_home + "</a></li>"; } } else if (strSlugPage == "dh-dk") { if (!String.IsNullOrEmpty(g)) { Navigation.TitleName = "<a href='" + urlRoot + "c2/dh-dk/Dang-ky-tuyen-sinh-truc-tuyen-20.aspx'>Trang Đăng ký tuyển sinh</a>"; Navigation.TitleCate = "<li><a href='" + urlRoot + "Default.aspx'>" + Resources.resource.T_home + "</a></li>"; } } else if (!String.IsNullOrEmpty(Id)) { NewsGroup newsgroup = newsgroupBSO.GetNewsGroupById(Convert.ToInt32(Id)); if (newsgroup != null && newsgroup.CateNewsID > 0) { CateNews catenews = catenewsBSO.GetCateNewsById(newsgroup.CateNewsID); CateNewsGroup cateNewsGroup = cateNewsgroupBSO.GetCateNewsGroupByGroupCate(catenews.GroupCate, Language.language); Navigation.TitleName = "<a href='" + urlRoot + "c3/" + catenewsBSO.GetSlugByCateId(catenews.CateNewsID) + "/" + GetString(catenews.CateNewsName) + "-" + catenews.GroupCate + "-" + catenews.CateNewsID + ".aspx'>" + catenews.CateNewsName + "</a>"; string cate = "<li><a href='" + urlRoot + "c2/" + cateNewsgroupBSO.GetSlugById(cateNewsGroup.CateNewsGroupID) + "/" + GetString(cateNewsGroup.CateNewsGroupName) + "-" + catenews.GroupCate + ".aspx'>"; string s1 = ""; while (catenews.ParentNewsID != 0) { int pId = catenews.ParentNewsID; catenews = catenewsBSO.GetCateNewsById(pId); s1 = "<li><a href='" + urlRoot + "c3/" + catenewsBSO.GetSlugByCateId(catenews.CateNewsID) + "/" + GetString(catenews.CateNewsName) + "-" + catenews.GroupCate + "-" + catenews.CateNewsID + ".aspx'>" + catenews.CateNewsName + "</a></li>" + s1; } cate += cateNewsGroup.CateNewsGroupName.ToString(); //Sửa lại cate += "</a></li>"; cate += s1; Navigation.TitleCate = "<li><a href='" + urlRoot + "Default.aspx'>" + Resources.resource.T_home + "</a></li>"; Navigation.TitleCate += cate; } } else { if (!String.IsNullOrEmpty(cId) && !String.IsNullOrEmpty(g)) { CateNews cateNewsById = catenewsBSO.GetCateNewsById(Convert.ToInt32(cId)); CateNewsGroup groupByGroupCate = cateNewsgroupBSO.GetCateNewsGroupByGroupCate(Convert.ToInt32(g), Language.language); if (groupByGroupCate != null && cateNewsById != null) { Navigation.TitleName = cateNewsById.CateNewsName; string cate = "<li><a href='" + urlRoot + "c2/" + cateNewsgroupBSO.GetSlugById(groupByGroupCate.CateNewsGroupID) + "/" + GetString(groupByGroupCate.CateNewsGroupName) + "-" + cateNewsById.GroupCate + ".aspx' title='" + groupByGroupCate.CateNewsGroupName + "'>"; string s1 = ""; while (cateNewsById.ParentNewsID != 0) { int parentNewsId = cateNewsById.ParentNewsID; cateNewsById = catenewsBSO.GetCateNewsById(parentNewsId); s1 = "<li><a href='" + urlRoot + "c3/" + catenewsBSO.GetSlugByCateId(cateNewsById.CateNewsID) + "/" + GetString(cateNewsById.CateNewsName) + "-" + cateNewsById.GroupCate + "-" + cateNewsById.CateNewsID + ".aspx' title='" + cateNewsById.CateNewsName + "'>" + cateNewsById.CateNewsName + "</a></li>" + s1; } cate += groupByGroupCate.CateNewsGroupName.ToString() + "</a></li>" + s1; Navigation.TitleCate = "<li><a href='" + urlRoot + "Default.aspx'>" + Resources.resource.T_home + "</a></li>"; Navigation.TitleCate += cate; } } else { if (!String.IsNullOrEmpty(g)) { CateNewsGroup groupByGroupCate = cateNewsgroupBSO.GetCateNewsGroupByGroupCate(Convert.ToInt32(g), Language.language); Navigation.TitleCate = "<li><a href='" + urlRoot + "Default.aspx'>" + Resources.resource.T_home + "</a></li>"; if (groupByGroupCate != null) { Navigation.TitleName = groupByGroupCate.CateNewsGroupName; } } } } } }