示例#1
0
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     HotelMobiModel.HotelMobiEntities HotelMobiEntity = new HotelMobiModel.HotelMobiEntities();
     HotelMobiModel.Dish objDish = new HotelMobiModel.Dish();
     objDish.Category = ddlCategory.SelectedValue;
     objDish.Description = txtDescription.Text.Trim();
     objDish.Ingredients = txtIngredients.Text.Trim();
     objDish.Name = txtname.Text.Trim();
     objDish.SubCategory = txtSubCategory.Text.Trim();
     objDish.Price = Convert.ToDecimal(txtPrice.Text.Trim());
     objDish.TimeTaken = Convert.ToInt32(txtMin.Text.Trim()) * 60 + Convert.ToInt32(txtsec.Text.Trim());
     objDish.InsertedAt = DateTime.Now;
     objDish.UpdatedAt = DateTime.Now;
     HotelMobiEntity.AddToDishes(objDish);
     HotelMobiEntity.SaveChanges();
     //MessageBox.Show("Are you sure you want to insert a new dish ?");
     //Response.Write("<script type=\"text/javascript\">alert('Are you sure you want to insert a new dish ?');</script>");
     Response.Redirect("~/Menu.aspx");
 }
 /// <summary>
 /// Create a new Dish object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="description">Initial value of the Description property.</param>
 /// <param name="ingredients">Initial value of the Ingredients property.</param>
 /// <param name="category">Initial value of the Category property.</param>
 /// <param name="subCategory">Initial value of the SubCategory property.</param>
 /// <param name="price">Initial value of the Price property.</param>
 /// <param name="timeTaken">Initial value of the TimeTaken property.</param>
 /// <param name="insertedAt">Initial value of the InsertedAt property.</param>
 /// <param name="updatedAt">Initial value of the UpdatedAt property.</param>
 public static Dish CreateDish(global::System.Int32 id, global::System.String name, global::System.String description, global::System.String ingredients, global::System.String category, global::System.String subCategory, global::System.Decimal price, global::System.Int32 timeTaken, global::System.DateTime insertedAt, global::System.DateTime updatedAt)
 {
     Dish dish = new Dish();
     dish.Id = id;
     dish.Name = name;
     dish.Description = description;
     dish.Ingredients = ingredients;
     dish.Category = category;
     dish.SubCategory = subCategory;
     dish.Price = price;
     dish.TimeTaken = timeTaken;
     dish.InsertedAt = insertedAt;
     dish.UpdatedAt = updatedAt;
     return dish;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Dishes EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToDishes(Dish dish)
 {
     base.AddObject("Dishes", dish);
 }