コード例 #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public NoName.NetShop.Model.NewsModel GetModel(int NewsId)
        {
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("UP_neNews_GetModel");

            db.AddInParameter(dbCommand, "NewsId", DbType.Int32, NewsId);

            NoName.NetShop.Model.NewsModel model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
コード例 #2
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public NoName.NetShop.Model.NewsModel ReaderBind(IDataReader dataReader)
        {
            NoName.NetShop.Model.NewsModel model = new NoName.NetShop.Model.NewsModel();
            object ojb;

            ojb = dataReader["NewsId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.NewsId = (int)ojb;
            }
            ojb = dataReader["NewsType"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.NewsType = (int)ojb;
            }
            ojb = dataReader["Status"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Status = (int)ojb;
            }
            model.Title         = dataReader["Title"].ToString();
            model.SubTitle      = dataReader["SubTitle"].ToString();
            model.Brief         = dataReader["Brief"].ToString();
            model.Content       = dataReader["Content"].ToString();
            model.SmallImageUrl = dataReader["SmallImageUrl"].ToString();
            model.Author        = dataReader["Author"].ToString();
            model.From          = dataReader["From"].ToString();
            model.VideoUrl      = dataReader["VideoUrl"].ToString();
            model.ImageUrl      = dataReader["ImageUrl"].ToString();
            model.ProductId     = dataReader["ProductId"].ToString();
            ojb = dataReader["InsertTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.InsertTime = (DateTime)ojb;
            }
            ojb = dataReader["ModifyTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ModifyTime = (DateTime)ojb;
            }
            model.Tags = dataReader["Tags"].ToString();
            return(model);
        }
コード例 #3
0
 private void ShowInfo(int NewsId)
 {
     NoName.NetShop.BLL.NewsModelBll bll   = new NoName.NetShop.BLL.NewsModelBll();
     NoName.NetShop.Model.NewsModel  model = bll.GetModel(NewsId);
     this.lblNewsType.Text      = model.NewsType.ToString();
     this.lblStatus.Text        = model.Status.ToString();
     this.lblTitle.Text         = model.Title;
     this.lblSubTitle.Text      = model.SubTitle;
     this.lblBrief.Text         = model.Brief;
     this.lblContent.Text       = model.Content;
     this.lblSmallImageUrl.Text = model.SmallImageUrl;
     this.lblAuthor.Text        = model.Author;
     this.lblFrom.Text          = model.From;
     this.lblVideoUrl.Text      = model.VideoUrl;
     this.lblImageUrl.Text      = model.ImageUrl;
     this.lblProductId.Text     = model.ProductId;
     this.lblInsertTime.Text    = model.InsertTime.ToString();
     this.lblModifyTime.Text    = model.ModifyTime.ToString();
     this.lblTags.Text          = model.Tags;
 }
コード例 #4
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public void Update(NoName.NetShop.Model.NewsModel model)
        {
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("UP_neNews_Update");

            db.AddInParameter(dbCommand, "NewsId", DbType.Int32, model.NewsId);
            db.AddInParameter(dbCommand, "NewsType", DbType.Byte, model.NewsType);
            db.AddInParameter(dbCommand, "Status", DbType.Byte, model.Status);
            db.AddInParameter(dbCommand, "Title", DbType.AnsiString, model.Title);
            db.AddInParameter(dbCommand, "SubTitle", DbType.AnsiString, model.SubTitle);
            db.AddInParameter(dbCommand, "Brief", DbType.AnsiString, model.Brief);
            db.AddInParameter(dbCommand, "Content", DbType.String, model.Content);
            db.AddInParameter(dbCommand, "SmallImageUrl", DbType.AnsiString, model.SmallImageUrl);
            db.AddInParameter(dbCommand, "Author", DbType.AnsiString, model.Author);
            db.AddInParameter(dbCommand, "From", DbType.AnsiString, model.From);
            db.AddInParameter(dbCommand, "VideoUrl", DbType.AnsiString, model.VideoUrl);
            db.AddInParameter(dbCommand, "ImageUrl", DbType.AnsiString, model.ImageUrl);
            db.AddInParameter(dbCommand, "ProductId", DbType.AnsiString, model.ProductId);
            db.AddInParameter(dbCommand, "InsertTime", DbType.DateTime, model.InsertTime);
            db.AddInParameter(dbCommand, "ModifyTime", DbType.DateTime, model.ModifyTime);
            db.AddInParameter(dbCommand, "Tags", DbType.AnsiString, model.Tags);
            db.ExecuteNonQuery(dbCommand);
        }
コード例 #5
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtNewsType.Text))
            {
                strErr += "NewsType不是数字!\\n";
            }
            if (!PageValidate.IsNumber(txtStatus.Text))
            {
                strErr += "Status不是数字!\\n";
            }
            if (this.txtTitle.Text == "")
            {
                strErr += "Title不能为空!\\n";
            }
            if (this.txtSubTitle.Text == "")
            {
                strErr += "SubTitle不能为空!\\n";
            }
            if (this.txtBrief.Text == "")
            {
                strErr += "Brief不能为空!\\n";
            }
            if (this.txtContent.Text == "")
            {
                strErr += "Content不能为空!\\n";
            }
            if (this.txtSmallImageUrl.Text == "")
            {
                strErr += "SmallImageUrl不能为空!\\n";
            }
            if (this.txtAuthor.Text == "")
            {
                strErr += "Author不能为空!\\n";
            }
            if (this.txtFrom.Text == "")
            {
                strErr += "From不能为空!\\n";
            }
            if (this.txtVideoUrl.Text == "")
            {
                strErr += "VideoUrl不能为空!\\n";
            }
            if (this.txtImageUrl.Text == "")
            {
                strErr += "ImageUrl不能为空!\\n";
            }
            if (this.txtProductId.Text == "")
            {
                strErr += "ProductId不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtInsertTime.Text))
            {
                strErr += "InsertTime不是时间格式!\\n";
            }
            if (!PageValidate.IsDateTime(txtModifyTime.Text))
            {
                strErr += "ModifyTime不是时间格式!\\n";
            }
            if (this.txtTags.Text == "")
            {
                strErr += "Tags不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      NewsType      = int.Parse(this.txtNewsType.Text);
            int      Status        = int.Parse(this.txtStatus.Text);
            string   Title         = this.txtTitle.Text;
            string   SubTitle      = this.txtSubTitle.Text;
            string   Brief         = this.txtBrief.Text;
            string   Content       = this.txtContent.Text;
            string   SmallImageUrl = this.txtSmallImageUrl.Text;
            string   Author        = this.txtAuthor.Text;
            string   From          = this.txtFrom.Text;
            string   VideoUrl      = this.txtVideoUrl.Text;
            string   ImageUrl      = this.txtImageUrl.Text;
            string   ProductId     = this.txtProductId.Text;
            DateTime InsertTime    = DateTime.Parse(this.txtInsertTime.Text);
            DateTime ModifyTime    = DateTime.Parse(this.txtModifyTime.Text);
            string   Tags          = this.txtTags.Text;


            NoName.NetShop.Model.NewsModel model = new NoName.NetShop.Model.NewsModel();
            model.NewsType      = NewsType;
            model.Status        = Status;
            model.Title         = Title;
            model.SubTitle      = SubTitle;
            model.Brief         = Brief;
            model.Content       = Content;
            model.SmallImageUrl = SmallImageUrl;
            model.Author        = Author;
            model.From          = From;
            model.VideoUrl      = VideoUrl;
            model.ImageUrl      = ImageUrl;
            model.ProductId     = ProductId;
            model.InsertTime    = InsertTime;
            model.ModifyTime    = ModifyTime;
            model.Tags          = Tags;

            NoName.NetShop.BLL.NewsModelBll bll = new NoName.NetShop.BLL.NewsModelBll();
            bll.Update(model);
        }
コード例 #6
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string strErr="";
            if(!PageValidate.IsNumber(txtNewsType.Text))
            {
            strErr+="NewsType�������֣�\\n";
            }
            if(!PageValidate.IsNumber(txtStatus.Text))
            {
            strErr+="Status�������֣�\\n";
            }
            if(this.txtTitle.Text =="")
            {
            strErr+="Title����Ϊ�գ�\\n";
            }
            if(this.txtSubTitle.Text =="")
            {
            strErr+="SubTitle����Ϊ�գ�\\n";
            }
            if(this.txtBrief.Text =="")
            {
            strErr+="Brief����Ϊ�գ�\\n";
            }
            if(this.txtContent.Text =="")
            {
            strErr+="Content����Ϊ�գ�\\n";
            }
            if(this.txtSmallImageUrl.Text =="")
            {
            strErr+="SmallImageUrl����Ϊ�գ�\\n";
            }
            if(this.txtAuthor.Text =="")
            {
            strErr+="Author����Ϊ�գ�\\n";
            }
            if(this.txtFrom.Text =="")
            {
            strErr+="From����Ϊ�գ�\\n";
            }
            if(this.txtVideoUrl.Text =="")
            {
            strErr+="VideoUrl����Ϊ�գ�\\n";
            }
            if(this.txtImageUrl.Text =="")
            {
            strErr+="ImageUrl����Ϊ�գ�\\n";
            }
            if(this.txtProductId.Text =="")
            {
            strErr+="ProductId����Ϊ�գ�\\n";
            }
            if(!PageValidate.IsDateTime(txtInsertTime.Text))
            {
            strErr+="InsertTime����ʱ���ʽ��\\n";
            }
            if(!PageValidate.IsDateTime(txtModifyTime.Text))
            {
            strErr+="ModifyTime����ʱ���ʽ��\\n";
            }
            if(this.txtTags.Text =="")
            {
            strErr+="Tags����Ϊ�գ�\\n";
            }

            if(strErr!="")
            {
            MessageBox.Show(this,strErr);
            return;
            }
            int NewsType=int.Parse(this.txtNewsType.Text);
            int Status=int.Parse(this.txtStatus.Text);
            string Title=this.txtTitle.Text;
            string SubTitle=this.txtSubTitle.Text;
            string Brief=this.txtBrief.Text;
            string Content=this.txtContent.Text;
            string SmallImageUrl=this.txtSmallImageUrl.Text;
            string Author=this.txtAuthor.Text;
            string From=this.txtFrom.Text;
            string VideoUrl=this.txtVideoUrl.Text;
            string ImageUrl=this.txtImageUrl.Text;
            string ProductId=this.txtProductId.Text;
            DateTime InsertTime=DateTime.Parse(this.txtInsertTime.Text);
            DateTime ModifyTime=DateTime.Parse(this.txtModifyTime.Text);
            string Tags=this.txtTags.Text;

            NoName.NetShop.Model.NewsModel model=new NoName.NetShop.Model.NewsModel();
            model.NewsType=NewsType;
            model.Status=Status;
            model.Title=Title;
            model.SubTitle=SubTitle;
            model.Brief=Brief;
            model.Content=Content;
            model.SmallImageUrl=SmallImageUrl;
            model.Author=Author;
            model.From=From;
            model.VideoUrl=VideoUrl;
            model.ImageUrl=ImageUrl;
            model.ProductId=ProductId;
            model.InsertTime=InsertTime;
            model.ModifyTime=ModifyTime;
            model.Tags=Tags;

            NoName.NetShop.BLL.NewsModelBll bll=new NoName.NetShop.BLL.NewsModelBll();
            bll.Update(model);
        }
コード例 #7
0
 /// <summary>
 /// ����ʵ�������
 /// </summary>
 public NoName.NetShop.Model.NewsModel ReaderBind(IDataReader dataReader)
 {
     NoName.NetShop.Model.NewsModel model=new NoName.NetShop.Model.NewsModel();
     object ojb;
     ojb = dataReader["NewsId"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.NewsId=(int)ojb;
     }
     ojb = dataReader["NewsType"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.NewsType=(int)ojb;
     }
     ojb = dataReader["Status"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.Status=(int)ojb;
     }
     model.Title=dataReader["Title"].ToString();
     model.SubTitle=dataReader["SubTitle"].ToString();
     model.Brief=dataReader["Brief"].ToString();
     model.Content=dataReader["Content"].ToString();
     model.SmallImageUrl=dataReader["SmallImageUrl"].ToString();
     model.Author=dataReader["Author"].ToString();
     model.From=dataReader["From"].ToString();
     model.VideoUrl=dataReader["VideoUrl"].ToString();
     model.ImageUrl=dataReader["ImageUrl"].ToString();
     model.ProductId=dataReader["ProductId"].ToString();
     ojb = dataReader["InsertTime"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.InsertTime=(DateTime)ojb;
     }
     ojb = dataReader["ModifyTime"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.ModifyTime=(DateTime)ojb;
     }
     model.Tags=dataReader["Tags"].ToString();
     return model;
 }