Example #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.NewsTypeInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into NewsTypeInfo(");
            strSql.Append("NewsTypeTitle)");
            strSql.Append(" values (");
            strSql.Append("@NewsTypeTitle)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@NewsTypeTitle", SqlDbType.VarChar, 200)
            };
            parameters[0].Value = model.NewsTypeTitle;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Example #2
0
        protected void datanewsquan_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            Maticsoft.BLL.NewsInfo newbll = new Maticsoft.BLL.NewsInfo();
            int index = int.Parse(datanewsquan.DataKeys[e.Item.ItemIndex].ToString());
            //DataSet bllds = newbll.GetList("NewsTypeID="+index+"");
            int pageSize = 5; //每页大小
            int page     = 1; //当前第几页
            int recordCount;  //总共有多少条数据

            if (Request.QueryString["page"] != null)
            {
                if (Request.QueryString["page"].ToString() != "")
                {
                    page = int.Parse(Request.QueryString["page"].ToString());
                }
            }
            recordCount = newbll.GetNewCount("NewsTypeID=" + index + "");
            int pageCount = recordCount / pageSize + 1;//共有多少页

            if (recordCount % pageSize == 0)
            {
                pageCount--;
            }
            DataSet  bllds  = newbll.GeNewsList(pageSize * (page - 1), pageSize, "NewsTypeID=" + index + "");
            DataList dlNews = e.Item.FindControl("datanewsfen") as DataList;

            dlNews.DataSource = bllds;
            dlNews.DataBind();
            Maticsoft.BLL.NewsTypeInfo   typebll   = new Maticsoft.BLL.NewsTypeInfo();
            Maticsoft.Model.NewsTypeInfo typemodel = typebll.GetModel(int.Parse(this.datanewsquan.DataKeys[e.Item.ItemIndex].ToString()));
            Label lbltype = e.Item.FindControl("lbltype") as Label;

            lbltype.Text = typemodel.NewsTypeTitle;
            Label lblpage = e.Item.FindControl("lblpage") as Label;
        }
Example #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.NewsTypeInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update NewsTypeInfo set ");
            strSql.Append("NewsTypeTitle=@NewsTypeTitle");
            strSql.Append(" where NewsTypeID=@NewsTypeID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@NewsTypeID",    SqlDbType.Int,     4),
                new SqlParameter("@NewsTypeTitle", SqlDbType.VarChar, 200)
            };
            parameters[0].Value = model.NewsTypeID;
            parameters[1].Value = model.NewsTypeTitle;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #4
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtNewsTypeTitle.Text.Trim().Length == 0)
            {
                strErr += "NewsTypeTitle不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int    NewsTypeID    = int.Parse(this.lblNewsTypeID.Text);
            string NewsTypeTitle = this.txtNewsTypeTitle.Text;


            Maticsoft.Model.NewsTypeInfo model = new Maticsoft.Model.NewsTypeInfo();
            model.NewsTypeID    = NewsTypeID;
            model.NewsTypeTitle = NewsTypeTitle;

            Maticsoft.BLL.NewsTypeInfo bll = new Maticsoft.BLL.NewsTypeInfo();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Example #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.NewsTypeInfo GetModel(int NewsTypeID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 NewsTypeID,NewsTypeTitle from NewsTypeInfo ");
            strSql.Append(" where NewsTypeID=@NewsTypeID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@NewsTypeID", SqlDbType.Int, 4)
            };
            parameters[0].Value = NewsTypeID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["NewsTypeID"].ToString() != "")
                {
                    model.NewsTypeID = int.Parse(ds.Tables[0].Rows[0]["NewsTypeID"].ToString());
                }
                model.NewsTypeTitle = ds.Tables[0].Rows[0]["NewsTypeTitle"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
Example #6
0
 private void ShowInfo(int NewsTypeID)
 {
     Maticsoft.BLL.NewsTypeInfo   bll   = new Maticsoft.BLL.NewsTypeInfo();
     Maticsoft.Model.NewsTypeInfo model = bll.GetModel(NewsTypeID);
     this.lblNewsTypeID.Text    = model.NewsTypeID.ToString();
     this.txtNewsTypeTitle.Text = model.NewsTypeTitle;
 }
Example #7
0
        protected void datamess_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            int index = int.Parse(datamess.DataKeys[e.Item.ItemIndex].ToString());

            Maticsoft.BLL.NewsInfo   newbll   = new Maticsoft.BLL.NewsInfo();
            Maticsoft.Model.NewsInfo newmodel = newbll.GetModel(index);
            int typeid = int.Parse(newmodel.NewsTypeID.ToString());

            Maticsoft.BLL.NewsTypeInfo   typebll   = new Maticsoft.BLL.NewsTypeInfo();
            Maticsoft.Model.NewsTypeInfo typemodel = typebll.GetModel(typeid);
            ((Label)e.Item.FindControl("lbltype")).Text = typemodel.NewsTypeTitle;
        }
