Пример #1
0
    public void DeleteRecItem(string iid, string pic)
    {
        #region Xóa ảnh items
        DataTable dt = new DataTable();
        dt = TatThanhJsc.Database.Items.GetItems("", ItemsColumns.ViimageColumn, ItemsTSql.GetItemsByIid(iid), "");

        string split = TatThanhJsc.AdminModul.Keyword.ParamsSpilitItems;
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            if (dt.Rows[i][ItemsColumns.ViimageColumn].ToString().IndexOf(split) < 0)
            {
                ImagesExtension.DeleteImageWhenDeleteItem(pic, dt.Rows[i][ItemsColumns.ViimageColumn].ToString());
                ImagesExtension.DeleteImageWhenDeleteItem(pic, dt.Rows[i][ItemsColumns.ViimageColumn].ToString().Replace("_HasThumb.", "_HasThumb_Thumb."));
            }
            else
            {
                foreach (
                    string s in
                    dt.Rows[i][ItemsColumns.ViimageColumn].ToString()
                    .Split(new string[] { split }, StringSplitOptions.RemoveEmptyEntries))
                {
                    ImagesExtension.DeleteImageWhenDeleteItem(pic, s);
                    ImagesExtension.DeleteImageWhenDeleteItem(pic, s.Replace("_HasThumb.", "_HasThumb_Thumb."));
                }
            }
        }
        #endregion

        DeleteSubItems(iid, pic);

        GroupsItems.DeleteItemsGroupsItemsByIid(iid);
    }
Пример #2
0
    public void DeleteCate(string igid, string pic)
    {
        condition = " CHARINDEX('," + igid + ",',IGPARENTSID) > 0 ";
        #region Xóa ảnh
        DataTable dt = new DataTable();
        dt = Groups.GetGroups("", GroupsColumns.VgimageColumn, condition, "");

        string split = TatThanhJsc.AdminModul.Keyword.ParamsSpilitItems;
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            if (dt.Rows[i][GroupsColumns.VgimageColumn].ToString().IndexOf(split) < 0)
            {
                ImagesExtension.DeleteImageWhenDeleteItem(pic, dt.Rows[i][GroupsColumns.VgimageColumn].ToString());
            }
            else
            {
                foreach (string s in dt.Rows[i][GroupsColumns.VgimageColumn].ToString().Split(new string[] { split }, StringSplitOptions.RemoveEmptyEntries))
                {
                    ImagesExtension.DeleteImageWhenDeleteItem(pic, s);
                }
            }
        }
        #endregion
        Groups.DeleteGroups(condition);
    }
Пример #3
0
    protected void btn_save_Click(object sender, EventArgs e)
    {
        if (rdOn.Checked == false)
        {
            on = "0";
        }
        SettingsExtension.SetOtherSettingKey(SettingsExtension.KeyNhacNenWebsite, StringExtension.GhepChuoi("", txt_source.Text, ltMediaName.Text, on), lang);

        #region Sound
        if (fuMedia.FileName.Length > 0 && fuMedia.PostedFile.ContentLength > 0)
        {
            ImagesExtension.DeleteImageWhenDeleteItem(pic, ltMediaName.Text);

            string filename = "";
            filename = System.IO.Path.GetFileName(fuMedia.PostedFile.FileName);
            string fileex = "";
            fileex = System.IO.Path.GetExtension(filename).ToLower();
            if (fileex == ".mp3" || fileex == ".wma")
            {
                string fileNotEx = System.IO.Path.GetFileNameWithoutExtension(fuMedia.PostedFile.FileName);
                vSound = StringExtension.ReplateTitle(fileNotEx) + DateTime.Now.Ticks.ToString() + fileex;
                fuMedia.SaveAs(Request.PhysicalApplicationPath + "/" + pic + "/" + vSound);
            }
            TatThanhJsc.Extension.SettingsExtension.SetOtherSettingKey(SettingsExtension.KeyNhacNenWebsite, StringExtension.GhepChuoi("", txt_source.Text, vSound, on), lang);
        }
        #endregion

        GetContentInControl();

        ScriptManager.RegisterStartupScript(this, this.GetType(), "alertSuccess", "ThongBao(3000,'Cập nhật thành công !');", true);
    }
Пример #4
0
    protected void LbDelFlagCurrent_Click(object sender, EventArgs e)
    {
        string[] fields    = { "nLanguageNationalFlag" };
        string[] values    = { "''" };
        string   condition = LanguageNationalTSql.GetByiLanguageNationalId(iLanguageNationalId);

        LanguageNational.UpdateLanguageNational(DataExtension.UpdateTransfer(fields, values), condition);
        ImagesExtension.DeleteImageWhenDeleteItem(pic, HdFlagNational.Value);
    }
    protected void btnXoaAnhHienTai_Click(object sender, EventArgs e)
    {
        ImagesExtension.DeleteImageWhenDeleteItem(pic, hdShareImage.Value);
        hdShareImage.Value       = "";
        btnXoaAnhHienTai.Visible = false;
        ltrShareImage.Text       = "";

        SettingsExtension.SetOtherSettingKey(SettingKey.SeoImageCustomerReviews, "", lang);
    }
Пример #6
0
 protected void lbtDelCurrentMedia_Click(object sender, EventArgs e)
 {
     if (rdOn.Checked == false)
     {
         on = "0";
     }
     ImagesExtension.DeleteImageWhenDeleteItem(pic, ltMediaName.Text);
     ltMediaName.Text = "";
     SettingsExtension.SetOtherSettingKey(SettingsExtension.KeyNhacNenWebsite, StringExtension.GhepChuoi("", txt_source.Text, ltMediaName.Text, on), lang);
 }
Пример #7
0
    private void DeleteLanguageItemImage(string iLanguageKeyId)
    {
        condition = DataExtension.AndConditon(LanguageItemTSql.GetByiLanguageKeyId(iLanguageKeyId));
        DataTable dt = new DataTable();

        dt = LanguageItem.GetLanguageItem("", LanguageItemColumns.nLanguageItemParams, condition, "");
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            ImagesExtension.DeleteImageWhenDeleteItem(FolderPic.Language, dt.Rows[i][LanguageItemColumns.nLanguageItemParams].ToString());
        }
    }
 void DeleteComment(string isid)
 {
     #region Xoá trả lời của comment
     DataTable dt = new DataTable();
     dt = Subitems.GetSubItems("", "*", DataExtension.AndConditon(SubitemsTSql.GetSubitemsByVskey(app + "Reply"), SubitemsTSql.GetSubitemsByVsurl(isid)), "");
     for (int i = 0; i < dt.Rows.Count; i++)
     {
         ImagesExtension.DeleteImageWhenDeleteItem(pic, dt.Rows[i][SubitemsColumns.VsimageColumn].ToString());
         Subitems.DeleteSubitems(dt.Rows[i][SubitemsColumns.IsidColumn].ToString());
     }
     #endregion
     Subitems.DeleteSubitems(isid);
 }
    public void DeleteSubItem(string isid, string pic)
    {
        DataTable dtItem = new DataTable();

        dtItem = Subitems.GetSubItems("", "*", SubitemsTSql.GetSubitemsByIsid(isid), "");
        if (dtItem.Rows.Count > 0)
        {
            string split = TatThanhJsc.AdminModul.Keyword.ParamsSpilitItems;
            #region Xoá trả lời của comment
            DataTable dt = new DataTable();
            dt = Subitems.GetSubItems("", "*", DataExtension.AndConditon(SubitemsTSql.GetSubitemsByVskey(dtItem.Rows[0][SubitemsColumns.VskeyColumn].ToString() + "Reply"), SubitemsTSql.GetSubitemsByVsurl(isid)), "");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                #region Xóa ảnh
                if (dt.Rows[i][SubitemsColumns.VsimageColumn].ToString().IndexOf(split) < 0)
                {
                    ImagesExtension.DeleteImageWhenDeleteItem(pic, dt.Rows[i][SubitemsColumns.VsimageColumn].ToString());
                }
                else
                {
                    foreach (string s in dt.Rows[i][SubitemsColumns.VsimageColumn].ToString().Split(new string[] { split }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        ImagesExtension.DeleteImageWhenDeleteItem(pic, s);
                    }
                }
                #endregion

                Subitems.DeleteSubitems(dt.Rows[i][SubitemsColumns.IsidColumn].ToString());
            }
            #endregion

            #region Xóa ảnh
            if (dtItem.Rows[0][SubitemsColumns.VsimageColumn].ToString().IndexOf(split) < 0)
            {
                ImagesExtension.DeleteImageWhenDeleteItem(pic, dtItem.Rows[0][SubitemsColumns.VsimageColumn].ToString());
            }
            else
            {
                foreach (string s in dtItem.Rows[0][SubitemsColumns.VsimageColumn].ToString().Split(new string[] { split }, StringSplitOptions.RemoveEmptyEntries))
                {
                    ImagesExtension.DeleteImageWhenDeleteItem(pic, s);
                }
            }
            #endregion
            Subitems.DeleteSubitems(isid);
        }
    }
    protected void lnk_delete_user_checked_Click(object sender, EventArgs e)
    {
        string ArrayId = "";

        for (int i = 0; i <= rptList.Items.Count - 1; i++)
        {
            CheckBox chkDelete = (CheckBox)rptList.Items[i].FindControl(("chk_item"));
            if (chkDelete != null)
            {
                if (chkDelete.Checked)
                {
                    ArrayId += chkDelete.ToolTip;
                    ArrayId += ",";
                }
            }
            else
            {
                return;
            }
        }
        if (ArrayId.Length > 0)
        {
            ArrayId = ArrayId.Substring(0, (ArrayId.Length - 1));
        }
        else
        {
            return;
        }

        char[] splitItem = { ',' };


        fields    = DataExtension.GetListColumns(SubitemsColumns.IsidColumn, SubitemsColumns.VsimageColumn);
        condition = " ISID in(" + ArrayId + ") ";
        DataTable dt = new DataTable();

        dt = Subitems.GetSubItems("", fields, condition, "");
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            ImagesExtension.DeleteImageWhenDeleteItem(pathFolderPic, dt.Rows[i][SubitemsColumns.VsimageColumn].ToString());
            Subitems.DeleteSubitems(dt.Rows[i][SubitemsColumns.IsidColumn].ToString());
        }

        chk_list.Checked = false;
        GetList();
    }
    protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        string c = e.CommandName.Trim();
        string p = e.CommandArgument.ToString().Trim();

        fields    = "*";
        condition = SubitemsTSql.GetSubitemsByIsid(p);
        DataTable dt = new DataTable();

        dt = Subitems.GetSubItems("", "*", condition, "");
        switch (c)
        {
            #region Delete
        case "delete":
            ImagesExtension.DeleteImageWhenDeleteItem(pathFolderPic, dt.Rows[0][SubitemsColumns.VsimageColumn].ToString());
            Subitems.DeleteSubitems(p);
            GetList();
            break;

            #endregion
            #region Edit Enable
        case "EditEnable":
            string[] fieldsEnable = { SubitemsColumns.IsenableColumn };
            string[] valuesEnable = { "" };
            if (dt.Rows[0][SubitemsColumns.IsenableColumn].ToString().Equals("0"))
            {
                valuesEnable[0] = "1";
                Subitems.UpdateSubitems(DataExtension.UpdateTransfer(fieldsEnable, valuesEnable), condition);
            }
            else
            {
                valuesEnable[0] = "0";
                Subitems.UpdateSubitems(DataExtension.UpdateTransfer(fieldsEnable, valuesEnable), condition);
            }
            GetList();
            break;

            #endregion
            #region Edit
        case "edit":
            //OpenUpdatePanel(p);
            Response.Redirect(UrlExtension.WebisteUrl + "cms/admin/Moduls/Deal/Item/PopUp/AddVideoToItems.aspx?iid=" + iid + "&isid=" + p);
            break;
            #endregion
        }
    }
Пример #12
0
    protected void btOK_Click(object sender, EventArgs e)
    {
        #region Image
        string vimg = "";
        if (flimg.FileName.Length > 0 && flimg.PostedFile.ContentLength > 0)
        {
            string filename = "";
            filename = System.IO.Path.GetFileName(flimg.PostedFile.FileName);
            string fileex = "";

            fileex = System.IO.Path.GetExtension(filename).ToLower();
            if (fileex == ".jpg" || fileex == ".jpeg" || fileex == ".gif" || fileex == ".png" || fileex == ".bmp" || fileex == ".JPG" || fileex == ".JPEG" || fileex == ".GIF" || fileex == ".PNG" || fileex == ".BMP")
            {
                string fileNotEx = System.IO.Path.GetFileNameWithoutExtension(flimg.PostedFile.FileName);
                vimg = StringExtension.ReplateTitle(fileNotEx) + DateTime.Now.Ticks.ToString() + fileex;
                flimg.SaveAs(Request.PhysicalApplicationPath + "/" + folderpic + "/" + vimg);
            }
        }
        #endregion
        if (hdUpdate.Value == "1")//Cập nhật
        {
            if (vimg.Length > 0)
            {
                string[] fields    = { TatThanhJsc.Columns.LanguageItemColumns.nLanguageItemParams };
                string[] values    = { "N'" + vimg + "'" };
                string   condition = DataExtension.AndConditon(LanguageItemTSql.GetByiLanguageKeyId(iLanguageKeyId),
                                                               LanguageItemTSql.GetByiLanguageNationalId(language));
                LanguageItem.UpdateLanguageItem(DataExtension.UpdateTransfer(fields, values), condition);
                //Xoá ảnh cũ
                ImagesExtension.DeleteImageWhenDeleteItem(folderpic, hdOldImage.Value);
            }
            else
            {
                vimg = hdOldImage.Value;
            }
        }
        else//Thêm mới
        {
            LanguageItem.InsertLanguageItem(language, iLanguageKeyId, "", "", vimg);
        }
        ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('Cập nhật thành công');ChangeImage('img" + iLanguageKeyId + "','" + UrlExtension.WebisteUrl + folderpic + "/" + vimg + "');window.close();", true);
    }
    protected void btSave_Click(object sender, EventArgs e)
    {
        #region Đóng dấu ảnh
        if (cbDongDauAnh.Checked)
        {
            SettingsExtension.SetOtherSettingKey(SettingKey.DongDauAnhTag, "1", language);
        }
        else
        {
            SettingsExtension.SetOtherSettingKey(SettingKey.DongDauAnhTag, "0", language);
        }

        #region Ảnh làm dấu
        if (fulDongDauAnh.PostedFile.ContentLength > 0)
        {
            //Xoá ảnh cũ
            if (hdLogoImage.Value.Length > 0)
            {
                ImagesExtension.DeleteImageWhenDeleteItem(pic, hdLogoImage.Value);
            }

            //Lưu ảnh mới
            string fileName = "";
            if (ImagesExtension.ValidType(fulDongDauAnh.FileName))
            {
                string fileEx = fulDongDauAnh.FileName.Substring(fulDongDauAnh.FileName.LastIndexOf("."));
                fileName = "WatermarkLogo" + fileEx;
                fulDongDauAnh.SaveAs(Request.PhysicalApplicationPath + "/" + pic + "/" + fileName);
                ltrLogoImage.Text = ImagesExtension.GetImage(pic, fileName, "", "", false, false, "");
            }
            SettingsExtension.SetOtherSettingKey(SettingKey.DongDauAnhTag_AnhDau, fileName, language);
        }
        #endregion

        SettingsExtension.SetOtherSettingKey(SettingKey.DongDauAnhTag_ViTri, rbViTriDongDau.SelectedValue, language);
        SettingsExtension.SetOtherSettingKey(SettingKey.DongDauAnhTag_LeNgang, tbLeX.Text, language);
        SettingsExtension.SetOtherSettingKey(SettingKey.DongDauAnhTag_LeDoc, tbLeY.Text, language);
        SettingsExtension.SetOtherSettingKey(SettingKey.DongDauAnhTag_TyLe, tbPhanTram.Text, language);
        SettingsExtension.SetOtherSettingKey(SettingKey.DongDauAnhTag_TrongSuot, tbTrongSuot.Text, language);
        #endregion

        #region Hạn chế kích thước ảnh đại diện
        if (cbHanCheKichThuoc.Checked)
        {
            SettingsExtension.SetOtherSettingKey(SettingKey.HanCheKichThuocAnhTag, "1", language);
        }
        else
        {
            SettingsExtension.SetOtherSettingKey(SettingKey.HanCheKichThuocAnhTag, "0", language);
        }

        SettingsExtension.SetOtherSettingKey(SettingKey.HanCheKichThuocAnhTag_MaxWidth, tbHanCheW.Text, language);
        SettingsExtension.SetOtherSettingKey(SettingKey.HanCheKichThuocAnhTag_MaxHeight, tbHanCheH.Text, language);
        #endregion

        #region Tạo ảnh nhỏ cho ảnh đại diện
        if (cbTaoAnhNho.Checked)
        {
            SettingsExtension.SetOtherSettingKey(SettingKey.TaoAnhNhoChoAnhTag, "1", language);
        }
        else
        {
            SettingsExtension.SetOtherSettingKey(SettingKey.TaoAnhNhoChoAnhTag, "0", language);
        }

        SettingsExtension.SetOtherSettingKey(SettingKey.TaoAnhNhoChoAnhTag_MaxWidth, tbAnhNhoW.Text, language);
        SettingsExtension.SetOtherSettingKey(SettingKey.TaoAnhNhoChoAnhTag_MaxHeight, tbAnhNhoH.Text, language);
        #endregion

        ScriptManager.RegisterStartupScript(this, this.GetType(), "alertSuccess", "ThongBao(3000,'Cập nhật thành công !');", true);
    }
    protected void btn_insert_update_Click(object sender, EventArgs e)
    {
        #region Image
        string vimg       = "";
        string vimg_thumb = "";
        if (flimg.PostedFile.ContentLength > 0)
        {
            string filename = flimg.FileName;
            string fileex   = filename.Substring(filename.LastIndexOf("."));
            string path     = Request.PhysicalApplicationPath + "/" + pic + "/";
            if (ImagesExtension.ValidType(fileex))
            {
                string fileNotEx = StringExtension.ReplateTitle(filename.Remove(filename.LastIndexOf(".") - 1));
                if (fileNotEx.Length > 9)
                {
                    fileNotEx = fileNotEx.Remove(9);
                }
                string ticks = DateTime.Now.Ticks.ToString();
                #region Lưu ảnh đại diện theo 2 trường hợp: tạo ảnh nhỏ hoặc không.
                //Kiểm tra xem có tạo ảnh nhỏ hay ko
                //Nếu không tạo ảnh nhỏ, tên tệp lưu bình thường theo kiểu: tên_tệp.phần_mở_rộng
                //Nếu tạo ảnh nhỏ, tên tệp sẽ theo kiểu: tên_tệp_HasThumb.phần_mở_rộng
                //Khi đó tên tệp ảnh nhỏ sẽ theo kiểu:   tên_tệp_HasThumb_Thumb.phần_mở_rộng
                //Với cách lưu tên ảnh này, khi thực hiện lưu vào csdl chỉ cần lưu tên ảnh gốc
                //khi hiển thị chỉ cần dựa vào tên ảnh gốc để biết ảnh đó có ảnh nhỏ hay không, việc này được thực hiện bởi ImagesExtension.GetImage, lập trình không cần làm gì thêm.
                if (cbTaoAnhNho.Checked)
                {
                    vimg = fileNotEx + "_" + ticks + "_HasThumb" + fileex;
                }
                else
                {
                    vimg = fileNotEx + "_" + ticks + fileex;
                }
                flimg.SaveAs(path + vimg);
                #endregion
                #region Hạn chế kích thước
                if (cbHanCheKichThuoc.Checked)
                {
                    ImagesExtension.ResizeImage(path + vimg, "", tbHanCheW.Text, tbHanCheH.Text);
                }
                #endregion
                #region Đóng dấu ảnh
                if (cbDongDauAnh.Checked)
                {
                    ImagesExtension.CreateWatermark(path + vimg, path + hdLogoImage.Value, hdViTriDongDau.Value, hdLeX.Value, hdLeY.Value, hdTyLe.Value, hdTrongSuot.Value);
                }
                #endregion
                #region Tạo ảnh nhỏ: Thực hiện cuối để đảm bảo ảnh nhỏ cũng có con dấu
                if (cbTaoAnhNho.Checked)
                {
                    vimg_thumb = fileNotEx + "_" + ticks + "_HasThumb_Thumb" + fileex;
                    ImagesExtension.ResizeImage(path + vimg, path + vimg_thumb, tbAnhNhoW.Text, tbAnhNhoH.Text);
                }
                #endregion
            }
        }
        #endregion
        #region Status
        string status = "0";
        if (chk_status.Checked == true)
        {
            status = "1";
        }
        #endregion

        #region Seo
        if (textLinkRewrite.Text.Trim().Equals(""))
        {
            textLinkRewrite.Text = txt_title_modul.Text;
        }
        if (textTagTitle.Text.Trim().Equals(""))
        {
            textTagTitle.Text = txt_title_modul.Text;
        }
        if (textTagKeyword.Text.Trim().Equals(""))
        {
            textTagKeyword.Text = txt_title_modul.Text;
        }
        if (textTagDescription.Text.Trim().Equals(""))
        {
            textTagDescription.Text = txtDesc.Text;
        }
        #endregion

        string content = StringExtension.GhepChuoi("", tbDiaChi.Text, tbDienThoai.Text, tbFax.Text, tbEmail.Text, tbKinhDo.Text, tbViDo.Text);

        #region Insert
        if (insert)
        {
            Groups.InsertGroups(language, app, DdlGroupWebsite.SelectedValue, txt_title_modul.Text, txtDesc.Text, content, textTagTitle.Text, textLinkRewrite.Text, StringExtension.ReplateTitle(textLinkRewrite.Text), textTagKeyword.Text, textTagDescription.Text, "", "", "", vimg, tbTenMien.Text, "", txt_ordermodul.Text, tbCreateDate.Text, DateTime.Now.ToString(), tbEndDate.Text, status);
        }
        #endregion
        #region Update
        else
        {
            if (vimg.Equals(""))
            {
                vimg = hd_img.Value;
            }
            else
            {
                ImagesExtension.DeleteImageWhenDeleteItem(pic, hd_img.Value);
            }
            Groups.UpdateGroups(language, app, txt_title_modul.Text, txtDesc.Text, content, textTagTitle.Text, textLinkRewrite.Text, StringExtension.ReplateTitle(textLinkRewrite.Text), textTagKeyword.Text, textTagDescription.Text, "", "", "", vimg, tbTenMien.Text, "", txt_ordermodul.Text, tbCreateDate.Text, DateTime.Now.ToString(), tbEndDate.Text, status, igid);
            if (DdlGroupWebsite.SelectedValue != hd_parent)
            {
                Groups.UpdateParentOfGroups(igid, DdlGroupWebsite.SelectedValue);
            }
        }
        #endregion

        #region Continue Insert
        if (ckbContinue.Checked == true)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "alertSuccess", "ThongBao(3000, 'Đã tạo: " + txt_title_modul.Text + "');", true);
            ResetControls();
            //Lấy lại danh sách danh mục
            GetGroupsInDdl();
        }
        else
        {
            Response.Redirect(LinkRedrect());
        }
        #endregion
    }
 protected void btnXoaAnhHienTai_Click(object sender, EventArgs e)
 {
     ImagesExtension.DeleteImageWhenDeleteItem(pic, hd_img.Value);
     hd_img.Value = ""; btnXoaAnhHienTai.Visible = false; ltimg.Text = "";
 }
Пример #16
0
    protected void WebUserControl1_btnHandler(string strValue)
    {
        string subconten     = StringExtension.GhepChuoi("", txtLinkQC.Text, ddl_type_open.SelectedValue);
        string contentDetail = StringExtension.GhepChuoi("", ContentExtendtions.ProcessStringContent(txt_content.Text, hdOldContent.Value, pic), txtTitleQC.Text, txtGiaLienHe.Text, txtLienHeNgay.Text);

        #region Image
        string vimg       = "";
        string vimg_thumb = "";
        if (flimg.PostedFile.ContentLength > 0)
        {
            string filename = flimg.FileName;
            string fileex   = filename.Substring(filename.LastIndexOf("."));
            string path     = Request.PhysicalApplicationPath + "/" + pic + "/";
            if (ImagesExtension.ValidType(fileex))
            {
                string fileNotEx = StringExtension.ReplateTitle(filename.Remove(filename.LastIndexOf(".") - 1));
                if (fileNotEx.Length > 9)
                {
                    fileNotEx = fileNotEx.Remove(9);
                }
                string ticks = DateTime.Now.Ticks.ToString();
                #region Lưu ảnh đại diện theo 2 trường hợp: tạo ảnh nhỏ hoặc không.
                //Kiểm tra xem có tạo ảnh nhỏ hay ko
                //Nếu không tạo ảnh nhỏ, tên tệp lưu bình thường theo kiểu: tên_tệp.phần_mở_rộng
                //Nếu tạo ảnh nhỏ, tên tệp sẽ theo kiểu: tên_tệp_HasThumb.phần_mở_rộng
                //Khi đó tên tệp ảnh nhỏ sẽ theo kiểu:   tên_tệp_HasThumb_Thumb.phần_mở_rộng
                //Với cách lưu tên ảnh này, khi thực hiện lưu vào csdl chỉ cần lưu tên ảnh gốc
                //khi hiển thị chỉ cần dựa vào tên ảnh gốc để biết ảnh đó có ảnh nhỏ hay không, việc này được thực hiện bởi ImagesExtension.GetImage, lập trình không cần làm gì thêm.
                if (cbTaoAnhNho.Checked)
                {
                    vimg = fileNotEx + "_" + ticks + "_HasThumb" + fileex;
                }
                else
                {
                    vimg = fileNotEx + "_" + ticks + fileex;
                }
                flimg.SaveAs(path + vimg);
                #endregion
                #region Hạn chế kích thước
                if (cbHanCheKichThuoc.Checked)
                {
                    ImagesExtension.ResizeImage(path + vimg, "", tbHanCheW.Text, tbHanCheH.Text);
                }
                #endregion
                #region Đóng dấu ảnh
                if (cbDongDauAnh.Checked)
                {
                    ImagesExtension.CreateWatermark(path + vimg, path + hdLogoImage.Value, hdViTriDongDau.Value, hdLeX.Value, hdLeY.Value, hdTyLe.Value, hdTrongSuot.Value);
                }
                #endregion
                #region Tạo ảnh nhỏ: Thực hiện cuối để đảm bảo ảnh nhỏ cũng có con dấu
                if (cbTaoAnhNho.Checked)
                {
                    vimg_thumb = fileNotEx + "_" + ticks + "_HasThumb_Thumb" + fileex;
                    ImagesExtension.ResizeImage(path + vimg, path + vimg_thumb, tbAnhNhoW.Text, tbAnhNhoH.Text);
                }
                #endregion
            }
        }
        #endregion
        #region Status
        string status           = "0";
        string checkDisplayHome = "0";
        if (chk_status.Checked == true)
        {
            status = "1";
        }
        if (chk_DisplayHome.Checked)
        {
            checkDisplayHome = "1";
        }
        #endregion

        #region Seo
        if (textLinkRewrite.Text.Trim().Equals(""))
        {
            textLinkRewrite.Text = txt_title_modul.Text;
        }
        if (textTagTitle.Text.Trim().Equals(""))
        {
            textTagTitle.Text = txt_title_modul.Text;
        }
        if (textTagKeyword.Text.Trim().Equals(""))
        {
            textTagKeyword.Text = txt_title_modul.Text;
        }
        if (textTagDescription.Text.Trim().Equals(""))
        {
            textTagDescription.Text = txtDesc.Text;
        }
        #endregion

        #region Insert
        if (insert)
        {
            Groups.InsertGroups(language, app, DdlGroupProduct.SelectedValue, txt_title_modul.Text, txtDesc.Text, contentDetail, textTagTitle.Text, textLinkRewrite.Text, StringExtension.ReplateTitle(textLinkRewrite.Text), textTagKeyword.Text, textTagDescription.Text, checkDisplayHome, subconten, dlTypeGroup.SelectedValue, vimg, "", "", txt_ordermodul.Text, DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), status);

            #region Logs
            string logAuthor     = CookieExtension.GetCookies("LoginSetting");
            string logCreateDate = DateTime.Now.ToString();
            Logs.InsertLogs(logCreateDate, Request.Url.ToString(), "", txt_title_modul.Text, logAuthor, "", logCreateDate + ": " + logAuthor + " tạo mới " + txt_title_modul.Text);
            #endregion
        }
        #endregion
        #region Update
        else
        {
            if (vimg.Equals(""))
            {
                vimg = hd_img.Value;
            }
            else
            {
                ImagesExtension.DeleteImageWhenDeleteItem(pic, hd_img.Value);
            }
            Groups.UpdateGroups(language, app, txt_title_modul.Text, txtDesc.Text, contentDetail, textTagTitle.Text, textLinkRewrite.Text, StringExtension.ReplateTitle(textLinkRewrite.Text), textTagKeyword.Text, textTagDescription.Text, checkDisplayHome, subconten, dlTypeGroup.SelectedValue, vimg, "", "", txt_ordermodul.Text, DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), status, igid);
            if (DdlGroupProduct.SelectedValue != hd_parent)
            {
                Groups.UpdateParentOfGroups(igid, DdlGroupProduct.SelectedValue);
            }

            #region Logs
            string logAuthor     = CookieExtension.GetCookies("LoginSetting");
            string logCreateDate = DateTime.Now.ToString();
            Logs.InsertLogs(logCreateDate, Request.Url.ToString(), "", txt_title_modul.Text, logAuthor, "", logCreateDate + ": " + logAuthor + " cập nhật " + txt_title_modul.Text);
            #endregion
        }
        #endregion


        #region After Insert/Update

        if (ckbContinue.Checked == true)
        {
            //ScriptManager.RegisterStartupScript(this, this.GetType(), "alertSuccess",
            //    "ThongBao(3000,'Đã tạo: " + txt_title.Text + "');", true);
            //Lưu vào session để gọi đến bên api
            Session["CotinuteCreateCate"]      = true;
            Session["CotinuteCreateTitleCate"] = txt_title_modul.Text;
            ResetControls();
            GetGroupsInDdl();
        }
        else
        {
            Session["CotinuteCreateCate"]             = false;
            Session["CotinuteCreateRedirectLinkCate"] = LinkRedrect();
        }

        #endregion
    }
Пример #17
0
 protected void lnk_delete_Image_current_Click(object sender, EventArgs e)
 {
     ImagesExtension.DeleteImageWhenDeleteItem(pic, hd_img.Value);
     ltimg.Visible = false;
     hd_img.Value  = "";
 }
    protected void btn_save_Click(object sender, EventArgs e)
    {
        #region Image
        string vimg = "";
        if (flimg.FileName.Length > 0 && flimg.PostedFile.ContentLength > 0)
        {
            string filename = "";
            filename = System.IO.Path.GetFileName(flimg.PostedFile.FileName);
            string fileex = "";

            fileex = System.IO.Path.GetExtension(filename).ToLower();
            if (fileex == ".jpg" || fileex == ".gif" || fileex == ".png" || fileex == ".bmp")
            {
                string fileNotEx = System.IO.Path.GetFileNameWithoutExtension(flimg.PostedFile.FileName);
                vimg = StringExtension.ReplateTitle(fileNotEx) + DateTime.Now.Ticks.ToString() + fileex;
                flimg.SaveAs(Request.PhysicalApplicationPath + "/" + FolderPic.SystemWebsite + "/" + vimg);
            }
        }
        #endregion
        if (vimg.Equals(""))
        {
            vimg = hd_img.Value;
        }
        if (!vimg.Equals(hd_img.Value))
        {
            ImagesExtension.DeleteImageWhenDeleteItem(pic, hd_img.Value);
        }
        SettingsExtension.SetOtherSettingKey(SettingsExtension.KeyLogoAdminWebsite, vimg, language);


        #region Image Map
        string vImageMap = "";
        if (FlMap.FileName.Length > 0 && FlMap.PostedFile.ContentLength > 0)
        {
            string filename = "";
            filename = System.IO.Path.GetFileName(FlMap.PostedFile.FileName);
            string fileex = "";
            fileex = System.IO.Path.GetExtension(filename).ToLower();
            if (fileex == ".ico")
            {
                string fileNotEx = System.IO.Path.GetFileNameWithoutExtension(FlMap.PostedFile.FileName);
                vImageMap = fileNotEx + DateTime.Now.Ticks.ToString() + fileex;
                FlMap.SaveAs(Request.PhysicalApplicationPath + "/" + FolderPic.SystemWebsite + "/" + vImageMap);
            }
        }
        #endregion

        if (vImageMap.Equals(""))
        {
            vImageMap = HdImageMap.Value;
        }
        if (!vImageMap.Equals(HdImageMap.Value))
        {
            ImagesExtension.DeleteImageWhenDeleteItem(pic, HdImageMap.Value);
        }
        SettingsExtension.SetOtherSettingKey(SettingsExtension.KeyFavicon, vImageMap, language);


        #region Image share
        string vimgFacebook = "";
        if (flimgFacebook.FileName.Length > 0 && flimgFacebook.PostedFile.ContentLength > 0)
        {
            string filename = "";
            filename = System.IO.Path.GetFileName(flimgFacebook.PostedFile.FileName);
            string fileex = "";

            fileex = System.IO.Path.GetExtension(filename).ToLower();
            if (fileex == ".jpg" || fileex == ".gif" || fileex == ".png" || fileex == ".bmp")
            {
                string fileNotEx = System.IO.Path.GetFileNameWithoutExtension(flimgFacebook.PostedFile.FileName);
                vimgFacebook = StringExtension.ReplateTitle(fileNotEx) + DateTime.Now.Ticks.ToString() + fileex;
                flimgFacebook.SaveAs(Request.PhysicalApplicationPath + "/" + FolderPic.SystemWebsite + "/" + vimgFacebook);
            }
        }
        #endregion
        if (vimgFacebook.Equals(""))
        {
            vimgFacebook = hd_imgFacebook.Value;
        }
        if (!vimgFacebook.Equals(hd_imgFacebook.Value))
        {
            ImagesExtension.DeleteImageWhenDeleteItem(pic, HdImageMap.Value);
        }
        SettingsExtension.SetOtherSettingKey("LogoShareHomepage", vimgFacebook, language);


        string content1   = ContentExtendtions.ProcessStringContent(txt_content_footer.Text, hdOldValue.Value, pic);
        string contenttop = ContentExtendtions.ProcessStringContent(txt_content_footer_top.Text, hdOldValueTop.Value, pic);

        SettingsExtension.SetOtherSettingKey(SettingsExtension.KeyContentFooterWebsite, content1, language);
        SettingsExtension.SetOtherSettingKey(SettingsExtension.KeyContentFooterWebsite + "Top", contenttop, language);

        SettingsExtension.SetOtherSettingKey(SettingsExtension.KeyPhoneContact, TextPhoneContact.Text, language);
        SettingsExtension.SetOtherSettingKey(SettingsExtension.KeyHotLine, TextHotLine.Text, language);
        SettingsExtension.SetOtherSettingKey("KeyContactEmail", tbEmail.Text, language);

        SettingsExtension.SetOtherSettingKey("YoutubeVideo", tbYoutubeVideo.Text, language);
        SettingsExtension.SetOtherSettingKey("KeyLinkFanPageFaceBook", tbKeyLinkFanPageFaceBook.Text, language);
        SettingsExtension.SetOtherSettingKey("KeyLinkFanPageGPlus", tbKeyLinkFanPageGPlus.Text, language);
        SettingsExtension.SetOtherSettingKey("KeyLinkFanPageTwitter", tbKeyLinkFanPageTwitter.Text, language);

        SettingsExtension.SetOtherSettingKey("KeyCurrency", ddlCurrency.SelectedValue, language);

        GetContentInControl();

        #region Logs
        string logAuthor     = CookieExtension.GetCookies("LoginSetting");
        string logCreateDate = DateTime.Now.ToString();
        Logs.InsertLogs(logCreateDate, Request.Url.ToString(), "", "Thông tin chung", logAuthor,
                        "",
                        logCreateDate + ": " + logAuthor + " cập nhật thông tin hệ thống (Thông tin chung)");

        #endregion
    }
    protected void btSave_Click(object sender, EventArgs e)
    {
        SettingsExtension.SetOtherSettingKey(SettingKey.SoProductTrenTrangChu, tbSoProductTrenTrangChu.Text, language);
        SettingsExtension.SetOtherSettingKey(SettingKey.SoProductKhacTrenMotTrang, tbSoProductKhacTrenMotTrang.Text, language);
        SettingsExtension.SetOtherSettingKey(SettingKey.SoProductTrenTrangDanhMuc, tbSoProductTrenTrangDanhMuc.Text, language);

        SettingsExtension.SetOtherSettingKey(SettingKey.NoiDungDauDonHang, tbDauDonHang.Text, language);
        SettingsExtension.SetOtherSettingKey(SettingKey.NoiDungCuoiDonHang, tbCuoiDonHang.Text, language);
        SettingsExtension.SetOtherSettingKey("KeyThongBaoSauDatHang", txtThongBaoCart.Text, language);
        SettingsExtension.SetOtherSettingKey("KeyNoiDungTaiTrangDatHang", tbNoiDungTaiTrangDatHang.Text, language);

        SettingsExtension.SetOtherSettingKey("NoiDungCuoiTrangDanhMucSanPham", tbNoiDungCuoiTrangDanhMucSanPham.Text, language);
        SettingsExtension.SetOtherSettingKey("PhoneBuyProductN", txtPhoneBuyProduct.Text, language);
        SettingsExtension.SetOtherSettingKey("KeyLuuY", tbKeyLuuY.Text, language);

        SettingsExtension.SetOtherSettingKey("ThongTinChuyenKhoanTaiTrangGioHang", tbThongTinChuyenKhoanTaiTrangGioHang.Text, language);

        #region Đóng dấu ảnh
        if (cbDongDauAnh.Checked)
        {
            SettingsExtension.SetOtherSettingKey(SettingKey.DongDauAnhProduct, "1", language);
        }
        else
        {
            SettingsExtension.SetOtherSettingKey(SettingKey.DongDauAnhProduct, "0", language);
        }

        #region Ảnh làm dấu
        if (fulDongDauAnh.PostedFile.ContentLength > 0)
        {
            //Xoá ảnh cũ
            if (hdLogoImage.Value.Length > 0)
            {
                ImagesExtension.DeleteImageWhenDeleteItem(pic, hdLogoImage.Value);
            }

            //Lưu ảnh mới
            string fileName = "";
            if (ImagesExtension.ValidType(fulDongDauAnh.FileName))
            {
                string fileEx = fulDongDauAnh.FileName.Substring(fulDongDauAnh.FileName.LastIndexOf("."));
                fileName = "WatermarkLogo" + fileEx;
                fulDongDauAnh.SaveAs(Request.PhysicalApplicationPath + "/" + pic + "/" + fileName);
                ltrLogoImage.Text = ImagesExtension.GetImage(pic, fileName, "", "", false, false, "");
            }
            SettingsExtension.SetOtherSettingKey(SettingKey.DongDauAnhProduct_AnhDau, fileName, language);
        }
        #endregion

        SettingsExtension.SetOtherSettingKey(SettingKey.DongDauAnhProduct_ViTri, rbViTriDongDau.SelectedValue, language);
        SettingsExtension.SetOtherSettingKey(SettingKey.DongDauAnhProduct_LeNgang, tbLeX.Text, language);
        SettingsExtension.SetOtherSettingKey(SettingKey.DongDauAnhProduct_LeDoc, tbLeY.Text, language);
        SettingsExtension.SetOtherSettingKey(SettingKey.DongDauAnhProduct_TyLe, tbPhanTram.Text, language);
        SettingsExtension.SetOtherSettingKey(SettingKey.DongDauAnhProduct_TrongSuot, tbTrongSuot.Text, language);
        #endregion

        #region Hạn chế kích thước ảnh đại diện
        if (cbHanCheKichThuoc.Checked)
        {
            SettingsExtension.SetOtherSettingKey(SettingKey.HanCheKichThuocAnhProduct, "1", language);
        }
        else
        {
            SettingsExtension.SetOtherSettingKey(SettingKey.HanCheKichThuocAnhProduct, "0", language);
        }

        SettingsExtension.SetOtherSettingKey(SettingKey.HanCheKichThuocAnhProduct_MaxWidth, tbHanCheW.Text, language);
        SettingsExtension.SetOtherSettingKey(SettingKey.HanCheKichThuocAnhProduct_MaxHeight, tbHanCheH.Text, language);
        #endregion

        #region Tạo ảnh nhỏ cho ảnh đại diện
        if (cbTaoAnhNho.Checked)
        {
            SettingsExtension.SetOtherSettingKey(SettingKey.TaoAnhNhoChoAnhProduct, "1", language);
        }
        else
        {
            SettingsExtension.SetOtherSettingKey(SettingKey.TaoAnhNhoChoAnhProduct, "0", language);
        }

        SettingsExtension.SetOtherSettingKey(SettingKey.TaoAnhNhoChoAnhProduct_MaxWidth, tbAnhNhoW.Text, language);
        SettingsExtension.SetOtherSettingKey(SettingKey.TaoAnhNhoChoAnhProduct_MaxHeight, tbAnhNhoH.Text, language);
        #endregion

        SaveConfigs();

        ScriptManager.RegisterStartupScript(this, this.GetType(), "alertSuccess", "ThongBao(3000,'Cập nhật thành công !');", true);
    }
Пример #20
0
    protected void btOK_Click(object sender, EventArgs e)
    {
        if (CheckExistedAcount(tbTenDangNhap.Text, insert, SecurityExtension.Decode(hdTenDangNhap.Value)))
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "alertSuccess", "ThongBao(3000,'Tên đăng nhập này đã được sử dụng. Vui lòng chọn tên đăng nhập khác.');", true);
            tbTenDangNhap.Focus();
            return;
        }

        if (CheckExistedEmail(tbEmail.Text, insert, SecurityExtension.Decode(hdTenDangNhap.Value)))
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "alertSuccess", "ThongBao(3000,'Email này đã được sử dụng. Vui lòng chọn email khác.');", true);
            tbEmail.Focus();
            return;
        }

        if (tbNgaySinh.Text.Length < 1)
        {
            tbNgaySinh.Text = DateTime.Now.AddYears(-20).ToString();
        }

        #region Image
        string vimg       = "";
        string vimg_thumb = "";
        if (flimg.PostedFile.ContentLength > 0)
        {
            string filename = flimg.FileName;
            string fileex   = filename.Substring(filename.LastIndexOf("."));
            string path     = Request.PhysicalApplicationPath + "/" + pic + "/";
            if (TatThanhJsc.Extension.ImagesExtension.ValidType(fileex))
            {
                string fileNotEx = StringExtension.ReplateTitle(filename.Remove(filename.LastIndexOf(".") - 1));
                if (fileNotEx.Length > 9)
                {
                    fileNotEx = fileNotEx.Remove(9);
                }
                string ticks = DateTime.Now.Ticks.ToString();
                #region Lưu ảnh đại diện theo 2 trường hợp: tạo ảnh nhỏ hoặc không.
                //Kiểm tra xem có tạo ảnh nhỏ hay ko
                //Nếu không tạo ảnh nhỏ, tên tệp lưu bình thường theo kiểu: tên_tệp.phần_mở_rộng
                //Nếu tạo ảnh nhỏ, tên tệp sẽ theo kiểu: tên_tệp_HasThumb.phần_mở_rộng
                //Khi đó tên tệp ảnh nhỏ sẽ theo kiểu:   tên_tệp_HasThumb_Thumb.phần_mở_rộng
                //Với cách lưu tên ảnh này, khi thực hiện lưu vào csdl chỉ cần lưu tên ảnh gốc
                //khi hiển thị chỉ cần dựa vào tên ảnh gốc để biết ảnh đó có ảnh nhỏ hay không, việc này được thực hiện bởi TatThanhJsc.Extension.ImagesExtension.GetImage, lập trình không cần làm gì thêm.
                if (cbTaoAnhNho.Checked)
                {
                    vimg = fileNotEx + "_" + ticks + "_HasThumb" + fileex;
                }
                else
                {
                    vimg = fileNotEx + "_" + ticks + fileex;
                }
                flimg.SaveAs(path + vimg);
                #endregion
                #region Hạn chế kích thước
                if (cbHanCheKichThuoc.Checked)
                {
                    ImagesExtension.ResizeImage(path + vimg, "", tbHanCheW.Text, tbHanCheH.Text);
                }
                #endregion
                #region Đóng dấu ảnh
                if (cbDongDauAnh.Checked)
                {
                    ImagesExtension.CreateWatermark(path + vimg, path + hdLogoImage.Value, hdViTriDongDau.Value, hdLeX.Value, hdLeY.Value, hdTyLe.Value, hdTrongSuot.Value);
                }
                #endregion
                #region Tạo ảnh nhỏ: Thực hiện cuối để đảm bảo ảnh nhỏ cũng có con dấu
                if (cbTaoAnhNho.Checked)
                {
                    vimg_thumb = fileNotEx + "_" + ticks + "_HasThumb_Thumb" + fileex;
                    ImagesExtension.ResizeImage(path + vimg, path + vimg_thumb, tbAnhNhoW.Text, tbAnhNhoH.Text);
                }
                #endregion
            }
        }

        #endregion



        #region Insert
        if (insert)
        {
            Members.InsertMembers(
                app, tbTenDangNhap.Text, tbMatKhau.Text, tbHoTen.Text, tbDiaChi.Text, tbDienThoai.Text,
                tbEmail.Text, tbNgaySinh.Text, ddlGioiTinh.SelectedValue, tbQuanHeXaHoi.Text, tbTrinhDoHocVan.Text, tbNgheNghiep.Text,
                "", vimg, "", "", ddlKichHoat.Text, ddlTrangThai.SelectedValue, "", "0", "0",
                tbCanNang.Text, tbChieuCao.Text, tbCauGioiThieuNgan.Text);

            #region Logs
            string logAuthor     = CookieExtension.GetCookies("LoginSetting");
            string logCreateDate = DateTime.Now.ToString();
            Logs.InsertLogs(logCreateDate, Request.Url.ToString(), "", tbTenDangNhap.Text, logAuthor, "", logCreateDate + ": " + logAuthor + " tạo mới thành viên " + tbTenDangNhap.Text);
            #endregion
        }
        #endregion
        #region Update
        else
        {
            if (vimg.Equals(""))
            {
                vimg = hd_img.Value;
            }
            else
            {
                ImagesExtension.DeleteImageWhenDeleteItem(pic, hd_img.Value);
            }

            Members.UpdateMembersInfo(imid, hdvProperty.Value, SecurityExtension.Decode(hdTenDangNhap.Value), tbHoTen.Text,
                                      tbDiaChi.Text, tbDienThoai.Text, tbEmail.Text, tbNgaySinh.Text, ddlGioiTinh.SelectedValue,
                                      tbQuanHeXaHoi.Text, tbTrinhDoHocVan.Text, tbNgheNghiep.Text, hdvMemberYahooNick.Value, vimg,
                                      hdvMemberPasswordQuestion.Value, hdvMemberPasswordAnswer.Value,
                                      ddlKichHoat.SelectedValue, ddlTrangThai.SelectedValue, hdvMemberComment.Value, hdiMemberTotalLogin.Value, hdiMemberTotalview.Value,
                                      tbCanNang.Text, tbChieuCao.Text, tbCauGioiThieuNgan.Text);

            if (tbMatKhau.Text.Length > 0 && tbMatKhau.Text == tbNhapLaiMatKhau.Text)
            {
                Members.UpdateMembersPasswordByAccount(SecurityExtension.Decode(hdTenDangNhap.Value), tbMatKhau.Text);
            }

            #region Logs
            string logAuthor     = CookieExtension.GetCookies("LoginSetting");
            string logCreateDate = DateTime.Now.ToString();
            Logs.InsertLogs(logCreateDate, Request.Url.ToString(), "", tbTenDangNhap.Text, logAuthor, "", logCreateDate + ": " + logAuthor + " cập nhật thành viên " + tbTenDangNhap.Text);
            #endregion
        }
        #endregion

        #region After Insert/Update
        if (cbTiepTuc.Checked)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "alertSuccess", "ThongBao(3000,'Đã tạo: " + tbTenDangNhap.Text + "');", true);
            ResetControls();
        }
        else
        {
            Response.Redirect(LinkRedirect());
        }
        #endregion
    }
    protected void btOK_Click(object sender, EventArgs e)
    {
        #region Image
        string vimg       = "";
        string vimg_thumb = "";
        if (flimg.PostedFile.ContentLength > 0)
        {
            string filename = flimg.FileName;
            string fileex   = filename.Substring(filename.LastIndexOf("."));
            string path     = Request.PhysicalApplicationPath + "/" + pathFolderPic + "/";
            if (ImagesExtension.ValidType(fileex))
            {
                string fileNotEx = StringExtension.ReplateTitle(filename.Remove(filename.LastIndexOf(".") - 1));
                if (fileNotEx.Length > 9)
                {
                    fileNotEx = fileNotEx.Remove(9);
                }
                string ticks = DateTime.Now.Ticks.ToString();
                #region Lưu ảnh đại diện theo 2 trường hợp: tạo ảnh nhỏ hoặc không.
                //Kiểm tra xem có tạo ảnh nhỏ hay ko
                //Nếu không tạo ảnh nhỏ, tên tệp lưu bình thường theo kiểu: tên_tệp.phần_mở_rộng
                //Nếu tạo ảnh nhỏ, tên tệp sẽ theo kiểu: tên_tệp_HasThumb.phần_mở_rộng
                //Khi đó tên tệp ảnh nhỏ sẽ theo kiểu:   tên_tệp_HasThumb_Thumb.phần_mở_rộng
                //Với cách lưu tên ảnh này, khi thực hiện lưu vào csdl chỉ cần lưu tên ảnh gốc
                //khi hiển thị chỉ cần dựa vào tên ảnh gốc để biết ảnh đó có ảnh nhỏ hay không, việc này được thực hiện bởi ImagesExtension.GetImage, lập trình không cần làm gì thêm.
                if (cbTaoAnhNho.Checked)
                {
                    vimg = fileNotEx + "_" + ticks + "_HasThumb" + fileex;
                }
                else
                {
                    vimg = fileNotEx + "_" + ticks + fileex;
                }
                flimg.SaveAs(path + vimg);
                #endregion
                #region Hạn chế kích thước
                if (cbHanCheKichThuoc.Checked)
                {
                    ImagesExtension.ResizeImage(path + vimg, "", tbHanCheW.Text, tbHanCheH.Text);
                }
                #endregion
                #region Đóng dấu ảnh
                if (cbDongDauAnh.Checked)
                {
                    ImagesExtension.CreateWatermark(path + vimg, path + hdLogoImage.Value, hdViTriDongDau.Value, hdLeX.Value, hdLeY.Value, hdTyLe.Value, hdTrongSuot.Value);
                }
                #endregion
                #region Tạo ảnh nhỏ: Thực hiện cuối để đảm bảo ảnh nhỏ cũng có con dấu
                if (cbTaoAnhNho.Checked)
                {
                    vimg_thumb = fileNotEx + "_" + ticks + "_HasThumb_Thumb" + fileex;
                    ImagesExtension.ResizeImage(path + vimg, path + vimg_thumb, tbAnhNhoW.Text, tbAnhNhoH.Text);
                }
                #endregion
            }
        }
        #endregion

        /*
         * Thêm mới video
         * modul - vskey,vsemail - mã màu,vstitle - tên, vsimage - video, vsauthor - thứ tự, isenable - trạng thái
         */

        string videoCode = tbYoutubecode.Text;                                          //viauthor: Mã nhúng video do người dùng nhập vào
        string videoKey  = TatThanhJsc.Extension.VideoExtension.GetVideoKey(videoCode); //viurl: Mã của video được tách ra từ khối mã người dùng nhập vào (chỉ chứa id của video đó, không chứa các thông tin khác -> phục vụ khi lấy ra hiển thị dễ dàng hơn)

        if (!update)
        {
            Subitems.InsertSubitems(iid, language, app, tbName.Text, "", vimg, videoCode, tbOrder.Text, videoKey, DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), ddlStatus.SelectedValue);
        }
        else
        {
            if (vimg.Equals(""))
            {
                vimg = hd_img;
            }
            else
            {
                ImagesExtension.DeleteImageWhenDeleteItem(pathFolderPic, hd_img);
            }
            Subitems.UpdateSubitems(iid, language, app, tbName.Text, "", vimg, videoCode, tbOrder.Text, videoKey, DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), ddlStatus.SelectedValue, currentIsid.Value);
        }

        ResetControls();
        GetList();
        pnList.Visible   = true;
        pnInsert.Visible = false;
    }
