private void SaveInfo(string strLink = "") { try { string Cat_Code = txtCode.Value; string Cat_Name = txtName.Value; string Cat_Desc = txtDesc.Value; string Cat_Url = txtUrl.Value; string Cat_Seo_Url = txtSeoUrl.Value; string Cat_Seo_Tittle = txtSeoTitle.Value; string Cat_Seo_Keyword = txtSeoKeyword.Value; string Cat_Seo_Description = txtSeoDescription.Value; string Cat_Target = ddlTarget.SelectedValue; int Cat_Parent_Id = Utils.CIntDef(ddlCategory.SelectedValue, 0); int Cat_Status = Utils.CIntDef(rblStatus.SelectedValue); //int Cat_Access = Utils.CIntDef(rblAccess.SelectedValue); int Cat_Pos = Utils.CIntDef(rblPos.SelectedValue); int Cat_Type = Utils.CIntDef(rblCatType.SelectedValue); int Cat_Footer = Utils.CIntDef(rblShowFooter.SelectedValue); int Cat_ShowItems = Utils.CIntDef(rblShowItems.SelectedValue); int Cat_Period = Utils.CIntDef(rblCatPeriod.SelectedValue); int Cat_Language = Utils.CIntDef(rblLanguage.SelectedValue); int Cat_Order = Utils.CIntDef(txtOrder.Value); int Cat_Order_Period = Utils.CIntDef(txtOrderPeriod.Value); int Cat_PageItem = Utils.CIntDef(txtpageItem.Value); string Cat_Parent_Path = "0"; int Cat_Rank = 1; //english language //string Cat_Code_En = txtCodeEn.Value; //string Cat_Name_En = txtNameEn.Value; //string Cat_Desc_En = txtDescEn.Value; //string Cat_Seo_Url_En = txtSeoUrlEn.Value; //string Cat_Seo_Tittle_En = txtSeoTitleEn.Value; //string Cat_Seo_Keyword_En = txtSeoKeywordEn.Value; //string Cat_Seo_Description_En = txtSeoDescriptionEn.Value; if (Cat_Parent_Id > 0) { var CatParent = DB.GetTable<ESHOP_CATEGORy>().Where(c => c.CAT_ID == Cat_Parent_Id); Cat_Parent_Path = CatParent.Single().CAT_PARENT_PATH + "," + Utils.CStrDef(Cat_Parent_Id); Cat_Rank = Utils.CIntDef(CatParent.Single().CAT_RANK) + 1; } //get image1 string Cat_Image1; if (trUploadImage1.Visible == true) { if (fileImage1.PostedFile != null) { Cat_Image1 = Path.GetFileName(fileImage1.PostedFile.FileName); } else { Cat_Image1 = ""; } } else { Cat_Image1 = hplImage1.Text; } ////get image2 //string Cat_Image2; //if (trUploadImage2.Visible == true) //{ // if (fileImage2.PostedFile != null) // { // Cat_Image2 = Path.GetFileName(fileImage2.PostedFile.FileName); // } // else // { // Cat_Image2 = ""; // } //} //else //{ // Cat_Image2 = hplImage2.Text; //} ////get image3 //string Cat_Image3; //if (trUploadImage3.Visible == true) //{ // if (fileImage3.PostedFile != null) // { // Cat_Image3 = Path.GetFileName(fileImage3.PostedFile.FileName); // } // else // { // Cat_Image3 = ""; // } //} //else //{ // Cat_Image3 = hplImage3.Text; //} if (m_cat_id == 0) { //insert ESHOP_CATEGORy cat_insert = new ESHOP_CATEGORy(); cat_insert.CAT_CODE = Cat_Code; cat_insert.CAT_NAME = Cat_Name; cat_insert.CAT_DESC = Cat_Desc; cat_insert.CAT_URL = Cat_Url; cat_insert.CAT_SEO_URL = Cat_Seo_Url; cat_insert.CAT_SEO_TITLE = Cat_Seo_Tittle; cat_insert.CAT_SEO_KEYWORD = Cat_Seo_Keyword; cat_insert.CAT_SEO_DESC = Cat_Seo_Description; cat_insert.CAT_TARGET = Cat_Target; cat_insert.CAT_PARENT_ID = Cat_Parent_Id; cat_insert.CAT_STATUS = Cat_Status; //cat_insert.CAT_ACCESS = Cat_Access; cat_insert.CAT_TYPE = Cat_Type; cat_insert.CAT_POSITION = Cat_Pos; cat_insert.CAT_SHOWFOOTER = Cat_Footer; cat_insert.CAT_SHOWITEM = Cat_ShowItems; cat_insert.CAT_PERIOD = Cat_Period; cat_insert.CAT_LANGUAGE = Cat_Language; cat_insert.CAT_ORDER = Cat_Order; cat_insert.CAT_PERIOD_ORDER = Cat_Order_Period; cat_insert.CAT_PAGEITEM = Cat_PageItem; cat_insert.CAT_PARENT_PATH = Cat_Parent_Path; cat_insert.CAT_RANK = Cat_Rank; cat_insert.CAT_IMAGE1 = Cat_Image1; //cat_insert.CAT_IMAGE2 = Cat_Image2; //cat_insert.CAT_IMAGE3 = Cat_Image3; //cat_insert.CAT_CODE_EN = Cat_Code_En; //cat_insert.CAT_NAME_EN = Cat_Name_En; //cat_insert.CAT_DESC_EN = Cat_Desc_En; //cat_insert.CAT_SEO_URL_EN = Cat_Seo_Url_En; //cat_insert.CAT_SEO_TITLE_EN = Cat_Seo_Tittle_En; //cat_insert.CAT_SEO_KEYWORD_EN = Cat_Seo_Keyword_En; //cat_insert.CAT_SEO_DESC_EN = Cat_Seo_Description_En; DB.ESHOP_CATEGORies.InsertOnSubmit(cat_insert); DB.SubmitChanges(); var _cat = DB.GetTable<ESHOP_CATEGORy>().OrderByDescending(g => g.CAT_ID).Take(1); m_cat_id = _cat.Single().CAT_ID; strLink = string.IsNullOrEmpty(strLink) ? "category_list.aspx" : strLink; } else { //update var c_update = DB.GetTable<ESHOP_CATEGORy>().Where(g => g.CAT_ID == m_cat_id); if (c_update.ToList().Count > 0) { c_update.Single().CAT_CODE = Cat_Code; c_update.Single().CAT_NAME = Cat_Name; c_update.Single().CAT_DESC = Cat_Desc; c_update.Single().CAT_URL = Cat_Url; c_update.Single().CAT_SEO_URL = Cat_Seo_Url; c_update.Single().CAT_SEO_TITLE = Cat_Seo_Tittle; c_update.Single().CAT_SEO_KEYWORD = Cat_Seo_Keyword; c_update.Single().CAT_SEO_DESC = Cat_Seo_Description; c_update.Single().CAT_TARGET = Cat_Target; c_update.Single().CAT_PARENT_ID = Cat_Parent_Id; c_update.Single().CAT_STATUS = Cat_Status; //c_update.Single().CAT_ACCESS = Cat_Access; c_update.Single().CAT_TYPE = Cat_Type; c_update.Single().CAT_POSITION = Cat_Pos; c_update.Single().CAT_SHOWFOOTER = Cat_Footer; c_update.Single().CAT_SHOWITEM = Cat_ShowItems; c_update.Single().CAT_LANGUAGE = Cat_Language; c_update.Single().CAT_ORDER = Cat_Order; c_update.Single().CAT_PAGEITEM = Cat_PageItem; c_update.Single().CAT_PERIOD = Cat_Period; c_update.Single().CAT_PERIOD_ORDER = Cat_Order_Period; c_update.Single().CAT_PARENT_PATH = Cat_Parent_Path; c_update.Single().CAT_RANK = Cat_Rank; c_update.Single().CAT_IMAGE1 = Cat_Image1; //c_update.Single().CAT_IMAGE2 = Cat_Image2; //c_update.Single().CAT_IMAGE3 = Cat_Image3; //c_update.Single().CAT_CODE_EN = Cat_Code_En; //c_update.Single().CAT_NAME_EN = Cat_Name_En; //c_update.Single().CAT_DESC_EN = Cat_Desc_En; //c_update.Single().CAT_SEO_URL_EN = Cat_Seo_Url_En; //c_update.Single().CAT_SEO_TITLE_EN = Cat_Seo_Tittle_En; //c_update.Single().CAT_SEO_KEYWORD_EN = Cat_Seo_Keyword_En; //c_update.Single().CAT_SEO_DESC_EN = Cat_Seo_Description_En; DB.SubmitChanges(); strLink = string.IsNullOrEmpty(strLink) ? "category_list.aspx" : strLink; } } //update images 1 if (trUploadImage1.Visible) { if (!string.IsNullOrEmpty(fileImage1.PostedFile.FileName)) { string pathfile = Server.MapPath("../data/categories/" + m_cat_id); string fullpathfile = pathfile + "/" + Cat_Image1; if (!Directory.Exists(pathfile)) { Directory.CreateDirectory(pathfile); } fileImage1.PostedFile.SaveAs(fullpathfile); } } ////update images 2 //if (trUploadImage2.Visible) //{ // if (!string.IsNullOrEmpty(fileImage2.PostedFile.FileName)) // { // string pathfile = Server.MapPath("../data/categories/" + m_cat_id); // string fullpathfile = pathfile + "/" + Cat_Image2; // if (!Directory.Exists(pathfile)) // { // Directory.CreateDirectory(pathfile); // } // fileImage2.PostedFile.SaveAs(fullpathfile); // } //} //if (trUploadImage3.Visible) //{ // if (!string.IsNullOrEmpty(fileImage3.PostedFile.FileName)) // { // string pathfile = Server.MapPath("../data/categories/" + m_cat_id); // string fullpathfile = pathfile + "/" + Cat_Image3; // if (!Directory.Exists(pathfile)) // { // Directory.CreateDirectory(pathfile); // } // fileImage3.PostedFile.SaveAs(fullpathfile); // } //} } catch (Exception ex) { clsVproErrorHandler.HandlerError(ex); } finally { if (!string.IsNullOrEmpty(strLink)) { Response.Redirect(strLink); } } }
private void SaveInfo(string strLink = "") { try { string Cat_Code = txtCode.Value; string Cat_Name = txtName.Value; string Cat_Desc = txtDesc.Value; string Cat_Url = txtUrl.Value; string Cat_Seo_Url = txtSeoUrl.Value; string Cat_Seo_Tittle = txtSeoTitle.Value; string Cat_Seo_Keyword = txtSeoKeyword.Value; string Cat_Seo_Description = txtSeoDescription.Value; string Cat_Target = ddlTarget.SelectedValue; int Cat_Parent_Id = Utils.CIntDef(ddlCategory.SelectedValue, 0); int Cat_Status = Utils.CIntDef(rblStatus.SelectedValue); //int Cat_Access = Utils.CIntDef(rblAccess.SelectedValue); int Cat_Pos = Utils.CIntDef(rblPos.SelectedValue); int Cat_Type = Utils.CIntDef(rblCatType.SelectedValue); int Cat_Footer = Utils.CIntDef(rblShowFooter.SelectedValue); int Cat_ShowItems = Utils.CIntDef(rblShowItems.SelectedValue); int Cat_Period = Utils.CIntDef(rblCatPeriod.SelectedValue); int Cat_Language = Utils.CIntDef(rblLanguage.SelectedValue); int Cat_Order = Utils.CIntDef(txtOrder.Value); int Cat_Order_Period = Utils.CIntDef(txtOrderPeriod.Value); int Cat_PageItem = Utils.CIntDef(txtpageItem.Value); string Cat_Parent_Path = "0"; int Cat_Rank = 1; //english language //string Cat_Code_En = txtCodeEn.Value; //string Cat_Name_En = txtNameEn.Value; //string Cat_Desc_En = txtDescEn.Value; //string Cat_Seo_Url_En = txtSeoUrlEn.Value; //string Cat_Seo_Tittle_En = txtSeoTitleEn.Value; //string Cat_Seo_Keyword_En = txtSeoKeywordEn.Value; //string Cat_Seo_Description_En = txtSeoDescriptionEn.Value; if (Cat_Parent_Id > 0) { var CatParent = DB.GetTable <ESHOP_CATEGORy>().Where(c => c.CAT_ID == Cat_Parent_Id); Cat_Parent_Path = CatParent.Single().CAT_PARENT_PATH + "," + Utils.CStrDef(Cat_Parent_Id); Cat_Rank = Utils.CIntDef(CatParent.Single().CAT_RANK) + 1; } //get image1 string Cat_Image1; if (trUploadImage1.Visible == true) { if (fileImage1.PostedFile != null) { Cat_Image1 = Path.GetFileName(fileImage1.PostedFile.FileName); } else { Cat_Image1 = ""; } } else { Cat_Image1 = hplImage1.Text; } ////get image2 //string Cat_Image2; //if (trUploadImage2.Visible == true) //{ // if (fileImage2.PostedFile != null) // { // Cat_Image2 = Path.GetFileName(fileImage2.PostedFile.FileName); // } // else // { // Cat_Image2 = ""; // } //} //else //{ // Cat_Image2 = hplImage2.Text; //} ////get image3 //string Cat_Image3; //if (trUploadImage3.Visible == true) //{ // if (fileImage3.PostedFile != null) // { // Cat_Image3 = Path.GetFileName(fileImage3.PostedFile.FileName); // } // else // { // Cat_Image3 = ""; // } //} //else //{ // Cat_Image3 = hplImage3.Text; //} if (m_cat_id == 0) { //insert ESHOP_CATEGORy cat_insert = new ESHOP_CATEGORy(); cat_insert.CAT_CODE = Cat_Code; cat_insert.CAT_NAME = Cat_Name; cat_insert.CAT_DESC = Cat_Desc; cat_insert.CAT_URL = Cat_Url; cat_insert.CAT_SEO_URL = Cat_Seo_Url; cat_insert.CAT_SEO_TITLE = Cat_Seo_Tittle; cat_insert.CAT_SEO_KEYWORD = Cat_Seo_Keyword; cat_insert.CAT_SEO_DESC = Cat_Seo_Description; cat_insert.CAT_TARGET = Cat_Target; cat_insert.CAT_PARENT_ID = Cat_Parent_Id; cat_insert.CAT_STATUS = Cat_Status; //cat_insert.CAT_ACCESS = Cat_Access; cat_insert.CAT_TYPE = Cat_Type; cat_insert.CAT_POSITION = Cat_Pos; cat_insert.CAT_SHOWFOOTER = Cat_Footer; cat_insert.CAT_SHOWITEM = Cat_ShowItems; cat_insert.CAT_PERIOD = Cat_Period; cat_insert.CAT_LANGUAGE = Cat_Language; cat_insert.CAT_ORDER = Cat_Order; cat_insert.CAT_PERIOD_ORDER = Cat_Order_Period; cat_insert.CAT_PAGEITEM = Cat_PageItem; cat_insert.CAT_PARENT_PATH = Cat_Parent_Path; cat_insert.CAT_RANK = Cat_Rank; cat_insert.CAT_IMAGE1 = Cat_Image1; //cat_insert.CAT_IMAGE2 = Cat_Image2; //cat_insert.CAT_IMAGE3 = Cat_Image3; //cat_insert.CAT_CODE_EN = Cat_Code_En; //cat_insert.CAT_NAME_EN = Cat_Name_En; //cat_insert.CAT_DESC_EN = Cat_Desc_En; //cat_insert.CAT_SEO_URL_EN = Cat_Seo_Url_En; //cat_insert.CAT_SEO_TITLE_EN = Cat_Seo_Tittle_En; //cat_insert.CAT_SEO_KEYWORD_EN = Cat_Seo_Keyword_En; //cat_insert.CAT_SEO_DESC_EN = Cat_Seo_Description_En; DB.ESHOP_CATEGORies.InsertOnSubmit(cat_insert); DB.SubmitChanges(); var _cat = DB.GetTable <ESHOP_CATEGORy>().OrderByDescending(g => g.CAT_ID).Take(1); m_cat_id = _cat.Single().CAT_ID; strLink = string.IsNullOrEmpty(strLink) ? "category.aspx?cat_id=" + m_cat_id + "" : strLink; } else { //update var c_update = DB.GetTable <ESHOP_CATEGORy>().Where(g => g.CAT_ID == m_cat_id); if (c_update.ToList().Count > 0) { c_update.Single().CAT_CODE = Cat_Code; c_update.Single().CAT_NAME = Cat_Name; c_update.Single().CAT_DESC = Cat_Desc; c_update.Single().CAT_URL = Cat_Url; c_update.Single().CAT_SEO_URL = Cat_Seo_Url; c_update.Single().CAT_SEO_TITLE = Cat_Seo_Tittle; c_update.Single().CAT_SEO_KEYWORD = Cat_Seo_Keyword; c_update.Single().CAT_SEO_DESC = Cat_Seo_Description; c_update.Single().CAT_TARGET = Cat_Target; c_update.Single().CAT_PARENT_ID = Cat_Parent_Id; c_update.Single().CAT_STATUS = Cat_Status; //c_update.Single().CAT_ACCESS = Cat_Access; c_update.Single().CAT_TYPE = Cat_Type; c_update.Single().CAT_POSITION = Cat_Pos; c_update.Single().CAT_SHOWFOOTER = Cat_Footer; c_update.Single().CAT_SHOWITEM = Cat_ShowItems; c_update.Single().CAT_LANGUAGE = Cat_Language; c_update.Single().CAT_ORDER = Cat_Order; c_update.Single().CAT_PAGEITEM = Cat_PageItem; c_update.Single().CAT_PERIOD = Cat_Period; c_update.Single().CAT_PERIOD_ORDER = Cat_Order_Period; c_update.Single().CAT_PARENT_PATH = Cat_Parent_Path; c_update.Single().CAT_RANK = Cat_Rank; c_update.Single().CAT_IMAGE1 = Cat_Image1; //c_update.Single().CAT_IMAGE2 = Cat_Image2; //c_update.Single().CAT_IMAGE3 = Cat_Image3; //c_update.Single().CAT_CODE_EN = Cat_Code_En; //c_update.Single().CAT_NAME_EN = Cat_Name_En; //c_update.Single().CAT_DESC_EN = Cat_Desc_En; //c_update.Single().CAT_SEO_URL_EN = Cat_Seo_Url_En; //c_update.Single().CAT_SEO_TITLE_EN = Cat_Seo_Tittle_En; //c_update.Single().CAT_SEO_KEYWORD_EN = Cat_Seo_Keyword_En; //c_update.Single().CAT_SEO_DESC_EN = Cat_Seo_Description_En; DB.SubmitChanges(); strLink = string.IsNullOrEmpty(strLink) ? "category.aspx?cat_id=" + m_cat_id + "" : strLink; } } //update images 1 if (trUploadImage1.Visible) { if (!string.IsNullOrEmpty(fileImage1.PostedFile.FileName)) { string pathfile = Server.MapPath("../data/categories/" + m_cat_id); string fullpathfile = pathfile + "/" + Cat_Image1; if (!Directory.Exists(pathfile)) { Directory.CreateDirectory(pathfile); } fileImage1.PostedFile.SaveAs(fullpathfile); } } ////update images 2 //if (trUploadImage2.Visible) //{ // if (!string.IsNullOrEmpty(fileImage2.PostedFile.FileName)) // { // string pathfile = Server.MapPath("../data/categories/" + m_cat_id); // string fullpathfile = pathfile + "/" + Cat_Image2; // if (!Directory.Exists(pathfile)) // { // Directory.CreateDirectory(pathfile); // } // fileImage2.PostedFile.SaveAs(fullpathfile); // } //} //if (trUploadImage3.Visible) //{ // if (!string.IsNullOrEmpty(fileImage3.PostedFile.FileName)) // { // string pathfile = Server.MapPath("../data/categories/" + m_cat_id); // string fullpathfile = pathfile + "/" + Cat_Image3; // if (!Directory.Exists(pathfile)) // { // Directory.CreateDirectory(pathfile); // } // fileImage3.PostedFile.SaveAs(fullpathfile); // } //} } catch (Exception ex) { clsVproErrorHandler.HandlerError(ex); } finally { if (!string.IsNullOrEmpty(strLink)) { Response.Redirect(strLink); } } }