예제 #1
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);
            }
        }
예제 #2
0
        private void Upd_ByCode(HttpContext context, int NUM_LANG)
        {
            int ret = -1;
            string jSonString = string.Empty;
            try {
                if (NUM_LANG < 1)
                    NUM_LANG = 1;
                AlbumsBO albumsBO = new AlbumsBO();
                String Code = context.Request.Form["txtCode"];
                List<Albums> listAlbums = albumsBO.Sel_ByCode(Code);

                if (listAlbums.Count <= NUM_LANG) {
                    int LoopUpdate = listAlbums.Count;
                    for (int i = 0; i < LoopUpdate; i++) {
                        listAlbums[i].ID = listAlbums[i].ID;

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

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

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

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

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

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

                        listAlbums[i].CreateByIDUser = currentSystemUsers.ID;

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

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

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

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

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