protected void btnok_Click(object sender, EventArgs e)
        {
            Maticsoft.BLL.NewsInfo   newbll   = new Maticsoft.BLL.NewsInfo();
            Maticsoft.Model.NewsInfo newmodel = newbll.GetModel(1);
            if (txtNewsTitle.Text.Trim() == "")
            {
                lblNewsTitle.Text = "请填写新闻标题";
                return;
            }
            newmodel.NewsTitle = txtNewsTitle.Text.Trim();
            lblNewsTitle.Text  = "";
            if (txtKeyword.Text.Trim() == "")
            {
                lblkeyword.Text = "请填写新闻关键字";
                return;
            }
            newmodel.NewsKey = txtKeyword.Text.Trim();
            lblkeyword.Text  = "";

            newmodel.NewsTypeID = int.Parse(drpNewsType.SelectedValue);
            if (txtwrite.Text.Trim() == "")
            {
                lblwrite.Text = "请填写新闻发布人";
                return;
            }
            newmodel.Write       = txtwrite.Text.Trim();
            lblwrite.Text        = "";
            newmodel.Fatime      = Convert.ToDateTime(txtfatime.Text.Trim());
            newmodel.ImageURL    = Image1.ImageUrl;
            newmodel.NewsContent = txtNewContent.Text.Trim();
            newbll.Update(newmodel);
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('信息添加成功!')</script>");
            bind();
        }
Exemple #2
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;
        }
        private void bind()
        {
            Maticsoft.BLL.NewsInfo newbll = new Maticsoft.BLL.NewsInfo();
            int index = int.Parse(Request.QueryString["NewsID"].ToString());

            Maticsoft.Model.NewsInfo newmodel = newbll.GetModel(index);
            txtfatime.Text            = Convert.ToDateTime(newmodel.Fatime.ToString()).ToString("yyyy-MM-dd");
            Image1.ImageUrl           = newmodel.ImageURL;
            txtKeyword.Text           = newmodel.NewsKey;
            txtNewContent.Text        = newmodel.NewsContent;
            txtNewsTitle.Text         = newmodel.NewsTitle;
            txtwrite.Text             = newmodel.Write;
            drpNewsType.SelectedValue = newmodel.NewsTypeID.ToString();
        }
Exemple #4
0
 private void ShowInfo(int NewsID)
 {
     Maticsoft.BLL.NewsInfo   bll   = new Maticsoft.BLL.NewsInfo();
     Maticsoft.Model.NewsInfo model = bll.GetModel(NewsID);
     this.lblNewsID.Text      = model.NewsID.ToString();
     this.txtNewsTitle.Text   = model.NewsTitle;
     this.txtNewsKey.Text     = model.NewsKey;
     this.txtWrite.Text       = model.Write;
     this.txtNewsTypeID.Text  = model.NewsTypeID.ToString();
     this.txtFatime.Text      = model.Fatime.ToString();
     this.txtImageURL.Text    = model.ImageURL;
     this.txtHitNum.Text      = model.HitNum.ToString();
     this.txtNewsContent.Text = model.NewsContent;
 }
Exemple #5
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;
        }
Exemple #6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.NewsInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update NewsInfo set ");
            strSql.Append("NewsTitle=@NewsTitle,");
            strSql.Append("NewsKey=@NewsKey,");
            strSql.Append("Write=@Write,");
            strSql.Append("NewsTypeID=@NewsTypeID,");
            strSql.Append("Fatime=@Fatime,");
            strSql.Append("ImageURL=@ImageURL,");
            strSql.Append("HitNum=@HitNum,");
            strSql.Append("NewsContent=@NewsContent");
            strSql.Append(" where NewsID=@NewsID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@NewsID",      SqlDbType.Int,         4),
                new SqlParameter("@NewsTitle",   SqlDbType.VarChar,   200),
                new SqlParameter("@NewsKey",     SqlDbType.VarChar,   200),
                new SqlParameter("@Write",       SqlDbType.VarChar,   200),
                new SqlParameter("@NewsTypeID",  SqlDbType.Int,         4),
                new SqlParameter("@Fatime",      SqlDbType.DateTime),
                new SqlParameter("@ImageURL",    SqlDbType.Text),
                new SqlParameter("@HitNum",      SqlDbType.Int,         4),
                new SqlParameter("@NewsContent", SqlDbType.Text)
            };
            parameters[0].Value = model.NewsID;
            parameters[1].Value = model.NewsTitle;
            parameters[2].Value = model.NewsKey;
            parameters[3].Value = model.Write;
            parameters[4].Value = model.NewsTypeID;
            parameters[5].Value = model.Fatime;
            parameters[6].Value = model.ImageURL;
            parameters[7].Value = model.HitNum;
            parameters[8].Value = model.NewsContent;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #7
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.NewsInfo GetModel(int NewsID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 NewsID,NewsTitle,NewsKey,Write,NewsTypeID,Fatime,ImageURL,HitNum,NewsContent from NewsInfo ");
            strSql.Append(" where NewsID=@NewsID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@NewsID", SqlDbType.Int, 4)
            };
            parameters[0].Value = NewsID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["NewsID"].ToString() != "")
                {
                    model.NewsID = int.Parse(ds.Tables[0].Rows[0]["NewsID"].ToString());
                }
                model.NewsTitle = ds.Tables[0].Rows[0]["NewsTitle"].ToString();
                model.NewsKey   = ds.Tables[0].Rows[0]["NewsKey"].ToString();
                model.Write     = ds.Tables[0].Rows[0]["Write"].ToString();
                if (ds.Tables[0].Rows[0]["NewsTypeID"].ToString() != "")
                {
                    model.NewsTypeID = int.Parse(ds.Tables[0].Rows[0]["NewsTypeID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Fatime"].ToString() != "")
                {
                    model.Fatime = DateTime.Parse(ds.Tables[0].Rows[0]["Fatime"].ToString());
                }
                model.ImageURL = ds.Tables[0].Rows[0]["ImageURL"].ToString();
                if (ds.Tables[0].Rows[0]["HitNum"].ToString() != "")
                {
                    model.HitNum = int.Parse(ds.Tables[0].Rows[0]["HitNum"].ToString());
                }
                model.NewsContent = ds.Tables[0].Rows[0]["NewsContent"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemple #8
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;
        }
Exemple #9
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.NewsInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into NewsInfo(");
            strSql.Append("NewsTitle,NewsKey,Write,NewsTypeID,Fatime,ImageURL,HitNum,NewsContent)");
            strSql.Append(" values (");
            strSql.Append("@NewsTitle,@NewsKey,@Write,@NewsTypeID,@Fatime,@ImageURL,@HitNum,@NewsContent)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@NewsTitle",   SqlDbType.VarChar,   200),
                new SqlParameter("@NewsKey",     SqlDbType.VarChar,   200),
                new SqlParameter("@Write",       SqlDbType.VarChar,   200),
                new SqlParameter("@NewsTypeID",  SqlDbType.Int,         4),
                new SqlParameter("@Fatime",      SqlDbType.DateTime),
                new SqlParameter("@ImageURL",    SqlDbType.Text),
                new SqlParameter("@HitNum",      SqlDbType.Int,         4),
                new SqlParameter("@NewsContent", SqlDbType.Text)
            };
            parameters[0].Value = model.NewsTitle;
            parameters[1].Value = model.NewsKey;
            parameters[2].Value = model.Write;
            parameters[3].Value = model.NewsTypeID;
            parameters[4].Value = model.Fatime;
            parameters[5].Value = model.ImageURL;
            parameters[6].Value = model.HitNum;
            parameters[7].Value = model.NewsContent;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemple #10
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtNewsTitle.Text.Trim().Length == 0)
            {
                strErr += "NewsTitle不能为空!\\n";
            }
            if (this.txtNewsKey.Text.Trim().Length == 0)
            {
                strErr += "NewsKey不能为空!\\n";
            }
            if (this.txtWrite.Text.Trim().Length == 0)
            {
                strErr += "Write不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtNewsTypeID.Text))
            {
                strErr += "NewsTypeID格式错误!\\n";
            }
            if (!PageValidate.IsDateTime(txtFatime.Text))
            {
                strErr += "Fatime格式错误!\\n";
            }
            if (this.txtImageURL.Text.Trim().Length == 0)
            {
                strErr += "ImageURL不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtHitNum.Text))
            {
                strErr += "HitNum格式错误!\\n";
            }
            if (this.txtNewsContent.Text.Trim().Length == 0)
            {
                strErr += "NewsContent不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      NewsID      = int.Parse(this.lblNewsID.Text);
            string   NewsTitle   = this.txtNewsTitle.Text;
            string   NewsKey     = this.txtNewsKey.Text;
            string   Write       = this.txtWrite.Text;
            int      NewsTypeID  = int.Parse(this.txtNewsTypeID.Text);
            DateTime Fatime      = DateTime.Parse(this.txtFatime.Text);
            string   ImageURL    = this.txtImageURL.Text;
            int      HitNum      = int.Parse(this.txtHitNum.Text);
            string   NewsContent = this.txtNewsContent.Text;


            Maticsoft.Model.NewsInfo model = new Maticsoft.Model.NewsInfo();
            model.NewsID      = NewsID;
            model.NewsTitle   = NewsTitle;
            model.NewsKey     = NewsKey;
            model.Write       = Write;
            model.NewsTypeID  = NewsTypeID;
            model.Fatime      = Fatime;
            model.ImageURL    = ImageURL;
            model.HitNum      = HitNum;
            model.NewsContent = NewsContent;

            Maticsoft.BLL.NewsInfo bll = new Maticsoft.BLL.NewsInfo();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }