void ThemAnhChoDeal()
    {
        //Lay igid
        if (Request.Params["iid"] != null)
        {
            string iid   = StringExtension.RemoveSqlInjectionChars(Request.Params["iid"]);
            string color = StringExtension.RemoveSqlInjectionChars(Request.Params["color"]);
            // Get the data
            HttpPostedFile fileUpload = Request.Files["Filedata"];

            string fileName      = fileUpload.FileName;
            string fileExtension = fileName.Substring(fileName.LastIndexOf("."));
            if (ImagesExtension.ValidType(fileExtension))
            {
                #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.
                string ticks = DateTime.Now.Ticks.ToString();
                if (SettingsExtension.GetSettingKey(SettingKey.TaoAnhNhoChoAnhDeal, lang) == "1")
                {
                    fileName = iid + "_" + ticks + "_HasThumb" + fileExtension;
                }
                else
                {
                    fileName = iid + "_" + ticks + fileExtension;
                }

                string path = Request.PhysicalApplicationPath + "/" + pic + "/";
                fileUpload.SaveAs(path + fileName);
                #endregion
                #region Hạn chế kích thước
                if (SettingsExtension.GetSettingKey(SettingKey.HanCheKichThuocAnhDeal, lang) == "1")
                {
                    ImagesExtension.ResizeImage(path + fileName, "", SettingsExtension.GetSettingKey(SettingKey.HanCheKichThuocAnhDeal_MaxWidth, lang), SettingsExtension.GetSettingKey(SettingKey.HanCheKichThuocAnhDeal_MaxHeight, lang));
                }
                #endregion
                #region Đóng dấu ảnh
                if (SettingsExtension.GetSettingKey(SettingKey.DongDauAnhDeal, lang) == "1")
                {
                    ImagesExtension.CreateWatermark(path + fileName, path + SettingsExtension.GetSettingKey(SettingKey.DongDauAnhDeal_AnhDau, lang), SettingsExtension.GetSettingKey(SettingKey.DongDauAnhDeal_ViTri, lang), SettingsExtension.GetSettingKey(SettingKey.DongDauAnhDeal_LeNgang, lang), SettingsExtension.GetSettingKey(SettingKey.DongDauAnhDeal_LeDoc, lang), SettingsExtension.GetSettingKey(SettingKey.DongDauAnhDeal_TyLe, lang), SettingsExtension.GetSettingKey(SettingKey.DongDauAnhDeal_TrongSuot, lang));
                }
                #endregion
                #region Tạo ảnh nhỏ: Thực hiện cuối để đảm bảo ảnh nhỏ cũng có con dấu
                if (SettingsExtension.GetSettingKey(SettingKey.TaoAnhNhoChoAnhDeal, lang) == "1")
                {
                    string vimg_thumb = iid + "_" + ticks + "_HasThumb_Thumb" + fileExtension;
                    ImagesExtension.ResizeImage(path + fileName, path + vimg_thumb, SettingsExtension.GetSettingKey(SettingKey.TaoAnhNhoChoAnhDeal_MaxWidth, lang), SettingsExtension.GetSettingKey(SettingKey.TaoAnhNhoChoAnhDeal_MaxHeight, lang));
                }
                #endregion


                Subitems.InsertSubitems(iid, lang, app, fileName, "", fileName, color, "1", "", DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), "1");

                //Session["CurrentUploadedFileName"] = fileName;
                Response.StatusCode = 200;
            }
        }
    }
    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 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);
    }
Example #4
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
    }
    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 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;
    }
    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);
    }
Example #8
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 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
    }
    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;
    }
Example #11
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 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
    }
    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
    }