Exemplo n.º 1
0
 public void UpdateSYS_Widget(SYS_Widget sys_Widget)
 {
     using (SqlConnection connection = GetConnection())
     {
         SqlCommand command = new SqlCommand("_SYS_WidgetUpdate", connection);
         command.CommandType = CommandType.StoredProcedure;
         command.Parameters.AddWithValue("@Type", 1);
         command.Parameters.AddWithValue("@ID", sys_Widget.Id);
         command.Parameters.AddWithValue("@WidgetControl", sys_Widget.WidgetControl);
         command.Parameters.AddWithValue("@WidgetDir", sys_Widget.WidgetDir);
         command.Parameters.AddWithValue("@WidgetInfo", sys_Widget.WidgetInfo);
         command.Parameters.AddWithValue("@WidgetName", sys_Widget.WidgetName);
         command.Parameters.AddWithValue("@WidgetStatus", sys_Widget.WidgetStatus);
         command.Parameters.AddWithValue("@WidgetType", sys_Widget.WidgetType);
         connection.Open();
         if (command.ExecuteNonQuery() <= 0)
         {
             throw new DataAccessException("khong cap nhat duoc sys_Widget");
         }
         else
         {
             command.Dispose();
         }
     }
 }
Exemplo n.º 2
0
        public SYS_Widget GetSYS_WidgetById(int Id)
        {
            SYS_Widget sys_Widget = null;

            using (SqlConnection connection = GetConnection())
            {
                SqlCommand command = new SqlCommand("_SYS_WidgetGetById", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@Id", Id);
                connection.Open();
                using (SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection))
                {
                    if (reader.Read())
                    {
                        sys_Widget = SYS_WidgetReader(reader);
                    }
                    else
                    {
                        throw new DataAccessException("Khong tim thay gia tri sys_Widget");
                    }
                    command.Dispose();
                }
            }
            return(sys_Widget);
        }
Exemplo n.º 3
0
        public int CreateSYS_WidgetGet(SYS_Widget sys_Widget)
        {
            int i = 0;

            using (SqlConnection connection = GetConnection())
            {
                SqlCommand command = new SqlCommand("_SYS_WidgetInsert", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@Type", 0);
                command.Parameters.AddWithValue("@Id", 0);
                command.Parameters.AddWithValue("@WidgetControl", sys_Widget.WidgetControl);
                command.Parameters.AddWithValue("@WidgetDir", sys_Widget.WidgetDir);
                command.Parameters.AddWithValue("@WidgetInfo", sys_Widget.WidgetInfo);
                command.Parameters.AddWithValue("@WidgetName", sys_Widget.WidgetName);
                command.Parameters.AddWithValue("@WidgetStatus", sys_Widget.WidgetStatus);
                command.Parameters.AddWithValue("@WidgetType", sys_Widget.WidgetType);

                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);
        }
Exemplo n.º 4
0
    protected void initControl(int ID)
    {
        if (ID > 0)
        {
            txtID.Value      = Convert.ToString(ID);
            btn_add.Visible  = false;
            btn_edit.Visible = true;

            btn_add1.Visible  = false;
            btn_add2.Visible  = false;
            btn_edit1.Visible = true;

            try
            {
                SYS_WidgetBSO sys_WidgetBSO = new SYS_WidgetBSO();
                SYS_Widget    sys_Widget    = sys_WidgetBSO.GetSYS_WidgetById(ID);

                Bind_ddlWidgetType();
                ddlWidgetType.SelectedValue = Convert.ToString(sys_Widget.WidgetType);

                txtWidgetName.Text = sys_Widget.WidgetName;

                GetFile();
                GetFileControl = sys_Widget.WidgetControl + ".ascx";
                ActipFile();

                try
                {
                    dropFolder.SelectedItem.Text = sys_Widget.WidgetDir.ToString();
                    dropFolder.SelectedValue     = sys_Widget.WidgetDir.ToString();
                }
                catch { }
                txtInfo.Text      = sys_Widget.WidgetInfo;
                chkStatus.Checked = sys_Widget.WidgetStatus;
            }
            catch (Exception ex)
            {
                error.Text = ex.Message.ToString();
            }
        }
        else
        {
            GetFile();
            ActipFile();
            Bind_ddlWidgetType();
            txtID.Value = "";
            ddlWidgetType.SelectedIndex = 0;
            btn_add.Visible             = true;
            btn_edit.Visible            = false;

            btn_add1.Visible  = true;
            btn_add2.Visible  = true;
            btn_edit1.Visible = false;
        }
    }
Exemplo n.º 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpCookie cookie_lang = Request.Cookies["LangInfo_CMS"];

        if (cookie_lang == null || cookie_lang["Lang"] == null || cookie_lang["Lang"] == string.Empty)
        {
            cookie_lang         = new HttpCookie("LangInfo_CMS");
            cookie_lang["Lang"] = "vi-VN";
            cookie_lang.Expires = DateTime.Now.AddDays(1);
            Response.Cookies.Add(cookie_lang);
        }
        Language.language = cookie_lang["Lang"].ToString();
        Session["Lang"]   = cookie_lang["Lang"].ToString();

        Config config = new Config();

        if (AspNetCache.CheckCache("Config_" + Language.language) == false)
        {
            ConfigBSO configBSO = new ConfigBSO();

            config = configBSO.GetAllConfig(Language.language);
            AspNetCache.SetCacheWithTime("Config_" + Language.language, config, 150);
        }
        else
        {
            config = (Config)AspNetCache.GetCache("Config_" + Language.language);
        }
        Page.Title = config.Titleweb;

        if (!string.IsNullOrEmpty(Request["id"]))
        {
            SYS_WidgetPageLayoutBSO _widgetPageLayoutBSO = new SYS_WidgetPageLayoutBSO();
            SYS_WidgetPageLayout    _widgetPageLayout    = _widgetPageLayoutBSO.GetSYS_WidgetPageLayoutById(Convert.ToInt32(Request["id"].ToString()));

            if (_widgetPageLayout != null)
            {
                SYS_WidgetBSO _widgetBSO = new SYS_WidgetBSO();
                SYS_Widget    _widget    = _widgetBSO.GetSYS_WidgetById(_widgetPageLayout.WidgetId);
                if (_widget != null)
                {
                    if (_widget.WidgetControl != "")
                    {
                        Control objControl1 = (Control)this.Page.LoadControl(ResolveUrl("~") + "Client/Modules/" + _widget.WidgetDir + "/" + _widget.WidgetControl + ".ascx");
                        objControl1.ID = _widgetPageLayout.Id.ToString();
                        PlaceHolder1.Controls.Add(objControl1);

                        //  PlaceHolder1.Controls.Add(LoadControl(ResolveUrl("~") + _widget.WidgetDir + "/" + _widget.WidgetControl));

                        ControlAddParameter(objControl1, _widgetPageLayout.Title, _widgetPageLayout.Icon, _widgetPageLayout.Value, Convert.ToInt32(_widgetPageLayout.Record), _widgetPageLayout.Info, _widgetPageLayout.Value2, Convert.ToInt32(_widgetPageLayout.Record2), _widgetPageLayout.HTML);
                    }
                }
            }
        }
    }
