Пример #1
0
        //設置操作
        protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            ChkAdminLevel(channel_id, DTEnums.ActionEnum.Edit.ToString()); //檢查許可權
            int id = Convert.ToInt32(((HiddenField)e.Item.FindControl("hidId")).Value);

            BLL.article            bll   = new BLL.article();
            Model.article_download model = bll.GetDownloadModel(id);
            switch (e.CommandName.ToLower())
            {
            case "ibtnmsg":
                if (model.is_msg == 1)
                {
                    bll.UpdateDownloadField(id, "is_msg=0");
                }
                else
                {
                    bll.UpdateDownloadField(id, "is_msg=1");
                }
                break;

            case "ibtnred":
                if (model.is_red == 1)
                {
                    bll.UpdateDownloadField(id, "is_red=0");
                }
                else
                {
                    bll.UpdateDownloadField(id, "is_red=1");
                }
                break;
            }
            this.RptBind("id>0" + CombSqlTxt(this.channel_id, this.category_id, this.keywords, this.property), "sort_id asc,add_time desc");
        }
Пример #2
0
        private void ShowInfo(int _id)
        {
            BLL.article            bll   = new BLL.article();
            Model.article_download model = bll.GetDownloadModel(_id);

            ddlCategoryId.SelectedValue = model.category_id.ToString();
            txtTitle.Text   = model.title;
            txtImgUrl.Text  = model.img_url;
            txtLinkUrl.Text = model.link_url;
            if (model.is_msg == 1)
            {
                cblItem.Items[0].Selected = true;
            }
            if (model.is_red == 1)
            {
                cblItem.Items[1].Selected = true;
            }
            if (model.is_lock == 1)
            {
                cblItem.Items[2].Selected = true;
            }
            txtSortId.Text         = model.sort_id.ToString();
            txtClick.Text          = model.click.ToString();
            txtDiggGood.Text       = model.digg_good.ToString();
            txtDiggBad.Text        = model.digg_bad.ToString();
            txtContent.Value       = model.content;
            txtSeoTitle.Text       = model.seo_title;
            txtSeoKeywords.Text    = model.seo_keywords;
            txtSeoDescription.Text = model.seo_description;
            //绑定附件
            rptAttach.DataSource = model.download_attachs;
            rptAttach.DataBind();
        }
Пример #3
0
 /// <summary>
 /// 重写虚方法,此方法将在Init事件前执行
 /// </summary>
 protected override void ShowPage()
 {
     id = DTRequest.GetQueryInt("id");
     BLL.article bll = new BLL.article();
     if (!bll.Exists(id))
     {
         HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!"));
         return;
     }
     model = bll.GetDownloadModel(id);
     //浏览数+1
     bll.UpdateField(id, "click=click+1");
     //跳转URL
     if (model.link_url != null)
         model.link_url = model.link_url.Trim();
     if (!string.IsNullOrEmpty(model.link_url))
     {
         HttpContext.Current.Response.Redirect(model.link_url);
     }
 }
Пример #4
0
 /// <summary>
 /// 重写虚方法,此方法将在Init事件前执行
 /// </summary>
 protected override void ShowPage()
 {
     id = DTRequest.GetQueryInt("id");
     BLL.article bll = new BLL.article();
     if (!bll.Exists(id))
     {
         HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!"));
         return;
     }
     model = bll.GetDownloadModel(id);
     //浏览数+1
     bll.UpdateField(id, "click=click+1");
     //跳转URL
     if (model.link_url != null)
     {
         model.link_url = model.link_url.Trim();
     }
     if (!string.IsNullOrEmpty(model.link_url))
     {
         HttpContext.Current.Response.Redirect(model.link_url);
     }
 }
Пример #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.article_download GetDownloadModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 id,channel_id,category_id,title,link_url,img_url,seo_title,seo_keywords,seo_description,content,sort_id,click,is_lock,user_id,add_time,is_msg,is_red,digg_good,digg_bad from view_article_download ");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters = {
					new SqlParameter("@id", SqlDbType.Int,4)};
            parameters[0].Value = id;

            Model.article_download model = new Model.article_download();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                #region  父表信息
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["channel_id"] != null && ds.Tables[0].Rows[0]["channel_id"].ToString() != "")
                {
                    model.channel_id = int.Parse(ds.Tables[0].Rows[0]["channel_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["category_id"] != null && ds.Tables[0].Rows[0]["category_id"].ToString() != "")
                {
                    model.category_id = int.Parse(ds.Tables[0].Rows[0]["category_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["title"] != null && ds.Tables[0].Rows[0]["title"].ToString() != "")
                {
                    model.title = ds.Tables[0].Rows[0]["title"].ToString();
                }
                if (ds.Tables[0].Rows[0]["link_url"] != null && ds.Tables[0].Rows[0]["link_url"].ToString() != "")
                {
                    model.link_url = ds.Tables[0].Rows[0]["link_url"].ToString();
                }
                if (ds.Tables[0].Rows[0]["img_url"] != null && ds.Tables[0].Rows[0]["img_url"].ToString() != "")
                {
                    model.img_url = ds.Tables[0].Rows[0]["img_url"].ToString();
                }
                if (ds.Tables[0].Rows[0]["seo_title"] != null && ds.Tables[0].Rows[0]["seo_title"].ToString() != "")
                {
                    model.seo_title = ds.Tables[0].Rows[0]["seo_title"].ToString();
                }
                if (ds.Tables[0].Rows[0]["seo_keywords"] != null && ds.Tables[0].Rows[0]["seo_keywords"].ToString() != "")
                {
                    model.seo_keywords = ds.Tables[0].Rows[0]["seo_keywords"].ToString();
                }
                if (ds.Tables[0].Rows[0]["seo_description"] != null && ds.Tables[0].Rows[0]["seo_description"].ToString() != "")
                {
                    model.seo_description = ds.Tables[0].Rows[0]["seo_description"].ToString();
                }
                if (ds.Tables[0].Rows[0]["content"] != null && ds.Tables[0].Rows[0]["content"].ToString() != "")
                {
                    model.content = ds.Tables[0].Rows[0]["content"].ToString();
                }
                if (ds.Tables[0].Rows[0]["sort_id"] != null && ds.Tables[0].Rows[0]["sort_id"].ToString() != "")
                {
                    model.sort_id = int.Parse(ds.Tables[0].Rows[0]["sort_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["click"] != null && ds.Tables[0].Rows[0]["click"].ToString() != "")
                {
                    model.click = int.Parse(ds.Tables[0].Rows[0]["click"].ToString());
                }
                if (ds.Tables[0].Rows[0]["is_lock"] != null && ds.Tables[0].Rows[0]["is_lock"].ToString() != "")
                {
                    model.is_lock = int.Parse(ds.Tables[0].Rows[0]["is_lock"].ToString());
                }
                if (ds.Tables[0].Rows[0]["user_id"] != null && ds.Tables[0].Rows[0]["user_id"].ToString() != "")
                {
                    model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["add_time"] != null && ds.Tables[0].Rows[0]["add_time"].ToString() != "")
                {
                    model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["is_msg"] != null && ds.Tables[0].Rows[0]["is_msg"].ToString() != "")
                {
                    model.is_msg = int.Parse(ds.Tables[0].Rows[0]["is_msg"].ToString());
                }
                if (ds.Tables[0].Rows[0]["is_red"] != null && ds.Tables[0].Rows[0]["is_red"].ToString() != "")
                {
                    model.is_red = int.Parse(ds.Tables[0].Rows[0]["is_red"].ToString());
                }
                if (ds.Tables[0].Rows[0]["digg_good"] != null && ds.Tables[0].Rows[0]["digg_good"].ToString() != "")
                {
                    model.digg_good = int.Parse(ds.Tables[0].Rows[0]["digg_good"].ToString());
                }
                if (ds.Tables[0].Rows[0]["digg_bad"] != null && ds.Tables[0].Rows[0]["digg_bad"].ToString() != "")
                {
                    model.digg_bad = int.Parse(ds.Tables[0].Rows[0]["digg_bad"].ToString());
                }
                #endregion  父表信息end

                model.download_attachs = new download_attach().GetList(id); //附件列表

                return model;
            }
            else
            {
                return null;
            }
        }
Пример #6
0
        private bool DoEdit(int _id)
        {
            bool result = true;

            BLL.article            bll   = new BLL.article();
            Model.article_download model = bll.GetDownloadModel(_id);

            model.channel_id      = this.channel_id;
            model.title           = txtTitle.Text.Trim();
            model.category_id     = int.Parse(ddlCategoryId.SelectedValue);
            model.link_url        = txtLinkUrl.Text.Trim();
            model.img_url         = txtImgUrl.Text.Trim();
            model.content         = txtContent.Value;
            model.seo_title       = txtSeoTitle.Text.Trim();
            model.seo_keywords    = txtSeoKeywords.Text.Trim();
            model.seo_description = txtSeoDescription.Text.Trim();
            model.sort_id         = int.Parse(txtSortId.Text.Trim());
            model.click           = int.Parse(txtClick.Text.Trim());
            model.digg_good       = int.Parse(txtDiggGood.Text.Trim());
            model.digg_bad        = int.Parse(txtDiggBad.Text.Trim());
            model.is_msg          = 0;
            model.is_red          = 0;
            model.is_lock         = 0;
            if (cblItem.Items[0].Selected == true)
            {
                model.is_msg = 1;
            }
            if (cblItem.Items[1].Selected == true)
            {
                model.is_red = 1;
            }
            if (cblItem.Items[2].Selected == true)
            {
                model.is_lock = 1;
            }

            //保存附件
            if (model.download_attachs != null)
            {
                model.download_attachs.Clear();
            }
            string hidFileList = Request.Params["hidFileName"];

            string[] pointArr = Request.Form.GetValues("txtPoint");
            if (!string.IsNullOrEmpty(hidFileList))
            {
                string[] fileListArr            = hidFileList.Split(',');
                List <Model.download_attach> ls = new List <Model.download_attach>();
                for (int i = 0; i < fileListArr.Length; i++)
                {
                    string[] fileArr = fileListArr[i].Split('|');
                    if (fileArr.Length == 3)
                    {
                        int    attach_id = int.Parse(fileArr[0]);
                        int    fileSize  = Utils.GetFileSize(fileArr[2]);
                        string fileExt   = Utils.GetFileExt(fileArr[2]);
                        int    _point    = int.Parse(pointArr[i]);
                        //删除旧文件
                        if (attach_id > 0)
                        {
                            new BLL.download_attach().DeleteFile(attach_id, fileArr[2]);
                        }
                        ls.Add(new Model.download_attach {
                            id = attach_id, article_id = _id, title = fileArr[1], file_path = fileArr[2], file_size = fileSize, file_ext = fileExt, point = _point
                        });
                    }
                }
                model.download_attachs = ls;
            }

            if (!bll.Update(model))
            {
                result = false;
            }
            return(result);
        }
Пример #7
0
        private bool DoAdd()
        {
            bool result = true;
            Model.article_download model = new Model.article_download();
            BLL.article bll = new BLL.article();

            model.channel_id = this.channel_id;
            model.title = txtTitle.Text.Trim();
            model.category_id = int.Parse(ddlCategoryId.SelectedValue);
            model.link_url = txtLinkUrl.Text.Trim();
            model.img_url = txtImgUrl.Text.Trim();
            model.content = txtContent.Value;
            model.seo_title = txtSeoTitle.Text.Trim();
            model.seo_keywords = txtSeoKeywords.Text.Trim();
            model.seo_description = txtSeoDescription.Text.Trim();
            model.sort_id = int.Parse(txtSortId.Text.Trim());
            model.click = int.Parse(txtClick.Text.Trim());
            model.digg_good = int.Parse(txtDiggGood.Text.Trim());
            model.digg_bad = int.Parse(txtDiggBad.Text.Trim());
            model.is_msg = 0;
            model.is_red = 0;
            model.is_lock = 0;
            if (cblItem.Items[0].Selected == true)
            {
                model.is_msg = 1;
            }
            if (cblItem.Items[1].Selected == true)
            {
                model.is_red = 1;
            }
            if (cblItem.Items[2].Selected == true)
            {
                model.is_lock = 1;
            }
            //保存附件
            string hidFileList = Request.Params["hidFileName"];
            if (!string.IsNullOrEmpty(hidFileList))
            {
                string[] fileListArr = hidFileList.Split(',');
                string[] pointArr = Request.Form.GetValues("txtPoint");
                List<Model.download_attach> ls = new List<Model.download_attach>();
                for (int i = 0; i < fileListArr.Length; i++)
                {
                    string[] fileArr = fileListArr[i].Split('|');
                    if (fileArr.Length == 3)
                    {
                        int fileSize = Utils.GetFileSize(fileArr[2]);
                        string fileExt = Utils.GetFileExt(fileArr[2]);
                        int _point = int.Parse(pointArr[i]);
                        ls.Add(new Model.download_attach { id = int.Parse(fileArr[0]), title = fileArr[1], file_path = fileArr[2], file_size = fileSize, file_ext = fileExt, point=_point });
                    }
                }
                model.download_attachs = ls;
            }

            if (bll.Add(model) < 1)
            {
                result = false;
            }
            return result;
        }
Пример #8
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.article_download model)
 {
     return(dal.Update(model));
 }
Пример #9
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Model.article_download model)
 {
     return(dal.Add(model));
 }
Пример #10
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.article_download GetDownloadModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,channel_id,category_id,title,link_url,img_url,seo_title,seo_keywords,seo_description,content,sort_id,click,is_lock,user_id,add_time,is_msg,is_red,digg_good,digg_bad from view_article_download ");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            Model.article_download model = new Model.article_download();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                #region  父表信息
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["channel_id"] != null && ds.Tables[0].Rows[0]["channel_id"].ToString() != "")
                {
                    model.channel_id = int.Parse(ds.Tables[0].Rows[0]["channel_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["category_id"] != null && ds.Tables[0].Rows[0]["category_id"].ToString() != "")
                {
                    model.category_id = int.Parse(ds.Tables[0].Rows[0]["category_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["title"] != null && ds.Tables[0].Rows[0]["title"].ToString() != "")
                {
                    model.title = ds.Tables[0].Rows[0]["title"].ToString();
                }
                if (ds.Tables[0].Rows[0]["link_url"] != null && ds.Tables[0].Rows[0]["link_url"].ToString() != "")
                {
                    model.link_url = ds.Tables[0].Rows[0]["link_url"].ToString();
                }
                if (ds.Tables[0].Rows[0]["img_url"] != null && ds.Tables[0].Rows[0]["img_url"].ToString() != "")
                {
                    model.img_url = ds.Tables[0].Rows[0]["img_url"].ToString();
                }
                if (ds.Tables[0].Rows[0]["seo_title"] != null && ds.Tables[0].Rows[0]["seo_title"].ToString() != "")
                {
                    model.seo_title = ds.Tables[0].Rows[0]["seo_title"].ToString();
                }
                if (ds.Tables[0].Rows[0]["seo_keywords"] != null && ds.Tables[0].Rows[0]["seo_keywords"].ToString() != "")
                {
                    model.seo_keywords = ds.Tables[0].Rows[0]["seo_keywords"].ToString();
                }
                if (ds.Tables[0].Rows[0]["seo_description"] != null && ds.Tables[0].Rows[0]["seo_description"].ToString() != "")
                {
                    model.seo_description = ds.Tables[0].Rows[0]["seo_description"].ToString();
                }
                if (ds.Tables[0].Rows[0]["content"] != null && ds.Tables[0].Rows[0]["content"].ToString() != "")
                {
                    model.content = ds.Tables[0].Rows[0]["content"].ToString();
                }
                if (ds.Tables[0].Rows[0]["sort_id"] != null && ds.Tables[0].Rows[0]["sort_id"].ToString() != "")
                {
                    model.sort_id = int.Parse(ds.Tables[0].Rows[0]["sort_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["click"] != null && ds.Tables[0].Rows[0]["click"].ToString() != "")
                {
                    model.click = int.Parse(ds.Tables[0].Rows[0]["click"].ToString());
                }
                if (ds.Tables[0].Rows[0]["is_lock"] != null && ds.Tables[0].Rows[0]["is_lock"].ToString() != "")
                {
                    model.is_lock = int.Parse(ds.Tables[0].Rows[0]["is_lock"].ToString());
                }
                if (ds.Tables[0].Rows[0]["user_id"] != null && ds.Tables[0].Rows[0]["user_id"].ToString() != "")
                {
                    model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["add_time"] != null && ds.Tables[0].Rows[0]["add_time"].ToString() != "")
                {
                    model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["is_msg"] != null && ds.Tables[0].Rows[0]["is_msg"].ToString() != "")
                {
                    model.is_msg = int.Parse(ds.Tables[0].Rows[0]["is_msg"].ToString());
                }
                if (ds.Tables[0].Rows[0]["is_red"] != null && ds.Tables[0].Rows[0]["is_red"].ToString() != "")
                {
                    model.is_red = int.Parse(ds.Tables[0].Rows[0]["is_red"].ToString());
                }
                if (ds.Tables[0].Rows[0]["digg_good"] != null && ds.Tables[0].Rows[0]["digg_good"].ToString() != "")
                {
                    model.digg_good = int.Parse(ds.Tables[0].Rows[0]["digg_good"].ToString());
                }
                if (ds.Tables[0].Rows[0]["digg_bad"] != null && ds.Tables[0].Rows[0]["digg_bad"].ToString() != "")
                {
                    model.digg_bad = int.Parse(ds.Tables[0].Rows[0]["digg_bad"].ToString());
                }
                #endregion  父表信息end

                model.download_attachs = new download_attach().GetList(id); //附件列表

                return(model);
            }
            else
            {
                return(null);
            }
        }
Пример #11
0
        /// <summary>
        /// 增加一条数据,及其子表数据
        /// </summary>
        public int Add(Model.article_download model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into dt_article(");
            strSql.Append("channel_id,category_id,title,link_url,img_url,seo_title,seo_keywords,seo_description,content,sort_id,click,is_lock,user_id,add_time)");
            strSql.Append(" values (");
            strSql.Append("@channel_id,@category_id,@title,@link_url,@img_url,@seo_title,@seo_keywords,@seo_description,@content,@sort_id,@click,@is_lock,@user_id,@add_time)");
            strSql.Append(";set @ReturnValue= @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@channel_id",      SqlDbType.Int,         4),
                new SqlParameter("@category_id",     SqlDbType.Int,         4),
                new SqlParameter("@title",           SqlDbType.NVarChar,  100),
                new SqlParameter("@link_url",        SqlDbType.NVarChar,  255),
                new SqlParameter("@img_url",         SqlDbType.NVarChar,  255),
                new SqlParameter("@seo_title",       SqlDbType.NVarChar,  255),
                new SqlParameter("@seo_keywords",    SqlDbType.NVarChar,  255),
                new SqlParameter("@seo_description", SqlDbType.NVarChar,  255),
                new SqlParameter("@content",         SqlDbType.NText),
                new SqlParameter("@sort_id",         SqlDbType.Int,         4),
                new SqlParameter("@click",           SqlDbType.Int,         4),
                new SqlParameter("@is_lock",         SqlDbType.TinyInt,     1),
                new SqlParameter("@user_id",         SqlDbType.Int,         4),
                new SqlParameter("@add_time",        SqlDbType.DateTime),
                new SqlParameter("@ReturnValue",     SqlDbType.Int)
            };
            parameters[0].Value      = model.channel_id;
            parameters[1].Value      = model.category_id;
            parameters[2].Value      = model.title;
            parameters[3].Value      = model.link_url;
            parameters[4].Value      = model.img_url;
            parameters[5].Value      = model.seo_title;
            parameters[6].Value      = model.seo_keywords;
            parameters[7].Value      = model.seo_description;
            parameters[8].Value      = model.content;
            parameters[9].Value      = model.sort_id;
            parameters[10].Value     = model.click;
            parameters[11].Value     = model.is_lock;
            parameters[12].Value     = model.user_id;
            parameters[13].Value     = model.add_time;
            parameters[14].Direction = ParameterDirection.Output;

            List <CommandInfo> sqllist = new List <CommandInfo>();
            CommandInfo        cmd     = new CommandInfo(strSql.ToString(), parameters);

            sqllist.Add(cmd);

            //附表信息
            StringBuilder strSql2 = new StringBuilder();

            strSql2.Append("insert into dt_article_download(");
            strSql2.Append("id,is_msg,is_red)");
            strSql2.Append(" values (");
            strSql2.Append("@id,@is_msg,@is_red)");
            SqlParameter[] parameters2 =
            {
                new SqlParameter("@id",     SqlDbType.Int,     4),
                new SqlParameter("@is_msg", SqlDbType.TinyInt, 1),
                new SqlParameter("@is_red", SqlDbType.TinyInt, 1)
            };
            parameters2[0].Direction = ParameterDirection.InputOutput;
            parameters2[1].Value     = model.is_msg;
            parameters2[2].Value     = model.is_red;
            cmd = new CommandInfo(strSql2.ToString(), parameters2);
            sqllist.Add(cmd);

            //顶和踩
            StringBuilder strSql3 = new StringBuilder();

            strSql3.Append("insert into dt_article_diggs(");
            strSql3.Append("id,digg_good,digg_bad)");
            strSql3.Append(" values (");
            strSql3.Append("@id,@digg_good,@digg_bad)");
            SqlParameter[] parameters3 =
            {
                new SqlParameter("@id",        SqlDbType.Int, 4),
                new SqlParameter("@digg_good", SqlDbType.Int, 4),
                new SqlParameter("@digg_bad",  SqlDbType.Int, 4)
            };
            parameters3[0].Direction = ParameterDirection.InputOutput;
            parameters3[1].Value     = model.digg_good;
            parameters3[2].Value     = model.digg_bad;
            cmd = new CommandInfo(strSql3.ToString(), parameters3);
            sqllist.Add(cmd);

            //下载附件
            if (model.download_attachs != null)
            {
                StringBuilder strSql4;
                foreach (Model.download_attach models in model.download_attachs)
                {
                    strSql4 = new StringBuilder();
                    strSql4.Append("insert into dt_download_attach(");
                    strSql4.Append("article_id,title,file_path,file_ext,file_size,down_num,point)");
                    strSql4.Append(" values (");
                    strSql4.Append("@article_id,@title,@file_path,@file_ext,@file_size,@down_num,@point)");
                    SqlParameter[] parameters4 =
                    {
                        new SqlParameter("@article_id", SqlDbType.Int,        4),
                        new SqlParameter("@title",      SqlDbType.NVarChar, 255),
                        new SqlParameter("@file_path",  SqlDbType.NVarChar, 255),
                        new SqlParameter("@file_ext",   SqlDbType.NVarChar, 100),
                        new SqlParameter("@file_size",  SqlDbType.Int,        4),
                        new SqlParameter("@down_num",   SqlDbType.Int,        4),
                        new SqlParameter("@point",      SqlDbType.Int, 4)
                    };
                    parameters4[0].Direction = ParameterDirection.InputOutput;
                    parameters4[1].Value     = models.title;
                    parameters4[2].Value     = models.file_path;
                    parameters4[3].Value     = models.file_ext;
                    parameters4[4].Value     = models.file_size;
                    parameters4[5].Value     = models.down_num;
                    parameters4[6].Value     = models.point;
                    cmd = new CommandInfo(strSql4.ToString(), parameters4);
                    sqllist.Add(cmd);
                }
            }

            DbHelperSQL.ExecuteSqlTranWithIndentity(sqllist);
            return((int)parameters[14].Value);
        }
Пример #12
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.article_download model)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("update dt_article set ");
                        strSql.Append("channel_id=@channel_id,");
                        strSql.Append("category_id=@category_id,");
                        strSql.Append("title=@title,");
                        strSql.Append("link_url=@link_url,");
                        strSql.Append("img_url=@img_url,");
                        strSql.Append("seo_title=@seo_title,");
                        strSql.Append("seo_keywords=@seo_keywords,");
                        strSql.Append("seo_description=@seo_description,");
                        strSql.Append("content=@content,");
                        strSql.Append("sort_id=@sort_id,");
                        strSql.Append("click=@click,");
                        strSql.Append("is_lock=@is_lock,");
                        strSql.Append("user_id=@user_id,");
                        strSql.Append("add_time=@add_time");
                        strSql.Append(" where id=@id");
                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@channel_id",      SqlDbType.Int,         4),
                            new SqlParameter("@category_id",     SqlDbType.Int,         4),
                            new SqlParameter("@title",           SqlDbType.NVarChar,  100),
                            new SqlParameter("@link_url",        SqlDbType.NVarChar,  255),
                            new SqlParameter("@img_url",         SqlDbType.NVarChar,  255),
                            new SqlParameter("@seo_title",       SqlDbType.NVarChar,  255),
                            new SqlParameter("@seo_keywords",    SqlDbType.NVarChar,  255),
                            new SqlParameter("@seo_description", SqlDbType.NVarChar,  255),
                            new SqlParameter("@content",         SqlDbType.NText),
                            new SqlParameter("@sort_id",         SqlDbType.Int,         4),
                            new SqlParameter("@click",           SqlDbType.Int,         4),
                            new SqlParameter("@is_lock",         SqlDbType.TinyInt,     1),
                            new SqlParameter("@user_id",         SqlDbType.Int,         4),
                            new SqlParameter("@add_time",        SqlDbType.DateTime),
                            new SqlParameter("@id",              SqlDbType.Int, 4)
                        };
                        parameters[0].Value  = model.channel_id;
                        parameters[1].Value  = model.category_id;
                        parameters[2].Value  = model.title;
                        parameters[3].Value  = model.link_url;
                        parameters[4].Value  = model.img_url;
                        parameters[5].Value  = model.seo_title;
                        parameters[6].Value  = model.seo_keywords;
                        parameters[7].Value  = model.seo_description;
                        parameters[8].Value  = model.content;
                        parameters[9].Value  = model.sort_id;
                        parameters[10].Value = model.click;
                        parameters[11].Value = model.is_lock;
                        parameters[12].Value = model.user_id;
                        parameters[13].Value = model.add_time;
                        parameters[14].Value = model.id;
                        DbHelperSQL.ExecuteSql(conn, trans, strSql.ToString(), parameters);

                        //修改副表
                        StringBuilder strSql21 = new StringBuilder();
                        strSql21.Append("update dt_article_download set ");
                        strSql21.Append("id=@id,");
                        strSql21.Append("is_msg=@is_msg,");
                        strSql21.Append("is_red=@is_red");
                        strSql21.Append(" where id=@id ");
                        SqlParameter[] parameters21 =
                        {
                            new SqlParameter("@id",     SqlDbType.Int,     4),
                            new SqlParameter("@is_msg", SqlDbType.TinyInt, 1),
                            new SqlParameter("@is_red", SqlDbType.TinyInt, 1)
                        };
                        parameters21[0].Value = model.id;
                        parameters21[1].Value = model.is_msg;
                        parameters21[2].Value = model.is_red;
                        DbHelperSQL.ExecuteSql(conn, trans, strSql21.ToString(), parameters21);

                        //修改顶和踩
                        StringBuilder strSql22 = new StringBuilder();
                        strSql22.Append("update dt_article_diggs set ");
                        strSql22.Append("digg_good=@digg_good,");
                        strSql22.Append("digg_bad=@digg_bad");
                        strSql22.Append(" where id=@id ");
                        SqlParameter[] parameters22 =
                        {
                            new SqlParameter("@digg_good", SqlDbType.Int, 4),
                            new SqlParameter("@digg_bad",  SqlDbType.Int, 4),
                            new SqlParameter("@id",        SqlDbType.Int, 4)
                        };
                        parameters22[0].Value = model.digg_good;
                        parameters22[1].Value = model.digg_bad;
                        parameters22[2].Value = model.id;
                        DbHelperSQL.ExecuteSql(conn, trans, strSql22.ToString(), parameters22);

                        //删除已删除的附件
                        new download_attach().DeleteList(conn, trans, model.download_attachs, model.id);
                        // 添加/修改附件
                        if (model.download_attachs != null)
                        {
                            StringBuilder strSql2;
                            foreach (Model.download_attach models in model.download_attachs)
                            {
                                strSql2 = new StringBuilder();
                                if (models.id > 0)
                                {
                                    strSql2.Append("update dt_download_attach set ");
                                    strSql2.Append("article_id=@article_id,");
                                    strSql2.Append("title=@title,");
                                    strSql2.Append("file_path=@file_path,");
                                    strSql2.Append("file_ext=@file_ext,");
                                    strSql2.Append("file_size=@file_size,");
                                    strSql2.Append("down_num=@down_num,");
                                    strSql2.Append("point=@point");
                                    strSql2.Append(" where id=@id");
                                    SqlParameter[] parameters2 =
                                    {
                                        new SqlParameter("@article_id", SqlDbType.Int,        4),
                                        new SqlParameter("@title",      SqlDbType.NVarChar, 255),
                                        new SqlParameter("@file_path",  SqlDbType.NVarChar, 255),
                                        new SqlParameter("@file_ext",   SqlDbType.NVarChar, 100),
                                        new SqlParameter("@file_size",  SqlDbType.Int,        4),
                                        new SqlParameter("@down_num",   SqlDbType.Int,        4),
                                        new SqlParameter("@point",      SqlDbType.Int,        4),
                                        new SqlParameter("@id",         SqlDbType.Int, 4)
                                    };
                                    parameters2[0].Value = models.article_id;
                                    parameters2[1].Value = models.title;
                                    parameters2[2].Value = models.file_path;
                                    parameters2[3].Value = models.file_ext;
                                    parameters2[4].Value = models.file_size;
                                    parameters2[5].Value = models.down_num;
                                    parameters2[6].Value = models.point;
                                    parameters2[7].Value = models.id;
                                    DbHelperSQL.ExecuteSql(conn, trans, strSql2.ToString(), parameters2);
                                }
                                else
                                {
                                    strSql2.Append("insert into dt_download_attach(");
                                    strSql2.Append("article_id,title,file_path,file_ext,file_size,down_num,point)");
                                    strSql2.Append(" values (");
                                    strSql2.Append("@article_id,@title,@file_path,@file_ext,@file_size,@down_num,@point)");
                                    SqlParameter[] parameters2 =
                                    {
                                        new SqlParameter("@article_id", SqlDbType.Int,        4),
                                        new SqlParameter("@title",      SqlDbType.NVarChar, 255),
                                        new SqlParameter("@file_path",  SqlDbType.NVarChar, 255),
                                        new SqlParameter("@file_ext",   SqlDbType.NVarChar, 100),
                                        new SqlParameter("@file_size",  SqlDbType.Int,        4),
                                        new SqlParameter("@down_num",   SqlDbType.Int,        4),
                                        new SqlParameter("@point",      SqlDbType.Int, 4)
                                    };
                                    parameters2[0].Value = models.article_id;
                                    parameters2[1].Value = models.title;
                                    parameters2[2].Value = models.file_path;
                                    parameters2[3].Value = models.file_ext;
                                    parameters2[4].Value = models.file_size;
                                    parameters2[5].Value = models.down_num;
                                    parameters2[6].Value = models.point;
                                    DbHelperSQL.ExecuteSql(conn, trans, strSql2.ToString(), parameters2);
                                }
                            }
                        }

                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        return(false);
                    }
                }
            }
            return(true);
        }
Пример #13
0
        private bool DoAdd()
        {
            bool result = true;

            Model.article_download model = new Model.article_download();
            BLL.article            bll   = new BLL.article();

            model.channel_id      = 9;
            model.title           = txtTitle.Text.Trim();
            model.category_id     = Utils.StringToNum(ddlCategoryId.SelectedValue);
            model.link_url        = txtLinkUrl.Text.Trim();
            model.img_url         = txtImgUrl.Text.Trim();
            model.content         = txtContent.Value;
            model.seo_title       = txtSeoTitle.Text.Trim();
            model.seo_keywords    = txtSeoKeywords.Text.Trim();
            model.seo_description = txtSeoDescription.Text.Trim();
            model.sort_id         = int.Parse(txtSortId.Text.Trim());
            model.click           = int.Parse(txtClick.Text.Trim());
            model.digg_good       = int.Parse(txtDiggGood.Text.Trim());
            model.digg_bad        = int.Parse(txtDiggBad.Text.Trim());
            model.is_msg          = 0;
            model.is_red          = 0;
            model.is_lock         = 0;
            if (cblItem.Items[0].Selected == true)
            {
                model.is_msg = 1;
            }
            if (cblItem.Items[1].Selected == true)
            {
                model.is_red = 1;
            }
            if (cblItem.Items[2].Selected == true)
            {
                model.is_lock = 1;
            }
            //儲存附件
            string hidFileList = Request.Params["hidFileName"];

            if (!string.IsNullOrEmpty(hidFileList))
            {
                string[] fileListArr            = hidFileList.Split(',');
                string[] pointArr               = Request.Form.GetValues("txtPoint");
                List <Model.download_attach> ls = new List <Model.download_attach>();
                for (int i = 0; i < fileListArr.Length; i++)
                {
                    string[] fileArr = fileListArr[i].Split('|');
                    if (fileArr.Length == 3)
                    {
                        int    fileSize = Utils.GetFileSize(fileArr[2]);
                        string fileExt  = Utils.GetFileExt(fileArr[2]);
                        int    _point   = int.Parse(pointArr[i]);
                        ls.Add(new Model.download_attach {
                            id = int.Parse(fileArr[0]), title = fileArr[1], file_path = fileArr[2], file_size = fileSize, file_ext = fileExt, point = _point
                        });
                    }
                }
                model.download_attachs = ls;
            }
            model.user_id = WEBUserCurrent.UserID;
            if (bll.Add(model) < 1)
            {
                result = false;
            }
            return(result);
        }
Пример #14
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            bool result = true;

            Model.article_download model = new Model.article_download();
            BLL.article            bll   = new BLL.article();

            model.channel_id      = 9;
            model.title           = txtTitle.Text.Trim();
            model.category_id     = int.Parse(ddlCategoryId.SelectedValue);
            model.link_url        = txtLinkUrl.Text.Trim();
            model.img_url         = txtImgUrl.Text.Trim();
            model.content         = txtContent.Value;
            model.seo_title       = txtSeoTitle.Text.Trim();
            model.seo_keywords    = txtSeoKeywords.Text.Trim();
            model.seo_description = txtSeoDescription.Text.Trim();
            model.sort_id         = int.Parse(txtSortId.Text.Trim());
            model.click           = int.Parse(txtClick.Text.Trim());
            model.digg_good       = int.Parse(txtDiggGood.Text.Trim());
            model.digg_bad        = int.Parse(txtDiggBad.Text.Trim());
            model.is_msg          = 0;
            model.is_red          = 0;
            model.is_lock         = 0;
            if (cblItem.Items[0].Selected == true)
            {
                model.is_msg = 1;
            }
            if (cblItem.Items[1].Selected == true)
            {
                model.is_red = 1;
            }
            if (cblItem.Items[2].Selected == true)
            {
                model.is_lock = 1;
            }
            //儲存附件
            string hidFileList = Request.Params["hidFileName"];

            if (!string.IsNullOrEmpty(hidFileList))
            {
                string[] fileListArr            = hidFileList.Split(',');
                string[] pointArr               = Request.Form.GetValues("txtPoint");
                List <Model.download_attach> ls = new List <Model.download_attach>();
                for (int i = 0; i < fileListArr.Length; i++)
                {
                    string[] fileArr = fileListArr[i].Split('|');
                    if (fileArr.Length == 3)
                    {
                        int    fileSize = Utils.GetFileSize(fileArr[2]);
                        string fileExt  = Utils.GetFileExt(fileArr[2]);
                        int    _point   = int.Parse(pointArr[i]);
                        ls.Add(new Model.download_attach {
                            id = int.Parse(fileArr[0]), title = fileArr[1], file_path = fileArr[2], file_size = fileSize, file_ext = fileExt, point = _point
                        });
                    }
                }
                model.download_attachs = ls;
            }

            if (bll.Add(model) < 1)
            {
                result = false;
            }
            if (!result)
            {
                this.Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('儲存過程中發生錯誤');window.location.href='upFile.aspx'</script>");
                return;
            }
            this.Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('添加成功');window.location.href='upFile.aspx'</script>");
        }