/// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public NoName.NetShop.Model.AnswerModel ReaderBind(IDataReader dataReader)
        {
            NoName.NetShop.Model.AnswerModel model = new NoName.NetShop.Model.AnswerModel();
            object ojb;

            ojb = dataReader["QuestionId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.QuestionId = (int)ojb;
            }
            ojb = dataReader["AnswerId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.AnswerId = (int)ojb;
            }
            model.Title   = dataReader["Title"].ToString();
            model.Brief   = dataReader["Brief"].ToString();
            model.Content = dataReader["Content"].ToString();
            ojb           = dataReader["AnswerTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.AnswerTime = (DateTime)ojb;
            }
            return(model);
        }
 private void ShowInfo(int AnswerId)
 {
     NoName.NetShop.BLL.AnswerModelBll bll   = new NoName.NetShop.BLL.AnswerModelBll();
     NoName.NetShop.Model.AnswerModel  model = bll.GetModel(AnswerId);
     this.lblQuestionId.Text = model.QuestionId.ToString();
     this.lblTitle.Text      = model.Title;
     this.lblBrief.Text      = model.Brief;
     this.lblContent.Text    = model.Content;
     this.lblAnswerTime.Text = model.AnswerTime.ToString();
 }
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public void Update(NoName.NetShop.Model.AnswerModel model)
        {
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("UP_qaAnswer_Update");

            db.AddInParameter(dbCommand, "QuestionId", DbType.Int32, model.QuestionId);
            db.AddInParameter(dbCommand, "AnswerId", DbType.Int32, model.AnswerId);
            db.AddInParameter(dbCommand, "Title", DbType.AnsiString, model.Title);
            db.AddInParameter(dbCommand, "Brief", DbType.AnsiString, model.Brief);
            db.AddInParameter(dbCommand, "Content", DbType.String, model.Content);
            db.AddInParameter(dbCommand, "AnswerTime", DbType.DateTime, model.AnswerTime);
            db.ExecuteNonQuery(dbCommand);
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtQuestionId.Text))
            {
                strErr += "QuestionId不是数字!\\n";
            }
            if (this.txtTitle.Text == "")
            {
                strErr += "Title不能为空!\\n";
            }
            if (this.txtBrief.Text == "")
            {
                strErr += "Brief不能为空!\\n";
            }
            if (this.txtContent.Text == "")
            {
                strErr += "Content不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtAnswerTime.Text))
            {
                strErr += "AnswerTime不是时间格式!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      QuestionId = int.Parse(this.txtQuestionId.Text);
            string   Title      = this.txtTitle.Text;
            string   Brief      = this.txtBrief.Text;
            string   Content    = this.txtContent.Text;
            DateTime AnswerTime = DateTime.Parse(this.txtAnswerTime.Text);


            NoName.NetShop.Model.AnswerModel model = new NoName.NetShop.Model.AnswerModel();
            model.QuestionId = QuestionId;
            model.Title      = Title;
            model.Brief      = Brief;
            model.Content    = Content;
            model.AnswerTime = AnswerTime;

            NoName.NetShop.BLL.AnswerModelBll bll = new NoName.NetShop.BLL.AnswerModelBll();
            bll.Update(model);
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public NoName.NetShop.Model.AnswerModel GetModel(int AnswerId)
        {
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("UP_qaAnswer_GetModel");

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

            NoName.NetShop.Model.AnswerModel model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string strErr="";
            if(!PageValidate.IsNumber(txtQuestionId.Text))
            {
            strErr+="QuestionId�������֣�\\n";
            }
            if(this.txtTitle.Text =="")
            {
            strErr+="Title����Ϊ�գ�\\n";
            }
            if(this.txtBrief.Text =="")
            {
            strErr+="Brief����Ϊ�գ�\\n";
            }
            if(this.txtContent.Text =="")
            {
            strErr+="Content����Ϊ�գ�\\n";
            }
            if(!PageValidate.IsDateTime(txtAnswerTime.Text))
            {
            strErr+="AnswerTime����ʱ���ʽ��\\n";
            }

            if(strErr!="")
            {
            MessageBox.Show(this,strErr);
            return;
            }
            int QuestionId=int.Parse(this.txtQuestionId.Text);
            string Title=this.txtTitle.Text;
            string Brief=this.txtBrief.Text;
            string Content=this.txtContent.Text;
            DateTime AnswerTime=DateTime.Parse(this.txtAnswerTime.Text);

            NoName.NetShop.Model.AnswerModel model=new NoName.NetShop.Model.AnswerModel();
            model.QuestionId=QuestionId;
            model.Title=Title;
            model.Brief=Brief;
            model.Content=Content;
            model.AnswerTime=AnswerTime;

            NoName.NetShop.BLL.AnswerModelBll bll=new NoName.NetShop.BLL.AnswerModelBll();
            bll.Add(model);
        }
 /// <summary>
 /// ����ʵ�������
 /// </summary>
 public NoName.NetShop.Model.AnswerModel ReaderBind(IDataReader dataReader)
 {
     NoName.NetShop.Model.AnswerModel model=new NoName.NetShop.Model.AnswerModel();
     object ojb;
     ojb = dataReader["QuestionId"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.QuestionId=(int)ojb;
     }
     ojb = dataReader["AnswerId"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.AnswerId=(int)ojb;
     }
     model.Title=dataReader["Title"].ToString();
     model.Brief=dataReader["Brief"].ToString();
     model.Content=dataReader["Content"].ToString();
     ojb = dataReader["AnswerTime"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.AnswerTime=(DateTime)ojb;
     }
     return model;
 }