Esempio n. 1
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtsdType.Text))
            {
                strErr += "sdType不是数字!\\n";
            }
            if (!PageValidate.IsNumber(txtuserId.Text))
            {
                strErr += "userId不是数字!\\n";
            }
            if (this.txtTitle.Text == "")
            {
                strErr += "Title不能为空!\\n";
            }
            if (this.txtContent.Text == "")
            {
                strErr += "Content不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtInsertTime.Text))
            {
                strErr += "InsertTime不是时间格式!\\n";
            }
            if (!PageValidate.IsDateTime(txtModifyTime.Text))
            {
                strErr += "ModifyTime不是时间格式!\\n";
            }
            if (!PageValidate.IsNumber(txtStatus.Text))
            {
                strErr += "Status不是数字!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      sdType     = int.Parse(this.txtsdType.Text);
            int      userId     = int.Parse(this.txtuserId.Text);
            string   Title      = this.txtTitle.Text;
            string   Content    = this.txtContent.Text;
            DateTime InsertTime = DateTime.Parse(this.txtInsertTime.Text);
            DateTime ModifyTime = DateTime.Parse(this.txtModifyTime.Text);
            int      Status     = int.Parse(this.txtStatus.Text);


            NoName.NetShop.Model.SupplyDemandModel model = new NoName.NetShop.Model.SupplyDemandModel();
            model.sdType     = sdType;
            model.userId     = userId;
            model.Title      = Title;
            model.Content    = Content;
            model.InsertTime = InsertTime;
            model.ModifyTime = ModifyTime;
            model.Status     = Status;

            NoName.NetShop.BLL.SupplyDemandModelBll bll = new NoName.NetShop.BLL.SupplyDemandModelBll();
            bll.Update(model);
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string strErr="";
            if(!PageValidate.IsNumber(txtsdType.Text))
            {
            strErr+="sdType�������֣�\\n";
            }
            if(!PageValidate.IsNumber(txtuserId.Text))
            {
            strErr+="userId�������֣�\\n";
            }
            if(this.txtTitle.Text =="")
            {
            strErr+="Title����Ϊ�գ�\\n";
            }
            if(this.txtContent.Text =="")
            {
            strErr+="Content����Ϊ�գ�\\n";
            }
            if(!PageValidate.IsDateTime(txtInsertTime.Text))
            {
            strErr+="InsertTime����ʱ���ʽ��\\n";
            }
            if(!PageValidate.IsDateTime(txtModifyTime.Text))
            {
            strErr+="ModifyTime����ʱ���ʽ��\\n";
            }
            if(!PageValidate.IsNumber(txtStatus.Text))
            {
            strErr+="Status�������֣�\\n";
            }

            if(strErr!="")
            {
            MessageBox.Show(this,strErr);
            return;
            }
            int sdType=int.Parse(this.txtsdType.Text);
            int userId=int.Parse(this.txtuserId.Text);
            string Title=this.txtTitle.Text;
            string Content=this.txtContent.Text;
            DateTime InsertTime=DateTime.Parse(this.txtInsertTime.Text);
            DateTime ModifyTime=DateTime.Parse(this.txtModifyTime.Text);
            int Status=int.Parse(this.txtStatus.Text);

            NoName.NetShop.Model.SupplyDemandModel model=new NoName.NetShop.Model.SupplyDemandModel();
            model.sdType=sdType;
            model.userId=userId;
            model.Title=Title;
            model.Content=Content;
            model.InsertTime=InsertTime;
            model.ModifyTime=ModifyTime;
            model.Status=Status;

            NoName.NetShop.BLL.SupplyDemandModelBll bll=new NoName.NetShop.BLL.SupplyDemandModelBll();
            bll.Add(model);
        }
Esempio n. 3
0
 private void ShowInfo(int sdId)
 {
     NoName.NetShop.BLL.SupplyDemandModelBll bll   = new NoName.NetShop.BLL.SupplyDemandModelBll();
     NoName.NetShop.Model.SupplyDemandModel  model = bll.GetModel(sdId);
     this.lblsdType.Text     = model.sdType.ToString();
     this.lbluserId.Text     = model.userId.ToString();
     this.lblTitle.Text      = model.Title;
     this.lblContent.Text    = model.Content;
     this.lblInsertTime.Text = model.InsertTime.ToString();
     this.lblModifyTime.Text = model.ModifyTime.ToString();
     this.lblStatus.Text     = model.Status.ToString();
 }
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public void Update(NoName.NetShop.Model.SupplyDemandModel model)
        {
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("UP_sdSupplyDemand_Update");

            db.AddInParameter(dbCommand, "sdId", DbType.Int32, model.sdId);
            db.AddInParameter(dbCommand, "sdType", DbType.Byte, model.sdType);
            db.AddInParameter(dbCommand, "userId", DbType.Int32, model.userId);
            db.AddInParameter(dbCommand, "Title", DbType.AnsiString, model.Title);
            db.AddInParameter(dbCommand, "Content", DbType.AnsiString, model.Content);
            db.AddInParameter(dbCommand, "InsertTime", DbType.DateTime, model.InsertTime);
            db.AddInParameter(dbCommand, "ModifyTime", DbType.DateTime, model.ModifyTime);
            db.AddInParameter(dbCommand, "Status", DbType.Byte, model.Status);
            db.ExecuteNonQuery(dbCommand);
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public NoName.NetShop.Model.SupplyDemandModel GetModel(int sdId)
        {
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("UP_sdSupplyDemand_GetModel");

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

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

            ojb = dataReader["sdId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.sdId = (int)ojb;
            }
            ojb = dataReader["sdType"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.sdType = (int)ojb;
            }
            ojb = dataReader["userId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.userId = (int)ojb;
            }
            model.Title   = dataReader["Title"].ToString();
            model.Content = dataReader["Content"].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;
            }
            ojb = dataReader["Status"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Status = (int)ojb;
            }
            return(model);
        }
 /// <summary>
 /// ����ʵ�������
 /// </summary>
 public NoName.NetShop.Model.SupplyDemandModel ReaderBind(IDataReader dataReader)
 {
     NoName.NetShop.Model.SupplyDemandModel model=new NoName.NetShop.Model.SupplyDemandModel();
     object ojb;
     ojb = dataReader["sdId"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.sdId=(int)ojb;
     }
     ojb = dataReader["sdType"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.sdType=(int)ojb;
     }
     ojb = dataReader["userId"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.userId=(int)ojb;
     }
     model.Title=dataReader["Title"].ToString();
     model.Content=dataReader["Content"].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;
     }
     ojb = dataReader["Status"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.Status=(int)ojb;
     }
     return model;
 }