Exemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Leadin.Model.Article model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_Article(");
            strSql.Append("Num,Title,SubTitle,TypeId,StrKey,Describe,Abstract,Introduction,Author,SourceInfo,ImgUrl,Content,StateInfo,IsHot,IsIndex,IsRec,AddTime)");
            strSql.Append(" values (");
            strSql.Append("@Num,@Title,@SubTitle,@TypeId,@StrKey,@Describe,@Abstract,@Introduction,@Author,@SourceInfo,@ImgUrl,@Content,@StateInfo,@IsHot,@IsIndex,@IsRec,@AddTime)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Num",          SqlDbType.NVarChar, 100),
                new SqlParameter("@Title",        SqlDbType.NVarChar, 200),
                new SqlParameter("@SubTitle",     SqlDbType.NVarChar, 200),
                new SqlParameter("@TypeId",       SqlDbType.Int,        4),
                new SqlParameter("@StrKey",       SqlDbType.NVarChar, 300),
                new SqlParameter("@Describe",     SqlDbType.NVarChar, 500),
                new SqlParameter("@Abstract",     SqlDbType.NVarChar, 500),
                new SqlParameter("@Introduction", SqlDbType.NVarChar, 500),
                new SqlParameter("@Author",       SqlDbType.NVarChar, 100),
                new SqlParameter("@SourceInfo",   SqlDbType.NVarChar, 100),
                new SqlParameter("@ImgUrl",       SqlDbType.NVarChar, 200),
                new SqlParameter("@Content",      SqlDbType.NText),
                new SqlParameter("@StateInfo",    SqlDbType.Int,        4),
                new SqlParameter("@IsHot",        SqlDbType.Int,        4),
                new SqlParameter("@IsIndex",      SqlDbType.Int,        4),
                new SqlParameter("@IsRec",        SqlDbType.Int,        4),
                new SqlParameter("@AddTime",      SqlDbType.DateTime)
            };
            parameters[0].Value  = model.Num;
            parameters[1].Value  = model.Title;
            parameters[2].Value  = model.SubTitle;
            parameters[3].Value  = model.TypeId;
            parameters[4].Value  = model.StrKey;
            parameters[5].Value  = model.Describe;
            parameters[6].Value  = model.Abstract;
            parameters[7].Value  = model.Introduction;
            parameters[8].Value  = model.Author;
            parameters[9].Value  = model.SourceInfo;
            parameters[10].Value = model.ImgUrl;
            parameters[11].Value = model.Content;
            parameters[12].Value = model.StateInfo;
            parameters[13].Value = model.IsHot;
            parameters[14].Value = model.IsIndex;
            parameters[15].Value = model.IsRec;
            parameters[16].Value = model.AddTime;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 提交
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOk_Click(object sender, EventArgs e)
        {
            Leadin.Model.Article model = new Leadin.Model.Article();


            bool IsEdit = string.IsNullOrEmpty(Request.Params["id"]);

            if (!IsEdit)
            {
                model = bll.GetModel(int.Parse(Request.Params["id"]));
            }
            model.Abstract     = Leadin.Common.Utils.DropHTML(txtContent.Text);
            model.Author       = txtAuthor.Text;
            model.Content      = txtContent.Text;
            model.Describe     = txtDescribe.Text;
            model.ImgUrl       = txtfileico1.Text;
            model.Introduction = txtIntroduction.Text;
            model.IsHot        = ckHot.Checked ? 1 : 0;
            model.IsIndex      = ckIndex.Checked ? 1 : 0;
            model.IsRec        = ckRec.Checked ? 1 : 0;
            model.SourceInfo   = txtSource.Text;
            model.StateInfo    = ckState.Checked ? 1 : 0;
            model.StrKey       = txtKey.Text;
            model.SubTitle     = txtSubTitle.Text;
            model.Title        = txtTitle.Text;
            model.TypeId       = int.Parse(ddlType.SelectedValue);


            if (IsEdit)
            {
                model.AddTime = DateTime.Now;
                model.Num     = SetNumId("AID");

                if (bll.Add(model) > 0)
                {
                    JsMessage("success", "资讯发布成功!", 1000, "List.aspx");
                }
                else
                {
                    JsMessage("error", "资讯发布失败,请检查您的输入!", 1000, "back");
                }
            }
            else
            {
                if (bll.Update(model))
                {
                    JsMessage("success", "资讯信息编辑成功!", 1000, "List.aspx");
                }
                else
                {
                    JsMessage("error", "资讯信息编辑失败,请检查您的输入!", 1000, "back");
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 绑定文章详细信息
 /// </summary>
 /// <param name="id"></param>
 void BindDetail(int id)
 {
     Leadin.Model.Article model = bll.GetModel(id);
     txtAuthor.Text        = model.Author;
     txtContent.Text       = model.Content;
     txtDescribe.Text      = model.Describe;
     txtfileico1.Text      = model.ImgUrl;
     txtKey.Text           = model.StrKey;
     txtSubTitle.Text      = model.SubTitle;
     txtTitle.Text         = model.Title;
     ddlType.SelectedValue = model.TypeId.ToString();
     ckHot.Checked         = model.IsHot == 1 ? true : false;
     ckIndex.Checked       = model.IsIndex == 1 ? true : false;
     ckRec.Checked         = model.IsRec == 1 ? true : false;
     ckState.Checked       = model.StateInfo == 1 ? true : false;
 }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Leadin.Model.Article GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,Num,Title,SubTitle,TypeId,StrKey,Describe,Abstract,Introduction,Author,SourceInfo,ImgUrl,Content,StateInfo,IsHot,IsIndex,IsRec,AddTime from tb_Article ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 属性改变
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void repList_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "lbtnState")//修改状态
            {
                HiddenField hidid = e.Item.FindControl("hidid") as HiddenField;

                Leadin.Model.Article model = bll.GetModel(int.Parse(hidid.Value));

                if (model.StateInfo == 1)
                {
                    model.StateInfo = 0;
                }
                else
                {
                    model.StateInfo = 1;
                }

                bll.Update(model);
            }
            if (e.CommandName == "lbtnIndex")//修改是否首页显示
            {
                HiddenField hidid = e.Item.FindControl("hidid") as HiddenField;

                Leadin.Model.Article model = bll.GetModel(int.Parse(hidid.Value));

                if (model.IsIndex == 1)
                {
                    model.IsIndex = 0;
                }
                else
                {
                    model.IsIndex = 1;
                }

                bll.Update(model);
            }
            if (e.CommandName == "lbtnhot")//修改是否热门显示
            {
                HiddenField hidid = e.Item.FindControl("hidid") as HiddenField;

                Leadin.Model.Article model = bll.GetModel(int.Parse(hidid.Value));

                if (model.IsHot == 1)
                {
                    model.IsHot = 0;
                }
                else
                {
                    model.IsHot = 1;
                }

                bll.Update(model);
            }
            if (e.CommandName == "lbtnRec")//修改是否推荐显示
            {
                HiddenField hidid = e.Item.FindControl("hidid") as HiddenField;

                Leadin.Model.Article model = bll.GetModel(int.Parse(hidid.Value));

                if (model.IsRec == 1)
                {
                    model.IsRec = 0;
                }
                else
                {
                    model.IsRec = 1;
                }

                bll.Update(model);
            }

            BindList();
        }
Exemplo n.º 6
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Leadin.Model.Article DataRowToModel(DataRow row)
 {
     Leadin.Model.Article model = new Leadin.Model.Article();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["Num"] != null)
         {
             model.Num = row["Num"].ToString();
         }
         if (row["Title"] != null)
         {
             model.Title = row["Title"].ToString();
         }
         if (row["SubTitle"] != null)
         {
             model.SubTitle = row["SubTitle"].ToString();
         }
         if (row["TypeId"] != null && row["TypeId"].ToString() != "")
         {
             model.TypeId = int.Parse(row["TypeId"].ToString());
         }
         if (row["StrKey"] != null)
         {
             model.StrKey = row["StrKey"].ToString();
         }
         if (row["Describe"] != null)
         {
             model.Describe = row["Describe"].ToString();
         }
         if (row["Abstract"] != null)
         {
             model.Abstract = row["Abstract"].ToString();
         }
         if (row["Introduction"] != null)
         {
             model.Introduction = row["Introduction"].ToString();
         }
         if (row["Author"] != null)
         {
             model.Author = row["Author"].ToString();
         }
         if (row["SourceInfo"] != null)
         {
             model.SourceInfo = row["SourceInfo"].ToString();
         }
         if (row["ImgUrl"] != null)
         {
             model.ImgUrl = row["ImgUrl"].ToString();
         }
         if (row["Content"] != null)
         {
             model.Content = row["Content"].ToString();
         }
         if (row["StateInfo"] != null && row["StateInfo"].ToString() != "")
         {
             model.StateInfo = int.Parse(row["StateInfo"].ToString());
         }
         if (row["IsHot"] != null && row["IsHot"].ToString() != "")
         {
             model.IsHot = int.Parse(row["IsHot"].ToString());
         }
         if (row["IsIndex"] != null && row["IsIndex"].ToString() != "")
         {
             model.IsIndex = int.Parse(row["IsIndex"].ToString());
         }
         if (row["IsRec"] != null && row["IsRec"].ToString() != "")
         {
             model.IsRec = int.Parse(row["IsRec"].ToString());
         }
         if (row["AddTime"] != null && row["AddTime"].ToString() != "")
         {
             model.AddTime = DateTime.Parse(row["AddTime"].ToString());
         }
     }
     return(model);
 }
