Ejemplo n.º 1
0
        public SYS_TemplatePage GetSYS_TemplatePageById(int Id)
        {
            SYS_TemplatePage sys_TemplatePage = null;

            using (SqlConnection connection = GetConnection())
            {
                SqlCommand command = new SqlCommand("_SYS_TemplatePageGetById", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@Id", Id);
                connection.Open();
                using (SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection))
                {
                    if (reader.Read())
                    {
                        sys_TemplatePage = SYS_TemplatePageReader(reader);
                    }
                    else
                    {
                        throw new DataAccessException("Khong tim thay gia tri sys_TemplatePage");
                    }
                    command.Dispose();
                }
            }
            return(sys_TemplatePage);
        }
Ejemplo n.º 2
0
        public int CreateSYS_TemplatePageGet(SYS_TemplatePage sys_TemplatePage)
        {
            int i = 0;

            using (SqlConnection connection = GetConnection())
            {
                SqlCommand command = new SqlCommand("_SYS_TemplatePageInsert", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@Type", 0);
                command.Parameters.AddWithValue("@Id", 0);
                command.Parameters.AddWithValue("@TemplateName", sys_TemplatePage.TemplateName);
                command.Parameters.AddWithValue("@TemplateControl", sys_TemplatePage.TemplateControl);
                command.Parameters.AddWithValue("@MasterControl", sys_TemplatePage.MasterControl);
                command.Parameters.AddWithValue("@Info", sys_TemplatePage.Info);
                command.Parameters.AddWithValue("@Language", sys_TemplatePage.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);
        }
Ejemplo n.º 3
0
        private SYS_TemplatePage SYS_TemplatePageReader(SqlDataReader reader)
        {
            SYS_TemplatePage sys_TemplatePage = new SYS_TemplatePage();

            sys_TemplatePage.Id              = (int)reader["Id"];
            sys_TemplatePage.Info            = (string)reader["Info"];
            sys_TemplatePage.TemplateControl = (string)reader["TemplateControl"];
            sys_TemplatePage.MasterControl   = (string)reader["MasterControl"];
            sys_TemplatePage.TemplateName    = (string)reader["TemplateName"];
            sys_TemplatePage.Language        = (string)reader["Language"];
            return(sys_TemplatePage);
        }
    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();
        }
    }
Ejemplo n.º 5
0
    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);
    }
Ejemplo n.º 6
0
    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);
                }
            }
        }
    }
Ejemplo n.º 7
0
    protected void btn_edit_Click(object sender, EventArgs e)
    {
        try
        {
            SYS_TemplatePage template = new SYS_TemplatePage();
            template = ReceiveHtml();

            SYS_TemplatePageBSO templateBSO = new SYS_TemplatePageBSO();
            templateBSO.UpdateSYS_TemplatePage(template);

            ViewTemplate();
            clientview.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Cập nhật thành công !</div>";
            initControl(template.Id);
        }
        catch (Exception ex)
        {
            clientview.Text = ex.Message.ToString();
        }
    }
Ejemplo n.º 8
0
    protected void btn_add_Click_more(object sender, EventArgs e)
    {
        try
        {
            SYS_TemplatePage template = new SYS_TemplatePage();
            template = ReceiveHtml();


            SYS_TemplatePageBSO templateBSO = new SYS_TemplatePageBSO();
            int id = templateBSO.CreateSYS_TemplatePageGet(template);

            ViewTemplate();
            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();
        }
    }
Ejemplo n.º 9
0
    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_TemplatePageBSO templateBSO = new SYS_TemplatePageBSO();
                SYS_TemplatePage    template    = templateBSO.GetSYS_TemplatePageById(Id);


                hddID.Value = Convert.ToString(template.Id);

                txtName.Text = template.TemplateName;
                txtInfo.Text = template.Info;
                GetFile();
                dropControl.SelectedValue = template.TemplateControl;
                GetFileMasterPage();
                ddlMasterPage.SelectedValue = template.MasterControl;
            }
            catch (Exception ex)
            {
                clientview.Text = ex.Message.ToString();
            }
        }
        else
        {
            GetFile();
            GetFileMasterPage();
            btn_edit.Visible = false;
            btn_add.Visible  = true;

            btn_edit1.Visible = false;
            btn_add1.Visible  = true;
            btn_add2.Visible  = true;
        }
    }
Ejemplo n.º 10
0
    private SYS_TemplatePage ReceiveHtml()
    {
        SYS_TemplatePage template = new SYS_TemplatePage();

        template.Id           = (hddID.Value != "") ? Convert.ToInt32(hddID.Value) : 0;
        template.TemplateName = txtName.Text;
        template.Info         = txtInfo.Text;
        if (dropControl.SelectedIndex > 0)
        {
            template.TemplateControl = dropControl.SelectedValue;
        }

        if (ddlMasterPage.SelectedIndex > 0)
        {
            template.MasterControl = ddlMasterPage.SelectedValue;
        }
        template.Language = Language.language;

        return(template);
    }
Ejemplo n.º 11
0
 public void UpdateSYS_TemplatePage(SYS_TemplatePage sys_TemplatePage)
 {
     using (SqlConnection connection = GetConnection())
     {
         SqlCommand command = new SqlCommand("_SYS_TemplatePageUpdate", connection);
         command.CommandType = CommandType.StoredProcedure;
         command.Parameters.AddWithValue("@Type", 1);
         command.Parameters.AddWithValue("@Id", sys_TemplatePage.Id);
         command.Parameters.AddWithValue("@TemplateName", sys_TemplatePage.TemplateName);
         command.Parameters.AddWithValue("@TemplateControl", sys_TemplatePage.TemplateControl);
         command.Parameters.AddWithValue("@MasterControl", sys_TemplatePage.MasterControl);
         command.Parameters.AddWithValue("@Info", sys_TemplatePage.Info);
         command.Parameters.AddWithValue("@Language", sys_TemplatePage.Language);
         connection.Open();
         if (command.ExecuteNonQuery() <= 0)
         {
             throw new DataAccessException("khong cap nhat duoc sys_TemplatePage");
         }
         else
         {
             command.Dispose();
         }
     }
 }
Ejemplo n.º 12
0
        public void UpdateSYS_TemplatePage(SYS_TemplatePage sys_TemplatePage)
        {
            SYS_TemplatePageDAO sys_TemplatePageDAO = new SYS_TemplatePageDAO();

            sys_TemplatePageDAO.UpdateSYS_TemplatePage(sys_TemplatePage);
        }
Ejemplo n.º 13
0
        public int CreateSYS_TemplatePageGet(SYS_TemplatePage sys_TemplatePage)
        {
            SYS_TemplatePageDAO sys_TemplatePageDAO = new SYS_TemplatePageDAO();

            return(sys_TemplatePageDAO.CreateSYS_TemplatePageGet(sys_TemplatePage));
        }