/// <summary> /// get data child for insert update /// </summary> /// <param name="contdescObj"></param> /// <returns></returns> private PNK_ProductDesc GetDataObjectChild(PNK_ProductDesc productcatdescObj, int lang) { switch (lang) { case 1: productcatdescObj.MainId = this.productcategoryId; productcatdescObj.LangId = Constant.DB.LangId; productcatdescObj.Title = SanitizeHtml.Sanitize(txtName.Value); productcatdescObj.TitleUrl = Utils.RemoveUnicode(SanitizeHtml.Sanitize(txtName.Value)); productcatdescObj.Brief = txtIntro.Text; productcatdescObj.Detail = txtDetailVi.Text; productcatdescObj.Position = txtPositionVi.Text; productcatdescObj.Utility = txtUtilityVi.Text; productcatdescObj.Pictures = txtPicturesVi.Text; productcatdescObj.Design = txtDesignVi.Text; productcatdescObj.Payment = txtPaymentVi.Text; productcatdescObj.Contact = txtContactVi.Text; productcatdescObj.WorkCarried = txtWorkCarriedVi.Text; productcatdescObj.TimeCarried = txtTimeCarriedVi.Text; productcatdescObj.Other = txtOtherVi.Text; productcatdescObj.MetaTitle = txtMetaTitle.Text; productcatdescObj.Metadescription = txtMetaDescription.Text; productcatdescObj.MetaKeyword = txtMetaKeyword.Text; productcatdescObj.H1 = txtH1.Text; productcatdescObj.H2 = txtH2.Text; productcatdescObj.H3 = txtH3.Text; break; case 2: productcatdescObj.MainId = this.productcategoryId; productcatdescObj.LangId = Constant.DB.LangId_En; string title = string.IsNullOrEmpty(txtNameEng.Value) ? SanitizeHtml.Sanitize(txtName.Value) : SanitizeHtml.Sanitize(txtNameEng.Value); productcatdescObj.Title = title; productcatdescObj.TitleUrl = Utils.RemoveUnicode(title); productcatdescObj.Brief = string.IsNullOrEmpty(txtIntroEng.Text) ? txtIntro.Text : txtIntroEng.Text; productcatdescObj.Detail = string.IsNullOrEmpty(txtDetailVi.Text) ? txtDetailVi.Text : txtDetailEng.Text; productcatdescObj.Position = string.IsNullOrEmpty(txtPositionEng.Text) ? txtPositionVi.Text : txtPositionEng.Text; productcatdescObj.Design = string.IsNullOrEmpty(txtDesignEng.Text) ? txtDesignVi.Text : txtDesignEng.Text; productcatdescObj.Pictures = string.IsNullOrEmpty(txtPicturesEng.Text) ? txtPicturesVi.Text : txtPicturesEng.Text; productcatdescObj.Payment = string.IsNullOrEmpty(txtPaymentEng.Text) ? txtPaymentVi.Text : txtPaymentEng.Text; productcatdescObj.Contact = string.IsNullOrEmpty(txtContactEng.Text) ? txtContactVi.Text : txtContactEng.Text; productcatdescObj.WorkCarried = string.IsNullOrEmpty(txtWorkCarriedEng.Text) ? txtWorkCarriedVi.Text : txtWorkCarriedEng.Text; productcatdescObj.TimeCarried = string.IsNullOrEmpty(txtTimeCarriedEng.Text) ? txtTimeCarriedVi.Text : txtTimeCarriedEng.Text; productcatdescObj.Other = string.IsNullOrEmpty(txtOtherEng.Text) ? txtOtherVi.Text : txtOtherEng.Text; productcatdescObj.MetaTitle = string.IsNullOrEmpty(txtMetaTitleEng.Text) ? txtMetaTitle.Text : txtMetaTitleEng.Text; productcatdescObj.Metadescription = string.IsNullOrEmpty(txtMetaDescriptionEng.Text) ? txtMetaDescription.Text : txtMetaDescriptionEng.Text; productcatdescObj.MetaKeyword = string.IsNullOrEmpty(txtMetaKeywordEng.Text) ? txtMetaKeyword.Text : txtMetaKeywordEng.Text; productcatdescObj.H1 = string.IsNullOrEmpty(txtH1Eng.Text) ? txtH1.Text : txtH1Eng.Text; productcatdescObj.H2 = string.IsNullOrEmpty(txtH2Eng.Text) ? txtH2.Text : txtH2Eng.Text; productcatdescObj.H3 = string.IsNullOrEmpty(txtH3Eng.Text) ? txtH3.Text : txtH3Eng.Text; break; } return(productcatdescObj); }
/// <summary> /// Save location /// </summary> private void SaveProduct() { //Xoá cache trước khi lưu CacheHelper.ClearAll(); PNK_Product productcatObj = new PNK_Product(); PNK_ProductDesc productcatObjVn = new PNK_ProductDesc(); PNK_ProductDesc productcatObjEn = new PNK_ProductDesc(); if (this.productcategoryId == int.MinValue) { //get data insert productcatObj = this.GetDataObjectParent(productcatObj); productcatObj.PostDate = DateTime.Now; productcatObj.Ordering = genericBLL.getOrdering(); productcatObjVn = this.GetDataObjectChild(productcatObjVn, Constant.DB.LangId); productcatObjEn = this.GetDataObjectChild(productcatObjEn, Constant.DB.LangId_En); List <PNK_ProductDesc> lst = new List <PNK_ProductDesc>(); lst.Add(productcatObjVn); lst.Add(productcatObjEn); //excute this.productcategoryId = generic2CBLL.Insert(productcatObj, lst); } else { string[] fields = { "Id" }; productcatObj.Id = this.productcategoryId; productcatObj = genericBLL.Load(productcatObj, fields); //get data update productcatObj = this.GetDataObjectParent(productcatObj); productcatObjVn = this.GetDataObjectChild(productcatObjVn, Constant.DB.LangId); productcatObjEn = this.GetDataObjectChild(productcatObjEn, Constant.DB.LangId_En); List <PNK_ProductDesc> lst = new List <PNK_ProductDesc>(); lst.Add(productcatObjVn); lst.Add(productcatObjEn); //excute generic2CBLL.Update(productcatObj, lst, fields); //neu ve Published oo thay doi thi chay ham ChangeWithTransaction de doi Published cac con va cac product //if (publisheddOld != productcatObj.Published) // PNK_Product.ChangeWithTransaction(DBConvert.ParseString(this.productcategoryId), productcatObj.Published); } }