protected void BtnSave_Click(object sender, EventArgs e) { string status = "0"; if (cbEnable.Checked == true) { status = "1"; } if (hdInsertUpdate.Value.Equals("insert")) { GroupsItems.InsertItemsGroupsItems(language, app, "", TbRep.Text, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "0", "0", "", "", "", DateTime.Now.ToString(), DateTime.Now.ToString(), "", igid, DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), "", status); } else { GroupsItems.UpdateItemsGroupsItems(language, app, "", TbRep.Text, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "0", "0", "", "", "", DateTime.Now.ToString(), DateTime.Now.ToString(), "", igid, DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), "", status, HdId.Value); } pnList.Visible = true; pnShorcut.Visible = false; GetVotes(); }
private void Booking() { string s = "Success"; #region Lấy thông tin string name = Request.Params["name"]; string phone = Request.Params["phone"]; string email = Request.Params["email"]; string nationality = Request.Params["nationality"]; string service = Request.Params["service"]; string content = Request.Params["content"]; string thongtinkhac = StringExtension.GhepChuoi("", phone, email, nationality); string igid = GetFirstCateId(); #endregion GroupsItems.InsertItemsGroupsItems(lang, "QLDDDV", "", service, "", content, "", "", name, "", "", "", "", "", "", "", "", thongtinkhac, "0", "0", "", "", DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), "", igid, DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), "", "0"); #region Gửi email thông báo đến string emailhethong = SettingsExtension.GetSettingKey(SettingsExtension.KeyMailWebsite, lang); string emailkhac = SettingsExtension.GetSettingKey(SettingsExtension.KeyEmailPhu, lang); string[] listemail = emailkhac.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); string date = DateTime.Now.ToString(); string subject = LanguageItemExtension.GetnLanguageItemTitleByName("Thông báo từ") + " " + UrlExtension.WebisteUrl + " " + date; string body = @" <div style='font:bold 14px Arial;padding-bottom:15px'>" + LanguageItemExtension.GetnLanguageItemTitleByName("Xin chào! Bạn có một đơn đặt dịch vụ từ") + @" " + UrlExtension.WebisteUrl + @"</div> <div style='font:bold 12px Arial;padding-bottom:10px'>" + LanguageItemExtension.GetnLanguageItemTitleByName("Chi tiết") + @":</div> <ul> <li>" + LanguageItemExtension.GetnLanguageItemTitleByName("Họ tên") + @": " + name + @"</li> <li>" + LanguageItemExtension.GetnLanguageItemTitleByName("Điện thoại") + @": " + phone + @"</li> <li>" + LanguageItemExtension.GetnLanguageItemTitleByName("Email") + @": " + email + @"</li> <li>" + LanguageItemExtension.GetnLanguageItemTitleByName("Quốc tích") + @": " + nationality + @"</li> <li>" + LanguageItemExtension.GetnLanguageItemTitleByName("Gửi lúc") + @": " + DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt") + @"</li> <li>" + LanguageItemExtension.GetnLanguageItemTitleByName("Dịch vụ đăng ký") + @": " + service + @"</li> <li>" + LanguageItemExtension.GetnLanguageItemTitleByName("Nội dung") + @": " + content + @"</li> </ul>"; EmailExtension.SendEmail(emailhethong, subject, body, listemail); #endregion string[] strArrayReturn = { s }; Response.Write(js.Serialize(strArrayReturn)); }
/// <summary> /// Gửi liên hệ và trả về thông báo (nếu thông báo trống tức là gửi liên hệ thành công) /// </summary> /// <returns></returns> protected string SendContact(string tbHoTen_dkh, string tbDienThoai_dkh, string tbEmail_dkh, string tbDiaChi_dkh, string noiDung, string firstCateId) { string check = ""; try { string thongtinkhac = StringExtension.GhepChuoi("", tbDienThoai_dkh, tbDiaChi_dkh, "", ""); GroupsItems.InsertItemsGroupsItems(lang, app, "", "<b>Đơn đăng ký tư vấn dịch vụ</b>", tbEmail_dkh, noiDung, "", "", tbHoTen_dkh, "", "", "", "", "", "", "", "", thongtinkhac, "0", "0", "", "", DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), "", firstCateId, DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), "", "0"); } catch { check = LanguageItemExtension.GetnLanguageItemTitleByName("Có lỗi xảy ra, vui lòng thử lại sau!"); } return(check); }
protected void btn_insert_update_Click(object sender, EventArgs e) { string contentDetail = ContentExtendtions.ProcessStringContent(txt_content.Text, hdOldService.Value, pic); #region Image string vimg = ""; string vimg_thumb = ""; if (flimg.PostedFile.ContentLength > 0) { string filename = flimg.FileName; string fileex = filename.Substring(filename.LastIndexOf(".")); string path = Request.PhysicalApplicationPath + "/" + pic + "/"; if (TatThanhJsc.Extension.ImagesExtension.ValidType(fileex)) { string fileNotEx = StringExtension.ReplateTitle(filename.Remove(filename.LastIndexOf(".") - 1)); if (fileNotEx.Length > 9) { fileNotEx = fileNotEx.Remove(9); } string ticks = DateTime.Now.Ticks.ToString(); #region Lưu ảnh đại diện theo 2 trường hợp: tạo ảnh nhỏ hoặc không. //Kiểm tra xem có tạo ảnh nhỏ hay ko //Nếu không tạo ảnh nhỏ, tên tệp lưu bình thường theo kiểu: tên_tệp.phần_mở_rộng //Nếu tạo ảnh nhỏ, tên tệp sẽ theo kiểu: tên_tệp_HasThumb.phần_mở_rộng //Khi đó tên tệp ảnh nhỏ sẽ theo kiểu: tên_tệp_HasThumb_Thumb.phần_mở_rộng //Với cách lưu tên ảnh này, khi thực hiện lưu vào csdl chỉ cần lưu tên ảnh gốc //khi hiển thị chỉ cần dựa vào tên ảnh gốc để biết ảnh đó có ảnh nhỏ hay không, việc này được thực hiện bởi TatThanhJsc.Extension.ImagesExtension.GetImage, lập trình không cần làm gì thêm. if (cbTaoAnhNho.Checked) { vimg = fileNotEx + "_" + ticks + "_HasThumb" + fileex; } else { vimg = fileNotEx + "_" + ticks + fileex; } flimg.SaveAs(path + vimg); #endregion #region Hạn chế kích thước if (cbHanCheKichThuoc.Checked) { ImagesExtension.ResizeImage(path + vimg, "", tbHanCheW.Text, tbHanCheH.Text); } #endregion #region Đóng dấu ảnh if (cbDongDauAnh.Checked) { ImagesExtension.CreateWatermark(path + vimg, path + hdLogoImage.Value, hdViTriDongDau.Value, hdLeX.Value, hdLeY.Value, hdTyLe.Value, hdTrongSuot.Value); } #endregion #region Tạo ảnh nhỏ: Thực hiện cuối để đảm bảo ảnh nhỏ cũng có con dấu if (cbTaoAnhNho.Checked) { vimg_thumb = fileNotEx + "_" + ticks + "_HasThumb_Thumb" + fileex; ImagesExtension.ResizeImage(path + vimg, path + vimg_thumb, tbAnhNhoW.Text, tbAnhNhoH.Text); } #endregion } } 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 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 #region Insert if (insert) { GroupsItems.InsertItemsGroupsItems(language, app, tbKey.Text, txt_title.Text, txt_description.Text, contentDetail, vimg, tbDanhSachTepDinhKem.Text, "", textTagTitle.Text, textLinkRewrite.Text, StringExtension.ReplateTitle(textLinkRewrite.Text), textTagKeyword.Text, textTagDescription.Text, "", "", "", "", "0", "0", "", "", 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 #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.Equals("")) { vimg = hd_img.Value; } else { TatThanhJsc.Extension.ImagesExtension.DeleteImageWhenDeleteItem(pic, hd_img.Value); } GroupsItems.UpdateItemsGroupsItems(language, app, tbKey.Text, txt_title.Text, txt_description.Text, contentDetail, vimg, tbDanhSachTepDinhKem.Text, "", textTagTitle.Text, textLinkRewrite.Text, StringExtension.ReplateTitle(textLinkRewrite.Text), textTagKeyword.Text, textTagDescription.Text, "", "", "", "", "0", "0", "", 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); #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 Properties-Chi thực hiện khi chức năng Quản lý thuộc tính được hiển thị if (ServiceConfig.KeyHienThiQuanLyThuocTinhDichVu) { 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 = TatThanhJsc.Extension.DataExtension.AndConditon( TatThanhJsc.TSql.SubitemsTSql.GetSubitemsByIid(iid), TatThanhJsc.TSql.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 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) { string chiTiet = ContentExtendtions.ProcessStringContent(tbChiTiet.Text, hdChiTiet.Value, pic); #region Trạng thái string trangThai = "0"; if (cbTrangThai.Checked == true) { trangThai = "1"; } #endregion #region Seo if (tbSeoLink.Text.Trim().Equals("")) { tbSeoLink.Text = tbHoTen.Text; } if (tbSeoTitle.Text.Trim().Equals("")) { tbSeoTitle.Text = tbHoTen.Text; } if (tbSeoKeyword.Text.Trim().Equals("")) { tbSeoKeyword.Text = tbHoTen.Text; } if (tbSeoDescription.Text.Trim().Equals("")) { tbSeoDescription.Text = ""; } #endregion #region Ngày đăng if (tbNgayDang.Text == "") { tbNgayDang.Text = DateTime.Now.ToString(); } #endregion string viparams = StringExtension.GhepChuoi("", tbCongTy.Text, tbChucVu.Text, tbTieuDeYKien.Text); #region Insert if (insert) { string image = flAnhDaiDien.Save(false, chiTiet); GroupsItems.InsertItemsGroupsItems(lang, app, "", tbHoTen.Text, "", chiTiet, image, tbDiaChi.Text, tbEmail.Text, tbSeoTitle.Text, tbSeoLink.Text, StringExtension.ReplateTitle(tbSeoLink.Text), tbSeoKeyword.Text, tbSeoDescription.Text, "", "", "", viparams, "", "", "", "", tbNgayDang.Text, DateTime.Now.ToString(), DateTime.Now.ToString(), tbThuTu.Text, ddlParentCate.SelectedValue, tbNgayDang.Text, DateTime.Now.ToString(), DateTime.Now.ToString(), tbThuTu.Text, trangThai); #region Logs string logAuthor = CookieExtension.GetCookies("LoginSetting"); string logCreateDate = DateTime.Now.ToString(); Logs.InsertLogs(logCreateDate, Request.Url.ToString(), "", tbHoTen.Text, logAuthor, "", logCreateDate + ": " + logAuthor + " tạo mới " + tbHoTen.Text); #endregion } #endregion #region Update else { string image = flAnhDaiDien.Save(true, chiTiet); GroupsItems.DeleteGroupsItems(GroupsItemsTSql.GetGroupsItemsByIgiid(hdGroupsItemId.Value)); GroupsItems.UpdateItemsGroupsItems(lang, app, "", tbHoTen.Text, "", chiTiet, image, tbDiaChi.Text, tbEmail.Text, tbSeoTitle.Text, tbSeoLink.Text, StringExtension.ReplateTitle(tbSeoLink.Text), tbSeoKeyword.Text, tbSeoDescription.Text, "", "", "", viparams, "", "", "", hdTotalView.Value, tbNgayDang.Text, DateTime.Now.ToString(), DateTime.Now.ToString(), tbThuTu.Text, ddlParentCate.SelectedValue, tbNgayDang.Text, DateTime.Now.ToString(), DateTime.Now.ToString(), tbThuTu.Text, trangThai, iid); #region Logs string logAuthor = CookieExtension.GetCookies("LoginSetting"); string logCreateDate = DateTime.Now.ToString(); Logs.InsertLogs(logCreateDate, Request.Url.ToString(), "", tbHoTen.Text, logAuthor, "", logCreateDate + ": " + logAuthor + " cập nhật " + tbHoTen.Text); #endregion } #endregion #region After Insert/Update if (cbTiepTuc.Checked == true) { ScriptManager.RegisterStartupScript(this, this.GetType(), "alertSuccess", "ThongBao(3000,'Đã tạo: " + tbHoTen.Text + "');", true); ResetControls(); } else { Response.Redirect(LinkRedrect()); } #endregion }
protected void btOK_Click(object sender, EventArgs e) { string content = StringExtension.GhepChuoi("", tbXuatPhat.Text, tbPhuongTien.Text, tbYoutubeEmbed.Text, tbMaDinhKemBanDoTour.Text, tbGioKhoiHanh.Text); #region Trạng thái string trangThai = "0"; if (cbTrangThai.Checked == true) { trangThai = "1"; } #endregion #region Seo if (tbSeoLink.Text.Trim().Equals("")) { tbSeoLink.Text = tbTenTour.Text; } if (tbSeoTitle.Text.Trim().Equals("")) { tbSeoTitle.Text = tbTenTour.Text; } if (tbSeoKeyword.Text.Trim().Equals("")) { tbSeoKeyword.Text = tbTenTour.Text; } if (tbSeoDescription.Text.Trim().Equals("")) { tbSeoDescription.Text = tbMoTa.Text; } #endregion #region Ngày đăng if (tbNgayDang.Text == "") { tbNgayDang.Text = DateTime.Now.ToString(); } #endregion string giaChuanKhiDatTour = StringExtension.GhepChuoi("", tbGiaChoNguoiLon.Text, tbGiaChoTreViThanhNien.Text, tbGiaChoTreEm.Text, tbGiaChoEmBe.Text); #region Insert if (insert) { string image = flAnhDaiDien.Save(false, tbMoTa.Text); GroupsItems.InsertItemsGroupsItems(lang, app, tbMaTour.Text, tbTenTour.Text, tbMoTa.Text, content, image, ddlThoiGianTour.SelectedValue, ddlDiemDen.SelectedValue, tbSeoTitle.Text, tbSeoLink.Text, StringExtension.ReplateTitle(tbSeoLink.Text), tbSeoKeyword.Text, tbSeoDescription.Text, giaChuanKhiDatTour, "", tbNgayKhoiHanh.Text, "", tbGiaNiemYet.Text, tbGiaKhuyenMai.Text, "", "", tbNgayDang.Text, DateTime.Now.ToString(), DateTime.Now.ToString(), tbThuTu.Text, ddlParentCate.SelectedValue, tbNgayDang.Text, DateTime.Now.ToString(), DateTime.Now.ToString(), tbThuTu.Text, trangThai); #region Lấy ra id của items vừa được thêm iid = GetInsertedId(app, tbTenTour.Text, tbNgayDang.Text); #endregion #region Logs string logAuthor = CookieExtension.GetCookies("LoginSetting"); string logCreateDate = DateTime.Now.ToString(); Logs.InsertLogs(logCreateDate, Request.Url.ToString(), "", tbTenTour.Text, logAuthor, "", logCreateDate + ": " + logAuthor + " tạo mới " + tbTenTour.Text); #endregion } #endregion #region Update else { string image = flAnhDaiDien.Save(true, tbMoTa.Text); GroupsItems.DeleteGroupsItems(GroupsItemsTSql.GetGroupsItemsByIgiid(hdGroupsItemId.Value)); GroupsItems.UpdateItemsGroupsItems(lang, app, tbMaTour.Text, tbTenTour.Text, tbMoTa.Text, content, image, ddlThoiGianTour.SelectedValue, ddlDiemDen.SelectedValue, tbSeoTitle.Text, tbSeoLink.Text, StringExtension.ReplateTitle(tbSeoLink.Text), tbSeoKeyword.Text, tbSeoDescription.Text, giaChuanKhiDatTour, "", tbNgayKhoiHanh.Text, "", tbGiaNiemYet.Text, tbGiaKhuyenMai.Text, "", hdTotalView.Value, tbNgayDang.Text, DateTime.Now.ToString(), DateTime.Now.ToString(), tbThuTu.Text, ddlParentCate.SelectedValue, tbNgayDang.Text, DateTime.Now.ToString(), DateTime.Now.ToString(), tbThuTu.Text, trangThai, iid); #region Logs string logAuthor = CookieExtension.GetCookies("LoginSetting"); string logCreateDate = DateTime.Now.ToString(); Logs.InsertLogs(logCreateDate, Request.Url.ToString(), "", tbTenTour.Text, logAuthor, "", logCreateDate + ": " + logAuthor + " cập nhật " + tbTenTour.Text); #endregion } #endregion #region Thuộc tính tour, mỗi thuộc tính làm một bản ghi liên kết Groups_Items #endregion #region After Insert/Update if (cbTiepTuc.Checked == true) { ScriptManager.RegisterStartupScript(this, this.GetType(), "alertSuccess", "ThongBao(3000,'Đã tạo: " + tbTenTour.Text + "');", true); ResetControls(); } else { Response.Redirect(LinkRedrect()); } #endregion }
protected void btn_insert_update_Click(object sender, EventArgs e) { string contentDetail = ContentExtendtions.ProcessStringContent(txt_content.Text, hdOldSupportOnline.Value, pic); #region Image string vimg = ""; string vimg_thumb = ""; if (flimg.PostedFile.ContentLength > 0) { string filename = flimg.FileName; string fileex = filename.Substring(filename.LastIndexOf(".")); string path = Request.PhysicalApplicationPath + "/" + pic + "/"; if (TatThanhJsc.Extension.ImagesExtension.ValidType(fileex)) { string fileNotEx = StringExtension.ReplateTitle(filename.Remove(filename.LastIndexOf(".") - 1)); if (fileNotEx.Length > 9) { fileNotEx = fileNotEx.Remove(9); } string ticks = DateTime.Now.Ticks.ToString(); #region Lưu ảnh đại diện theo 2 trường hợp: tạo ảnh nhỏ hoặc không. //Kiểm tra xem có tạo ảnh nhỏ hay ko //Nếu không tạo ảnh nhỏ, tên tệp lưu bình thường theo kiểu: tên_tệp.phần_mở_rộng //Nếu tạo ảnh nhỏ, tên tệp sẽ theo kiểu: tên_tệp_HasThumb.phần_mở_rộng //Khi đó tên tệp ảnh nhỏ sẽ theo kiểu: tên_tệp_HasThumb_Thumb.phần_mở_rộng //Với cách lưu tên ảnh này, khi thực hiện lưu vào csdl chỉ cần lưu tên ảnh gốc //khi hiển thị chỉ cần dựa vào tên ảnh gốc để biết ảnh đó có ảnh nhỏ hay không, việc này được thực hiện bởi TatThanhJsc.Extension.ImagesExtension.GetImage, lập trình không cần làm gì thêm. if (cbTaoAnhNho.Checked) { vimg = fileNotEx + "_" + ticks + "_HasThumb" + fileex; } else { vimg = fileNotEx + "_" + ticks + fileex; } flimg.SaveAs(path + vimg); #endregion #region Hạn chế kích thước if (cbHanCheKichThuoc.Checked) { ImagesExtension.ResizeImage(path + vimg, "", tbHanCheW.Text, tbHanCheH.Text); } #endregion #region Đóng dấu ảnh if (cbDongDauAnh.Checked) { ImagesExtension.CreateWatermark(path + vimg, path + hdLogoImage.Value, hdViTriDongDau.Value, hdLeX.Value, hdLeY.Value, hdTyLe.Value, hdTrongSuot.Value); } #endregion #region Tạo ảnh nhỏ: Thực hiện cuối để đảm bảo ảnh nhỏ cũng có con dấu if (cbTaoAnhNho.Checked) { vimg_thumb = fileNotEx + "_" + ticks + "_HasThumb_Thumb" + fileex; ImagesExtension.ResizeImage(path + vimg, path + vimg_thumb, tbAnhNhoW.Text, tbAnhNhoH.Text); } #endregion } } 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 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 phoneMobileEmail = StringExtension.GhepChuoi("", tbPhone.Text, tbMobile.Text, tbEmail.Text, tbZalo.Text, tbViber.Text, tbFacebook.Text, tbLoaiKhac.Text); #region Insert if (insert) { GroupsItems.InsertItemsGroupsItems(language, app, tbKey.Text, txt_title.Text, txt_description.Text, contentDetail, vimg, tbYahoo.Text, tbSkype.Text, textTagTitle.Text, textLinkRewrite.Text, StringExtension.ReplateTitle(textLinkRewrite.Text), textTagKeyword.Text, textTagDescription.Text, "", "", "", phoneMobileEmail, "0", "0", "", "", timeCreateDate, DateTime.Now.ToString(), DateTime.Now.ToString(), "", ddl_group_product.SelectedValue, timeCreateDate, DateTime.Now.ToString(), DateTime.Now.ToString(), "", 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 { TatThanhJsc.Extension.ImagesExtension.DeleteImageWhenDeleteItem(pic, hd_img.Value); } GroupsItems.UpdateItemsGroupsItems(language, app, tbKey.Text, txt_title.Text, txt_description.Text, contentDetail, vimg, tbYahoo.Text, tbSkype.Text, textTagTitle.Text, textLinkRewrite.Text, StringExtension.ReplateTitle(textLinkRewrite.Text), textTagKeyword.Text, textTagDescription.Text, "", "", "", phoneMobileEmail, "0", "0", "", HdIitotalview.Value, 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 btOK_Click(object sender, EventArgs e) { string contentDetail = ContentExtendtions.ProcessStringContent(tbContent.Text, hdOldContent.Value, pic); #region Status string status = "0"; if (cbStatus.Checked == true) { status = "1"; } #endregion #region Time Create Date string timeCreateDate = ""; timeCreateDate = tbCreateDate.Text; #endregion #region Seo if (tbSeoLink.Text.Trim().Equals("")) { tbSeoLink.Text = tbTitle.Text; } if (tbSeoTitle.Text.Trim().Equals("")) { tbSeoTitle.Text = tbTitle.Text; } if (tbSeoKeyword.Text.Trim().Equals("")) { tbSeoKeyword.Text = tbTitle.Text; } if (tbSeoDescription.Text.Trim().Equals("")) { tbSeoDescription.Text = tbDesc.Text; } #endregion #region Insert if (insert) { string image = flAnhDaiDien.Save(false, contentDetail); GroupsItems.InsertItemsGroupsItems(language, app, "", tbTitle.Text, tbDesc.Text, contentDetail, image, tbAdvLink.Text, "", tbSeoTitle.Text, tbSeoLink.Text, StringExtension.ReplateTitle(tbSeoLink.Text), tbSeoKeyword.Text, tbSeoDescription.Text, "", "", "", ddlMoTabMoi.SelectedValue, "0", "0", "", "", timeCreateDate, DateTime.Now.ToString(), DateTime.Now.ToString(), tbOrder.Text, ddlParentCate.SelectedValue, timeCreateDate, DateTime.Now.ToString(), DateTime.Now.ToString(), tbOrder.Text, status); #region Logs string logAuthor = CookieExtension.GetCookies("LoginSetting"); string logCreateDate = DateTime.Now.ToString(); Logs.InsertLogs(logCreateDate, Request.Url.ToString(), "", tbTitle.Text, logAuthor, "", logCreateDate + ": " + logAuthor + " tạo mới " + tbTitle.Text); #endregion } #endregion #region Update else { string image = flAnhDaiDien.Save(true, contentDetail); GroupsItems.DeleteGroupsItems(GroupsItemsTSql.GetGroupsItemsByIgiid(hdGroupsItemId.Value)); GroupsItems.UpdateItemsGroupsItems(language, app, "", tbTitle.Text, tbDesc.Text, contentDetail, image, tbAdvLink.Text, "", tbSeoTitle.Text, tbSeoLink.Text, StringExtension.ReplateTitle(tbSeoLink.Text), tbSeoKeyword.Text, tbSeoDescription.Text, "", "", "", ddlMoTabMoi.SelectedValue, "0", "0", "", hdTotalView.Value, timeCreateDate, DateTime.Now.ToString(), DateTime.Now.ToString(), tbOrder.Text, ddlParentCate.SelectedValue, timeCreateDate, DateTime.Now.ToString(), DateTime.Now.ToString(), tbOrder.Text, status, iid); #region Logs string logAuthor = CookieExtension.GetCookies("LoginSetting"); string logCreateDate = DateTime.Now.ToString(); Logs.InsertLogs(logCreateDate, Request.Url.ToString(), "", tbTitle.Text, logAuthor, "", logCreateDate + ": " + logAuthor + " cập nhật " + tbTitle.Text); #endregion } #endregion #region After Insert/Update if (ckbContinue.Checked == true) { ScriptManager.RegisterStartupScript(this, this.GetType(), "alertSuccess", "ThongBao(3000,'Đã tạo: " + tbTitle.Text + "');", true); ResetControls(); } else { Response.Redirect(LinkRedrect()); } #endregion }
protected void btOK_Click(object sender, EventArgs e) { string tongQuan = ContentExtendtions.ProcessStringContent(tbTongQuan.Text, hdTongQuan.Value, pic); string lichTrinh = ContentExtendtions.ProcessStringContent(tbLichTrinh.Text, hdLichTrinh.Value, pic); string bangGia = ContentExtendtions.ProcessStringContent(tbBangGiaVaChoO.Text, hdBangGiaVaChoO.Value, pic); #region Bao gồm - included string baoGom = ContentExtendtions.ProcessStringContent(tbBaoGom.Text, hdBaoGom.Value, pic); if (baoGom.Trim() == "")//Nếu không nhập bao gồm thì lấy danh sách id tích chọn { for (int i = 0; i < cblBaoGom.Items.Count; i++) { if (cblBaoGom.Items[i].Selected) { baoGom += cblBaoGom.Items[i].Value + ","; } } if (baoGom != "") { baoGom = "id-" + baoGom; } } else { baoGom = "text-" + baoGom; } #endregion #region Không bao gồm - excluded string khongBaoGom = ContentExtendtions.ProcessStringContent(tbKhongBaoGom.Text, hdKhongBaoGom.Value, pic); if (khongBaoGom.Trim() == "")//Nếu không nhập không bao gồm thì lấy danh sách id tích chọn { for (int i = 0; i < cblKhongBaoGom.Items.Count; i++) { if (cblKhongBaoGom.Items[i].Selected) { khongBaoGom += cblKhongBaoGom.Items[i].Value + ","; } } if (khongBaoGom != "") { khongBaoGom = "id-" + khongBaoGom; } } else { khongBaoGom = "text-" + khongBaoGom; } #endregion string dieuKhoanKhac = ContentExtendtions.ProcessStringContent(tbDieuKhoanKhac.Text, hdDieuKhoanKhac.Value, pic); string cabin = "";//Chuyển sang lưu ở subitem tương tự loại phòng của hotel string services = ContentExtendtions.ProcessStringContent(tbServices.Text, hdServices.Value, pic); string content = StringExtension.GhepChuoi("", tongQuan, lichTrinh, bangGia, tbMaDinhKemBanDoCruises.Text, GoogleMapMarkLocation.ViDo, GoogleMapMarkLocation.KinhDo, baoGom, khongBaoGom, dieuKhoanKhac, cabin, services); string thoiGian = tbSoNgay.Text + "-" + tbSoDem.Text; #region Các điểm đến string cacDiemDen = tbCacDiemDenSeQua.Text; if (cacDiemDen.Trim() == "")//Nếu không nhập thì lấy danh sách id tích chọn { cacDiemDen = hdIdCacDiemDenSeQua.Value; if (cacDiemDen != "") { cacDiemDen = "id-" + cacDiemDen; } } else { cacDiemDen = "text-" + cacDiemDen; } #endregion #region Trạng thái string trangThai = "0"; if (cbTrangThai.Checked == true) { trangThai = "1"; } #endregion #region Seo if (tbSeoLink.Text.Trim().Equals("")) { tbSeoLink.Text = tbTenCruises.Text; } if (tbSeoTitle.Text.Trim().Equals("")) { tbSeoTitle.Text = tbTenCruises.Text; } if (tbSeoKeyword.Text.Trim().Equals("")) { tbSeoKeyword.Text = tbTenCruises.Text; } if (tbSeoDescription.Text.Trim().Equals("")) { tbSeoDescription.Text = tbMoTa.Text; } #endregion #region Ngày đăng if (tbNgayDang.Text == "") { tbNgayDang.Text = DateTime.Now.ToString(); } #endregion #region Insert if (insert) { string image = flAnhDaiDien.Save(false, tongQuan); GroupsItems.InsertItemsGroupsItems(lang, app, tbMaCruises.Text, tbTenCruises.Text, tbMoTa.Text, content, image, cacDiemDen, thoiGian, tbSeoTitle.Text, tbSeoLink.Text, StringExtension.ReplateTitle(tbSeoLink.Text), tbSeoKeyword.Text, tbSeoDescription.Text, "", "", tbNgayKhoiHanh.Text, "", tbGiaNiemYet.Text, tbGiaKhuyenMai.Text, tbTongSoKhach.Text, "", tbNgayDang.Text, DateTime.Now.ToString(), DateTime.Now.ToString(), tbThuTu.Text, ddlParentCate.SelectedValue, tbNgayDang.Text, DateTime.Now.ToString(), DateTime.Now.ToString(), tbThuTu.Text, trangThai); #region Lấy ra id của items vừa được thêm iid = GetInsertedId(app, tbTenCruises.Text, tbNgayDang.Text); #endregion #region Logs string logAuthor = CookieExtension.GetCookies("LoginSetting"); string logCreateDate = DateTime.Now.ToString(); Logs.InsertLogs(logCreateDate, Request.Url.ToString(), "", tbTenCruises.Text, logAuthor, "", logCreateDate + ": " + logAuthor + " tạo mới " + tbTenCruises.Text); #endregion } #endregion #region Update else { string image = flAnhDaiDien.Save(true, tongQuan); GroupsItems.DeleteGroupsItems(GroupsItemsTSql.GetGroupsItemsByIgiid(hdGroupsItemId.Value)); GroupsItems.UpdateItemsGroupsItems(lang, app, tbMaCruises.Text, tbTenCruises.Text, tbMoTa.Text, content, image, cacDiemDen, thoiGian, tbSeoTitle.Text, tbSeoLink.Text, StringExtension.ReplateTitle(tbSeoLink.Text), tbSeoKeyword.Text, tbSeoDescription.Text, "", "", tbNgayKhoiHanh.Text, "", tbGiaNiemYet.Text, tbGiaKhuyenMai.Text, tbTongSoKhach.Text, hdTotalView.Value, tbNgayDang.Text, DateTime.Now.ToString(), DateTime.Now.ToString(), tbThuTu.Text, ddlParentCate.SelectedValue, tbNgayDang.Text, DateTime.Now.ToString(), DateTime.Now.ToString(), tbThuTu.Text, trangThai, iid); #region Logs string logAuthor = CookieExtension.GetCookies("LoginSetting"); string logCreateDate = DateTime.Now.ToString(); Logs.InsertLogs(logCreateDate, Request.Url.ToString(), "", tbTenCruises.Text, logAuthor, "", logCreateDate + ": " + logAuthor + " cập nhật " + tbTenCruises.Text); #endregion } #endregion #region Thuộc tính tour, mỗi thuộc tính làm một bản ghi liên kết Groups_Items //Lặp qua mỗi thuộc tính --> gọi hàm thêm mới, cập nhật thuộc tính for (int i = 0; i < cblThuocTinh.Items.Count; i++) { if (cblThuocTinh.Items[i].Selected) { InsertProperty(cblThuocTinh.Items[i].Value, iid); } else { DeleteProperty(cblThuocTinh.Items[i].Value, iid); } } #endregion #region After Insert/Update if (cbTiepTuc.Checked == true) { ScriptManager.RegisterStartupScript(this, this.GetType(), "alertSuccess", "ThongBao(3000,'Đã tạo: " + tbTenCruises.Text + "');", true); ResetControls(); } else { Response.Redirect(LinkRedrect()); } #endregion }
protected void btOK_Click(object sender, EventArgs e) { string chiTiet = ContentExtendtions.ProcessStringContent(tbChiTiet.Text, hdChiTiet.Value, pic); #region Trạng thái string trangThai = "0"; if (cbTrangThai.Checked == true) { trangThai = "1"; } #endregion #region IID người đăng string iidNguoiDang = ""; string thongtindangbai = ""; string ngayxuatban = ""; if (AboutUsConfig.KeyDuyetTin) { if (HorizaMenuConfig.ShowDuyetTin1 || HorizaMenuConfig.ShowDuyetTin2) { iidNguoiDang = CookieExtension.GetCookies("userId"); ngayxuatban = DateTime.Now.ToString(); } } #endregion #region Seo if (tbSeoLink.Text.Trim().Equals("")) { tbSeoLink.Text = tbTitle.Text; } if (tbSeoTitle.Text.Trim().Equals("")) { tbSeoTitle.Text = tbTitle.Text; } if (tbSeoKeyword.Text.Trim().Equals("")) { tbSeoKeyword.Text = tbTitle.Text; } if (tbSeoDescription.Text.Trim().Equals("")) { tbSeoDescription.Text = tbDesc.Text; } #endregion #region Ngày đăng if (tbNgayDang.Text == "") { tbNgayDang.Text = DateTime.Now.ToString(); } #endregion #region Các thông tin liên hệ khác như Facebook, Google +, Twitter,... string subInfos = StringExtension.GhepChuoi("", tbFacebook.Text, tbGooglePlus.Text, tbTwitter.Text, tbYoutube.Text, tbInstagram.Text, tbPhone.Text, tbEmail.Text, tbSkype.Text, tbViber.Text, tbZalo.Text); #endregion #region Insert if (insert) { string image = flAnhDaiDien.Save(false, chiTiet); GroupsItems.InsertItemsGroupsItems(lang, app, tbKey.Text, tbTitle.Text, tbDesc.Text, chiTiet, image, iidNguoiDang, "", tbSeoTitle.Text, tbSeoLink.Text, StringExtension.ReplateTitle(tbSeoLink.Text), tbSeoKeyword.Text, tbSeoDescription.Text, thongtindangbai, ngayxuatban, "", subInfos, "", "", "", "", tbNgayDang.Text, DateTime.Now.ToString(), DateTime.Now.ToString(), tbThuTu.Text, ddlParentCate.SelectedValue, tbNgayDang.Text, DateTime.Now.ToString(), DateTime.Now.ToString(), tbThuTu.Text, trangThai); #region Logs string logAuthor = CookieExtension.GetCookies("LoginSetting"); string logCreateDate = DateTime.Now.ToString(); Logs.InsertLogs(logCreateDate, Request.Url.ToString(), "", tbTitle.Text, logAuthor, "", logCreateDate + ": " + logAuthor + " tạo mới " + tbTitle.Text); #endregion } #endregion #region Update else { string image = flAnhDaiDien.Save(true, chiTiet); if (AboutUsConfig.KeyDuyetTin) { string userRole = CookieExtension.GetCookies("RolesUser"); if (HorizaMenuConfig.ShowDuyetTin2) { if (hdEnable.Value == PhanQuyen.DuyetTin.Cap1 && StringExtension.RoleInListRoles(PhanQuyen.DuyetTin.Cap1, userRole)) { trangThai = "0"; } else if (hdEnable.Value == "1" && StringExtension.RoleInListRoles(PhanQuyen.DuyetTin.Cap2, userRole)) { trangThai = "1"; } else if (hdEnable.Value != "0" && hdEnable.Value != "1") { trangThai = hdEnable.Value; } } else { if (hdEnable.Value == PhanQuyen.DuyetTin.Cap2 && StringExtension.RoleInListRoles(PhanQuyen.DuyetTin.Cap2, userRole)) { trangThai = "0"; } else if (hdEnable.Value != "0" && hdEnable.Value != "1") { trangThai = hdEnable.Value; } } } string nguoiDangCu = hdNguoiDangCu.Value; string thongtincu = hdThongTinThem.Value; string ngayxuatbancu = hdNgayXuatBan.Value; GroupsItems.DeleteGroupsItems(GroupsItemsTSql.GetGroupsItemsByIgiid(hdGroupsItemId.Value)); GroupsItems.UpdateItemsGroupsItems(lang, app, tbKey.Text, tbTitle.Text, tbDesc.Text, chiTiet, image, nguoiDangCu, "", tbSeoTitle.Text, tbSeoLink.Text, StringExtension.ReplateTitle(tbSeoLink.Text), tbSeoKeyword.Text, tbSeoDescription.Text, thongtincu, ngayxuatbancu, "", subInfos, "", "", "", hdTotalView.Value, tbNgayDang.Text, DateTime.Now.ToString(), DateTime.Now.ToString(), tbThuTu.Text, ddlParentCate.SelectedValue, tbNgayDang.Text, DateTime.Now.ToString(), DateTime.Now.ToString(), tbThuTu.Text, trangThai, iid); #region Logs string logAuthor = CookieExtension.GetCookies("LoginSetting"); string logCreateDate = DateTime.Now.ToString(); Logs.InsertLogs(logCreateDate, Request.Url.ToString(), "", tbTitle.Text, logAuthor, "", logCreateDate + ": " + logAuthor + " cập nhật " + tbTitle.Text); #endregion } #endregion #region After Insert/Update if (cbTiepTuc.Checked == true) { ScriptManager.RegisterStartupScript(this, this.GetType(), "alertSuccess", "ThongBao(3000,'Đã tạo: " + tbTitle.Text + "');", true); ResetControls(); } else { Response.Redirect(LinkRedrect()); } #endregion }
//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) { string contentDetail = ContentExtendtions.ProcessStringContent(tbContent.Text, hdOldContent.Value, pic); #region Status string status = "0"; if (cbStatus.Checked == true) { status = "1"; } #endregion #region Time Create Date string timeCreateDate = ""; timeCreateDate = tbCreateDate.Text; #endregion #region Seo if (tbSeoLink.Text.Trim().Equals("")) { tbSeoLink.Text = tbTitle.Text; } if (tbSeoTitle.Text.Trim().Equals("")) { tbSeoTitle.Text = tbTitle.Text; } if (tbSeoKeyword.Text.Trim().Equals("")) { tbSeoKeyword.Text = tbTitle.Text; } if (tbSeoDescription.Text.Trim().Equals("")) { tbSeoDescription.Text = tbDesc.Text; } #endregion string videoCode = tbYouTube.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) #region Insert if (insert) { string image = flAnhDaiDien.Save(false, contentDetail); GroupsItems.InsertItemsGroupsItems(language, app, "", tbTitle.Text, tbDesc.Text, contentDetail, image, videoKey, videoCode, tbSeoTitle.Text, tbSeoLink.Text, StringExtension.ReplateTitle(tbSeoLink.Text), tbSeoKeyword.Text, tbSeoDescription.Text, "", "", "", "", "0", "0", "", "", timeCreateDate, DateTime.Now.ToString(), DateTime.Now.ToString(), tbOrder.Text, ddlParentCate.SelectedValue, timeCreateDate, DateTime.Now.ToString(), DateTime.Now.ToString(), tbOrder.Text, status); #region Logs string logAuthor = CookieExtension.GetCookies("LoginSetting"); string logCreateDate = DateTime.Now.ToString(); Logs.InsertLogs(logCreateDate, Request.Url.ToString(), "", tbTitle.Text, logAuthor, "", logCreateDate + ": " + logAuthor + " tạo mới " + tbTitle.Text); #endregion } #endregion #region Update else { string image = flAnhDaiDien.Save(true, contentDetail); GroupsItems.DeleteGroupsItems(GroupsItemsTSql.GetGroupsItemsByIgiid(hdGroupsItemId.Value)); GroupsItems.UpdateItemsGroupsItems(language, app, "", tbTitle.Text, tbDesc.Text, contentDetail, image, videoKey, videoCode, tbSeoTitle.Text, tbSeoLink.Text, StringExtension.ReplateTitle(tbSeoLink.Text), tbSeoKeyword.Text, tbSeoDescription.Text, "", "", "", "", "0", "0", "", hdTotalView.Value, timeCreateDate, DateTime.Now.ToString(), DateTime.Now.ToString(), tbOrder.Text, ddlParentCate.SelectedValue, timeCreateDate, DateTime.Now.ToString(), DateTime.Now.ToString(), tbOrder.Text, status, iid); #region Logs string logAuthor = CookieExtension.GetCookies("LoginSetting"); string logCreateDate = DateTime.Now.ToString(); Logs.InsertLogs(logCreateDate, Request.Url.ToString(), "", tbTitle.Text, logAuthor, "", logCreateDate + ": " + logAuthor + " cập nhật " + tbTitle.Text); #endregion } #endregion #region After Insert/Update if (ckbContinue.Checked == true) { ScriptManager.RegisterStartupScript(this, this.GetType(), "alertSuccess", "ThongBao(3000,'Đã tạo: " + tbTitle.Text + "');", true); ResetControls(); } else { Response.Redirect(LinkRedrect()); } #endregion }
void ThemAnhChoWebsite() { //Lay igid if (Request.Params["igid"] != null) { string igid = StringExtension.RemoveSqlInjectionChars(Request.Params["igid"]); // 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.TaoAnhNhoChoAnhWebsite, lang) == "1") { fileName = igid + "_" + ticks + "_HasThumb" + fileExtension; } else { fileName = igid + "_" + ticks + fileExtension; } string path = Request.PhysicalApplicationPath + "/" + pic + "/"; fileUpload.SaveAs(path + fileName); #endregion #region Hạn chế kích thước if (SettingsExtension.GetSettingKey(SettingKey.HanCheKichThuocAnhWebsite, lang) == "1") { ImagesExtension.ResizeImage(path + fileName, "", SettingsExtension.GetSettingKey(SettingKey.HanCheKichThuocAnhWebsite_MaxWidth, lang), SettingsExtension.GetSettingKey(SettingKey.HanCheKichThuocAnhWebsite_MaxHeight, lang)); } #endregion #region Đóng dấu ảnh if (SettingsExtension.GetSettingKey(SettingKey.DongDauAnhWebsite, lang) == "1") { ImagesExtension.CreateWatermark(path + fileName, path + SettingsExtension.GetSettingKey(SettingKey.DongDauAnhWebsite_AnhDau, lang), SettingsExtension.GetSettingKey(SettingKey.DongDauAnhWebsite_ViTri, lang), SettingsExtension.GetSettingKey(SettingKey.DongDauAnhWebsite_LeNgang, lang), SettingsExtension.GetSettingKey(SettingKey.DongDauAnhWebsite_LeDoc, lang), SettingsExtension.GetSettingKey(SettingKey.DongDauAnhWebsite_TyLe, lang), SettingsExtension.GetSettingKey(SettingKey.DongDauAnhWebsite_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.TaoAnhNhoChoAnhWebsite, lang) == "1") { string vimg_thumb = igid + "_" + ticks + "_HasThumb_Thumb" + fileExtension; ImagesExtension.ResizeImage(path + fileName, path + vimg_thumb, SettingsExtension.GetSettingKey(SettingKey.TaoAnhNhoChoAnhWebsite_MaxWidth, lang), SettingsExtension.GetSettingKey(SettingKey.TaoAnhNhoChoAnhWebsite_MaxHeight, lang)); } #endregion GroupsItems.InsertItemsGroupsItems(lang, app, "", fileName, "", "", fileName, "", "", "", "", "", "", "", "", "", "", "", "0", "0", "0", "0", DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), "1", igid, DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), "1", "1"); //Session["CurrentUploadedFileName"] = fileName; Response.StatusCode = 200; } } }
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 if (!update) { GroupsItems.InsertItemsGroupsItems(language, app, "", tbName.Text, "", "", vimg, "", "", "", "", "", "", "", "", "", "", "", "0", "0", "0", "0", DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), tbOrder.Text, igid, DateTime.Now.ToString(), DateTime.Now.ToString(), DateTime.Now.ToString(), tbOrder.Text, ddlStatus.SelectedValue); } else { if (vimg.Equals("")) { vimg = hd_img; } else { ImagesExtension.DeleteImageWhenDeleteItem(pathFolderPic, hd_img); } TatThanhJsc.Database.Items.UpdateItems(language, app, "", tbName.Text, "", "", vimg, "", "", "", "", "", "", "", "", "", "", "", "0", "0", "0", "0", tbOrder.Text, DateTime.Now.ToString(), DateTime.Now.ToString(), ddlStatus.SelectedValue, currentIid.Value); } ResetControls(); GetList(); pnList.Visible = true; pnInsert.Visible = false; }
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 }