Ejemplo n.º 1
0
    protected void lbtUpdate_Click(object sender, EventArgs e)
    {
        string sScritp = "<script>";

        sScritp += "var a = opener.parent.dhxLayout.cells(\"a\");";
        sScritp += "var b = opener.parent.dhxLayout.cells(\"b\");";
        sScritp += "a.attachURL(\"Tree.aspx\");";
        sScritp += "b.attachURL(\"/Admin/Modules/Mod/ModList.aspx\");";
        sScritp += "window.close();";
        sScritp += "</script>";
        //====================Lấy Level========================
        //string sql = "SELECT Mod_Level FROM tbl_Mod WHERE Mod_ID=" + ddlGroup.SelectedValue;
        //DataSet ds = UpdateData.UpdateBySql(sql);
        //DataRowCollection rows = ds.Tables[0].Rows;
        string group = ddlGroup.SelectedValue.ToString();

        if (Convert.ToInt32(ddlGroup.SelectedValue) == -1)
        {
            level = 1;
            group = "0";
        }
        else
        {
            level = Convert.ToInt32(ModControl.GetModField("Level", Convert.ToInt32(ddlGroup.SelectedValue))) + 1;
        }
        //============================================
        Hashtable tbIn      = new Hashtable();
        Hashtable tbInCat   = new Hashtable();
        int       ModtypeID = Int32.Parse(ddlModtype.SelectedValue);
        string    isUse     = (cbIsUse.Checked == true) ? "1" : "0";
        string    code      = txtCode.Text.Trim() == "" ? ApplicationUtil.GetTitle(txtName.Text.ToString()).ToLower() : txtCode.Text.Trim().ToLower();
        string    url       = txtURL.Text.Trim() == "" ? ApplicationUtil.GetTitle(txtName.Text.ToString()).ToLower() : txtURL.Text.Trim().ToLower();

        tbIn.Add("Mod_Parent", group);
        tbIn.Add("Modtype_ID", ddlModtype.SelectedValue);
        tbIn.Add("Mod_Img", txtImg.Text.Replace("/upload", "upload"));
        tbIn.Add("Mod_Name", txtName.Text);
        tbIn.Add("Mod_Code", code);
        tbIn.Add("Mod_URL", url);
        tbIn.Add("Mod_Des", txtDes.Text);
        tbIn.Add("Mod_Title", txtTitle.Text);
        tbIn.Add("Mod_Key", txtKey.Text);
        tbIn.Add("Mod_Content", CKContent.Text);
        tbIn.Add("Mod_Level", level.ToString());
        tbIn.Add("Mod_Pos", txtPos.Text);
        tbIn.Add("Mod_Status", isUse);
        //========================CAT===============================//
        tbInCat.Add("Name", txtName.Text);
        tbInCat.Add("Code", txtCode.Text);
        tbInCat.Add("Modtype_ID", ddlModtype.SelectedValue);
        tbInCat.Add("Description", txtDes.Text);
        tbInCat.Add("isPublish", isUse);
        if (act == "add")
        {
            tbIn.Add("lang", Session["lang"].ToString());
            bool _insert = UpdateData.Insert("tbl_Mod", tbIn);
            if (_insert)
            {
                string            sql1  = "SELECT Mod_ID FROM tbl_Mod order by Mod_ID DESC";
                DataSet           ds1   = UpdateData.UpdateBySql(sql1);
                DataRowCollection rows1 = ds1.Tables[0].Rows;
                UpdateData.InsertBySql("INSERT INTO tbl_ModsiteUser(Mod_ID,User_ID) VALUES(" + rows1[0]["Mod_ID"] + "," + Session["UserID"] + ")");
                if (Session["UserID"].ToString() != "56")
                {
                    UpdateData.InsertBySql("INSERT INTO tbl_ModsiteUser(Mod_ID,User_ID) VALUES(" + rows1[0]["Mod_ID"] + ",56)");
                }
                FunctionDB.AddLog(Session["DepartID"].ToString(), Session["Username"].ToString(), "Thêm", "Module:" + txtName.Text);
                Response.Redirect("/Admin/Modules/Mod/ModList.aspx?TopicId=" + TopicID);
            }
        }
        if (act == "edit")
        {
            bool _update = UpdateData.Update("tbl_Mod", tbIn, "Mod_ID=" + id);
            if (_update)
            {
                bool _updateCat = false;
                if (_updateCat)
                {
                    FunctionDB.AddLog(Session["DepartID"].ToString(), Session["Username"].ToString(), "Sửa", "Module:" + txtName.Text);
                }
            }
        }
        Response.Write(sScritp);
    }
Ejemplo n.º 2
0
    protected void lbtUpdate_Click(object sender, EventArgs e)
    {
        string sScritp = "<script>";

        sScritp += "var b = opener.parent.dhxLayout.cells(\"b\");";
        sScritp += "b.attachURL(\"ContentList.aspx?TopicID=" + ddlModID.SelectedValue + "\");";
        sScritp += "window.close();";
        sScritp += "</script>";

        //string sql = "SELECT Tag_Url FROM tbl_Tag";
        //DataSet dsSQL = UpdateData.UpdateBySql(sql);
        //DataRowCollection rowsSQL = dsSQL.Tables[0].Rows;
        //ArrayList arrSQL = FunctionDB.GetRowAsArrayList(dsSQL, "Tag_Url");

        ////DataSet dsM = UpdateData.UpdateBySql("SELECT MAX(Content_ID) AS maxID FROM tbl_Content");
        ////DataRowCollection rowsM = dsM.Tables[0].Rows;
        ////int maxID = Convert.ToInt32(rowsM[0]["maxID"].ToString())+1;

        //string[] mID = txtTag.Text.Split(',');

        //for (int i = 0; i < mID.Length; i++)
        //{
        //    if (mID[i] != "")
        //    {
        //        string nTag = mID[i].ToString().Trim();
        //        string uTag = ApplicationUtil.GetTitle(mID[i].ToString().Trim());
        //        Hashtable tbTag = new Hashtable();
        //        //if (act == "add")
        //        //    tbTag.Add("Content_ID", maxID.ToString());
        //        tbTag.Add("Tag_Name", nTag);
        //        tbTag.Add("Tag_Url", uTag);
        //        if (arrSQL.Contains(uTag))
        //        {
        //            UpdateData.Update("tbl_Tag", tbTag, "Tag_Url='" + uTag + "'");
        //            UpdateData.UpdateBySql("UPDATE tbl_Tag SET Tag_Count=Tag_Count+1 WHERE Tag_Url='" + uTag + "'");
        //        }
        //        else
        //        {
        //            UpdateData.Insert("tbl_Tag", tbTag);
        //            arrSQL = FunctionDB.GetRowAsArrayList(dsSQL, "Tag_Url");
        //        }
        //    }
        //}
        string url   = txtURL.Text.Trim() == "" ? ApplicationUtil.GetTitle(txtName.Text.ToString()).ToLower() : txtURL.Text.Trim().ToLower();
        string title = txtTitle.Text.Trim() == "" ? txtName.Text.ToString() : txtTitle.Text.Trim();
        //string urlTag = txtTag.Text.Trim() == "" ? ApplicationUtil.GetTitle(txtKey.Text.ToString()).ToLower() : ApplicationUtil.GetTitle(txtTag.Text.Trim()).ToLower();
        Hashtable tbIn  = new Hashtable();
        string    isUse = (cbIsUse.Checked == true) ? "1" : "0";

        tbIn.Add("Mod_ID", ddlModID.SelectedValue);
        tbIn.Add("User_ID", Session["UserID"].ToString());
        tbIn.Add("Content_Name", txtName.Text);
        tbIn.Add("Content_Text", CKContent.Text);
        tbIn.Add("Content_Img", txtImg.Text.Replace("/upload", "upload"));
        //tbIn.Add("Content_URL", txtURL.Text);
        tbIn.Add("Content_Pos", txtPos.Text);
        tbIn.Add("Content_Status", isUse);
        tbIn.Add("Content_URL", url);
        tbIn.Add("Content_Title", title);
        tbIn.Add("Content_Key", txtKey.Text);
        tbIn.Add("Content_Des", txtMeta.Text);
        //tbIn.Add("Content_Tag", txtTag.Text);
        //tbIn.Add("Content_UrlTags", urlTag);
        if (act == "add")
        {
            tbIn.Add("lang", Session["lang"].ToString());
            bool _insert = UpdateData.Insert("tbl_Content", tbIn);
            if (_insert)
            {
                FunctionDB.AddLog(Session["DepartID"].ToString(), Session["Username"].ToString(), "Thêm ", "Bài: " + txtName.Text);
            }
        }
        if (act == "edit")
        {
            bool _update = UpdateData.Update("tbl_Content", tbIn, "Content_ID=" + id);
            if (_update)
            {
                FunctionDB.AddLog(Session["DepartID"].ToString(), Session["Username"].ToString(), "Sửa", "Bài: " + txtName.Text);
            }
        }
        Response.Write(sScritp);
    }
Ejemplo n.º 3
0
    protected void lbtUpdate_Click(object sender, EventArgs e)
    {
        string sScript = "<script>";

        sScript += "var b = opener.parent.dhxLayout.cells(\"b\");";
        sScript += "b.attachURL(\"ContentList.aspx?TopicID=" + TopicID + "\");";
        sScript += "window.close();";
        sScript += "</script>";
        string            sql     = "SELECT Tag_Url FROM tbl_Tag";
        DataSet           dsSQL   = UpdateData.UpdateBySql(sql);
        DataRowCollection rowsSQL = dsSQL.Tables[0].Rows;
        ArrayList         arrSQL  = FunctionDB.GetRowAsArrayList(dsSQL, "Tag_Url");

        string[] mID = txtTags.Text.Split(',');
        for (int i = 0; i < mID.Length; i++)
        {
            if (mID[i] != "")
            {
                string    nTag  = mID[i].ToString().Trim();
                string    uTag  = ApplicationUtil.GetTitle(mID[i].ToString().Trim());
                Hashtable tbTag = new Hashtable();
                tbTag.Add("Tag_Name", nTag);
                tbTag.Add("Tag_Url", uTag);
                if (arrSQL.Contains(uTag))
                {
                    UpdateData.Update("tbl_Tag", tbTag, "Tag_Url='" + uTag + "'");
                }
                else
                {
                    UpdateData.Insert("tbl_Tag", tbTag);
                    arrSQL = FunctionDB.GetRowAsArrayList(dsSQL, "Tag_Url");
                }
            }
        }
        Hashtable tbIn  = new Hashtable();
        string    isUse = (cbIsUse.Checked == true) ? "1" : "0";
        //string url = txtURL.Text.Trim() == "" ? ApplicationUtil.GetTitle(txtName.Text.ToString()) : txtURL.Text.Trim();
        string urlTag = txtTags.Text.Trim() == "" ? ApplicationUtil.GetTitle(txtKey.Text.ToString()) : ApplicationUtil.GetTitle(txtTags.Text.Trim());

        tbIn.Add("Mod_ID", TopicID.ToString());
        tbIn.Add("Chuyenkhoa_ID", ddlChuyenkhoa.SelectedValue);
        tbIn.Add("Chuyenmuc_ID", ddlChuyenmuc.SelectedValue);
        tbIn.Add("User_ID", Session["UserID"].ToString());
        tbIn.Add("Content_Name", txtTile.Text);
        //tbIn.Add("Content_Code", txtName.Text); // ho ten
        tbIn.Add("Content_Code", txtCode.Text);
        tbIn.Add("Content_Title", txtTitle.Text);
        tbIn.Add("Content_Key", txtKey.Text);
        tbIn.Add("Content_Des", txtMeta.Text);
        tbIn.Add("Content_Tags", txtTags.Text);
        tbIn.Add("Content_UrlTags", urlTag);
        tbIn.Add("Content_Avata", txtTel.Text);
        //tbIn.Add("Content_URL", txtEmail.Text);
        tbIn.Add("Content_Intro", CKTeaser.Text);
        tbIn.Add("Content_Text", CKContent.Text);
        tbIn.Add("Content_Status", isUse);
        if (act == "add")
        {
            tbIn.Add("lang", Session["lang"].ToString());
            bool _insert = UpdateData.Insert("tbl_Content", tbIn);
            if (_insert)
            {
                FunctionDB.AddLog(Session["DepartID"].ToString(), Session["Username"].ToString(), "Thêm ", "Câu hỏi: " + CKTeaser.Text);
            }
        }
        if (act == "edit")
        {
            bool _update = UpdateData.Update("tbl_Content", tbIn, "Content_ID=" + id);
            if (_update)
            {
                FunctionDB.AddLog(Session["DepartID"].ToString(), Session["Username"].ToString(), "Sửa", "Câu hỏi: " + CKTeaser.Text);
            }
        }
        Response.Write(sScript);
    }