Beispiel #1
0
        /// <summary>
        ///  增加一条数据
        /// </summary>
        public int Add(tbNews model)
        {
            SqlParameter[] parameters = {
                    new SqlParameter("@NewsTitle", SqlDbType.NVarChar,20),
                    new SqlParameter("@NewsContent", SqlDbType.Text),
                    new SqlParameter("@TypeID", SqlDbType.Int,4),
                    new SqlParameter("@OldUrl", SqlDbType.NVarChar,100),
                    new SqlParameter("@Author", SqlDbType.NVarChar,20),
                    new SqlParameter("@KeyWords", SqlDbType.NVarChar,200),
                    new SqlParameter("@Metades", SqlDbType.NVarChar,200),
                    new SqlParameter("@Review", SqlDbType.NVarChar,200),
                    new SqlParameter("@ClickNum", SqlDbType.Int,4),
                    new SqlParameter("@ImgUrl",SqlDbType.NVarChar,200)
                   };

              parameters[0].Value = model.NewsTitle;
              parameters[1].Value = model.NewsContent;
              parameters[2].Value = model.TypeID;
              parameters[3].Value = model.OldUrl;
              parameters[4].Value = model.Author;
              parameters[5].Value = model.KeyWords;
              parameters[6].Value = model.Metades;
              parameters[7].Value = model.Review;
              parameters[8].Value = model.ClickNum;
              parameters[9].Value = model.ImgUrl;

            return   db.ExcuteCommandReturnInt("tbNews_ADD", CommandType.StoredProcedure, parameters);
        }
Beispiel #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string img =DateTime.Now.ToString("yyyyMMddhhmmss")+fpImg.FileName;
            tbNews news = new tbNews()
            {
                Author = this.txtAuthor.Text,
                ClickNum = int.Parse(this.txtClick.Text),
                KeyWords = this.txtKeyword.Text,
                Metades = this.txtZhaiyao.Text,
                OldUrl = this.txtForm.Text,
                NewsContent = this.FCKeditor1.Value,
                NewsTitle = this.txtTitle.Text,
                Review = this.txtDaodu.Text,
                TypeID = int.Parse(this.ddlClassId.SelectedValue),
                ImgUrl = img
            };

              int count=  newbll.Add(news);
              if (count != 0)
              {
              //上传图片
              string path=Server.MapPath(@"\Admin\FileImg\NewsImg\");
              if (MyComm.FileUpLoad(fpImg, path, img) == "false")
              {
                  ClientScript.RegisterStartupScript(this.GetType(), "test", "alert('文件上传失败')", true);
              }

              }
        }