protected void btnPlaceOrder_Click(object sender, EventArgs e) { HotelMobiEntities dbContext = new HotelMobiEntities(); int OrderId = 0; if (dbContext.Orders.Count() == 0) OrderId = 1; else { OrderId = Convert.ToInt32(dbContext.Orders.OrderByDescending(x => x.Id).First().OrderId) + 1; } foreach (GridViewRow row in gvItems.Rows) { if (row.RowType == DataControlRowType.DataRow) { var hdn = (HiddenField)row.FindControl("hfId"); var chk = (CheckBox)row.FindControl("cbSelect"); Order _Order = new Order(); if (((CheckBox)row.FindControl("cbSelect")).Checked) { _Order.OrderId = OrderId; _Order.DishId = Convert.ToInt32(hdn.Value); _Order.PlacedAt = DateTime.Now; _Order.IsServed = false; dbContext.AddToOrders(_Order); dbContext.SaveChanges(); } if (Convert.ToInt32(hdn.Value) != 0) { } } } }
public string GetSeconds(DateTime dt, int dishId) { HotelMobiModel.HotelMobiEntities dbContext = new HotelMobiModel.HotelMobiEntities(); var dish = dbContext.Dishes.Where(x => x.Id == dishId); DateTime ToBeServedAt = dt.AddSeconds(dish.First().TimeTaken); int secs = (int)ToBeServedAt.Subtract(DateTime.Now).TotalSeconds; return secs.ToString(); }
protected void Page_Load(object sender, EventArgs e) { HotelMobiEntities dbContext = new HotelMobiEntities(); //rptrItems.DataSource = dbContext.Dishes; //rptrItems.DataBind(); if (!IsPostBack) { gvItems.DataSource = dbContext.Dishes; gvItems.DataBind(); } }
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"); }
// static int i = 10; protected void Page_Load(object sender, EventArgs e) { HotelMobiModel.HotelMobiEntities dbContext = new HotelMobiModel.HotelMobiEntities(); rptrOrderItems.DataSource = dbContext.Orders.OrderBy(x=>x.PlacedAt); rptrOrderItems.DataBind(); }