Example #1
0
        private void Upd_ByCode(HttpContext context, int NUM_LANG)
        {
            int ret = -1;
                String jSonString = "";
                try
                {
                    if (NUM_LANG < 1)
                    {
                        NUM_LANG = 1;
                    }
                    List<Files> aFiles = new List<Files>();
                    FilesBO aFilesBO = new FilesBO();
                    String Code = context.Request.Form["txtCode"];

                    aFiles = aFilesBO.Sel_ByCode(Code);

                    int LoopUpdate = 0;

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

                            aFiles[i].ID = aFiles[i].ID;

                            aFiles[i].Code = aFiles[i].Code;
                            aFiles[i].IDLang = aFiles[i].IDLang;

                            aFiles[i].CodeAlbums = !String.IsNullOrEmpty(context.Request.Form["txt_CodeAlbums"]) ? Convert.ToString(context.Request.Form["txt_CodeAlbums"]) : aFiles[i].CodeAlbums;

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

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

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

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

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

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

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

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

                            aFiles[i].Width = !String.IsNullOrEmpty(context.Request.Form["txtWidth"]) ? Convert.ToInt32(context.Request.Form["txtWidth"]) : aFiles[i].Width;

                            aFiles[i].Height = !String.IsNullOrEmpty(context.Request.Form["txtHeight"]) ? Convert.ToInt32(context.Request.Form["txtHeight"]) : aFiles[i].Height;

                           // aFiles[i].Code = !String.IsNullOrEmpty(context.Request.Form["Code"]) ? Convert.ToString(context.Request.Form["txt_Code"]) : aFiles[i].Code;

                            //aFiles[i].IDLang = !String.IsNullOrEmpty(context.Request.Form["txt_IDLang"]) ? Convert.ToInt32(context.Request.Form["txt_IDLang"]) : aFiles[i].IDLang;

                            ret = aFilesBO.Upd(aFiles[i]);
                            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);
                }
        }
Example #2
0
        private void Sel_ByCode(HttpContext context)
        {
            FilesBO aFilesBO = new FilesBO();
                    List<Files> obj = new List<Files>();

                    string Code = context.Request.QueryString["Code"];
                    String jSonString = "";

                    if (string.IsNullOrEmpty(context.Request.QueryString["Disable"]))
                    {
                        obj = aFilesBO.Sel_ByCode(Code);
                    }
                    else
                    {
                        obj = aFilesBO.Sel_ByCode(Code, bool.Parse(context.Request.QueryString["Disable"]));
                    }

                    int count = obj.Count;

                    for (int i = 0; i < obj.Count; i++)
                    {
                        obj[i].Intro = HttpUtility.HtmlDecode(obj[i].Intro);
                        // obj[i].Contents_Intro = HttpUtility.HtmlDecode(obj[i].Intro);
                    }
                    if (obj != null)
                    {
                        _converter.DateTimeFormat = "dd/MM/yyyy";
                        jSonString = JsonConvert.SerializeObject(obj, _converter);
                    }

                    jSonString = "{\"data\":" + jSonString + "}";
                    context.Response.Write(jSonString);
        }