Пример #22
0
    protected void BtnOk_Click(object sender, EventArgs e)
    {
        #region Image
        string vimg = "";
        if (flimg.FileName.Length > 0 && flimg.PostedFile.ContentLength > 0)
        {
            string filename = "";
            filename = System.IO.Path.GetFileName(flimg.PostedFile.FileName);
            string fileex = "";
            fileex = System.IO.Path.GetExtension(filename).ToLower();
            string fileNotEx = System.IO.Path.GetFileNameWithoutExtension(flimg.PostedFile.FileName);
            if (fileNotEx.Length > 10)
            {
                fileNotEx = fileNotEx.Remove(10);
            }
            vimg = StringExtension.ReplateTitle(fileNotEx) + DateTime.Now.Ticks.ToString() + fileex;
            flimg.SaveAs(Request.PhysicalApplicationPath + "/" + pic + "/" + vimg);
        }
        #endregion
        #region Status
        string status = "0";
        if (ChkStatus.Checked == true)
        {
            status = "1";
        }
        #endregion
        if (HdInsertUpdate == true)
        {
            LanguageNational.InsertLanguageNational(TbNameNational.Text, vimg, TbOrder.Text, status);

            #region Logs
            string logAuthor     = CookieExtension.GetCookies("LoginSetting");
            string logCreateDate = DateTime.Now.ToString();
            Logs.InsertLogs(logCreateDate, Request.Url.ToString(), "", TbNameNational.Text, logAuthor, "", logCreateDate + ": " + logAuthor + " tạo mới ngôn ngữ " + TbNameNational.Text);
            #endregion
        }
        else
        {
            if (vimg.Equals(""))
            {
                vimg = HdFlagNational.Value;
            }
            else
            {
                ImagesExtension.DeleteImageWhenDeleteItem(pic, HdFlagNational.Value);
            }
            LanguageNational.UpdateLanguageNational(iLanguageNationalId, TbNameNational.Text, vimg, TbOrder.Text, status);

            #region Logs
            string logAuthor     = CookieExtension.GetCookies("LoginSetting");
            string logCreateDate = DateTime.Now.ToString();
            Logs.InsertLogs(logCreateDate, Request.Url.ToString(), "", TbNameNational.Text, logAuthor, "", logCreateDate + ": " + logAuthor + " cập nhật ngôn ngữ " + TbNameNational.Text);
            #endregion
        }
        if (pnTiepTuc.Visible)
        {
            if (ckTiepTuc.Checked)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alertSuccess", "ThongBao(3000, 'Đã tạo: " + TbNameNational.Text + "');", true);
                TbNameNational.Text = "";
                TbOrder.Text        = "";
            }
            else
            {
                Response.Redirect(LinkAdmin.GoAdminSubModul(CodeApplications.Language, "national"));
            }
        }
        else
        {
            Response.Redirect(LinkAdmin.GoAdminSubModul(CodeApplications.Language, "national"));
        }
    }
Пример #23
0
    protected void btOK_Click(object sender, EventArgs e)
    {
        #region Vgparams: là menu(0) hay trang nội dung (1) - Mở ra trang mới(1) hay không(0) - Mô tả menu - Đơn cấp(0) hay đa cấp(1) - Tiêu đề bài viết nếu menu là trang nội dung
        string vgparams = StringExtension.GhepChuoi(TatThanhJsc.AdminModul.Keyword.ParamsSpilitItems, "0", ddlNewTabOption.SelectedValue);
        #endregion
        #region Image
        string vImg = "";
        if (flimg.FileName.Length > 0 && flimg.PostedFile.ContentLength > 0)
        {
            string filename = flimg.FileName;
            string fileex   = filename.Substring(filename.LastIndexOf("."));
            if (ImagesExtension.ValidType(fileex))
            {
                string fileNotEx = System.IO.Path.GetFileNameWithoutExtension(flimg.PostedFile.FileName);
                if (fileNotEx.Length > 10)
                {
                    fileNotEx = fileNotEx.Remove(10);
                }
                vImg = StringExtension.ReplateTitle(fileNotEx) + DateTime.Now.Ticks.ToString() + fileex;
                flimg.SaveAs(Request.PhysicalApplicationPath + "/" + pic + "/" + vImg);
            }
        }
        #endregion
        #region ImageHover
        string vImgHover = "";
        if (flimgHover.FileName.Length > 0 && flimgHover.PostedFile.ContentLength > 0)
        {
            string filename = flimgHover.FileName;
            string fileex   = filename.Substring(filename.LastIndexOf("."));
            if (ImagesExtension.ValidType(fileex))
            {
                string fileNotEx = System.IO.Path.GetFileNameWithoutExtension(flimgHover.PostedFile.FileName);
                if (fileNotEx.Length > 10)
                {
                    fileNotEx = fileNotEx.Remove(10);
                }
                vImgHover = fileNotEx + DateTime.Now.Ticks.ToString() + fileex;
                flimgHover.SaveAs(Request.PhysicalApplicationPath + "/" + pic + "/" + vImgHover);
            }
        }
        #endregion
        #region Status
        string status = "0";
        if (cbStatus.Checked == true)
        {
            status = "1";
        }
        #endregion
        #region Seo
        string sSeo = "";
        if (tbLinkRewrite.Text.Equals(""))
        {
            tbLinkRewrite.Text = tbTagTitle.Text;
        }
        if (tbTagTitle.Text.Equals(""))
        {
            tbTagTitle.Text = tbTagTitle.Text;
        }

        #endregion
        #region Insert
        if (insert)
        {
            string[] image       = { "", vImg, vImgHover };
            string   imageInsert = StringExtension.GhepChuoi(TatThanhJsc.AdminModul.Keyword.ParamsSpilitItems, image);
            Groups.InsertGroups(language, app, ddlParrentCategories.SelectedValue, tbTitle.Text, tbUrl.Text, "", tbTagTitle.Text, tbLinkRewrite.Text, StringExtension.ReplateTitle(tbLinkRewrite.Text), tbTagKeyword.Text, tbTagDescription.Text, "", "", "", imageInsert, vgparams, "0", tbOrder.Text, DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), status);

            if (pnTiepTucMenu.Visible)
            {
                if (cbContinue.Checked)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alertSuccess", "ThongBao(3000, 'Đã tạo: " + tbTitle.Text + "');", true);
                    ResetMenuControls();
                }
                else
                {
                    #region After Insert/Update
                    ResetMenuControls();
                    Response.Redirect(LinkRedirect());
                    #endregion
                }
            }
            else
            {
                #region After Insert/Update
                ResetMenuControls();
                Response.Redirect(LinkRedirect());
                #endregion
            }
        }
        #endregion
        #region Update
        else
        {
            if (vImg.Equals(""))
            {
                vImg = hdImg.Value;
            }
            else
            {
                ImagesExtension.DeleteImageWhenDeleteItem(pic, hdImg.Value);
            }

            if (vImgHover.Equals(""))
            {
                vImgHover = hdImg2.Value;
            }
            else
            {
                ImagesExtension.DeleteImageWhenDeleteItem(pic, hdImg2.Value);
            }

            string[] image       = { "", vImg, vImgHover };
            string   imageInsert = StringExtension.GhepChuoi(TatThanhJsc.AdminModul.Keyword.ParamsSpilitItems, image);
            Groups.UpdateGroups(language, app, tbTitle.Text, tbUrl.Text, "", tbTagTitle.Text, tbLinkRewrite.Text, StringExtension.ReplateTitle(tbLinkRewrite.Text), tbTagKeyword.Text, tbTagDescription.Text, "", "", "", imageInsert, vgparams, hdTotalItem.Value, tbOrder.Text, DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), status, igid);

            if (ddlParrentCategories.SelectedValue != hd_parent)
            {
                Groups.UpdateParentOfGroups(igid, ddlParrentCategories.SelectedValue);
            }
            #region After Insert/Update
            ResetMenuControls();
            Response.Redirect(LinkRedirect());
            #endregion
        }
        #endregion
    }
    protected void btOK_Click(object sender, EventArgs e)
    {
        #region Image
        string vimg       = "";
        string vimg_thumb = "";
        if (flimg.PostedFile.ContentLength > 0)
        {
            string filename = flimg.FileName;
            string fileex   = filename.Substring(filename.LastIndexOf("."));
            string path     = Request.PhysicalApplicationPath + "/" + pathFolderPic + "/";
            if (ImagesExtension.ValidType(fileex))
            {
                string fileNotEx = StringExtension.ReplateTitle(filename.Remove(filename.LastIndexOf(".") - 1));
                if (fileNotEx.Length > 9)
                {
                    fileNotEx = fileNotEx.Remove(9);
                }
                string ticks = DateTime.Now.Ticks.ToString();
                #region Lưu ảnh đại diện theo 2 trường hợp: tạo ảnh nhỏ hoặc không.
                //Kiểm tra xem có tạo ảnh nhỏ hay ko
                //Nếu không tạo ảnh nhỏ, tên tệp lưu bình thường theo kiểu: tên_tệp.phần_mở_rộng
                //Nếu tạo ảnh nhỏ, tên tệp sẽ theo kiểu: tên_tệp_HasThumb.phần_mở_rộng
                //Khi đó tên tệp ảnh nhỏ sẽ theo kiểu:   tên_tệp_HasThumb_Thumb.phần_mở_rộng
                //Với cách lưu tên ảnh này, khi thực hiện lưu vào csdl chỉ cần lưu tên ảnh gốc
                //khi hiển thị chỉ cần dựa vào tên ảnh gốc để biết ảnh đó có ảnh nhỏ hay không, việc này được thực hiện bởi ImagesExtension.GetImage, lập trình không cần làm gì thêm.
                if (cbTaoAnhNho.Checked)
                {
                    vimg = fileNotEx + "_" + ticks + "_HasThumb" + fileex;
                }
                else
                {
                    vimg = fileNotEx + "_" + ticks + fileex;
                }
                flimg.SaveAs(path + vimg);
                #endregion
                #region Hạn chế kích thước
                if (cbHanCheKichThuoc.Checked)
                {
                    ImagesExtension.ResizeImage(path + vimg, "", tbHanCheW.Text, tbHanCheH.Text);
                }
                #endregion
                #region Đóng dấu ảnh
                if (cbDongDauAnh.Checked)
                {
                    ImagesExtension.CreateWatermark(path + vimg, path + hdLogoImage.Value, hdViTriDongDau.Value, hdLeX.Value, hdLeY.Value, hdTyLe.Value, hdTrongSuot.Value);
                }
                #endregion
                #region Tạo ảnh nhỏ: Thực hiện cuối để đảm bảo ảnh nhỏ cũng có con dấu
                if (cbTaoAnhNho.Checked)
                {
                    vimg_thumb = fileNotEx + "_" + ticks + "_HasThumb_Thumb" + fileex;
                    ImagesExtension.ResizeImage(path + vimg, path + vimg_thumb, tbAnhNhoW.Text, tbAnhNhoH.Text);
                }
                #endregion
            }
        }
        #endregion

        /*
         * Thêm mới loại
         */
        string param  = StringExtension.GhepChuoi("", tbMoTa.Text, tbParam2.Text, tbParam3.Text);
        string prices = StringExtension.GhepChuoi("", tbPrice.Text, tbPriceOld.Text);

        if (!update)
        {
            Subitems.InsertSubitems(iid, language, app, tbName.Text, param, vimg, prices, tbOrder.Text, tbParam1.Text, tbCreateDate.Text, DateTime.Now.ToString(), tbEnddate.Text, ddlStatus.SelectedValue);
        }
        else
        {
            if (vimg.Equals(""))
            {
                vimg = hd_img;
            }
            else
            {
                ImagesExtension.DeleteImageWhenDeleteItem(pathFolderPic, hd_img);
            }
            Subitems.UpdateSubitems(iid, language, app, tbName.Text, param, vimg, prices, tbOrder.Text, tbParam1.Text, tbCreateDate.Text, DateTime.Now.ToString(), tbEnddate.Text, ddlStatus.SelectedValue, currentIsid.Value);
        }

        ResetControls();
        GetList();
        pnList.Visible   = true;
        pnInsert.Visible = false;
    }
    protected void btn_insert_update_Click(object sender, EventArgs e)
    {
        #region Image
        string fileType = "1";//1: ảnh thường, 2: flash
        string vimg     = "";
        if (flimg.FileName.Length > 0 && flimg.PostedFile.ContentLength > 0)
        {
            string filename = flimg.FileName;
            string fileex   = filename.Substring(filename.LastIndexOf(".")).ToLower();
            string path     = Request.PhysicalApplicationPath + "/" + pic + "/";
            if (ImagesExtension.ValidType(fileex, ",.jpg,.jpeg,.png,.gif,.swf,"))
            {
                string fileNotEx = StringExtension.ReplateTitle(filename.Remove(filename.LastIndexOf(".") - 1));
                if (fileNotEx.Length > 9)
                {
                    fileNotEx = fileNotEx.Remove(9);
                }
                string ticks = DateTime.Now.Ticks.ToString();
                vimg = fileNotEx + "_" + ticks + fileex;
                flimg.SaveAs(path + vimg);
            }
            if (fileex == ".swf")
            {
                fileType = "2";            //Ảnh flash
            }
        }
        #endregion

        #region Image2
        string vimg2 = "";
        if (flimg2.FileName.Length > 0 && flimg2.PostedFile.ContentLength > 0)
        {
            string filename = flimg2.FileName;
            string fileex   = filename.Substring(filename.LastIndexOf(".")).ToLower();
            string path     = Request.PhysicalApplicationPath + "/" + pic + "/";
            if (ImagesExtension.ValidType(fileex, ",.jpg,.jpeg,.png,.gif,.swf,"))
            {
                string fileNotEx = StringExtension.ReplateTitle(filename.Remove(filename.LastIndexOf(".") - 1));
                if (fileNotEx.Length > 9)
                {
                    fileNotEx = fileNotEx.Remove(9);
                }
                string ticks = DateTime.Now.Ticks.ToString();
                vimg2 = fileNotEx + "_" + ticks + fileex;
                flimg2.SaveAs(path + vimg2);
            }
        }
        #endregion

        #region Status
        string status = "0";
        if (chk_status.Checked == true)
        {
            status = "1";
        }
        #endregion

        #region IID người đăng
        string iidNguoiDang    = "";
        string thongtindangbai = "";
        string ngayxuatban     = "";
        if (AdvertisingConfig.KeyDuyetTin)
        {
            if (HorizaMenuConfig.ShowDuyetTin1 || HorizaMenuConfig.ShowDuyetTin2)
            {
                iidNguoiDang = CookieExtension.GetCookies("userId");
                ngayxuatban  = DateTime.Now.ToString();
            }
        }
        #endregion

        #region Insert
        if (insert)
        {
            string vicontent = StringExtension.GhepChuoi("", vimg2);
            GroupsItems.InsertItemsGroupsItems(language, app, txt_width_adv.Text, txt_title.Text,
                                               txt_height_adv.Text, vicontent, vimg, iidNguoiDang, txt_link_to_image.Text,
                                               TbDesc.Text, txt_link_adv.Text, "", "", "", thongtindangbai, ngayxuatban, "", ddl_type_open.SelectedValue, fileType, "",
                                               "", "", DateTime.Now.ToString(), DateTime.Now.ToString(),
                                               DateTime.Now.ToString(), "", ddl_group_product.SelectedValue,
                                               DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(),
                                               txt_order.Text, status);

            #region Logs
            string logAuthor     = CookieExtension.GetCookies("LoginSetting");
            string logCreateDate = DateTime.Now.ToString();
            Logs.InsertLogs(logCreateDate, Request.Url.ToString(), "", txt_title.Text, logAuthor, "", logCreateDate + ": " + logAuthor + " tạo mới " + txt_title.Text);
            #endregion
        }
        #endregion
        #region Update
        else
        {
            if (vimg.Length < 1)
            {
                fileType = "1";//1: ảnh thường, 2: flash
                vimg     = hdImg.Value;
                string fileex = "";
                if (vimg.LastIndexOf(".") > -1)
                {
                    fileex = vimg.Substring(vimg.LastIndexOf(".")).ToLower();
                }
                if (fileex == ".swf")
                {
                    fileType = "2";          //Ảnh flash
                }
            }
            else
            {
                ImagesExtension.DeleteImageWhenDeleteItem(pic, hdImg.Value);
            }

            if (vimg2.Length < 1)
            {
                vimg2 = hdImg2.Value;
            }
            else
            {
                ImagesExtension.DeleteImageWhenDeleteItem(pic, hdImg2.Value);
            }
            string vicontent = StringExtension.GhepChuoi("", vimg2);

            if (AdvertisingConfig.KeyDuyetTin)
            {
                string userRole = CookieExtension.GetCookies("RolesUser");
                if (HorizaMenuConfig.ShowDuyetTin2)
                {
                    if (hdEnable.Value == PhanQuyen.DuyetTin.Cap1 && StringExtension.RoleInListRoles(PhanQuyen.DuyetTin.Cap1, userRole))
                    {
                        status = "0";
                    }
                    else if (hdEnable.Value == "1" && StringExtension.RoleInListRoles(PhanQuyen.DuyetTin.Cap2, userRole))
                    {
                        status = "1";
                    }
                    else if (hdEnable.Value != "0" && hdEnable.Value != "1")
                    {
                        status = hdEnable.Value;
                    }
                }
                else
                {
                    if (hdEnable.Value == PhanQuyen.DuyetTin.Cap2 && StringExtension.RoleInListRoles(PhanQuyen.DuyetTin.Cap2, userRole))
                    {
                        status = "0";
                    }
                    else if (hdEnable.Value != "0" && hdEnable.Value != "1")
                    {
                        status = hdEnable.Value;
                    }
                }
            }

            string nguoiDangCu   = hdNguoiDangCu.Value;
            string thongtincu    = hdThongTinThem.Value;
            string ngayxuatbancu = hdNgayXuatBan.Value;
            GroupsItems.UpdateItemsGroupsItems(language, app, txt_width_adv.Text, txt_title.Text,
                                               txt_height_adv.Text, vicontent, vimg, nguoiDangCu, txt_link_to_image.Text,
                                               TbDesc.Text, txt_link_adv.Text, "", "", "", thongtincu, ngayxuatbancu, "", ddl_type_open.SelectedValue, fileType, "",
                                               "", "", DateTime.Now.ToString(), DateTime.Now.ToString(),
                                               DateTime.Now.ToString(), "", ddl_group_product.SelectedValue,
                                               DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(),
                                               txt_order.Text, status, iid);

            #region Logs
            string logAuthor     = CookieExtension.GetCookies("LoginSetting");
            string logCreateDate = DateTime.Now.ToString();
            Logs.InsertLogs(logCreateDate, Request.Url.ToString(), "", txt_title.Text, logAuthor, "", logCreateDate + ": " + logAuthor + " cập nhật " + txt_title.Text);
            #endregion
        }
        #endregion

        #region After Insert/Update
        if (ckbContinue.Checked == true)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "alertSuccess", "ThongBao(3000,'Đã tạo: " + txt_title.Text + "');", true);
            ResetControls();
        }
        else
        {
            Response.Redirect(LinkRedrect());
        }
        #endregion
    }
Пример #26
0
    //protected void btn_insert_update_Click(object sender, EventArgs e)
    protected void WebUserControl1_btnHandler(string strValue)
    {
        #region Image
        string vimg          = "";
        string vimg_thumb    = "";
        string contentDetail = ContentExtendtions.ProcessStringContent(txt_content.Text, hdOldContent.Value, pic);
        if (flimg.PostedFile.ContentLength > 0)
        {
            string filename = flimg.FileName;
            string fileex   = filename.Substring(filename.LastIndexOf("."));
            string path     = Request.PhysicalApplicationPath + "/" + pic + "/";
            if (ImagesExtension.ValidType(fileex))
            {
                string fileNotEx = StringExtension.ReplateTitle(filename.Remove(filename.LastIndexOf(".") - 1));
                if (fileNotEx.Length > 9)
                {
                    fileNotEx = fileNotEx.Remove(9);
                }
                string ticks = DateTime.Now.Ticks.ToString();
                #region Lưu ảnh đại diện theo 2 trường hợp: tạo ảnh nhỏ hoặc không.
                //Kiểm tra xem có tạo ảnh nhỏ hay ko
                //Nếu không tạo ảnh nhỏ, tên tệp lưu bình thường theo kiểu: tên_tệp.phần_mở_rộng
                //Nếu tạo ảnh nhỏ, tên tệp sẽ theo kiểu: tên_tệp_HasThumb.phần_mở_rộng
                //Khi đó tên tệp ảnh nhỏ sẽ theo kiểu:   tên_tệp_HasThumb_Thumb.phần_mở_rộng
                //Với cách lưu tên ảnh này, khi thực hiện lưu vào csdl chỉ cần lưu tên ảnh gốc
                //khi hiển thị chỉ cần dựa vào tên ảnh gốc để biết ảnh đó có ảnh nhỏ hay không, việc này được thực hiện bởi ImagesExtension.GetImage, lập trình không cần làm gì thêm.
                if (cbTaoAnhNho.Checked)
                {
                    vimg = fileNotEx + "_" + ticks + "_HasThumb" + fileex;
                }
                else
                {
                    vimg = fileNotEx + "_" + ticks + fileex;
                }
                flimg.SaveAs(path + vimg);
                #endregion
                #region Hạn chế kích thước
                if (cbHanCheKichThuoc.Checked)
                {
                    ImagesExtension.ResizeImage(path + vimg, "", tbHanCheW.Text, tbHanCheH.Text);
                }
                #endregion
                #region Đóng dấu ảnh
                if (cbDongDauAnh.Checked)
                {
                    ImagesExtension.CreateWatermark(path + vimg, path + hdLogoImage.Value, hdViTriDongDau.Value, hdLeX.Value, hdLeY.Value, hdTyLe.Value, hdTrongSuot.Value);
                }
                #endregion
                #region Tạo ảnh nhỏ: Thực hiện cuối để đảm bảo ảnh nhỏ cũng có con dấu
                if (cbTaoAnhNho.Checked)
                {
                    vimg_thumb = fileNotEx + "_" + ticks + "_HasThumb_Thumb" + fileex;
                    ImagesExtension.ResizeImage(path + vimg, path + vimg_thumb, tbAnhNhoW.Text, tbAnhNhoH.Text);
                }
                #endregion
            }
        }
        else
        {
            if (hd_img.Value.Length < 1 || cbLayAnhTuNoiDung.Checked)//nếu không upload ảnh và cũng không có ảnh cũ -> tìm ảnh đầu tiên trong nội dung làm ảnh đại diện
            {
                if (hd_img.Value.Length > 0)
                {
                    TatThanhJsc.Extension.ImagesExtension.DeleteImageWhenDeleteItem(pic, hd_img.Value);
                }

                string urlImg = ImagesExtension.GetFirstImageInContent(contentDetail);

                if (urlImg.Length > 0)
                {
                    string filename = urlImg;
                    string fileex   = filename.Substring(filename.LastIndexOf("."));
                    string path     = Request.PhysicalApplicationPath + "/" + pic + "/";
                    if (TatThanhJsc.Extension.ImagesExtension.ValidType(fileex))
                    {
                        string fileNotEx = StringExtension.ReplateTitle(filename.Remove(filename.LastIndexOf(".") - 1));
                        if (fileNotEx.Length > 9)
                        {
                            fileNotEx = fileNotEx.Remove(9);
                        }
                        string ticks = DateTime.Now.Ticks.ToString();
                        #region Lưu ảnh đại diện theo 2 trường hợp: tạo ảnh nhỏ hoặc không.
                        //Kiểm tra xem có tạo ảnh nhỏ hay ko
                        //Nếu không tạo ảnh nhỏ, tên tệp lưu bình thường theo kiểu: tên_tệp.phần_mở_rộng
                        //Nếu tạo ảnh nhỏ, tên tệp sẽ theo kiểu: tên_tệp_HasThumb.phần_mở_rộng
                        //Khi đó tên tệp ảnh nhỏ sẽ theo kiểu:   tên_tệp_HasThumb_Thumb.phần_mở_rộng
                        //Với cách lưu tên ảnh này, khi thực hiện lưu vào csdl chỉ cần lưu tên ảnh gốc
                        //khi hiển thị chỉ cần dựa vào tên ảnh gốc để biết ảnh đó có ảnh nhỏ hay không, việc này được thực hiện bởi TatThanhJsc.Extension.ImagesExtension.GetImage, lập trình không cần làm gì thêm.
                        if (cbTaoAnhNho.Checked)
                        {
                            vimg = fileNotEx + "_" + ticks + "_HasThumb";
                        }
                        else
                        {
                            vimg = fileNotEx + "_" + ticks;
                        }

                        if (ImagesExtension.SaveImageFromUrl(path + vimg, urlImg).Length > 0)
                        {
                            vimg += fileex;

                            #region Hạn chế kích thước
                            if (cbHanCheKichThuoc.Checked)
                            {
                                ImagesExtension.ResizeImage(path + vimg, "", tbHanCheW.Text, tbHanCheH.Text);
                            }
                            #endregion
                            #region Đóng dấu ảnh
                            if (cbDongDauAnh.Checked)
                            {
                                ImagesExtension.CreateWatermark(path + vimg, path + hdLogoImage.Value, hdViTriDongDau.Value, hdLeX.Value, hdLeY.Value, hdTyLe.Value, hdTrongSuot.Value);
                            }
                            #endregion
                            #region Tạo ảnh nhỏ: Thực hiện cuối để đảm bảo ảnh nhỏ cũng có con dấu
                            if (cbTaoAnhNho.Checked)
                            {
                                vimg_thumb = fileNotEx + "_" + ticks + "_HasThumb_Thumb" + fileex;
                                ImagesExtension.ResizeImage(path + vimg, path + vimg_thumb, tbAnhNhoW.Text, tbAnhNhoH.Text);
                            }
                            #endregion
                        }
                        else
                        {
                            vimg = "";
                        }
                        #endregion
                    }
                }
            }
        }
        #endregion

        string specProduct      = ContentExtendtions.ProcessStringContent(txt_spec.Text, hdOldSpec.Value, pic);
        string conditionProduct = ContentExtendtions.ProcessStringContent(txt_condition.Text, hdOldCondition.Value, pic);
        string storeProduct     = ContentExtendtions.ProcessStringContent(txt_store.Text, hdOldStore.Value, pic);

        #region Status
        string status = "0";
        if (chk_status.Checked == true)
        {
            status = "1";
        }

        #region IID người đăng
        string iidNguoiDang    = "";
        string thongtindangbai = "";
        string ngayxuatban     = "";
        if (DealConfig.KeyDuyetTin)
        {
            if (HorizaMenuConfig.ShowDuyetTin1 || HorizaMenuConfig.ShowDuyetTin2)
            {
                iidNguoiDang = CookieExtension.GetCookies("userId");
                ngayxuatban  = DateTime.Now.ToString();
            }
        }
        #endregion

        #endregion
        #region Time Create Date
        string timeCreateDate = "";
        timeCreateDate = txt_startdate.Text;
        #endregion
        #region End Date
        string end_date = "0";
        if (chk_EndDate.Checked == true)
        {
            end_date = "1";
        }
        #endregion
        #region Seo
        if (textLinkRewrite.Text.Trim().Equals(""))
        {
            textLinkRewrite.Text = txt_title.Text;
        }
        if (textTagTitle.Text.Trim().Equals(""))
        {
            textTagTitle.Text = txt_title.Text;
        }
        if (textTagKeyword.Text.Trim().Equals(""))
        {
            textTagKeyword.Text = txt_title.Text;
        }
        if (textTagDescription.Text.Trim().Equals(""))
        {
            textTagDescription.Text = txt_description.Text;
        }
        #endregion
        #region Insert
        if (insert)
        {
            GroupsItems.InsertItemsGroupsItems(language, app, tbKey.Text, txt_title.Text, txt_description.Text, StringExtension.GhepChuoi("", contentDetail, specProduct, conditionProduct, storeProduct), vimg, iidNguoiDang, tbSoNguoiMuaToiThieu.Text, textTagTitle.Text, textLinkRewrite.Text, StringExtension.ReplateTitle(textLinkRewrite.Text), textTagKeyword.Text, textTagDescription.Text, thongtindangbai, ngayxuatban, ddlHinhThucNhan.SelectedValue, end_date, tbPrice.Text, tbPriceOld.Text, txt_quantity.Text, "", timeCreateDate, DateTime.Now.ToString(), txt_endDate.Text + " " + ddl_hour.SelectedValue + ":" + ddl_minute.SelectedValue, tbOrder.Text, ddl_group_product.SelectedValue, timeCreateDate, DateTime.Now.ToString(), txt_endDate.Text + " " + ddl_hour.SelectedValue + ":" + ddl_minute.SelectedValue, tbOrder.Text, status);

            #region Lay ra iid cua item vua duoc luu
            condition = DataExtension.AndConditon(
                ItemsTSql.GetItemsByDicreatedate(timeCreateDate),
                ItemsTSql.GetItemsByViapp(app));
            DataTable dtInsertedItems = new DataTable();
            dtInsertedItems = GroupsItems.GetAllData("1", "Items.iid", condition, ItemsColumns.IidColumn + " desc");
            if (dtInsertedItems.Rows.Count > 0)
            {
                iid = dtInsertedItems.Rows[0][ItemsColumns.IidColumn].ToString();
            }
            #endregion
        }
        #endregion
        #region Update
        else
        {
            if (vimg.Equals(""))
            {
                vimg = hd_img.Value;
            }
            else
            {
                ImagesExtension.DeleteImageWhenDeleteItem(pic, hd_img.Value);
            }

            if (DealConfig.KeyDuyetTin)
            {
                string userRole = CookieExtension.GetCookies("RolesUser");
                if (HorizaMenuConfig.ShowDuyetTin2)
                {
                    if (hdEnable.Value == PhanQuyen.DuyetTin.Cap1 && StringExtension.RoleInListRoles(PhanQuyen.DuyetTin.Cap1, userRole))
                    {
                        status = "0";
                    }
                    else if (hdEnable.Value == "1" && StringExtension.RoleInListRoles(PhanQuyen.DuyetTin.Cap2, userRole))
                    {
                        status = "1";
                    }
                    else if (hdEnable.Value != "0" && hdEnable.Value != "1")
                    {
                        status = hdEnable.Value;
                    }
                }
                else
                {
                    if (hdEnable.Value == PhanQuyen.DuyetTin.Cap2 && StringExtension.RoleInListRoles(PhanQuyen.DuyetTin.Cap2, userRole))
                    {
                        status = "0";
                    }
                    else if (hdEnable.Value != "0" && hdEnable.Value != "1")
                    {
                        status = hdEnable.Value;
                    }
                }
            }

            string nguoiDangCu   = hdNguoiDangCu.Value;
            string thongtincu    = hdThongTinThem.Value;
            string ngayxuatbancu = hdNgayXuatBan.Value;
            GroupsItems.UpdateItemsGroupsItems(language, app, tbKey.Text, txt_title.Text, txt_description.Text, StringExtension.GhepChuoi("", contentDetail, specProduct, conditionProduct, storeProduct), vimg, nguoiDangCu, tbSoNguoiMuaToiThieu.Text, textTagTitle.Text, textLinkRewrite.Text, StringExtension.ReplateTitle(textLinkRewrite.Text), textTagKeyword.Text, textTagDescription.Text, thongtincu, ngayxuatbancu, ddlHinhThucNhan.SelectedValue, end_date, tbPrice.Text, tbPriceOld.Text, txt_quantity.Text, HdIitotalview.Value, timeCreateDate, DateTime.Now.ToString(), txt_endDate.Text + " " + ddl_hour.SelectedValue + ":" + ddl_minute.SelectedValue, tbOrder.Text, ddl_group_product.SelectedValue, timeCreateDate, DateTime.Now.ToString(), txt_endDate.Text + " " + ddl_hour.SelectedValue + ":" + ddl_minute.SelectedValue, tbOrder.Text, status, iid);
        }
        #endregion

        #region Properties-Chi thực hiện khi chức năng Quản lý thuộc tính được hiển thị
        if (DealConfig.KeyHienThiQuanLyThuocTinhDeal)
        {
            string properties = parramSpitString;
            for (int i = 0; i < rptProperties.Items.Count; i++)
            {
                CheckBox checkBoxProperties = (CheckBox)rptProperties.Items[i].FindControl("checkBoxProperties");
                if (checkBoxProperties.Checked == true)
                {
                    properties += checkBoxProperties.ToolTip + parramSpitString;
                }
            }

            condition = DataExtension.AndConditon(
                SubitemsTSql.GetSubitemsByIid(iid),
                SubitemsTSql.GetSubitemsByVskey(propertyModul));
            fields = DataExtension.GetListColumns(SubitemsColumns.IsidColumn, SubitemsColumns.VscontentColumn);
            DataTable dt = new DataTable();
            dt = Subitems.GetSubItems("", fields, condition, "");

            if (dt.Rows.Count > 0)
            {
                string isid = dt.Rows[0][SubitemsColumns.IsidColumn].ToString();
                //Cap nhat
                Subitems.UpdateSubitems(iid, language, propertyModul, "", properties, "", "", "", "", DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), "1", isid);
            }
            else
            {
                //Them moi
                Subitems.InsertSubitems(iid, language, propertyModul, "", properties, "", "", "", "", DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), "1");
            }
        }
        #endregion

        #region Nicks - Chỉ hiển thị khi chức năng add nick được hiển thị
        if (DealConfig.KeyHienThiAddNickChoDeal)
        {
            string nicks = parramSpitString;
            for (int i = 0; i < rptNicks.Items.Count; i++)
            {
                CheckBox checkBoxNicks = (CheckBox)rptNicks.Items[i].FindControl("checkBoxNicks");
                if (checkBoxNicks.Checked == true)
                {
                    nicks += checkBoxNicks.ToolTip + parramSpitString;
                }
            }

            condition = DataExtension.AndConditon(
                SubitemsTSql.GetSubitemsByIid(iid),
                SubitemsTSql.GetSubitemsByVskey(TatThanhJsc.OtherModul.CodeApplications.SupportOnline));
            fields = DataExtension.GetListColumns(SubitemsColumns.IsidColumn, SubitemsColumns.VscontentColumn);
            DataTable dt = new DataTable();
            dt = Subitems.GetSubItems("", fields, condition, "");

            if (dt.Rows.Count > 0)
            {
                string isid = dt.Rows[0][SubitemsColumns.IsidColumn].ToString();
                //Cap nhat
                Subitems.UpdateSubitems(iid, language, TatThanhJsc.OtherModul.CodeApplications.SupportOnline, "", nicks, "", "", "", "", DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), "1", isid);
            }
            else
            {
                //Them moi
                Subitems.InsertSubitems(iid, language, TatThanhJsc.OtherModul.CodeApplications.SupportOnline, "", nicks, "", "", "", "", DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), "1");
            }
        }
        #endregion

        #region FilterProperties - Chỉ hiển thị khi tính năng lọc deal được hiển thị
        if (DealConfig.KeyHienThiThuocTinhLocDeal)
        {
            string filterProperties = parramSpitString;
            for (int i = 0; i < rptParentFilter.Items.Count; i++)
            {
                RadioButtonList rdblListAnswer = (RadioButtonList)rptParentFilter.Items[i].FindControl("rdblAnswer");
                if (rdblListAnswer != null)
                {
                    if (rdblListAnswer.SelectedValue.Length > 0)
                    {
                        filterProperties += rdblListAnswer.SelectedValue + parramSpitString;
                    }
                }

                CheckBoxList cblListAnswer = (CheckBoxList)rptParentFilter.Items[i].FindControl("cblAnswer");
                if (cblListAnswer != null)
                {
                    for (int j = 0; j < cblListAnswer.Items.Count; j++)
                    {
                        if (cblListAnswer.Items[j].Selected == true)
                        {
                            filterProperties += cblListAnswer.Items[j].Value + parramSpitString;
                        }
                    }
                }
            }

            condition = DataExtension.AndConditon(
                SubitemsTSql.GetSubitemsByIid(iid),
                SubitemsTSql.GetSubitemsByVskey(CodeApplications.DealFilterProperties));
            fields = DataExtension.GetListColumns(SubitemsColumns.IsidColumn, SubitemsColumns.VscontentColumn);
            DataTable dt = new DataTable();
            dt = Subitems.GetSubItems("", fields, condition, "");

            if (dt.Rows.Count > 0)
            {
                string isid = dt.Rows[0][SubitemsColumns.IsidColumn].ToString();
                //Cap nhat
                Subitems.UpdateSubitems(iid, language, CodeApplications.DealFilterProperties, "", filterProperties, "", "", "", "", DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), "1", isid);
            }
            else
            {
                //Them moi
                Subitems.InsertSubitems(iid, language, CodeApplications.DealFilterProperties, "", filterProperties, "", "", "", "", DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), "1");
            }
        }
        #endregion

        #region After Insert/Update

        if (ckbContinue.Checked == true)
        {
            //ScriptManager.RegisterStartupScript(this, this.GetType(), "alertSuccess",
            //    "ThongBao(3000,'Đã tạo: " + txt_title.Text + "');", true);
            //Lưu vào session để gọi đến bên api
            Session["CotinuteCreate"]      = true;
            Session["CotinuteCreateTitle"] = txt_title.Text;
            ResetControls();
        }
        else
        {
            Session["CotinuteCreate"]             = false;
            Session["CotinuteCreateRedirectLink"] = LinkRedrect();
        }

        #endregion
    }
    protected void btSave_Click(object sender, EventArgs e)
    {
        #region Cấu hình số lượng
        SettingsExtension.SetOtherSettingKey(SettingKey.SoCustomerReviewsTrenTrangChu, tbSoCustomerReviewsTrenTrangChu.Text, lang);
        SettingsExtension.SetOtherSettingKey(SettingKey.SoCustomerReviewsKhacTrenMotTrang, tbSoCustomerReviewsKhacTrenMotTrang.Text, lang);
        SettingsExtension.SetOtherSettingKey(SettingKey.SoCustomerReviewsTrenTrangDanhMuc, tbSoCustomerReviewsTrenTrangDanhMuc.Text, lang);
        #endregion

        #region Cấu hình đóng dấu ảnh
        #region Đóng dấu ảnh
        if (cbDongDauAnh.Checked)
        {
            SettingsExtension.SetOtherSettingKey(SettingKey.DongDauAnhCustomerReviews, "1", lang);
        }
        else
        {
            SettingsExtension.SetOtherSettingKey(SettingKey.DongDauAnhCustomerReviews, "0", lang);
        }

        #region Ảnh làm dấu
        if (fulDongDauAnh.PostedFile.ContentLength > 0)
        {
            //Xoá ảnh cũ
            if (hdWatermarkLogo.Value.Length > 0)
            {
                ImagesExtension.DeleteImageWhenDeleteItem(pic, hdWatermarkLogo.Value);
            }

            //Lưu ảnh mới
            string fileName = "";
            if (ImagesExtension.ValidType(fulDongDauAnh.FileName))
            {
                string fileEx = fulDongDauAnh.FileName.Substring(fulDongDauAnh.FileName.LastIndexOf("."));
                fileName = "WatermarkLogo" + fileEx;
                fulDongDauAnh.SaveAs(Request.PhysicalApplicationPath + "/" + pic + "/" + fileName);
                ltrWatermarkLogo.Text = ImagesExtension.GetImage(pic, fileName, "", "", false, false, "");
            }
            SettingsExtension.SetOtherSettingKey(SettingKey.DongDauAnhCustomerReviews_AnhDau, fileName, lang);
        }
        #endregion

        SettingsExtension.SetOtherSettingKey(SettingKey.DongDauAnhCustomerReviews_ViTri, rbViTriDongDau.SelectedValue, lang);
        SettingsExtension.SetOtherSettingKey(SettingKey.DongDauAnhCustomerReviews_LeNgang, tbLeX.Text, lang);
        SettingsExtension.SetOtherSettingKey(SettingKey.DongDauAnhCustomerReviews_LeDoc, tbLeY.Text, lang);
        SettingsExtension.SetOtherSettingKey(SettingKey.DongDauAnhCustomerReviews_TyLe, tbPhanTram.Text, lang);
        SettingsExtension.SetOtherSettingKey(SettingKey.DongDauAnhCustomerReviews_TrongSuot, tbTrongSuot.Text, lang);
        #endregion

        #region Hạn chế kích thước ảnh đại diện
        if (cbHanCheKichThuoc.Checked)
        {
            SettingsExtension.SetOtherSettingKey(SettingKey.HanCheKichThuocAnhCustomerReviews, "1", lang);
        }
        else
        {
            SettingsExtension.SetOtherSettingKey(SettingKey.HanCheKichThuocAnhCustomerReviews, "0", lang);
        }

        SettingsExtension.SetOtherSettingKey(SettingKey.HanCheKichThuocAnhCustomerReviews_MaxWidth, tbHanCheW.Text, lang);
        SettingsExtension.SetOtherSettingKey(SettingKey.HanCheKichThuocAnhCustomerReviews_MaxHeight, tbHanCheH.Text, lang);
        #endregion

        #region Tạo ảnh nhỏ cho ảnh đại diện
        if (cbTaoAnhNho.Checked)
        {
            SettingsExtension.SetOtherSettingKey(SettingKey.TaoAnhNhoChoAnhCustomerReviews, "1", lang);
        }
        else
        {
            SettingsExtension.SetOtherSettingKey(SettingKey.TaoAnhNhoChoAnhCustomerReviews, "0", lang);
        }

        SettingsExtension.SetOtherSettingKey(SettingKey.TaoAnhNhoChoAnhCustomerReviews_MaxWidth, tbAnhNhoW.Text, lang);
        SettingsExtension.SetOtherSettingKey(SettingKey.TaoAnhNhoChoAnhCustomerReviews_MaxHeight, tbAnhNhoH.Text, lang);
        #endregion
        #endregion

        #region Cấu hình tối ưu seo
        SettingsExtension.SetOtherSettingKey(SettingKey.TitleCustomerReviews, tbTitle.Text, lang);
        SettingsExtension.SetOtherSettingKey(SettingKey.DescriptionCustomerReviews, tbDescription.Text, lang);

        SettingsExtension.SetOtherSettingKey(SettingKey.SeoTitleCustomerReviews, tbSeoTitle.Text, lang);
        SettingsExtension.SetOtherSettingKey(SettingKey.SeoUrlCustomerReviews, tbSeoUrl.Text, lang);
        SettingsExtension.SetOtherSettingKey(SettingKey.SeoKeywordCustomerReviews, tbSeoKeyword.Text, lang);
        SettingsExtension.SetOtherSettingKey(SettingKey.SeoDescriptionCustomerReviews, tbSeoDescription.Text, lang);

        #region Hình ảnh khi share
        if (flShareImage.PostedFile.ContentLength > 0)
        {
            //Xoá ảnh cũ
            if (hdShareImage.Value.Length > 0)
            {
                ImagesExtension.DeleteImageWhenDeleteItem(pic, hdShareImage.Value);
            }

            //Lưu ảnh mới
            string fileName = "";
            if (ImagesExtension.ValidType(flShareImage.FileName))
            {
                string filename  = flShareImage.FileName;
                string fileEx    = flShareImage.FileName.Substring(flShareImage.FileName.LastIndexOf("."));
                string fileNotEx = StringExtension.ReplateTitle(filename.Remove(filename.LastIndexOf(".") - 1));
                if (fileNotEx.Length > 9)
                {
                    fileNotEx = fileNotEx.Remove(9);
                }
                string ticks = DateTime.Now.Ticks.ToString();
                fileName = fileNotEx + "_" + ticks + fileEx;


                flShareImage.SaveAs(Request.PhysicalApplicationPath + "/" + pic + "/" + fileName);
                ltrShareImage.Text = ImagesExtension.GetImage(pic, fileName, "", "", false, false, "");
            }
            SettingsExtension.SetOtherSettingKey(SettingKey.SeoImageCustomerReviews, fileName, lang);
        }
        #endregion
        #endregion

        ScriptManager.RegisterStartupScript(this, this.GetType(), "alertSuccess", "ThongBao(3000,'Cập nhật thành công !');", true);
    }
Пример #28
0
    protected void WebUserControl1_btnHandler(string strValue)
    {
        #region Image
        string vimg          = "";
        string vimg_thumb    = "";
        string contentDetail = StringExtension.GhepChuoi("",
                                                         ContentExtendtions.ProcessStringContent(txt_content.Text, hdOldProduct.Value, pic),
                                                         ContentExtendtions.ProcessStringContent(txtThongSoKyThuat.Text, hdThongSoKyThua.Value, pic),
                                                         ContentExtendtions.ProcessStringContent(txtVideoGioiThieu.Text, hdVideoGioiThieu.Value, pic),
                                                         txtXuatXu.Text, txtCongXuat.Text, txtDienAp.Text, txtLuuLuong.Text, txtCotAp.Text, txtTruynDong.Text, txtVatLieu.Text, txtBaoHanh.Text);
        if (flimg.PostedFile.ContentLength > 0)
        {
            string filename = flimg.FileName;
            string fileex   = filename.Substring(filename.LastIndexOf("."));
            string path     = Request.PhysicalApplicationPath + "/" + pic + "/";
            if (ImagesExtension.ValidType(fileex))
            {
                string fileNotEx = StringExtension.ReplateTitle(filename.Remove(filename.LastIndexOf(".") - 1));
                if (fileNotEx.Length > 9)
                {
                    fileNotEx = fileNotEx.Remove(9);
                }
                string ticks = DateTime.Now.Ticks.ToString();
                #region Lưu ảnh đại diện theo 2 trường hợp: tạo ảnh nhỏ hoặc không.
                //Kiểm tra xem có tạo ảnh nhỏ hay ko
                //Nếu không tạo ảnh nhỏ, tên tệp lưu bình thường theo kiểu: tên_tệp.phần_mở_rộng
                //Nếu tạo ảnh nhỏ, tên tệp sẽ theo kiểu: tên_tệp_HasThumb.phần_mở_rộng
                //Khi đó tên tệp ảnh nhỏ sẽ theo kiểu:   tên_tệp_HasThumb_Thumb.phần_mở_rộng
                //Với cách lưu tên ảnh này, khi thực hiện lưu vào csdl chỉ cần lưu tên ảnh gốc
                //khi hiển thị chỉ cần dựa vào tên ảnh gốc để biết ảnh đó có ảnh nhỏ hay không, việc này được thực hiện bởi ImagesExtension.GetImage, lập trình không cần làm gì thêm.
                if (cbTaoAnhNho.Checked)
                {
                    vimg = fileNotEx + "_" + ticks + "_HasThumb" + fileex;
                }
                else
                {
                    vimg = fileNotEx + "_" + ticks + fileex;
                }
                flimg.SaveAs(path + vimg);
                #endregion
                #region Hạn chế kích thước
                if (cbHanCheKichThuoc.Checked)
                {
                    ImagesExtension.ResizeImage(path + vimg, "", tbHanCheW.Text, tbHanCheH.Text);
                }
                #endregion
                #region Đóng dấu ảnh
                if (cbDongDauAnh.Checked)
                {
                    ImagesExtension.CreateWatermark(path + vimg, path + hdLogoImage.Value, hdViTriDongDau.Value, hdLeX.Value, hdLeY.Value, hdTyLe.Value, hdTrongSuot.Value);
                }
                #endregion
                #region Tạo ảnh nhỏ: Thực hiện cuối để đảm bảo ảnh nhỏ cũng có con dấu
                if (cbTaoAnhNho.Checked)
                {
                    vimg_thumb = fileNotEx + "_" + ticks + "_HasThumb_Thumb" + fileex;
                    ImagesExtension.ResizeImage(path + vimg, path + vimg_thumb, tbAnhNhoW.Text, tbAnhNhoH.Text);
                }
                #endregion
            }
        }
        else
        {
            if (hd_img.Value.Length < 1 || cbLayAnhTuNoiDung.Checked)//nếu không upload ảnh và cũng không có ảnh cũ -> tìm ảnh đầu tiên trong nội dung làm ảnh đại diện
            {
                if (hd_img.Value.Length > 0)
                {
                    TatThanhJsc.Extension.ImagesExtension.DeleteImageWhenDeleteItem(pic, hd_img.Value);
                }

                string urlImg = ImagesExtension.GetFirstImageInContent(contentDetail);

                if (urlImg.Length > 0)
                {
                    string filename = urlImg;
                    string fileex   = filename.Substring(filename.LastIndexOf("."));
                    string path     = Request.PhysicalApplicationPath + "/" + pic + "/";
                    if (TatThanhJsc.Extension.ImagesExtension.ValidType(fileex))
                    {
                        string fileNotEx = StringExtension.ReplateTitle(filename.Remove(filename.LastIndexOf(".") - 1));
                        if (fileNotEx.Length > 9)
                        {
                            fileNotEx = fileNotEx.Remove(9);
                        }
                        string ticks = DateTime.Now.Ticks.ToString();
                        #region Lưu ảnh đại diện theo 2 trường hợp: tạo ảnh nhỏ hoặc không.
                        //Kiểm tra xem có tạo ảnh nhỏ hay ko
                        //Nếu không tạo ảnh nhỏ, tên tệp lưu bình thường theo kiểu: tên_tệp.phần_mở_rộng
                        //Nếu tạo ảnh nhỏ, tên tệp sẽ theo kiểu: tên_tệp_HasThumb.phần_mở_rộng
                        //Khi đó tên tệp ảnh nhỏ sẽ theo kiểu:   tên_tệp_HasThumb_Thumb.phần_mở_rộng
                        //Với cách lưu tên ảnh này, khi thực hiện lưu vào csdl chỉ cần lưu tên ảnh gốc
                        //khi hiển thị chỉ cần dựa vào tên ảnh gốc để biết ảnh đó có ảnh nhỏ hay không, việc này được thực hiện bởi TatThanhJsc.Extension.ImagesExtension.GetImage, lập trình không cần làm gì thêm.
                        if (cbTaoAnhNho.Checked)
                        {
                            vimg = fileNotEx + "_" + ticks + "_HasThumb";
                        }
                        else
                        {
                            vimg = fileNotEx + "_" + ticks;
                        }

                        if (ImagesExtension.SaveImageFromUrl(path + vimg, urlImg).Length > 0)
                        {
                            vimg += fileex;

                            #region Hạn chế kích thước
                            if (cbHanCheKichThuoc.Checked)
                            {
                                ImagesExtension.ResizeImage(path + vimg, "", tbHanCheW.Text, tbHanCheH.Text);
                            }
                            #endregion
                            #region Đóng dấu ảnh
                            if (cbDongDauAnh.Checked)
                            {
                                ImagesExtension.CreateWatermark(path + vimg, path + hdLogoImage.Value, hdViTriDongDau.Value, hdLeX.Value, hdLeY.Value, hdTyLe.Value, hdTrongSuot.Value);
                            }
                            #endregion
                            #region Tạo ảnh nhỏ: Thực hiện cuối để đảm bảo ảnh nhỏ cũng có con dấu
                            if (cbTaoAnhNho.Checked)
                            {
                                vimg_thumb = fileNotEx + "_" + ticks + "_HasThumb_Thumb" + fileex;
                                ImagesExtension.ResizeImage(path + vimg, path + vimg_thumb, tbAnhNhoW.Text, tbAnhNhoH.Text);
                            }
                            #endregion
                        }
                        else
                        {
                            vimg = "";
                        }
                        #endregion
                    }
                }
            }
        }
        #endregion
        #region file
        // file Catalog
        string fileNameCatalog = "";
        string fileLink        = txtLinkCatalog.Text;
        if (fileCatalog.PostedFile.ContentLength > 0)
        {
            string filename = fileCatalog.FileName;
            string fileex   = filename.Substring(filename.LastIndexOf("."));
            string path     = Request.PhysicalApplicationPath + "/" + pic + "/";

            string fileNotEx = StringExtension.ReplateTitle(filename.Remove(filename.LastIndexOf(".") - 1));
            if (fileNotEx.Length > 9)
            {
                fileNotEx = fileNotEx.Remove(9);
            }
            // lấy giá trị random, tránh trường hợp đường dẫn trùng nhau
            string ticks = DateTime.Now.Ticks.ToString();
            #region Lưu tệp đính kèm
            fileNameCatalog = fileNotEx + "_" + ticks + fileex;
            fileCatalog.SaveAs(path + fileNameCatalog);
            #endregion
        }

        //file Document
        string fileNameDocument = "";
        string fileLinkCatalog  = txtLinkDocument.Text;
        if (fileDocument.PostedFile.ContentLength > 0)
        {
            string filename = fileDocument.FileName;
            string fileex   = filename.Substring(filename.LastIndexOf("."));
            string path     = Request.PhysicalApplicationPath + "/" + pic + "/";

            string fileNotEx = StringExtension.ReplateTitle(filename.Remove(filename.LastIndexOf(".") - 1));
            if (fileNotEx.Length > 9)
            {
                fileNotEx = fileNotEx.Remove(9);
            }
            // lấy giá trị random, tránh trường hợp đường dẫn trùng nhau
            string ticks = DateTime.Now.Ticks.ToString();
            #region Lưu tệp đính kèm
            fileNameDocument = fileNotEx + "_" + ticks + fileex;
            fileDocument.SaveAs(path + fileNameDocument);
            #endregion
        }
        #endregion
        #region Status
        string status  = "0";
        string conhang = "0";
        string hangmoi = "0";
        if (chk_status.Checked == true)
        {
            status = "1";
        }
        if (ckbConHang.Checked)
        {
            conhang = "1";
        }
        if (ckCheckHot.Checked)
        {
            hangmoi = "1";
        }
        #endregion
        #region Time Create Date
        string timeCreateDate = "";
        timeCreateDate = txtCreateDate.Text;
        #endregion
        #region Seo
        if (textLinkRewrite.Text.Trim().Equals(""))
        {
            textLinkRewrite.Text = txt_title.Text;
        }
        if (textTagTitle.Text.Trim().Equals(""))
        {
            textTagTitle.Text = txt_title.Text;
        }
        if (textTagKeyword.Text.Trim().Equals(""))
        {
            textTagKeyword.Text = txt_title.Text;
        }
        if (textTagDescription.Text.Trim().Equals(""))
        {
            textTagDescription.Text = txt_description.Text;
        }
        #endregion

        string viparams = StringExtension.GhepChuoi("", tbThongSo.Text, conhang, hangmoi);

        // Check lưu file Document and catalog
        if (fileNameCatalog.Equals(""))
        {
            fileNameCatalog = hdFileCatalog.Value;
        }
        if (fileNameDocument.Equals(""))
        {
            fileNameDocument = hdFileDocument.Value;
        }
        string viUrl = StringExtension.GhepChuoi("",
                                                 fileNameCatalog,
                                                 txtLinkCatalog.Text,
                                                 fileNameDocument,
                                                 txtLinkDocument.Text);
        #region Insert
        if (insert)
        {
            GroupsItems.InsertItemsGroupsItems(language, app, tbKey.Text, txt_title.Text, txt_description.Text,
                                               contentDetail, vimg, viUrl, tbThuongHieu.Text, textTagTitle.Text, textLinkRewrite.Text,
                                               StringExtension.ReplateTitle(textLinkRewrite.Text), textTagKeyword.Text, textTagDescription.Text, txtXuatXu.Text, "",
                                               "", viparams, tbPrice.Text, tbPriceOld.Text, "", "", timeCreateDate, DateTime.Now.ToString(),
                                               DateTime.Now.ToString(), tbOrder.Text, ddl_group_product.SelectedValue, timeCreateDate,
                                               DateTime.Now.ToString(), DateTime.Now.ToString(), tbOrder.Text, status);

            #region Lay ra iid cua item vua duoc luu
            condition = DataExtension.AndConditon(
                ItemsTSql.GetItemsByDicreatedate(timeCreateDate),
                ItemsTSql.GetItemsByViapp(app));
            DataTable dtInsertedItems = new DataTable();

            dtInsertedItems = GroupsItems.GetAllData("1", "Items.iid", condition, ItemsColumns.IidColumn + " desc");
            if (dtInsertedItems.Rows.Count > 0)
            {
                iid = dtInsertedItems.Rows[0][ItemsColumns.IidColumn].ToString();
            }
            #endregion
        }
        #endregion
        #region Update
        else
        {
            if (vimg.Equals(""))
            {
                vimg = hd_img.Value;
            }
            else
            {
                ImagesExtension.DeleteImageWhenDeleteItem(pic, hd_img.Value);
            }

            GroupsItems.DeleteGroupsItems(GroupsItemsTSql.GetByIgiid(hdigi_id.Value));
            GroupsItems.UpdateItemsGroupsItems(language, app, tbKey.Text, txt_title.Text, txt_description.Text,
                                               contentDetail, vimg, viUrl, tbThuongHieu.Text, textTagTitle.Text, textLinkRewrite.Text,
                                               StringExtension.ReplateTitle(textLinkRewrite.Text), textTagKeyword.Text, textTagDescription.Text, txtXuatXu.Text, "",
                                               "", viparams, tbPrice.Text, tbPriceOld.Text, "", HdIitotalview.Value, timeCreateDate, DateTime.Now.ToString(),
                                               DateTime.Now.ToString(), tbOrder.Text, ddl_group_product.SelectedValue, timeCreateDate,
                                               DateTime.Now.ToString(), DateTime.Now.ToString(), tbOrder.Text, status, iid);
        }
        #endregion

        #region Thêm vào các danh mục khác

        //string igparentsid = "";
        //foreach (ListItem item in cbListCates.Items)
        //{

        //    if(item.Selected && item.Value != ddl_group_product.SelectedValue)
        //    {
        //        igparentsid = GetParentsId(item.Value);
        //        GroupsItems.InsertGroupsItems(item.Value, iid, igparentsid, DateTime.Now.ToString(),
        //            DateTime.Now.ToString(), DateTime.Now.ToString(), tbOrder.Text);
        //    }
        //}
        #endregion

        #region Properties-Chi thực hiện khi chức năng Quản lý thuộc tính được hiển thị
        if (ProductConfig.KeyHienThiQuanLyThuocTinhSanPham)
        {
            string properties = parramSpitString;
            for (int i = 0; i < rptProperties.Items.Count; i++)
            {
                CheckBox checkBoxProperties = (CheckBox)rptProperties.Items[i].FindControl("checkBoxProperties");
                if (checkBoxProperties.Checked == true)
                {
                    properties += checkBoxProperties.ToolTip + parramSpitString;
                }
            }

            condition = DataExtension.AndConditon(
                SubitemsTSql.GetSubitemsByIid(iid),
                SubitemsTSql.GetSubitemsByVskey(propertyModul));
            fields = DataExtension.GetListColumns(SubitemsColumns.IsidColumn, SubitemsColumns.VscontentColumn);
            DataTable dt = new DataTable();
            dt = Subitems.GetSubItems("", fields, condition, "");

            if (dt.Rows.Count > 0)
            {
                string isid = dt.Rows[0][SubitemsColumns.IsidColumn].ToString();
                //Cap nhat
                Subitems.UpdateSubitems(iid, language, propertyModul, "", properties, "", "", "", "", DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), "1", isid);
            }
            else
            {
                //Them moi
                Subitems.InsertSubitems(iid, language, propertyModul, "", properties, "", "", "", "", DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), "1");
            }
        }
        #endregion

        #region Nicks - Chỉ hiển thị khi chức năng add nick được hiển thị
        if (ProductConfig.KeyHienThiAddNickChoSanPham)
        {
            string nicks = parramSpitString;
            for (int i = 0; i < rptNicks.Items.Count; i++)
            {
                CheckBox checkBoxNicks = (CheckBox)rptNicks.Items[i].FindControl("checkBoxNicks");
                if (checkBoxNicks.Checked == true)
                {
                    nicks += checkBoxNicks.ToolTip + parramSpitString;
                }
            }

            condition = DataExtension.AndConditon(
                SubitemsTSql.GetSubitemsByIid(iid),
                SubitemsTSql.GetSubitemsByVskey(TatThanhJsc.OtherModul.CodeApplications.SupportOnline));
            fields = DataExtension.GetListColumns(SubitemsColumns.IsidColumn, SubitemsColumns.VscontentColumn);
            DataTable dt = new DataTable();
            dt = Subitems.GetSubItems("", fields, condition, "");

            if (dt.Rows.Count > 0)
            {
                string isid = dt.Rows[0][SubitemsColumns.IsidColumn].ToString();
                //Cap nhat
                Subitems.UpdateSubitems(iid, language, TatThanhJsc.OtherModul.CodeApplications.SupportOnline, "", nicks, "", "", "", "", DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), "1", isid);
            }
            else
            {
                //Them moi
                Subitems.InsertSubitems(iid, language, TatThanhJsc.OtherModul.CodeApplications.SupportOnline, "", nicks, "", "", "", "", DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), "1");
            }
        }
        #endregion

        #region FilterProperties - Chỉ hiển thị khi tính năng lọc sản phẩm được hiển thị
        if (ProductConfig.KeyHienThiThuocTinhLocSanPham)
        {
            string filterProperties = parramSpitString;
            for (int i = 0; i < rptParentFilter.Items.Count; i++)
            {
                RadioButtonList rdblListAnswer = (RadioButtonList)rptParentFilter.Items[i].FindControl("rdblAnswer");
                if (rdblListAnswer != null)
                {
                    if (rdblListAnswer.SelectedValue.Length > 0)
                    {
                        filterProperties += rdblListAnswer.SelectedValue + parramSpitString;
                    }
                }

                CheckBoxList cblListAnswer = (CheckBoxList)rptParentFilter.Items[i].FindControl("cblAnswer");
                if (cblListAnswer != null)
                {
                    for (int j = 0; j < cblListAnswer.Items.Count; j++)
                    {
                        if (cblListAnswer.Items[j].Selected == true)
                        {
                            filterProperties += cblListAnswer.Items[j].Value + parramSpitString;
                        }
                    }
                }
            }

            condition = DataExtension.AndConditon(
                SubitemsTSql.GetSubitemsByIid(iid),
                SubitemsTSql.GetSubitemsByVskey(CodeApplications.ProductFilterProperties));
            fields = DataExtension.GetListColumns(SubitemsColumns.IsidColumn, SubitemsColumns.VscontentColumn);
            DataTable dt = new DataTable();
            dt = Subitems.GetSubItems("", fields, condition, "");

            if (dt.Rows.Count > 0)
            {
                string isid = dt.Rows[0][SubitemsColumns.IsidColumn].ToString();
                //Cap nhat
                Subitems.UpdateSubitems(iid, language, CodeApplications.ProductFilterProperties, "", filterProperties, "", "", "", "", DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), "1", isid);
            }
            else
            {
                //Them moi
                Subitems.InsertSubitems(iid, language, CodeApplications.ProductFilterProperties, "", filterProperties, "", "", "", "", DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), "1");
            }
        }
        #endregion

        #region After Insert/Update

        if (ckbContinue.Checked == true)
        {
            //ScriptManager.RegisterStartupScript(this, this.GetType(), "alertSuccess",
            //    "ThongBao(3000,'Đã tạo: " + txt_title.Text + "');", true);
            //Lưu vào session để gọi đến bên api
            Session["CotinuteCreate"]      = true;
            Session["CotinuteCreateTitle"] = txt_title.Text;
            ResetControls();
        }
        else
        {
            Session["CotinuteCreate"]             = false;
            Session["CotinuteCreateRedirectLink"] = LinkRedrect();
        }

        #endregion
    }
    protected void btOK_Click(object sender, EventArgs e)
    {
        string vimg = "";//Không xử lý thêm ảnh mà chỉ thêm file

        //#region Image
        //string vimg = "";
        //string vimg_thumb = "";
        //if (flimg.PostedFile.ContentLength > 0)
        //{
        //    string filename = flimg.FileName;
        //    string fileex = filename.Substring(filename.LastIndexOf("."));
        //    string path = Request.PhysicalApplicationPath + "/" + pathFolderPic + "/";
        //    if (ImagesExtension.ValidType(fileex))
        //    {
        //        string fileNotEx = StringExtension.ReplateTitle(filename.Remove(filename.LastIndexOf(".") - 1));
        //        if (fileNotEx.Length > 9) fileNotEx = fileNotEx.Remove(9);
        //        string ticks = DateTime.Now.Ticks.ToString();
        //        #region Lưu ảnh đại diện theo 2 trường hợp: tạo ảnh nhỏ hoặc không.
        //        //Kiểm tra xem có tạo ảnh nhỏ hay ko
        //        //Nếu không tạo ảnh nhỏ, tên tệp lưu bình thường theo kiểu: tên_tệp.phần_mở_rộng
        //        //Nếu tạo ảnh nhỏ, tên tệp sẽ theo kiểu: tên_tệp_HasThumb.phần_mở_rộng
        //        //Khi đó tên tệp ảnh nhỏ sẽ theo kiểu:   tên_tệp_HasThumb_Thumb.phần_mở_rộng
        //        //Với cách lưu tên ảnh này, khi thực hiện lưu vào csdl chỉ cần lưu tên ảnh gốc
        //        //khi hiển thị chỉ cần dựa vào tên ảnh gốc để biết ảnh đó có ảnh nhỏ hay không, việc này được thực hiện bởi ImagesExtension.GetImage, lập trình không cần làm gì thêm.
        //        if (cbTaoAnhNho.Checked)
        //            vimg = fileNotEx + "_" + ticks + "_HasThumb" + fileex;
        //        else
        //            vimg = fileNotEx + "_" + ticks + fileex;
        //        flimg.SaveAs(path + vimg);
        //        #endregion
        //        #region Hạn chế kích thước
        //        if (cbHanCheKichThuoc.Checked)
        //            ImagesExtension.ResizeImage(path + vimg, "", tbHanCheW.Text, tbHanCheH.Text);
        //        #endregion
        //        #region Đóng dấu ảnh
        //        if (cbDongDauAnh.Checked)
        //            ImagesExtension.CreateWatermark(path + vimg, path + hdLogoImage.Value, hdViTriDongDau.Value, hdLeX.Value, hdLeY.Value, hdTyLe.Value, hdTrongSuot.Value);
        //        #endregion
        //        #region Tạo ảnh nhỏ: Thực hiện cuối để đảm bảo ảnh nhỏ cũng có con dấu
        //        if (cbTaoAnhNho.Checked)
        //        {
        //            vimg_thumb = fileNotEx + "_" + ticks + "_HasThumb_Thumb" + fileex;
        //            ImagesExtension.ResizeImage(path + vimg, path + vimg_thumb, tbAnhNhoW.Text, tbAnhNhoH.Text);

        //
        //        }
        //        #endregion

        //
        //    }
        //}
        //#endregion

        #region File
        string file     = "";
        string fileLink = tbFileLink.Text;
        if (flFile.PostedFile.ContentLength > 0)
        {
            string filename = flFile.FileName;
            string fileex   = filename.Substring(filename.LastIndexOf("."));
            string path     = Request.PhysicalApplicationPath + "/" + pathFolderPic + "/";

            string fileNotEx = StringExtension.ReplateTitle(filename.Remove(filename.LastIndexOf(".") - 1));
            if (fileNotEx.Length > 9)
            {
                fileNotEx = fileNotEx.Remove(9);
            }
            string ticks = DateTime.Now.Ticks.ToString();
            #region Lưu tệp đính kèm
            file = fileNotEx + "_" + ticks + fileex;
            flFile.SaveAs(path + file);
            #endregion
        }
        #endregion

        /*
         * Thêm mới tệp đính kèm
         * modul - vskey,vsemail - mã màu,vstitle - tên, vsimage - tệp đính kèm, vsauthor - thứ tự, isenable - trạng thái
         */
        string color = "";
        if (!update)
        {
            string vicontent = StringExtension.GhepChuoi("", file, fileLink);
            Subitems.InsertSubitems(iid, language, app, tbName.Text, vicontent, vimg, color, tbOrder.Text, "",
                                    DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), ddlStatus.SelectedValue);
        }
        else
        {
            if (vimg.Equals(""))
            {
                vimg = hd_img;
            }
            else
            {
                ImagesExtension.DeleteImageWhenDeleteItem(pathFolderPic, hd_img);
            }

            if (file.Equals(""))
            {
                file = hdFile.Value;
            }
            else
            {
                TatThanhJsc.Extension.ImagesExtension.DeleteImageWhenDeleteItem(pathFolderPic, hdFile.Value);
            }

            string vicontent = StringExtension.GhepChuoi("", file, fileLink);

            Subitems.UpdateSubitems(iid, language, app, tbName.Text, vicontent, vimg, color, tbOrder.Text, "",
                                    DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), ddlStatus.SelectedValue,
                                    currentIsid.Value);
        }

        ResetControls();
        GetList();
        pnList.Visible   = true;
        pnInsert.Visible = false;
    }
    protected void btn_insert_update_Click(object sender, EventArgs e)
    {
        #region Image
        string vimg       = "";
        string vimg_thumb = "";
        if (flimg.PostedFile.ContentLength > 0)
        {
            string filename = flimg.FileName;
            string fileex   = filename.Substring(filename.LastIndexOf("."));
            string path     = Request.PhysicalApplicationPath + "/" + pic + "/";
            if (ImagesExtension.ValidType(fileex))
            {
                string fileNotEx = StringExtension.ReplateTitle(filename.Remove(filename.LastIndexOf(".") - 1));
                if (fileNotEx.Length > 9)
                {
                    fileNotEx = fileNotEx.Remove(9);
                }
                string ticks = DateTime.Now.Ticks.ToString();
                #region Lưu ảnh đại diện theo 2 trường hợp: tạo ảnh nhỏ hoặc không.
                //Kiểm tra xem có tạo ảnh nhỏ hay ko
                //Nếu không tạo ảnh nhỏ, tên tệp lưu bình thường theo kiểu: tên_tệp.phần_mở_rộng
                //Nếu tạo ảnh nhỏ, tên tệp sẽ theo kiểu: tên_tệp_HasThumb.phần_mở_rộng
                //Khi đó tên tệp ảnh nhỏ sẽ theo kiểu:   tên_tệp_HasThumb_Thumb.phần_mở_rộng
                //Với cách lưu tên ảnh này, khi thực hiện lưu vào csdl chỉ cần lưu tên ảnh gốc
                //khi hiển thị chỉ cần dựa vào tên ảnh gốc để biết ảnh đó có ảnh nhỏ hay không, việc này được thực hiện bởi ImagesExtension.GetImage, lập trình không cần làm gì thêm.
                if (cbTaoAnhNho.Checked)
                {
                    vimg = fileNotEx + "_" + ticks + "_HasThumb" + fileex;
                }
                else
                {
                    vimg = fileNotEx + "_" + ticks + fileex;
                }
                flimg.SaveAs(path + vimg);
                #endregion
                #region Hạn chế kích thước
                if (cbHanCheKichThuoc.Checked)
                {
                    ImagesExtension.ResizeImage(path + vimg, "", tbHanCheW.Text, tbHanCheH.Text);
                }
                #endregion
                #region Đóng dấu ảnh
                if (cbDongDauAnh.Checked)
                {
                    ImagesExtension.CreateWatermark(path + vimg, path + hdLogoImage.Value, hdViTriDongDau.Value, hdLeX.Value, hdLeY.Value, hdTyLe.Value, hdTrongSuot.Value);
                }
                #endregion
                #region Tạo ảnh nhỏ: Thực hiện cuối để đảm bảo ảnh nhỏ cũng có con dấu
                if (cbTaoAnhNho.Checked)
                {
                    vimg_thumb = fileNotEx + "_" + ticks + "_HasThumb_Thumb" + fileex;
                    ImagesExtension.ResizeImage(path + vimg, path + vimg_thumb, tbAnhNhoW.Text, tbAnhNhoH.Text);
                }
                #endregion
            }
        }
        #endregion
        #region Status
        string status = "0";
        if (chk_status.Checked == true)
        {
            status = "1";
        }
        #endregion
        #region Time Create Date
        string timeCreateDate = "";
        timeCreateDate = txtCreateDate.Text;
        #endregion
        #region Seo
        if (textLinkRewrite.Text.Trim().Equals(""))
        {
            textLinkRewrite.Text = txt_title.Text;
        }
        if (textTagTitle.Text.Trim().Equals(""))
        {
            textTagTitle.Text = txt_title.Text;
        }
        if (textTagKeyword.Text.Trim().Equals(""))
        {
            textTagKeyword.Text = txt_title.Text;
        }
        if (textTagDescription.Text.Trim().Equals(""))
        {
            textTagDescription.Text = txt_description.Text;
        }
        #endregion
        string newContent = ContentExtendtions.ProcessStringContent(txt_content.Text, hdOldContent.Value, pic);
        #region Insert
        if (insert)
        {
            GroupsItems.InsertItemsGroupsItems(language, app, "", txt_title.Text, txt_description.Text, newContent, vimg, "", "", textTagTitle.Text, textLinkRewrite.Text, StringExtension.ReplateTitle(textLinkRewrite.Text), textTagKeyword.Text, textTagDescription.Text, "", "", "", "", "", "", "", "", timeCreateDate, DateTime.Now.ToString(), DateTime.Now.ToString(), "", ddl_group_product.SelectedValue, txtCreateDate.Text, DateTime.Now.ToString(), DateTime.Now.ToString(), "", status);

            #region Lay ra iid cua item vua duoc luu
            condition = DataExtension.AndConditon(
                ItemsTSql.GetItemsByVititle(txt_title.Text),
                ItemsTSql.GetItemsByViapp(app));
            DataTable dtInsertedItems = new DataTable();
            dtInsertedItems = GroupsItems.GetAllData("1", "Items.iid", condition, ItemsColumns.IidColumn + " desc");
            if (dtInsertedItems.Rows.Count > 0)
            {
                iid = dtInsertedItems.Rows[0][ItemsColumns.IidColumn].ToString();
            }
            #endregion
        }
        #endregion
        #region Update
        else
        {
            if (vimg.Equals(""))
            {
                vimg = hd_img;
            }
            else
            {
                ImagesExtension.DeleteImageWhenDeleteItem(pic, hd_img);
            }
            GroupsItems.UpdateItemsGroupsItems(language, app, "", txt_title.Text, txt_description.Text, newContent, vimg, "", "", textTagTitle.Text, textLinkRewrite.Text, StringExtension.ReplateTitle(textLinkRewrite.Text), textTagKeyword.Text, textTagDescription.Text, "", "", "", "", "", "", "", HdIitotalview, timeCreateDate, DateTime.Now.ToString(), DateTime.Now.ToString(), "", ddl_group_product.SelectedValue, timeCreateDate, DateTime.Now.ToString(), DateTime.Now.ToString(), "", status, iid);
        }
        #endregion
        #region After Insert/Update
        if (ckbContinue.Checked == true)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "alertSuccess", "ThongBao(3000,'Đã tạo: " + txt_title.Text + "');", true);
            ResetControls();
        }
        else
        {
            Response.Redirect(LinkRedrect());
        }
        #endregion
    }