Esempio n. 1
0
 private void ShowInfo(int QuestionId)
 {
     NoName.NetShop.BLL.QuestionModelBll bll   = new NoName.NetShop.BLL.QuestionModelBll();
     NoName.NetShop.Model.QuestionModel  model = bll.GetModel(QuestionId);
     this.lblUserId.Text         = model.UserId.ToString();
     this.lblContentType.Text    = model.ContentType.ToString();
     this.lblContentId.Text      = model.ContentId;
     this.lblTitle.Text          = model.Title;
     this.lblContent.Text        = model.Content;
     this.lblBrief.Text          = model.Brief;
     this.lblInsertTime.Text     = model.InsertTime.ToString();
     this.lblLastAnswerTime.Text = model.LastAnswerTime.ToString();
     this.lblLastAnswerId.Text   = model.LastAnswerId;
     this.lblAnswerNum.Text      = model.AnswerNum.ToString();
 }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public NoName.NetShop.Model.QuestionModel GetModel(int QuestionId)
        {
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("UP_qaQuestion_GetModel");

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

            NoName.NetShop.Model.QuestionModel model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public void Update(NoName.NetShop.Model.QuestionModel model)
        {
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("UP_qaQuestion_Update");

            db.AddInParameter(dbCommand, "QuestionId", DbType.Int32, model.QuestionId);
            db.AddInParameter(dbCommand, "UserId", DbType.Int32, model.UserId);
            db.AddInParameter(dbCommand, "ContentType", DbType.Byte, model.ContentType);
            db.AddInParameter(dbCommand, "ContentId", DbType.AnsiString, model.ContentId);
            db.AddInParameter(dbCommand, "Title", DbType.AnsiString, model.Title);
            db.AddInParameter(dbCommand, "Content", DbType.AnsiString, model.Content);
            db.AddInParameter(dbCommand, "Brief", DbType.AnsiString, model.Brief);
            db.AddInParameter(dbCommand, "InsertTime", DbType.DateTime, model.InsertTime);
            db.AddInParameter(dbCommand, "LastAnswerTime", DbType.DateTime, model.LastAnswerTime);
            db.AddInParameter(dbCommand, "LastAnswerId", DbType.AnsiString, model.LastAnswerId);
            db.AddInParameter(dbCommand, "AnswerNum", DbType.Int32, model.AnswerNum);
            db.ExecuteNonQuery(dbCommand);
        }
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public NoName.NetShop.Model.QuestionModel ReaderBind(IDataReader dataReader)
        {
            NoName.NetShop.Model.QuestionModel model = new NoName.NetShop.Model.QuestionModel();
            object ojb;

            ojb = dataReader["QuestionId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.QuestionId = (int)ojb;
            }
            ojb = dataReader["UserId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.UserId = (int)ojb;
            }
            ojb = dataReader["ContentType"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ContentType = (int)ojb;
            }
            model.ContentId = dataReader["ContentId"].ToString();
            model.Title     = dataReader["Title"].ToString();
            model.Content   = dataReader["Content"].ToString();
            model.Brief     = dataReader["Brief"].ToString();
            ojb             = dataReader["InsertTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.InsertTime = (DateTime)ojb;
            }
            ojb = dataReader["LastAnswerTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.LastAnswerTime = (DateTime)ojb;
            }
            model.LastAnswerId = dataReader["LastAnswerId"].ToString();
            ojb = dataReader["AnswerNum"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.AnswerNum = (int)ojb;
            }
            return(model);
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string strErr="";
            if(!PageValidate.IsNumber(txtUserId.Text))
            {
            strErr+="UserId�������֣�\\n";
            }
            if(!PageValidate.IsNumber(txtContentType.Text))
            {
            strErr+="ContentType�������֣�\\n";
            }
            if(this.txtContentId.Text =="")
            {
            strErr+="ContentId����Ϊ�գ�\\n";
            }
            if(this.txtTitle.Text =="")
            {
            strErr+="Title����Ϊ�գ�\\n";
            }
            if(this.txtContent.Text =="")
            {
            strErr+="Content����Ϊ�գ�\\n";
            }
            if(this.txtBrief.Text =="")
            {
            strErr+="Brief����Ϊ�գ�\\n";
            }
            if(!PageValidate.IsDateTime(txtInsertTime.Text))
            {
            strErr+="InsertTime����ʱ���ʽ��\\n";
            }
            if(!PageValidate.IsDateTime(txtLastAnswerTime.Text))
            {
            strErr+="LastAnswerTime����ʱ���ʽ��\\n";
            }
            if(this.txtLastAnswerId.Text =="")
            {
            strErr+="LastAnswerId����Ϊ�գ�\\n";
            }
            if(!PageValidate.IsNumber(txtAnswerNum.Text))
            {
            strErr+="AnswerNum�������֣�\\n";
            }

            if(strErr!="")
            {
            MessageBox.Show(this,strErr);
            return;
            }
            int UserId=int.Parse(this.txtUserId.Text);
            int ContentType=int.Parse(this.txtContentType.Text);
            string ContentId=this.txtContentId.Text;
            string Title=this.txtTitle.Text;
            string Content=this.txtContent.Text;
            string Brief=this.txtBrief.Text;
            DateTime InsertTime=DateTime.Parse(this.txtInsertTime.Text);
            DateTime LastAnswerTime=DateTime.Parse(this.txtLastAnswerTime.Text);
            string LastAnswerId=this.txtLastAnswerId.Text;
            int AnswerNum=int.Parse(this.txtAnswerNum.Text);

            NoName.NetShop.Model.QuestionModel model=new NoName.NetShop.Model.QuestionModel();
            model.UserId=UserId;
            model.ContentType=ContentType;
            model.ContentId=ContentId;
            model.Title=Title;
            model.Content=Content;
            model.Brief=Brief;
            model.InsertTime=InsertTime;
            model.LastAnswerTime=LastAnswerTime;
            model.LastAnswerId=LastAnswerId;
            model.AnswerNum=AnswerNum;

            NoName.NetShop.BLL.QuestionModelBll bll=new NoName.NetShop.BLL.QuestionModelBll();
            bll.Update(model);
        }
Esempio n. 6
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtUserId.Text))
            {
                strErr += "UserId不是数字!\\n";
            }
            if (!PageValidate.IsNumber(txtContentType.Text))
            {
                strErr += "ContentType不是数字!\\n";
            }
            if (this.txtContentId.Text == "")
            {
                strErr += "ContentId不能为空!\\n";
            }
            if (this.txtTitle.Text == "")
            {
                strErr += "Title不能为空!\\n";
            }
            if (this.txtContent.Text == "")
            {
                strErr += "Content不能为空!\\n";
            }
            if (this.txtBrief.Text == "")
            {
                strErr += "Brief不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtInsertTime.Text))
            {
                strErr += "InsertTime不是时间格式!\\n";
            }
            if (!PageValidate.IsDateTime(txtLastAnswerTime.Text))
            {
                strErr += "LastAnswerTime不是时间格式!\\n";
            }
            if (this.txtLastAnswerId.Text == "")
            {
                strErr += "LastAnswerId不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtAnswerNum.Text))
            {
                strErr += "AnswerNum不是数字!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      UserId         = int.Parse(this.txtUserId.Text);
            int      ContentType    = int.Parse(this.txtContentType.Text);
            string   ContentId      = this.txtContentId.Text;
            string   Title          = this.txtTitle.Text;
            string   Content        = this.txtContent.Text;
            string   Brief          = this.txtBrief.Text;
            DateTime InsertTime     = DateTime.Parse(this.txtInsertTime.Text);
            DateTime LastAnswerTime = DateTime.Parse(this.txtLastAnswerTime.Text);
            string   LastAnswerId   = this.txtLastAnswerId.Text;
            int      AnswerNum      = int.Parse(this.txtAnswerNum.Text);

            NoName.NetShop.Model.QuestionModel model = new NoName.NetShop.Model.QuestionModel();
            model.UserId         = UserId;
            model.ContentType    = ContentType;
            model.ContentId      = ContentId;
            model.Title          = Title;
            model.Content        = Content;
            model.Brief          = Brief;
            model.InsertTime     = InsertTime;
            model.LastAnswerTime = LastAnswerTime;
            model.LastAnswerId   = LastAnswerId;
            model.AnswerNum      = AnswerNum;

            NoName.NetShop.BLL.QuestionModelBll bll = new NoName.NetShop.BLL.QuestionModelBll();
            bll.Add(model);
        }
 /// <summary>
 /// ����ʵ�������
 /// </summary>
 public NoName.NetShop.Model.QuestionModel ReaderBind(IDataReader dataReader)
 {
     NoName.NetShop.Model.QuestionModel model=new NoName.NetShop.Model.QuestionModel();
     object ojb;
     ojb = dataReader["QuestionId"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.QuestionId=(int)ojb;
     }
     ojb = dataReader["UserId"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.UserId=(int)ojb;
     }
     ojb = dataReader["ContentType"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.ContentType=(int)ojb;
     }
     model.ContentId=dataReader["ContentId"].ToString();
     model.Title=dataReader["Title"].ToString();
     model.Content=dataReader["Content"].ToString();
     model.Brief=dataReader["Brief"].ToString();
     ojb = dataReader["InsertTime"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.InsertTime=(DateTime)ojb;
     }
     ojb = dataReader["LastAnswerTime"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.LastAnswerTime=(DateTime)ojb;
     }
     model.LastAnswerId=dataReader["LastAnswerId"].ToString();
     ojb = dataReader["AnswerNum"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.AnswerNum=(int)ojb;
     }
     return model;
 }