Exemplo n.º 7
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Leadin.Model.Article model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_Article set ");
            strSql.Append("Num=@Num,");
            strSql.Append("Title=@Title,");
            strSql.Append("SubTitle=@SubTitle,");
            strSql.Append("TypeId=@TypeId,");
            strSql.Append("StrKey=@StrKey,");
            strSql.Append("Describe=@Describe,");
            strSql.Append("Abstract=@Abstract,");
            strSql.Append("Introduction=@Introduction,");
            strSql.Append("Author=@Author,");
            strSql.Append("SourceInfo=@SourceInfo,");
            strSql.Append("ImgUrl=@ImgUrl,");
            strSql.Append("Content=@Content,");
            strSql.Append("StateInfo=@StateInfo,");
            strSql.Append("IsHot=@IsHot,");
            strSql.Append("IsIndex=@IsIndex,");
            strSql.Append("IsRec=@IsRec,");
            strSql.Append("AddTime=@AddTime");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Num",          SqlDbType.NVarChar,  100),
                new SqlParameter("@Title",        SqlDbType.NVarChar,  200),
                new SqlParameter("@SubTitle",     SqlDbType.NVarChar,  200),
                new SqlParameter("@TypeId",       SqlDbType.Int,         4),
                new SqlParameter("@StrKey",       SqlDbType.NVarChar,  300),
                new SqlParameter("@Describe",     SqlDbType.NVarChar,  500),
                new SqlParameter("@Abstract",     SqlDbType.NVarChar,  500),
                new SqlParameter("@Introduction", SqlDbType.NVarChar,  500),
                new SqlParameter("@Author",       SqlDbType.NVarChar,  100),
                new SqlParameter("@SourceInfo",   SqlDbType.NVarChar,  100),
                new SqlParameter("@ImgUrl",       SqlDbType.NVarChar,  200),
                new SqlParameter("@Content",      SqlDbType.NText),
                new SqlParameter("@StateInfo",    SqlDbType.Int,         4),
                new SqlParameter("@IsHot",        SqlDbType.Int,         4),
                new SqlParameter("@IsIndex",      SqlDbType.Int,         4),
                new SqlParameter("@IsRec",        SqlDbType.Int,         4),
                new SqlParameter("@AddTime",      SqlDbType.DateTime),
                new SqlParameter("@Id",           SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.Num;
            parameters[1].Value  = model.Title;
            parameters[2].Value  = model.SubTitle;
            parameters[3].Value  = model.TypeId;
            parameters[4].Value  = model.StrKey;
            parameters[5].Value  = model.Describe;
            parameters[6].Value  = model.Abstract;
            parameters[7].Value  = model.Introduction;
            parameters[8].Value  = model.Author;
            parameters[9].Value  = model.SourceInfo;
            parameters[10].Value = model.ImgUrl;
            parameters[11].Value = model.Content;
            parameters[12].Value = model.StateInfo;
            parameters[13].Value = model.IsHot;
            parameters[14].Value = model.IsIndex;
            parameters[15].Value = model.IsRec;
            parameters[16].Value = model.AddTime;
            parameters[17].Value = model.Id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }