protected void btEdit_Click(object sender, EventArgs e) { RestaurantName = Request.QueryString["RestaurantName"].ToString(); CityID = int.Parse(Request.QueryString["CityID"].ToString()); PageStart = int.Parse(Request.QueryString["PageStart"].ToString()); RestaurantID = int.Parse(Request.QueryString["RestaurantID"].ToString()); RestaurantInfoBLL _ResInfoBLL = new RestaurantInfoBLL(); RestaurantFoodInfo _ResFoodInfo = new RestaurantFoodInfo(); _ResFoodInfo.FoodName = this.txtFoodName.Text.Trim(); if (this.txtFoodPrice.Text.Trim() != "") { _ResFoodInfo.FoodPrice = float.Parse(this.txtFoodPrice.Text.Trim()); } else { _ResFoodInfo.FoodPrice = 0.0f; } _ResFoodInfo.RestaurantID = RestaurantID; if (_ResInfoBLL.AddResFood(_ResFoodInfo)) { Response.Write("<script language='javascript'>"); Response.Write("alert('添加成功');"); Response.Write("document.location.href='RestaurantFoodList.aspx?&CityID=" + CityID.ToString() + "&RestaurantID=" + RestaurantID.ToString() + "&PageStart=" + PageStart.ToString() + "&RestaurantName=" + RestaurantName + "';"); Response.Write("</script>"); } }
/// <summary> /// 向餐馆中添加一个菜 /// </summary> /// <param name="_ResFoodInfo"></param> /// <returns></returns> public bool AddResFood(RestaurantFoodInfo _ResFoodInfo) { String Sql = "insert into FoodInfo(FoodName,FoodPrice,RestaurantID) values(@FoodName,@FoodPrice,@RestaurantID)"; SqlParameter[] Paras = new SqlParameter[] { new SqlParameter("@FoodName", _ResFoodInfo.FoodName), new SqlParameter("@FoodPrice", _ResFoodInfo.FoodPrice), new SqlParameter("RestaurantID", _ResFoodInfo.RestaurantID) }; if (SqlHelper.ExecuteNonQuery(Sql, Paras, CommandType.Text) > 0) { return(true); } return(false); }
/// <summary> /// 向餐馆中添加一个菜 /// </summary> /// <param name="_ResFoodInfo"></param> /// <returns></returns> public bool AddResFood(RestaurantFoodInfo _ResFoodInfo) { return(this._RestInfoDAL.AddResFood(_ResFoodInfo)); }