Exemplo n.º 1
0
        public void Ins(HttpContext context, int NUM_LANG)
        {
            int ret = -1;
            String jSonString = "";
            try
            {
                CategoryLevel1 aCategoryLevel1 = new CategoryLevel1();

                aCategoryLevel1.Status = !String.IsNullOrEmpty(context.Request.Form["cbbStatus"]) ? Convert.ToInt32(context.Request.Form["cbbStatus"]) : 0;
                aCategoryLevel1.Disable = !String.IsNullOrEmpty(context.Request.Form["cbbDisable"]) ? Convert.ToBoolean(context.Request.Form["cbbDisable"]) : false;
                // aCategoryLevel1.CodeCategoryLevel2 = !String.IsNullOrEmpty(context.Request.Form["txt_CodeCategoryLevel2"]) ? Convert.ToString(context.Request.Form["txt_CodeCategoryLevel2"]) : "";

                aCategoryLevel1.Type = !String.IsNullOrEmpty(context.Request.Form["cbbType"]) ? Convert.ToInt32(context.Request.Form["cbbType"]) : 0;
                aCategoryLevel1.IDAlbum = !String.IsNullOrEmpty(context.Request.Form["ddlAlbum"]) ? Convert.ToInt32(context.Request.Form["ddlAlbum"]) : 0;
                aCategoryLevel1.Image = !String.IsNullOrEmpty(context.Request.Form["txtImage_1"]) ? Convert.ToString(context.Request.Form["txtImage_1"]) : "";
                aCategoryLevel1.Image1 = !String.IsNullOrEmpty(context.Request.Form["txtImage_2"]) ? Convert.ToString(context.Request.Form["txtImage_2"]) : "";
                aCategoryLevel1.Image2 = !String.IsNullOrEmpty(context.Request.Form["txtImage_3"]) ? Convert.ToString(context.Request.Form["txtImage_3"]) : "";
                aCategoryLevel1.Image3 = !String.IsNullOrEmpty(context.Request.Form["txtImage_4"]) ? Convert.ToString(context.Request.Form["txtImage_4"]) : "";
                aCategoryLevel1.Tag = !String.IsNullOrEmpty(context.Request.Form["txtTag"]) ? Convert.ToString(context.Request.Form["txtTag"]) : "";

                aCategoryLevel1.ViewCount = !String.IsNullOrEmpty(context.Request.Form["txtViewCount"]) ? Convert.ToInt32(context.Request.Form["txtViewCount"]) : 0;
                long a = DateTime.Now.Ticks;
                TimeSpan Codespan = new TimeSpan(a);
                aCategoryLevel1.Code = Math.Floor(Codespan.TotalSeconds).ToString();

                for (int i = 1; i <= NUM_LANG; i++)
                {
                    aCategoryLevel1.IDLang = !String.IsNullOrEmpty(context.Request.Form["IDLang_" + i]) ? Convert.ToInt32(context.Request.Form["IDLang_" + i]) : 0;

                    aCategoryLevel1.Note = !String.IsNullOrEmpty(context.Request.Form["txtNote_Lang" + i]) ? Convert.ToString(context.Request.Form["txtNote_Lang" + i]) : "";
                    aCategoryLevel1.CategoryNameLevel1 = !String.IsNullOrEmpty(context.Request.Form["txtCategoryNameLevel1_Lang" + i]) ? Convert.ToString(context.Request.Form["txtCategoryNameLevel1_Lang" + i]) : "";
                    aCategoryLevel1.Intro = !String.IsNullOrEmpty(context.Request.Form["txtIntro_Lang" + i]) ? Convert.ToString(HttpUtility.HtmlDecode(context.Request.Form["txtIntro_Lang" + i])) : "";
                    aCategoryLevel1.Info = !String.IsNullOrEmpty(context.Request.Form["txtInfo_Lang" + i]) ? Convert.ToString(HttpUtility.HtmlDecode(context.Request.Form["txtInfo_Lang" + i])) : "";
                    CategoryLevel1BO aCategoryLevel1BO = new CategoryLevel1BO();
                    ret = aCategoryLevel1BO.Ins(aCategoryLevel1);
                    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);
            }
        }
Exemplo n.º 2
0
 public int Upd(CategoryLevel1 aCategoryLevel1)
 {
     try
     {
         aDatabaseDA.CategoryLevel1.AddOrUpdate(aCategoryLevel1);
         return aDatabaseDA.SaveChanges();
     }
     catch (Exception ex)
     {
         throw new Exception(String.Format("CategoryLevel1BO.Upd: {0}", ex.Message));
     }
 }
Exemplo n.º 3
0
        private int CreateCategoryLevel1Default(HttpContext context, string CategoryNameLevel1, int NUM_LANG)
        {
            List<CategoryLevel1> aList = new List<CategoryLevel1>();
            CategoryLevel1 aCategoryLevel1 = new CategoryLevel1();

            for (int i = 1; i <= NUM_LANG; i++) {
                aCategoryLevel1 = new CategoryLevel1();

                aCategoryLevel1.Code = "000";
                aCategoryLevel1.IDLang = !String.IsNullOrEmpty(context.Request.Form["IDLang_" + i]) ? Convert.ToInt32(context.Request.Form["IDLang_" + i]) : 0;

                aCategoryLevel1.CategoryNameLevel1 = CategoryNameLevel1;
                aCategoryLevel1.Intro = "[Defaul CategoryLevel1]";
                aCategoryLevel1.Info = "[Defaul CategoryLevel1]";

                aCategoryLevel1.Status = 0;
                aCategoryLevel1.Disable = false;
                aCategoryLevel1.Type = 0;
                aCategoryLevel1.IDAlbum = 0;
                aCategoryLevel1.Image = "";
                aCategoryLevel1.Image1 = "";
                aCategoryLevel1.Image2 = "";
                aCategoryLevel1.Image3 = "";
                aCategoryLevel1.Tag = "";
                aCategoryLevel1.Note = "";
                aCategoryLevel1.Tag = "";
                aCategoryLevel1.ViewCount = 0;

                aList.Add(aCategoryLevel1);
            }
            CategoryLevel1BO aCategoryLevel1BO = new CategoryLevel1BO();

            return aCategoryLevel1BO.Ins(ref aList);
        }