Ejemplo n.º 1
0
        public void Upd_ByCode(HttpContext context, int NUM_LANG)
        {
            int ret = -1;
            String jSonString = "";
            try
            {
                if (NUM_LANG < 1)
                {
                    NUM_LANG = 1;
                }
                List<CategoryLevel2> aListCategoryLevel2 = new List<CategoryLevel2>();
                CategoryLevel2BO aCategoryLevel1BO = new CategoryLevel2BO();
                String Code = context.Request.Form["txtCode"];

                aListCategoryLevel2 = aCategoryLevel1BO.Sel_ByCode(Code);
                int LoopUpdate = 0;

                if (aListCategoryLevel2.Count <= NUM_LANG)
                {
                    LoopUpdate = aListCategoryLevel2.Count;
                    for (int i = 0; i < LoopUpdate; i++)
                    {

                        aListCategoryLevel2[i].ID = aListCategoryLevel2[i].ID;
                        aListCategoryLevel2[i].Code = aListCategoryLevel2[i].Code;
                        aListCategoryLevel2[i].IDLang = aListCategoryLevel2[i].IDLang;
                        aListCategoryLevel2[i].Type = !String.IsNullOrEmpty(context.Request.Form["cbbType"]) ? Convert.ToInt32(context.Request.Form["cbbType"]) : aListCategoryLevel2[i].Type;
                        aListCategoryLevel2[i].ViewCount = !String.IsNullOrEmpty(context.Request.Form["txtViewCount"]) ? Convert.ToInt64(context.Request.Form["txtViewCount"]) : 0;
                        aListCategoryLevel2[i].Status = !String.IsNullOrEmpty(context.Request.Form["cbbStatus"]) ? Convert.ToInt32(context.Request.Form["cbbStatus"]) : aListCategoryLevel2[i].Status;
                        aListCategoryLevel2[i].Disable = !String.IsNullOrEmpty(context.Request.Form["cbbDisable"]) ? Convert.ToBoolean(context.Request.Form["cbbDisable"]) : aListCategoryLevel2[i].Disable;
                        aListCategoryLevel2[i].Tag = !String.IsNullOrEmpty(context.Request.Form["txtTag"]) ? Convert.ToString(context.Request.Form["txtTag"]) : aListCategoryLevel2[i].Tag;
                        aListCategoryLevel2[i].IDAlbum = !String.IsNullOrEmpty(context.Request.Form["cbbIDAlbum"]) ? Convert.ToInt32(context.Request.Form["cbbIDAlbum"]) : aListCategoryLevel2[i].IDAlbum;
                        aListCategoryLevel2[i].Image = !String.IsNullOrEmpty(context.Request.Form["txtImage_1"]) ? Convert.ToString(context.Request.Form["txtImage_1"]) : "";
                        aListCategoryLevel2[i].Image1 = !String.IsNullOrEmpty(context.Request.Form["txtImage_2"]) ? Convert.ToString(context.Request.Form["txtImage_2"]) : "";
                        aListCategoryLevel2[i].Image2 = !String.IsNullOrEmpty(context.Request.Form["txtImage_3"]) ? Convert.ToString(context.Request.Form["txtImage_3"]) : "";
                        aListCategoryLevel2[i].Image3 = !String.IsNullOrEmpty(context.Request.Form["txtImage_4"]) ? Convert.ToString(context.Request.Form["txtImage_4"]) : "";
                        aListCategoryLevel2[i].CategoryNameLevel2 = !String.IsNullOrEmpty(context.Request.Form["txtCategoryNameLevel2_Lang" + (i + 1)]) ? Convert.ToString(context.Request.Form["txtCategoryNameLevel2_Lang" + (i + 1)]) : aListCategoryLevel2[i].CategoryNameLevel2;
                        aListCategoryLevel2[i].Note = !String.IsNullOrEmpty(context.Request.Form["txtNote_Lang" + (i + 1)]) ? Convert.ToString(context.Request.Form["txtNote_Lang" + (i + 1)]) : aListCategoryLevel2[i].Note;
                        aListCategoryLevel2[i].Intro = !String.IsNullOrEmpty(context.Request.Form["txtIntro_Lang" + (i + 1)]) ? Convert.ToString(context.Request.Form["txtIntro_Lang" + (i + 1)]) : aListCategoryLevel2[i].Intro;
                        aListCategoryLevel2[i].Info = !String.IsNullOrEmpty(context.Request.Form["txtInfo_Lang" + (i + 1)]) ? Convert.ToString(context.Request.Form["txtInfo_Lang" + (i + 1)]) : aListCategoryLevel2[i].Info;

                        ret = aCategoryLevel1BO.Upd(aListCategoryLevel2);
                        if (ret == 0)
                        {
                            jSonString = "{\"status\":\"error|" + ret.ToString() + "\"}";
                            break;
                        }
                    }
                    if (ret != 0)
                    { jSonString = "{\"status\": \"success\"}"; }
                }
            }
            catch (Exception ex)
            {
                jSonString = "{\"status\":\"error\" ,\"message\":\"" + ex.Message.ToString() + "\"}";
            }
            finally
            {
                context.Response.Write(jSonString);
            }
        }
Ejemplo n.º 2
0
        public void Sel_ByCode(HttpContext context)
        {
            String jSonString = "";
            string Code = context.Request.QueryString["Code"];
            //---
            bool Disable = !String.IsNullOrEmpty(context.Request.QueryString["Disable"])
                ? Convert.ToBoolean(context.Request.QueryString["Disable"])
                : false;

            int Limit = context.Request.QueryString["Limit"] != null && context.Request.QueryString["Limit"] != "undefined" ? int.Parse(context.Request.QueryString["Limit"]) : 50;
            int IntroLenght = context.Request.QueryString["IntroLenght"] != null && context.Request.QueryString["IntroLenght"] != "undefined" ? int.Parse(context.Request.QueryString["IntroLenght"]) : 100;
            int InfoLenght = context.Request.QueryString["InfoLenght"] != null && context.Request.QueryString["InfoLenght"] != "undefined" ? int.Parse(context.Request.QueryString["InfoLenght"]) : 100;
            string Order = string.IsNullOrEmpty(context.Request.QueryString["Order"]) == false ? context.Request.QueryString["Order"] : "CategoryNameLevel2_ID";
            bool IsDesc = context.Request.QueryString["IsDesc"] != null && context.Request.QueryString["IsDesc"] != "undefined" ? bool.Parse(context.Request.QueryString["IsDesc"]) : true;

            CategoryLevel2BO aCategoryLevel2BO = new CategoryLevel2BO();

            //--
            List<CategoryLevel2> obj = String.IsNullOrEmpty(context.Request.QueryString["Disable"])
                ? aCategoryLevel2BO.Sel_ByCode(Code)
                : aCategoryLevel2BO.Sel_ByCode(Code, Disable);

            obj = this.ConvertList(obj, InfoLenght, IntroLenght, Limit, Order, IsDesc);

            //obj.Info = HttpUtility.HtmlDecode(obj.Info);
            //obj.Intro = HttpUtility.HtmlDecode(obj.Intro);

            if (obj != null)
            {
                _converter.DateTimeFormat = "dd/MM/yyyy";

                jSonString = JsonConvert.SerializeObject(obj, _converter);
            }
            jSonString = "{\"data\":" + jSonString + "}";
            context.Response.Write(jSonString);
        }