private void Sel_ByID(HttpContext context) { string jSonString = string.Empty; LanguagesBO languagesBO = new LanguagesBO(); int id = Convert.ToInt32(context.Request.QueryString["ID"]); bool disable = !String.IsNullOrEmpty(Convert.ToString(context.Request.QueryString["Disable"])) ? Convert.ToBoolean(context.Request.QueryString["Disable"]) : false; Languages languages = String.IsNullOrEmpty(Convert.ToString(context.Request.QueryString["Disable"])) ? languagesBO.Sel_ByID(id) : languagesBO.Sel_ByID(id, disable); if (!languages.Equals(null)) { _converter.DateTimeFormat = "dd/MM/yyyy"; jSonString = JsonConvert.SerializeObject(languages, _converter); } jSonString = "{\"data\":" + jSonString + "}"; context.Response.Write(jSonString); }
private void Upd_ByID(HttpContext context) { LanguagesBO languagesBO = new LanguagesBO(); String jSonString = ""; try { int languagesId = Convert.ToInt32(context.Request.Form["txtID"]); var aLanguages = languagesBO.Sel_ByID(languagesId); aLanguages.NameLang = !String.IsNullOrEmpty(context.Request.Form["txtNameLang"]) ? Convert.ToString(context.Request.Form["txtNameLang"]) : aLanguages.NameLang; aLanguages.Image = !String.IsNullOrEmpty(context.Request.Form["txtImage_1"]) ? Convert.ToString(context.Request.Form["txtImage_1"]) : aLanguages.Image; aLanguages.Directory = !String.IsNullOrEmpty(context.Request.Form["txtDirectory"]) ? Convert.ToString(context.Request.Form["txtDirectory"]) : aLanguages.Directory; aLanguages.Filename = !String.IsNullOrEmpty(context.Request.Form["txtFilename"]) ? Convert.ToString(context.Request.Form["txtFilename"]) : aLanguages.Filename; aLanguages.Status = !String.IsNullOrEmpty(context.Request.Form["cbbStatus"]) ? Convert.ToInt32(context.Request.Form["cbbStatus"]) : aLanguages.Status; aLanguages.Type = !String.IsNullOrEmpty(context.Request.Form["cbbType"]) ? Convert.ToInt32(context.Request.Form["cbbType"]) : aLanguages.Type; aLanguages.Disable = !String.IsNullOrEmpty(context.Request.Form["cbbDisable"]) ? Convert.ToBoolean(context.Request.Form["cbbDisable"]) : aLanguages.Disable; int ret = languagesBO.Upd(aLanguages); if (ret != 0) jSonString = "{\"status\": \"success\"}"; if (ret == 0) jSonString = "{\"status\":\"error|" + ret + "\"}"; } catch (Exception ex) { jSonString = "{\"status\":\"error\" ,\"message\":\"" + ex.Message + "\"}"; } finally { context.Response.Write(jSonString); } }
public static string Load_DynamicDataLanguage_Page(HttpContext Context, string SYSTEM) { string PageHTML = Context.Request["filename"].ToString(); LanguagesBO aLanguagesBO = new LanguagesBO(); ConfigsBO aConfigsBO = new ConfigsBO(); List<Configs> ListConfigsCMS = new List<Configs>(); List<string> ListCodeCMS = new List<string>(); ListConfigsCMS = aConfigsBO.Sel_ByAccessKey(key_DEF_LANG_CMS); for (int i = 0; i < ListConfigsCMS.Count; i++) { ListCodeCMS.Add(ListConfigsCMS[i].Value.ToString()); } string ListCodeTemptCMS = String.Join(",", ListCodeCMS); List<Configs> ListConfigsWEB = new List<Configs>(); List<string> ListCodeWEB = new List<string>(); ListConfigsWEB = aConfigsBO.Sel_ByAccessKey(key_DEF_LANG_WEB); for (int i = 0; i < ListConfigsCMS.Count; i++) { ListCodeWEB.Add(ListConfigsWEB[i].Value.ToString()); } string ListCodeTemptWEB = String.Join(",", ListCodeWEB); sys_NUM_LANG = aLanguagesBO.Sel().ToList().Count; if (SYSTEM == "CMS") { sys_DEF_LANG = int.Parse(ListCodeTemptCMS); } else if (SYSTEM == "WEB") { sys_DEF_LANG = int.Parse(ListCodeTemptWEB); } if (!string.IsNullOrEmpty(Context.Request.QueryString["IDLang"])) { sys_CUR_LANG = Convert.ToInt32(Context.Request.QueryString["IDLang"]); } else { if (Context.GetSection(key_CUR_LANG) != null) { sys_CUR_LANG = Convert.ToInt32(Context.GetSection(key_CUR_LANG).ToString()); } // Cuoi cung moi lay den ngon ngu mac dinh else { sys_CUR_LANG = int.Parse(ListCodeTemptCMS); } } string PhysicalPath = Context.Server.MapPath(@"\\Languages\\" + aLanguagesBO.Sel_ByID(sys_CUR_LANG).NameLang + "\\" + PageHTML + ".xml"); XmlDocument doc = new XmlDocument(); doc.Load(PhysicalPath); XmlElement element = doc.DocumentElement; XmlNodeList attr_coll = doc.SelectNodes("//item"); List<LanguagesItem> List_ItemLang = new List<LanguagesItem>(); LanguagesItem Item; foreach (XmlNode node in attr_coll) { Item = new LanguagesItem(); Item.Text = node.InnerText; Item.Key = node.Attributes["Index"].Value; List_ItemLang.Add(Item); } String jSonString = ""; InfoLang aInfoLang = new InfoLang(); aInfoLang.DATA_LANG = List_ItemLang; aInfoLang.sys_CUR_LANG = sys_CUR_LANG; aInfoLang.sys_DEF_LANG = sys_DEF_LANG; aInfoLang.sys_NUM_LANG = sys_NUM_LANG; _converter.DateTimeFormat = "dd/MM/yyyy"; jSonString = JsonConvert.SerializeObject(aInfoLang, _converter); CORE_Language.aInfoLang.DATA_LANG = List_ItemLang; // Chỗ chứa dữ liệu cho cách thức truy cập từ trang aspx return jSonString; }