Пример #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(BookShop.Model.RoomType model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into RoomType(");
            strSql.Append("TypeName,Price,AddBed,BedPrice,Remark)");
            strSql.Append(" values (");
            strSql.Append("@TypeName,@Price,@AddBed,@BedPrice,@Remark)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@TypeName", SqlDbType.VarChar, 50),
                new SqlParameter("@Price",    SqlDbType.Money,    8),
                new SqlParameter("@AddBed",   SqlDbType.Int,      4),
                new SqlParameter("@BedPrice", SqlDbType.Money,    8),
                new SqlParameter("@Remark",   SqlDbType.VarChar, 100)
            };
            parameters[0].Value = model.TypeName;
            parameters[1].Value = model.Price;
            parameters[2].Value = model.AddBed;
            parameters[3].Value = model.BedPrice;
            parameters[4].Value = model.Remark;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(BookShop.Model.RoomType model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update RoomType set ");
            strSql.Append("TypeName=@TypeName,");
            strSql.Append("Price=@Price,");
            strSql.Append("AddBed=@AddBed,");
            strSql.Append("BedPrice=@BedPrice,");
            strSql.Append("Remark=@Remark");
            strSql.Append(" where TypeId=@TypeId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@TypeId",   SqlDbType.Int,      4),
                new SqlParameter("@TypeName", SqlDbType.VarChar, 50),
                new SqlParameter("@Price",    SqlDbType.Money,    8),
                new SqlParameter("@AddBed",   SqlDbType.Int,      4),
                new SqlParameter("@BedPrice", SqlDbType.Money,    8),
                new SqlParameter("@Remark",   SqlDbType.VarChar, 100)
            };
            parameters[0].Value = model.TypeId;
            parameters[1].Value = model.TypeName;
            parameters[2].Value = model.Price;
            parameters[3].Value = model.AddBed;
            parameters[4].Value = model.BedPrice;
            parameters[5].Value = model.Remark;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Пример #3
0
 private void ShowInfo(int TypeId)
 {
     BookShop.BLL.RoomTypeService bll   = new BookShop.BLL.RoomTypeService();
     BookShop.Model.RoomType      model = bll.GetModel(TypeId);
     this.lblTypeName.Text = model.TypeName;
     this.lblPrice.Text    = model.Price.ToString();
     this.lblAddBed.Text   = model.AddBed.ToString();
     this.lblBedPrice.Text = model.BedPrice.ToString();
     this.lblRemark.Text   = model.Remark;
 }
Пример #4
0
		public void btnUpdate_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtTypeName.Text =="")
			{
				strErr+="TypeName不能为空!\\n";	
			}
			if(!PageValidate.IsDecimal(txtPrice.Text))
			{
				strErr+="Price不是数字!\\n";	
			}
			if(!PageValidate.IsNumber(txtAddBed.Text))
			{
				strErr+="AddBed不是数字!\\n";	
			}
			if(!PageValidate.IsDecimal(txtBedPrice.Text))
			{
				strErr+="BedPrice不是数字!\\n";	
			}
			if(this.txtRemark.Text =="")
			{
				strErr+="Remark不能为空!\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			string TypeName=this.txtTypeName.Text;
			decimal Price=decimal.Parse(this.txtPrice.Text);
			int AddBed=int.Parse(this.txtAddBed.Text);
			decimal BedPrice=decimal.Parse(this.txtBedPrice.Text);
			string Remark=this.txtRemark.Text;


			BookShop.Model.RoomType model=new BookShop.Model.RoomType();
			model.TypeName=TypeName;
			model.Price=Price;
			model.AddBed=AddBed;
			model.BedPrice=BedPrice;
			model.Remark=Remark;

			BookShop.BLL.RoomTypeService bll=new BookShop.BLL.RoomTypeService();
			bll.Update(model);

		}
Пример #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public BookShop.Model.RoomType GetModel(int TypeId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 TypeId,TypeName,Price,AddBed,BedPrice,Remark from RoomType ");
            strSql.Append(" where TypeId=@TypeId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@TypeId", SqlDbType.Int, 4)
            };
            parameters[0].Value = TypeId;

            BookShop.Model.RoomType model = new BookShop.Model.RoomType();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["TypeId"].ToString() != "")
                {
                    model.TypeId = int.Parse(ds.Tables[0].Rows[0]["TypeId"].ToString());
                }
                model.TypeName = ds.Tables[0].Rows[0]["TypeName"].ToString();
                if (ds.Tables[0].Rows[0]["Price"].ToString() != "")
                {
                    model.Price = decimal.Parse(ds.Tables[0].Rows[0]["Price"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AddBed"].ToString() != "")
                {
                    model.AddBed = int.Parse(ds.Tables[0].Rows[0]["AddBed"].ToString());
                }
                if (ds.Tables[0].Rows[0]["BedPrice"].ToString() != "")
                {
                    model.BedPrice = decimal.Parse(ds.Tables[0].Rows[0]["BedPrice"].ToString());
                }
                model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }