Example #1
0
        private void addRecipe_btn_Click(object sender, EventArgs e)
        {
            m_recipe = recipe.Createrecipe(1, name_tb.Text);
            m_recipe.description = desc_rb.Text;
            m_recipe.food_category_id = (int)food_category_cb.SelectedValue;
            m_cafecontext.recipe.AddObject(m_recipe);

            for (int i=0; i<tempstuff.Count; i++)
                m_cafecontext.recipe_stuff.AddObject(tempstuff[i]);

            m_cafecontext.SaveChanges();
            this.Close();
        }
Example #2
0
        private void CashierFrom_Load(object sender, EventArgs e)
        {
            IQueryable<recipe_stuff> recipestuffQuery = from rs in cafeContext.recipe_stuff
                                                        select rs;
            IQueryable<ingridient> ingQuery = from ing in cafeContext.ingridient
                                              select ing;
            recipe_stuff[] rsA = recipestuffQuery.ToArray();
            ingridient[] ingA = ingQuery.ToArray();

            IQueryable<recipe> recipeQuery = from r in cafeContext.recipe
                                             select r;
            recipe[] rA = recipeQuery.ToArray();
            List<Button> btnlist = new List<Button>();

            foreach (recipe r in rA)
            {
                r.totalcost = 0;
                for (int i = 0; i < rsA.Count(); i++)
                    if (rsA[i].recipe_id == r.recipe_id)
                        for (int j = 0; j < ingA.Count(); j++)
                            if (ingA[j].ingridient_id == rsA[i].ingridient_id)
                                r.totalcost += ingA[j].cost * rsA[i].count;

                btnlist.Add(new Button()
                    {
                        Name = r.name + "Btn",
                        Text = r.name + " " + r.totalcost.ToString()+ " $",
                        Size = new System.Drawing.Size(80, 40),
                    }
                    );
                btnlist.Last<Button>().Click +=
                    new EventHandler((s, args) =>
                    {
                        orderList.Items.Add((s as Button).Text);
                        recipe re = new recipe();
                        re = getRecipe((s as Button).Name, rA);
                        m_currentOrder.Add(re);
                        totalOrder_tb.Text = getCurrentCost().ToString();
                    });
            }
            foreach (Button b in btnlist)
                this.ItemsflowLayoutPanel1.Controls.Add(b);
        }
Example #3
0
 private recipe getRecipe(string text, recipe[] A)
 {
     for (int i = 0; i < A.Count(); i++)
         if (A[i].name + "Btn" == text)
             return A[i];
     return null;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the recipe EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTorecipe(recipe recipe)
 {
     base.AddObject("recipe", recipe);
 }
 /// <summary>
 /// Create a new recipe object.
 /// </summary>
 /// <param name="recipe_id">Initial value of the recipe_id property.</param>
 /// <param name="name">Initial value of the name property.</param>
 public static recipe Createrecipe(global::System.Int32 recipe_id, global::System.String name)
 {
     recipe recipe = new recipe();
     recipe.recipe_id = recipe_id;
     recipe.name = name;
     return recipe;
 }