Example #8
0
 protected void btntype_Click(object sender, EventArgs e)
 {
     if (txtaddtype.Text.Trim() == "")
     {
         lbladdtype.Text = "请填写新闻类型";
         return;
     }
     Maticsoft.BLL.NewsTypeInfo   typebll   = new Maticsoft.BLL.NewsTypeInfo();
     Maticsoft.Model.NewsTypeInfo typemodel = new Maticsoft.Model.NewsTypeInfo();
     typemodel.NewsTypeTitle = txtaddtype.Text.Trim();
     typebll.Add(typemodel);
     Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<SCRIPT>alert('信息提交成功)</SCRIPT>");
 }
Example #9
0
 protected void btnNews_Click(object sender, EventArgs e)
 {
     Maticsoft.BLL.NewsTypeInfo   newsbll  = new Maticsoft.BLL.NewsTypeInfo();
     Maticsoft.Model.NewsTypeInfo newmodel = new Maticsoft.Model.NewsTypeInfo();
     if (txtNewsInfo.Text.Trim() == "")
     {
         Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请将填写完整!')</script>");
         return;
     }
     newmodel.NewsTypeTitle = txtNewsInfo.Text.Trim();
     newsbll.Add(newmodel);
     Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('信息添加成功!')</script>");
     txtNewsInfo.Text = "";
 }
Example #10
0
        private void bind(int newsid)
        {
            Maticsoft.BLL.NewsInfo   newbll   = new Maticsoft.BLL.NewsInfo();
            Maticsoft.Model.NewsInfo newmodel = newbll.GetModel(newsid);
            int typeid = int.Parse(newmodel.NewsTypeID.ToString());

            Maticsoft.BLL.NewsTypeInfo   typebll   = new Maticsoft.BLL.NewsTypeInfo();
            Maticsoft.Model.NewsTypeInfo typemodel = typebll.GetModel(typeid);
            lblFatime.Text         = Convert.ToDateTime(newmodel.Fatime.ToString()).ToString("yyyy-MM-dd");
            lblNewsContent.Text    = newmodel.NewsContent;
            lblNewsTitle.Text      = newmodel.NewsTitle;
            lblNewsTypeTitle.Text  = typemodel.NewsTypeTitle;
            lblNewsTypeTitle1.Text = typemodel.NewsTypeTitle;
            lblWrite.Text          = newmodel.Write;
            imgnews.ImageUrl       = newmodel.ImageURL;
        }
Example #11
0
        private void bind()
        {
            Maticsoft.BLL.NewsInfo newsbll = new Maticsoft.BLL.NewsInfo();
            int index = int.Parse(Request.QueryString["NewsID"].ToString());

            Maticsoft.Model.NewsInfo   newmodel = newsbll.GetModel(index);
            Maticsoft.BLL.NewsTypeInfo typebll  = new Maticsoft.BLL.NewsTypeInfo();
            int typeid = int.Parse(newmodel.NewsTypeID.ToString());

            Maticsoft.Model.NewsTypeInfo typemodel = typebll.GetModel(typeid);
            lblkey.Text       = newmodel.NewsKey;
            lblstarttime.Text = Convert.ToDateTime(newmodel.Fatime.ToString()).ToString("yyyy-MM-dd");
            lbltitle.Text     = newmodel.NewsTitle;
            lbltype.Text      = typemodel.NewsTypeTitle;
            lblwrite.Text     = newmodel.Write;
            Image1.ImageUrl   = newmodel.ImageURL;
            txtcontent.Text   = newmodel.NewsContent;
        }
Example #12
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtNewsTypeTitle.Text.Trim().Length == 0)
            {
                strErr += "NewsTypeTitle不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string NewsTypeTitle = this.txtNewsTypeTitle.Text;

            Maticsoft.Model.NewsTypeInfo model = new Maticsoft.Model.NewsTypeInfo();
            model.NewsTypeTitle = NewsTypeTitle;

            Maticsoft.BLL.NewsTypeInfo bll = new Maticsoft.BLL.NewsTypeInfo();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }