Beispiel #1
0
        public NewsCategoryInfo GetInfo(int id)
        {
            NewsCategoryInfo info = null;

            SqlParameter[] param =
            {
                new SqlParameter("@Id", id)
            };
            var r = DataHelper.ExecuteReader(Config.ConnectString, "usp_NewsCategory_GetById", param);

            if (r != null)
            {
                info = new NewsCategoryInfo();
                while (r.Read())
                {
                    info.Id              = Int32.Parse(r["Id"].ToString());
                    info.Name            = r["Name"].ToString();
                    info.Link            = r["Link"].ToString();
                    info.Sort            = Int32.Parse(r["Sort"].ToString());
                    info.Description     = r["Description"].ToString();
                    info.MetaDescription = r["MetaDescription"].ToString();
                    info.MetaKeyword     = r["MetaKeyword"].ToString();
                    info.MetaHeading     = r["MetaHeading"].ToString();
                    info.Image           = r["Image"].ToString();
                    info.TitleRewrite    = r["TitleRewrite"].ToString();
                    info.ParentId        = Int32.Parse(r["ParentId"].ToString());
                }
                r.Close();
                r.Dispose();
            }
            return(info);
        }
Beispiel #2
0
 protected void Bind()
 {
     if (Request.QueryString["id"] != null)
     {
         if (Tools.TryParseMethod(Request.QueryString["id"].ToString()) != 0)
         {
             NewsCategoryInfo info = ncBLL.getAllById(id);
             if (info.nc_fatherid != 0)
             {
                 lbcategory.Text = ncBLL.getAllById(info.nc_id).nc_name;
             }
             lbName.Text    = info.nc_name;
             lbSorting.Text = info.nc_sorting.ToString();
             img1.ImageUrl  = Tools.GetAppSettings("NewsImageTruePath") + info.nc_image;
             if (info.nc_show)
             {
                 lbShow.Text = "顯示";
             }
             else
             {
                 lbShow.Text = "不顯示";
             }
         }
     }
 }
Beispiel #3
0
    public string getTitle(int id)
    {
        if (id == 0)
        {
            return("此為主類別");
        }
        NewsCategoryInfo info = ncBLL.getAllById(id);

        return(info.nc_name);
    }
Beispiel #4
0
        private void SearchHierarchyVailNow(int fid)
        {
            NewsCategoryInfo info = getAllById(fid);

            if (info.nc_id != 0)
            {
                HerichCountMath += 1;
                SearchHierarchyVailNow(info.nc_fatherid);
            }
        }
Beispiel #5
0
        public NewsCategoryInfo getAllById(int id)
        {
            NewsCategoryInfo info   = new NewsCategoryInfo();
            IDataReader      reader = db.GetDataById(id).CreateDataReader();

            while (reader.Read())
            {
                info = NewsCategoryInfo.Populate(reader);
            }
            return(info);
        }
Beispiel #6
0
        public List <NewsCategoryInfo> UpdataSorting(int fatherid, int sorting)
        {
            List <NewsCategoryInfo> infos  = new List <NewsCategoryInfo>();
            IDataReader             reader = db.UpdataSorting(fatherid, sorting, lidValue).CreateDataReader();

            while (reader.Read())
            {
                infos.Add(NewsCategoryInfo.Populate(reader));
            }
            return(infos);
        }
Beispiel #7
0
        /// <summary>
        /// 取出所有Father與Lid符合的資料,並以Sort排序
        /// </summary>
        /// <param name="fatherId"></param>
        /// <param name="lidvalue"></param>
        /// <returns></returns>
        public List <NewsCategoryInfo> GetDataByFatherIdAndLidOrderSorting(int fatherId, int lidvalue)
        {
            List <NewsCategoryInfo> infos  = new List <NewsCategoryInfo>();
            IDataReader             reader = db.GetDataByFatherIdAndLidOrderSorting(fatherId, lidvalue).CreateDataReader();

            while (reader.Read())
            {
                infos.Add(NewsCategoryInfo.Populate(reader));
            }
            return(infos);
        }
Beispiel #8
0
        public List <NewsCategoryInfo> getAll()
        {
            List <NewsCategoryInfo> infos  = new List <NewsCategoryInfo>();
            IDataReader             reader = db.GetData().CreateDataReader();

            while (reader.Read())
            {
                infos.Add(NewsCategoryInfo.Populate(reader));
            }
            return(infos);
        }
Beispiel #9
0
        public int GetDataByFatherIdAndLidOrderSortDESC(int fatherId, int lidvalue)
        {
            NewsCategoryInfo info   = new NewsCategoryInfo();
            IDataReader      reader = db.GetDataByFatherIdAndLidOrderSortDESC(fatherId, lidvalue).CreateDataReader();

            if (reader.Read())
            {
                info = NewsCategoryInfo.Populate(reader);
                return(info.nc_sorting + 1);
            }
            return(1);
        }
Beispiel #10
0
        public bool SearchHierarchyEqualVail(int id, int Hierarchy)
        {
            NewsCategoryInfo info = getAllById(id);

            if (info.nc_id != 0)
            {
                SearchHierarchyVailNow(info.nc_fatherid);
            }
            if (Hierarchy == HerichCountMath)
            {
                return(true);
            }
            return(false);
        }
Beispiel #11
0
    protected void InsertData()
    {
        NewsCategoryInfo info = new NewsCategoryInfo();

        info.nc_fatherid = Tools.TryParseMethod(ddlCategory.SelectedValue);
        info.nc_name     = txtName.Text;
        info.nc_image    = Image1.AlternateText;
        info.nc_show     = bool.Parse(rbShow.SelectedValue);
        info.l_id        = lid;
        if (ncBLL.Insert(info) > 0)
        {
            Response.Redirect("List.aspx?header=" + Getmessage("30009"));
        }
    }
Beispiel #12
0
        public List <NewsCategoryInfo> GetList(int pageIndex, int pageSize, out int total)
        {
            List <NewsCategoryInfo> list = null;
            var t = 0;

            SqlParameter[] param =
            {
                new SqlParameter("@pageIndex", pageIndex),
                new SqlParameter("@pageSize",  pageSize),
                new SqlParameter("@totalrow",  DbType.Int32)
                {
                    Direction = ParameterDirection.Output
                }
            };
            SqlCommand comx;
            var        r = DataHelper.ExecuteReader(Config.ConnectString, "usp_NewsCategory_GetList", param, out comx);

            if (r != null)
            {
                list = new List <NewsCategoryInfo>();
                while (r.Read())
                {
                    var info = new NewsCategoryInfo();
                    info.Id              = Int32.Parse(r["Id"].ToString());
                    info.Name            = r["Name"].ToString();
                    info.Link            = r["Link"].ToString();
                    info.Sort            = Int32.Parse(r["Sort"].ToString());
                    info.Description     = r["Description"].ToString();
                    info.MetaDescription = r["MetaDescription"].ToString();
                    info.MetaKeyword     = r["MetaKeyword"].ToString();
                    info.MetaHeading     = r["MetaHeading"].ToString();
                    info.Image           = r["Image"].ToString();
                    info.TitleRewrite    = r["TitleRewrite"].ToString();
                    info.ParentId        = Int32.Parse(r["ParentId"].ToString());


                    list.Add(info);
                }
                r.Close();
                r.Dispose();
                t = int.Parse(comx.Parameters[2].Value.ToString());
            }

            total = t;
            return(list);
        }
Beispiel #13
0
 public int Add(NewsCategoryInfo info)
 {
     SqlParameter[] param =
     {
         new SqlParameter("@Name",            info.Name),
         new SqlParameter("@Link",            info.Link),
         new SqlParameter("@Sort",            info.Sort),
         new SqlParameter("@Description",     info.Description),
         new SqlParameter("@MetaDescription", info.MetaDescription),
         new SqlParameter("@MetaKeyword",     info.MetaKeyword),
         new SqlParameter("@MetaHeading",     info.MetaHeading),
         new SqlParameter("@Image",           info.Image),
         new SqlParameter("@TitleRewrite",    info.TitleRewrite),
         new SqlParameter("@ParentId",        info.ParentId)
     };
     return(int.Parse(DataHelper.ExecuteScalar(Config.ConnectString, "usp_NewsCategory_Add", param).ToString()));
 }
Beispiel #14
0
 public void Bind()
 {
     if (Request.QueryString["id"] != null)
     {
         if (Tools.TryParseMethod(id.ToString()) != 0)
         {
             NewsCategoryInfo info = ncBLL.getAllById(id);
             txtName.Text = info.nc_name;
             ddlCategory.SelectedValue = info.nc_fatherid.ToString();
             if (info.nc_fatherid == 0)
             {
                 ddlCategory.Enabled = false;
             }
             Image1.ImageUrl      = Tools.GetAppSettings("NewsImageTruePath") + info.nc_image;
             Image1.AlternateText = info.nc_image;
             rbShow.SelectedValue = info.nc_show.ToString().ToLower();
             hfImg.Value          = info.nc_image;
         }
     }
 }
Beispiel #15
0
        public int Update(NewsCategoryInfo info)
        {
            int check = 1;
            NewsCategoryInfo ncinfo = getAllById(info.nc_id);

            //1.限制選自己
            if (info.nc_fatherid != info.nc_id)
            {
                //2.不可選自己的下一層
                List <NewsCategoryInfo> checkinfos = GetallSortData(info.nc_id); //以自己為父,取出向下所有資料
                foreach (NewsCategoryInfo ckinfo in checkinfos)
                {
                    if (ckinfo.nc_id == info.nc_fatherid) //選取值FatherId 若等於 nc_id,即不可更新
                    {
                        check = 0;
                    }
                }
                if (check == 1)
                {
                    if (info.nc_fatherid == ncinfo.nc_fatherid)
                    {
                        countmath = ncinfo.nc_sorting;
                    }
                    else
                    {
                        countmath = GetDataByFatherIdAndLidOrderSortDESC(info.nc_fatherid, lidValue);
                        result    = UpdataSorting(ncinfo.nc_fatherid, ncinfo.nc_sorting);
                        foreach (NewsCategoryInfo sortinfo in result)
                        {
                            db.Update(sortinfo.nc_name, sortinfo.nc_fatherid, sortinfo.nc_image, sortinfo.nc_show, sortinfo.l_id, countmath, sortinfo.nc_id);
                        }
                    }
                    return(db.Update(info.nc_name, info.nc_fatherid, info.nc_image, info.nc_show, info.l_id, countmath, info.nc_id));
                }
            }
            return(check);
        }
        private bool AddNewCate()
        {
            if (string.IsNullOrEmpty(txtCategoryname.Text) || string.IsNullOrEmpty(txtSort.Text))
            {
                ltrThongbao.Text = "Cần nhập đủ các trường!";
                return(false);
            }
            var info = new NewsCategoryInfo();

            info.Name = txtCategoryname.Text;
            var nextId = UntilityFunction.nextId("NewsCategory");

            info.Link            = Rewrite.GenCate(info.Name, nextId, Rewrite.News);
            info.Sort            = int.Parse(txtSort.Text);
            info.Description     = txtMota.Text;
            info.MetaDescription = txtMota.Text;
            info.MetaHeading     = "";
            info.MetaKeyword     = txtTukhoa.Text;
            info.ParentId        = 0;
            info.TitleRewrite    = "";
            info.Image           = "";
            NewsCategoryImpl.Instance.Add(info);
            return(true);
        }
Beispiel #17
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (!Directory.Exists(Server.MapPath("NewsImageTruePath")))
     {
         System.IO.Directory.CreateDirectory(Server.MapPath("~/ImageCollection/news/"));
     }
     if (ncBLL.SearchHierarchyDownVail(Tools.TryParseMethod(ddlCategory.SelectedValue), id, int.Parse(UserInfoConfig.GetUserConfig("HierarchyNewsCategory"))))
     {
         if (hfImg.Value != Image1.AlternateText)
         {
             FileInfo file = new FileInfo(Server.MapPath(Image1.ImageUrl));
             file.CopyTo(Server.MapPath(Tools.GetAppSettings("NewsImageTruePath") + Image1.AlternateText));
             if (File.Exists(Server.MapPath(Tools.GetAppSettings("NewsImageTruePath") + hfImg.Value)))
             {
                 File.Delete(Server.MapPath(Tools.GetAppSettings("NewsImageTruePath") + hfImg.Value));
             }
         }
         NewsCategoryInfo info = ncBLL.getAllById(id);
         info.nc_fatherid = Tools.TryParseMethod(ddlCategory.SelectedValue);
         info.nc_name     = txtName.Text;
         info.nc_show     = bool.Parse(rbShow.SelectedValue);
         info.nc_image    = Image1.AlternateText;
         if (ncBLL.Update(info) > 0)
         {
             Response.Redirect("List.aspx?header=修改訊息完成!", true);
         }
         else
         {
             ShowMessage("更新失敗: 更新類別不可為自身、不可為自身以下的子類別");
         }
     }
     else
     {
         ShowMessage("轉換類別超越階層限制數");
     }
 }
Beispiel #18
0
        //NEW End
        public int Insert(NewsCategoryInfo info)
        {
            int sortinfo = GetDataByFatherIdAndLidOrderSortDESC(info.nc_fatherid, info.l_id);

            return(db.Insert(info.nc_name, info.nc_fatherid, info.nc_image, info.nc_show, info.l_id, sortinfo));
        }