コード例 #1
0
        public void SetValue(Contents aNews)
        {
            this.ID = aNews.ID;
            this.Type = aNews.Type;
            this.Title = aNews.Title;
            this.Info = aNews.Info;
            this.Intro = aNews.Intro;
            this.Status = aNews.Status;
            this.CreatedBy = aNews.CreatedBy;
            this.Disable = aNews.Disable;
            this.Tag = aNews.Tag;
            this.DateCreated = aNews.DateCreated;
            this.DateEdited = aNews.DateEdited;
            this.UpdateBy = aNews.UpdateBy;
            this.PublishDate = aNews.PublishDate;
            this.ExpireDate = aNews.ExpireDate;

            this.Image = aNews.Image;
            this.Image1 = aNews.Image1;
            this.Image2 = aNews.Image2;
            this.Image3 = aNews.Image3;
            this.ViewCount = aNews.ViewCount;

            this.IDAlbum = aNews.IDAlbum;
            this.IDLang = aNews.IDLang;
            this.Code = aNews.Code;
            this.ExtendProperties1 = aNews.ExtendProperties1;
            this.ExtendProperties2 = aNews.ExtendProperties2;
            this.ExtendProperties3 = aNews.ExtendProperties3;
        }
コード例 #2
0
        public Contents ConvertToCotents()
        {
            Contents aContent = new Contents();
            aContent.ID = this.ID;
            aContent.Type = this.Type;
            aContent.Title = this.Title;
            aContent.Info = this.Info;
            aContent.Intro = this.Intro;
            aContent.Status = this.Status;
            aContent.CreatedBy = this.CreatedBy;
            aContent.Disable = this.Disable;
            aContent.Tag = this.Tag;
            aContent.DateCreated = this.DateCreated;
            aContent.DateEdited = this.DateEdited;
            aContent.UpdateBy = this.UpdateBy;
            aContent.PublishDate = this.PublishDate;
            aContent.ExpireDate = this.ExpireDate;

            aContent.Image = this.Image;
            aContent.Image1 = this.Image1;
            aContent.Image2 = this.Image2;
            aContent.Image3 = this.Image3;
            aContent.ViewCount = this.ViewCount;

            aContent.IDAlbum = this.IDAlbum;
            aContent.IDLang = this.IDLang;
            aContent.Code = this.Code;
            aContent.ExtendProperties1 = this.ExtendProperties1;
            aContent.ExtendProperties2 = this.ExtendProperties2;
            aContent.ExtendProperties3 = this.ExtendProperties3;
            return aContent;
        }
コード例 #3
0
ファイル: ]BO.cs プロジェクト: ntlzz93/ToolGenCode
 public int Upd(Contents aContents)
 {
     try
     {
         aDatabaseDA.Contents.AddOrUpdate(aContents);
         return aDatabaseDA.SaveChanges();
     }
     catch (Exception ex)
     {
         throw new Exception(String.Format("ContentsBO.Upd: {0}", ex.Message));
     }
 }
コード例 #4
0
ファイル: ContentsAction.cs プロジェクト: califaxit/manhquang
        public void Ins(HttpContext context, int NUM_LANG)
        {
            ConfigsBO aConfigsBO = new ConfigsBO();

            //CodeCategoryLevel1 = Convert.ToString(context.Request.Form["txtCodeCategoryLevel1"]);

            String jSonString = "";
            try {
                List<Contents> aListContents = new List<Contents>();

                ContentsBO aContentsBO = new ContentsBO();
                Contents aContents = new Contents();
                TimeSpan Codespan = new TimeSpan(DateTime.Now.Ticks);
                string Code = Math.Floor(Codespan.TotalSeconds).ToString();

                for (int i = 1; i <= NUM_LANG; i++) {
                    aContents = new Contents();
                    aContents.Code = Code;
                    aContents.Data = null;

                    aContents.Type = !String.IsNullOrEmpty(context.Request.Form["cbbType"]) ? Convert.ToInt32(context.Request.Form["cbbType"]) : 0;
                    aContents.Status = !String.IsNullOrEmpty(context.Request.Form["cbbStatus"]) ? Convert.ToInt32(context.Request.Form["cbbStatus"]) : 0;
                    aContents.CreatedBy = aCurrentSystemUsers.Username;

                    aContents.Disable = !String.IsNullOrEmpty(context.Request.Form["cbbDisable"]) ? Convert.ToBoolean(context.Request.Form["cbbDisable"]) : false;
                    aContents.Tag = !String.IsNullOrEmpty(context.Request.Form["txtTag"]) ? Convert.ToString(context.Request.Form["txtTag"]) : "";
                    aContents.DateCreated = !String.IsNullOrEmpty(context.Request.Form["txtDateCreated"]) ? DateTime.ParseExact(context.Request.Form["txtDateCreated"], "dd/MM/yyyy", culture) : DateTime.Now;

                    aContents.DateEdited = !String.IsNullOrEmpty(context.Request.Form["txtDateEdited"]) ? DateTime.ParseExact(context.Request.Form["txtDateEdited"], "dd/MM/yyyy", culture) : DateTime.Now;
                    aContents.UpdateBy = !String.IsNullOrEmpty(context.Request.Form["txtUpdateBy"]) ? Convert.ToString(context.Request.Form["txtUpdateBy"]) : "";
                    aContents.PublishDate = !String.IsNullOrEmpty(context.Request.Form["txtPublishDate"]) ? DateTime.ParseExact(context.Request.Form["txtPublishDate"], "dd/MM/yyyy", culture) : DateTime.Now;

                    aContents.ExpireDate = !String.IsNullOrEmpty(context.Request.Form["txtExpireDate"]) ? DateTime.ParseExact(context.Request.Form["txtExpireDate"], "dd/MM/yyyy", culture) : DateTime.Now;
                    aContents.IDAlbum = !String.IsNullOrEmpty(context.Request.Form["txtIDAlbum"]) ? Convert.ToInt32(context.Request.Form["txtIDAlbum"]) : 0;
                    aContents.ViewCount = !String.IsNullOrEmpty(context.Request.Form["txtViewCount"]) ? Convert.ToInt64(context.Request.Form["txtViewCount"]) : 0;

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

                    aContents.Title = !String.IsNullOrEmpty(context.Request.Form["txtTitle_Lang" + i]) ? Convert.ToString(context.Request.Form["txtTitle_Lang" + i]) : "";
                    aContents.Intro = !String.IsNullOrEmpty(context.Request.Form["txtIntro_Lang" + i]) ? Convert.ToString(HttpUtility.HtmlDecode(context.Request.Form["txtIntro_Lang" + i])) : "";
                    aContents.Info = !String.IsNullOrEmpty(context.Request.Form["txtInfo_Lang" + i]) ? Convert.ToString(HttpUtility.HtmlDecode(context.Request.Form["txtInfo_Lang" + i])) : "";

                    aContents.ExtendProperties1 = !String.IsNullOrEmpty(context.Request.Form["txtExtendProperties1_Lang" + i]) ? Convert.ToString(context.Request.Form["txtExtendProperties1_Lang" + i]) : "";
                    aContents.ExtendProperties2 = !String.IsNullOrEmpty(context.Request.Form["txtExtendProperties2_Lang" + i]) ? Convert.ToString(context.Request.Form["txtExtendProperties2_Lang" + i]) : "";
                    aContents.ExtendProperties3 = !String.IsNullOrEmpty(context.Request.Form["txtExtendProperties3_Lang" + i]) ? Convert.ToString(context.Request.Form["txtExtendProperties3_Lang" + i]) : "";

                    aContents.Image = !String.IsNullOrEmpty(context.Request.Form["txtImage_1"]) ? Convert.ToString(context.Request.Form["txtImage_1"]) : "";
                    aContents.IDLang = !String.IsNullOrEmpty(context.Request.Form["IDLang_" + i]) ? Convert.ToInt32(context.Request.Form["IDLang_" + i]) : 0;

                    aListContents.Add(aContents);
                }

                int Ret1 = -1;
                Ret1 = aContentsBO.Ins(ref aListContents);
                if (Ret1 < aListContents.Count) {
                    jSonString = "{\"status\":\"error\" ,\"message\":\"" + Ret1.ToString() + "\"}";
                    aContentsBO.Del(aListContents);
                    return;
                }
                else {
                    string ListTempt = !String.IsNullOrEmpty(context.Request.Form["ckbCodeCategoryLevel1[]"]) ? Convert.ToString(context.Request.Form["ckbCodeCategoryLevel1[]"]) : "";
                    if (string.IsNullOrEmpty(ListTempt) == true) {
                        CategoryLevel1BO aCategoryLevel1BO = new CategoryLevel1BO();
                        List<CategoryLevel1> aListItem = aCategoryLevel1BO.Sel_ByCode("000");
                        if (aListItem.Count > 0) {
                            ListTempt = aListItem[0].Code;
                        }
                        else {
                            this.CreateCategoryLevel1Default(context, "[Default]", NUM_LANG);
                            ListTempt = "000";
                        }
                    }

                    //else if (string.IsNullOrEmpty(ListTempt) == false)
                    //{
                    List<string> ListCodeCategoryLevel1 = ListTempt.Split(',').ToList();
                    List<Contents_CategoryLevel1> aListContents_CategoryLevel1 = new List<Contents_CategoryLevel1>();
                    Contents_CategoryLevel1 aContents_CategoryLevel1 = new Contents_CategoryLevel1();

                    for (int ii = 0; ii < aListContents.Count; ii++) {
                        for (int iii = 0; iii < ListCodeCategoryLevel1.Count; iii++) {
                            aContents_CategoryLevel1 = new Contents_CategoryLevel1();

                            aContents_CategoryLevel1.CodeCategoryLevel1 = ListCodeCategoryLevel1[iii].ToString();
                            aContents_CategoryLevel1.CodeContents = aListContents[ii].Code.ToString();
                            aContents_CategoryLevel1.Disable = aListContents[ii].Disable;
                            aContents_CategoryLevel1.IDLang = aListContents[ii].IDLang;
                            aContents_CategoryLevel1.Status = aListContents[ii].Status;
                            aContents_CategoryLevel1.Type = aListContents[ii].Type;

                            aListContents_CategoryLevel1.Add(aContents_CategoryLevel1);
                        }
                    }
                    Contents_CategoryLevel1BO aContents_CategoryLevel1BO = new Contents_CategoryLevel1BO();
                    int Ret2 = -1;
                    Ret2 = aContents_CategoryLevel1BO.Ins(ref aListContents_CategoryLevel1);
                    if (Ret2 < aListContents_CategoryLevel1.Count) {
                        aContents_CategoryLevel1BO.Del(aListContents_CategoryLevel1);
                        aContentsBO.Del(aListContents);
                        jSonString = "{\"status\":\"error\" ,\"message\":\"" + Ret2.ToString() + "\"}";
                        return;
                    }
                    //}
                }

                jSonString = "{\"status\": \"success\"}";
            }
            catch (Exception ex) {
                jSonString = "{\"status\":\"error\" ,\"message\":\"" + ex.Message.ToString() + "\"}";
            }
            finally {
                context.Response.Write(jSonString);
            }
        }