示例#1
0
        private void Sel_ByID(HttpContext context)
        {
            String   jSonString = "";
            AlbumsBO albumsBO   = new AlbumsBO();
            int      id         = Convert.ToInt32(context.Request.QueryString["IDAlbums"]);
            bool     disable    = !String.IsNullOrEmpty(context.Request.QueryString["Disable"])
                ? Convert.ToBoolean(context.Request.QueryString["Disable"])
                : false;
            Albums albums = String.IsNullOrEmpty(context.Request.QueryString["Disable"])
                ? albumsBO.Sel_ByID(id)
                : albumsBO.Sel_ByID(id, disable);

            if (albums != null)
            {
                _converter.DateTimeFormat = "dd/MM/yyyy";
                jSonString = JsonConvert.SerializeObject(albums, _converter);
            }
            jSonString = "{\"data\":" + jSonString + "}";
            context.Response.Write(jSonString);
        }
示例#2
0
        private void Upd_ByID(HttpContext context)
        {
            string jSonString = string.Empty;

            try {
                AlbumsBO albumsBO = new AlbumsBO();
                int      id       = Convert.ToInt32(context.Request.Form["txtID"]);
                Albums   albums   = albumsBO.Sel_ByID(id);

                albums.ID = albums.ID;

                albums.Title = !String.IsNullOrEmpty(context.Request.Form["txtTitle_Lang"])
                    ? Convert.ToString(context.Request.Form["txtTitle_Lang"])
                    : albums.Title;

                albums.Info = !String.IsNullOrEmpty(context.Request.Form["txtInfo_Lang"])
                    ? Convert.ToString(HttpUtility.HtmlDecode(context.Request.Form["txtInfo_Lang"]))
                    : albums.Info;

                albums.Intro = !String.IsNullOrEmpty(context.Request.Form["txtIntro_Lang"])
                    ? Convert.ToString(context.Request.Form["txtIntro_Lang"])
                    : albums.Intro;

                albums.Status = !String.IsNullOrEmpty(context.Request.Form["cbbStatus"])
                    ? Convert.ToInt32(context.Request.Form["cbbStatus"])
                    : albums.Status;

                albums.Disable = !String.IsNullOrEmpty(context.Request.Form["cbbDisable"])
                    ? Convert.ToBoolean(context.Request.Form["txt_Disable"])
                    : albums.Disable;

                albums.CreateDate = !String.IsNullOrEmpty(context.Request.Form["dtpPublishDate"])
                    ? DateTime.ParseExact(context.Request.Form["dtpPublishDate"], "dd/MM/yyyy", _culture)
                    : albums.CreateDate;

                albums.CreateByIDUser = currentSystemUsers.ID;

                albums.Image = !String.IsNullOrEmpty(context.Request.Form["txtImage_1"])
                    ? Convert.ToString(context.Request.Form["txtImage_1"])
                    : albums.Image;

                albums.Image1 = !String.IsNullOrEmpty(context.Request.Form["txtImage_2"])
                    ? Convert.ToString(context.Request.Form["txtImage_2"])
                    : albums.Image1;
                albums.Image2 = !String.IsNullOrEmpty(context.Request.Form["txtImage_3"])
                    ? Convert.ToString(context.Request.Form["txtImage_3"])
                    : albums.Image2;
                albums.Image3 = !String.IsNullOrEmpty(context.Request.Form["txtImage_4"])
                    ? Convert.ToString(context.Request.Form["txtImage_4"])
                    : albums.Image3;

                albums.Type = !String.IsNullOrEmpty(context.Request.Form["cbbType"])
                    ? Convert.ToInt32(context.Request.Form["cbbType"])
                    : albums.Type;

                albums.IDLang = !String.IsNullOrEmpty(context.Request.Form["IDLang_"])
                    ? Convert.ToInt32(context.Request.Form["IDLang_"])
                    : albums.IDLang;
                albums.ViewCount = !String.IsNullOrEmpty(context.Request.Form["txtViewCount"])
                    ? Convert.ToInt64(context.Request.Form["txtViewCount"])
                    : albums.ViewCount;
                albums.DownloadCount = !String.IsNullOrEmpty(context.Request.Form["txtDownloadCount"])
                    ? Convert.ToInt64(context.Request.Form["txtDownloadCount"])
                    : albums.DownloadCount;

                var ret = albumsBO.Upd_Albums(albums);
                if (ret == 0)
                {
                    jSonString = "{\"status\":\"error|" + ret + "\"}";
                }
                else if (ret != 0)
                {
                    jSonString = "{\"status\": \"success\"}";
                }
            }
            catch (Exception ex) {
                jSonString = "{\"status\":\"error\" ,\"message\":\"" + ex.Message + "\"}";
            }
            finally {
                context.Response.Write(jSonString);
            }
        }