Exemplo n.º 6
0
        private SYS_Widget SYS_WidgetReader(SqlDataReader reader)
        {
            SYS_Widget sys_Widget = new SYS_Widget();

            sys_Widget.Id            = (int)reader["Id"];
            sys_Widget.WidgetControl = (string)reader["WidgetControl"];
            sys_Widget.WidgetDir     = (string)reader["WidgetDir"];
            sys_Widget.WidgetInfo    = (string)reader["WidgetInfo"];
            sys_Widget.WidgetName    = (string)reader["WidgetName"];
            sys_Widget.WidgetType    = (int)reader["WidgetType"];
            sys_Widget.WidgetStatus  = (bool)reader["WidgetStatus"];


            return(sys_Widget);
        }
Exemplo n.º 7
0
    public SYS_Widget ReceiveHtml()
    {
        SYS_Widget sys_Widget = new SYS_Widget();

        sys_Widget.Id            = (txtID.Value != "") ? Convert.ToInt32(txtID.Value) : 0;
        sys_Widget.WidgetName    = (txtWidgetName.Text != "") ? txtWidgetName.Text.Trim() : "";
        sys_Widget.WidgetDir     = (dropFolder.SelectedValue != "") ? dropFolder.SelectedItem.Text : "";
        sys_Widget.WidgetControl = (dropControl.SelectedValue != "") ? dropControl.SelectedValue.Replace(".ascx", "") : "";
        sys_Widget.WidgetType    = (ddlWidgetType.SelectedValue != "") ? Convert.ToInt32(ddlWidgetType.SelectedValue) : 0;

        sys_Widget.WidgetInfo = txtInfo.Text;

        sys_Widget.WidgetStatus = chkStatus.Checked;

        return(sys_Widget);
    }
Exemplo n.º 8
0
    protected void Edit()
    {
        SYS_WidgetBSO sys_WidgetBSO = new SYS_WidgetBSO();
        SYS_Widget    sys_Widget    = ReceiveHtml();

        try
        {
            sys_WidgetBSO.UpdateSYS_Widget(sys_Widget);
            error.Text = "<div style='color:#ff0000;font:bold 12px Arial;padding:5px 0;'>Cập nhật thành công !</div>";
            initControl(sys_Widget.Id);
        }
        catch (Exception ex)
        {
            error.Text = ex.Message.ToString();
        }
    }
Exemplo n.º 9
0
    protected void Add()
    {
        SYS_WidgetBSO sys_WidgetBSO = new SYS_WidgetBSO();
        SYS_Widget    sys_Widget    = ReceiveHtml();

        try
        {
            int id = sys_WidgetBSO.CreateSYS_WidgetGet(sys_Widget);
            error.Text = "<div style='color:#ff0000;font:bold 12px Arial;padding:5px 0;'>Thêm mới thành công !</div>";
            initControl(id);
        }
        catch (Exception ex)
        {
            error.Text = ex.Message.ToString();
        }
    }
Exemplo n.º 10
0
    protected void btn_add_Click_more(object sender, EventArgs e)
    {
        SYS_WidgetBSO sys_WidgetBSO = new SYS_WidgetBSO();
        SYS_Widget    sys_Widget    = ReceiveHtml();

        try
        {
            int id = sys_WidgetBSO.CreateSYS_WidgetGet(sys_Widget);
            error.Text = "<div style='color:#ff0000;font:bold 12px Arial;padding:5px 0;'>Thêm mới thành công !</div>";
            AspNetCache.Reset();
            ViewWidgetAll();
        }
        catch (Exception ex)
        {
            error.Text = ex.Message.ToString();
        }
    }
Exemplo n.º 11
0
        public void UpdateSYS_Widget(SYS_Widget sys_Widget)
        {
            SYS_WidgetDAO sys_WidgetDAO = new SYS_WidgetDAO();

            sys_WidgetDAO.UpdateSYS_Widget(sys_Widget);
        }
Exemplo n.º 12
0
        public int CreateSYS_WidgetGet(SYS_Widget sys_Widget)
        {
            SYS_WidgetDAO sys_WidgetDAO = new SYS_WidgetDAO();

            return(sys_WidgetDAO.CreateSYS_WidgetGet(sys_Widget));
        }