예제 #1
0
 protected void OnAddItem(SRL_Ingredient e)
 {
     if (AddItem != null)
     {
         AddItem(e);
     }
 }
예제 #2
0
        public void AddIngridiant(SRL_Ingredient ingredient)
        {
            List <SRL_Ingredient> list = Ingredients;

            string         foodName    = ingredient.FoodName;
            SRL_Ingredient tIngredient = list.Find(f => f.FoodName == foodName);

            if (tIngredient == null)
            {
                list.Add(ingredient);
            }

            Ingredients = list;

            dlistIngredients.DataSource = Ingredients.ToArray();
            dlistIngredients.DataBind();
        }
예제 #3
0
        internal bool AddGeneralListItem(SRL_Ingredient ingredient, int listId)
        {
            using (DataContext)
            {
                try
                {
                    int count = (from p in DataContext.GeneralListDetails
                                 where p.LIST_ID == listId && p.ITEM_NAME == ingredient.FoodName
                                 select p).Count();

                    if (count == 0)
                    {
                        GeneralListDetail generalListDetail = new GeneralListDetail
                        {
                            ITEM_NAME           = ingredient.FoodName,
                            LIST_ID             = listId,
                            COMPLETE_QUANTITY   = ingredient.CompleteValue,
                            MEASUREMENT_UNIT_ID = ingredient.MeasurementUnitId,
                            MEASUREMENT_UNIT    = ingredient.MeasurementUnitName
                        };
                        DataContext.GeneralListDetails.InsertOnSubmit(generalListDetail);
                    }
                    else
                    {
                        GeneralListDetail generalListDetail = (from p in DataContext.GeneralListDetails
                                                               where
                                                               p.LIST_ID == listId &&
                                                               p.ITEM_NAME == ingredient.FoodName
                                                               select p).Single();

                        generalListDetail.COMPLETE_QUANTITY   = ingredient.CompleteValue;
                        generalListDetail.MEASUREMENT_UNIT_ID = ingredient.MeasurementUnitId;
                        generalListDetail.MEASUREMENT_UNIT    = ingredient.MeasurementUnitName;
                    }
                    DataContext.SubmitChanges();

                    return(true);
                }
                catch
                {
                    return(false);
                }
            }
        }
예제 #4
0
        protected void btnUpdateIngredient_Click(object sender, EventArgs e)
        {
            LinkButton   btn  = sender as LinkButton;
            DataListItem item = btn.Parent.Parent as DataListItem;

            List <SRL_Ingredient> list       = Ingredients.ToList();
            SRL_Ingredient        ingredient = list[item.ItemIndex];

            txtFoodName.Text = ingredient.FoodName;

            if (!string.IsNullOrEmpty(ingredient.CompleteValue))
            {
                txtQuantity.Text = ingredient.CompleteValue;
            }
            else
            {
                txtQuantity.Text = "";
            }

            //if (!string.IsNullOrEmpty(ingredient.FractionValue))
            //{
            //    ddlFractions.Text = ingredient.FractionValue;
            //}
            //else
            //{
            //    ddlFractions.Text = "";
            //}

            ddlMeasurementUnits.Text = ingredient.MeasurementUnitId.ToString();

            btnAddIngerdient.CommandArgument = item.ItemIndex.ToString();
            imgAdd.Visible    = false;
            imgUpdate.Visible = true;

            UpdatePanel3.Update();
            UpdatePanel4.Update();
        }
예제 #5
0
 public void DeleteSummeryListItem(int summeryId, int sourceId, SRL_Ingredient ingredient)
 {
     new SummeryListDA().DeleteListItem(summeryId, sourceId, ingredient);
 }
예제 #6
0
 public bool AddSummeryListItem(SRL_Ingredient ingredient, int listId, int sourceId)
 {
     return(new SummeryListDA().AddListItem(ingredient, listId, sourceId));
 }
예제 #7
0
 public bool AddGeneralListItem(SRL_Ingredient ingredient, int listId)
 {
     return(new GeneralListDA().AddGeneralListItem(ingredient, listId));
 }
예제 #8
0
    private string PrintMenuRecipes(int menuId)
    {
        MyBuyList.Shared.Entities.Menu menu = BusinessFacade.Instance.GetMenu(menuId);
        string data = "<html>" +
                      "<body dir='rtl'>" +
                      "<table  dir='rtl'> " +
                      "<tr>" +
                      "<td style='width:400px;'> " +
                      " &nbsp; " +
                      "</td> " +
                      "<td>" +
                      "&nbsp;" +
                      "</td>" +
                      "<td rowspan='2'>" +
                      "<img src='http://www.mybuylist.com/Images/New/Logo.gif' />" +
                      "</td>" +
                      "</tr>" +
                      "<tr>" +
                      "<td colspan='2' align='center'>" +
                      "&nbsp;" +
                      "<b style='font-size:larger; color:Red;'>" + menu.MenuName + "</b>" +

                      "</td>" +
                      "</tr>" +
                      "<tr> " +
                      "<td>  ";


        MenuRecipe[] recipeList = BusinessFacade.Instance.GetMenuRecipes(menuId).ToArray <MenuRecipe>();
        Dictionary <int, List <int> > recipeServList = BusinessFacade.Instance.GetMenuRecipesIngrid(menuId);
        bool isFirst = true;

        foreach (MenuRecipe currMenuRecipe in recipeList)
        {
            if (isFirst)
            {
                isFirst = false;
            }
            else
            {
                data += "<hr />";
            }

            if (recipeServList.ContainsKey(currMenuRecipe.RecipeId))
            {
                List <int> RecipeServings = recipeServList[currMenuRecipe.RecipeId];
                RecipeServings.Sort();
                data += "<b>" + currMenuRecipe.Recipe.RecipeName + "</b><br>";

                foreach (int serv in RecipeServings)
                {
                    if (serv == currMenuRecipe.Recipe.Servings)
                    {
                        data += "<b>מצרכים כפי שהוגדרו במתכון המקורי (" + serv.ToString() + " מנות):</b> <br>";
                        foreach (Ingredient cuurIngredient in currMenuRecipe.Recipe.Ingredients)
                        {
                            data += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + new SRL_Ingredient(cuurIngredient).DisplayIngredient;
                            data += "<br>";
                        }
                    }
                    else
                    {
                        data += "<b>מצרכים כפי שבחרת לארוחה עבור (" + serv.ToString() + " מנות):</b> <br>";
                        foreach (Ingredient cuurIngredient in currMenuRecipe.Recipe.Ingredients)
                        {
                            SRL_Ingredient cuurSRLIngredient = new SRL_Ingredient();
                            cuurSRLIngredient.FoodId              = cuurIngredient.FoodId;
                            cuurSRLIngredient.FoodName            = BusinessFacade.Instance.GetFood(cuurSRLIngredient.FoodId).FoodName;
                            cuurSRLIngredient.MeasurementUnitId   = cuurIngredient.MeasurementUnitId;
                            cuurSRLIngredient.MeasurementUnitName = BusinessFacade.Instance.GetMeasurementUnit(cuurSRLIngredient.MeasurementUnitId).UnitName;
                            cuurSRLIngredient.Quantity            = Decimal.Round((cuurIngredient.Quantity / currMenuRecipe.Recipe.Servings) * serv, 2);
                            cuurSRLIngredient.Remarks             = cuurIngredient.Remarks;
                            data += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + cuurSRLIngredient.DisplayIngredient;
                            data += "<br>";
                        }
                    }
                }

                data += "<br><b>אופן הכנה: </b><br>";
                data += currMenuRecipe.Recipe.PreparationMethod + "<br><br>";
            }
            else
            {
                data += "<b>" + currMenuRecipe.Recipe.RecipeName + "</b><br>";
                data += "<b>מצרכים:</b> <br>";
                foreach (Ingredient cuurIngredient in currMenuRecipe.Recipe.Ingredients)
                {
                    data += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + new SRL_Ingredient(cuurIngredient).DisplayIngredient;
                    data += "<br>";
                }

                data += "<br><b>אופן הכנה: </b><br>";
                data += currMenuRecipe.Recipe.PreparationMethod + "<br><br>";
            }
        }


        data += "</td> " +
                "</tr> " +
                "</table> " +
                "</body>" +
                "</html>";

        return(data);
    }
예제 #9
0
 internal bool AddGeneralListItem(SRL_Ingredient ingredient, int listId)
 {
     return(DataLayer.DataFacade.Instance.AddGeneralListItem(ingredient, listId));
 }
예제 #10
0
        protected void btnAddItemCommand(object sender, CommandEventArgs e)
        {
            List <SRL_Ingredient> list       = Ingredients;
            SRL_Ingredient        ingredient = null;
            string commandArg = e.CommandArgument as string;

            if (string.IsNullOrEmpty(txtFoodName.Text) || string.IsNullOrEmpty(txtQuantity.Text))
            {
                return;
            }

            if (commandArg == MyGlobalResources.Add)
            {
                ingredient = list.Find(f => f.FoodName == txtFoodName.Text);
                if (ingredient == null)
                {
                    ingredient = new SRL_Ingredient();
                    list.Add(ingredient);
                    ingredient.Quantity = 0;
                }
            }
            else if (!string.IsNullOrEmpty(commandArg))
            {
                int itemIndex = int.Parse(commandArg);
                ingredient          = list[itemIndex];
                ingredient.Quantity = 0;
            }

            if (ingredient == null)
            {
                return;
            }

            ingredient.FoodName = txtFoodName.Text;
            if (!string.IsNullOrEmpty(txtQuantity.Text))
            {
                ingredient.Quantity += decimal.Parse(txtQuantity.Text);
            }
            //if (!string.IsNullOrEmpty(ddlFractions.SelectedItem.Value))
            //{
            //    ingredient.Quantity += decimal.Parse(ddlFractions.SelectedItem.Value);
            //}

            int completeValue = ((int)ingredient.Quantity);

            //decimal fractionValue = ingredient.Quantity - completeValue;

            ingredient.CompleteValue = completeValue.ToString();
            //ingredient.FractionValue = fractionValue.ToString();

            ingredient.MeasurementUnitId   = int.Parse(ddlMeasurementUnits.SelectedItem.Value);
            ingredient.MeasurementUnitName = ddlMeasurementUnits.SelectedItem.Text;

            Ingredients = list;
            dlistIngredients.DataSource = Ingredients.ToArray();
            dlistIngredients.DataBind();

            txtFoodName.Text = "";
            txtQuantity.Text = "";
            //ddlFractions.Text = "";
            ddlMeasurementUnits.SelectedIndex = 0;

            btnAddIngerdient.CommandArgument = MyGlobalResources.Add;
            imgAdd.Visible    = true;
            imgUpdate.Visible = false;

            UpdatePanel2.Update();
            UpdatePanel3.Update();
            UpdatePanel4.Update();

            OnAddItem(ingredient);
        }
예제 #11
0
 private void AfterAddItem(SRL_Ingredient ingredient)
 {
     ucSummeryList1.AddIngridiant(ingredient);
 }
예제 #12
0
        internal bool AddListItem(SRL_Ingredient ingredient, int listId, int sourceId)
        {
            using (DataContext)
            {
                SummeryListDetail summeryListDetail;
                try
                {
                    // Get the food id
                    Food food = (from p in DataContext.Foods where p.FoodName == ingredient.FoodName select p).SingleOrDefault();
                    if (food != null)
                    {
                        ingredient.FoodId = food.FoodId;
                    }

                    // Add to Summery Sources
                    if (food != null)
                    {
                        SummerySource summerySource = (from p in DataContext.SummerySources
                                                       where
                                                       p.SUMMERY_ID == listId && p.SOURCE_ID == sourceId &&
                                                       p.FOOD_ID == food.FoodId
                                                       select p).SingleOrDefault();
                        if (summerySource == null)
                        {
                            summerySource = new SummerySource
                            {
                                SUMMERY_ID = listId,
                                SOURCE_ID  = sourceId,
                                FOOD_ID    = food.FoodId,
                                QUANTITY   = ingredient.Quantity
                            };
                            DataContext.SummerySources.InsertOnSubmit(summerySource);
                        }
                        else
                        {
                            summerySource.QUANTITY = ingredient.Quantity;
                        }

                        DataContext.SubmitChanges();
                    }

                    // ReCalculate summery list
                    IQueryable <decimal?> summerySources = from p in DataContext.SummerySources where p.SUMMERY_ID == listId && p.FOOD_ID == ingredient.FoodId select p.QUANTITY;
                    decimal?sum = summerySources.Sum();

                    summeryListDetail = (from p in DataContext.SummeryListDetails
                                         where p.LIST_ID == listId && p.FOOD_ID == ingredient.FoodId
                                         select p).SingleOrDefault();

                    if (summeryListDetail == null)
                    {
                        summeryListDetail = new SummeryListDetail
                        {
                            FOOD_ID             = ingredient.FoodId,
                            FOOD_NAME           = ingredient.FoodName,
                            LIST_ID             = listId,
                            QUANTITY            = sum.HasValue ? sum.Value : 0,
                            MEASUREMENT_UNIT_ID = ingredient.MeasurementUnitId,
                            MEASUREMENT_UNIT    = ingredient.MeasurementUnitName
                        };
                        DataContext.SummeryListDetails.InsertOnSubmit(summeryListDetail);
                    }
                    else
                    {
                        summeryListDetail.QUANTITY = sum.HasValue ? sum.Value : 0;
                    }
                    DataContext.SubmitChanges();

                    return(true);
                }
                catch
                {
                    return(false);
                }
            }
        }
예제 #13
0
        internal void DeleteListItem(int summeryId, int sourceId, SRL_Ingredient ingredient)
        {
            using (DataContext)
            {
                try
                {
                    SummerySource summerySource = (from p in DataContext.SummerySources
                                                   where
                                                   p.SUMMERY_ID == summeryId && p.SOURCE_ID == sourceId &&
                                                   p.FOOD_ID == ingredient.FoodId
                                                   select p).SingleOrDefault();
                    if (summerySource != null)
                    {
                        summerySource.QUANTITY -= ingredient.Quantity;
                        if (summerySource.QUANTITY <= 0)
                        {
                            DataContext.SummerySources.DeleteOnSubmit(summerySource);
                        }
                    }

                    // ReCalculate summery list
                    IQueryable <decimal?> summerySources = from p in DataContext.SummerySources where p.SUMMERY_ID == summeryId && p.FOOD_ID == ingredient.FoodId select p.QUANTITY;
                    decimal?sum = summerySources.Sum() - ingredient.Quantity;

                    SummeryListDetail summeryListDetail = (from p in DataContext.SummeryListDetails
                                                           where p.LIST_ID == summeryId && p.FOOD_ID == ingredient.FoodId
                                                           select p).SingleOrDefault();

                    if (summeryListDetail == null)
                    {
                        if (sum > 0)
                        {
                            summeryListDetail = new SummeryListDetail
                            {
                                FOOD_ID             = ingredient.FoodId,
                                FOOD_NAME           = ingredient.FoodName,
                                LIST_ID             = summeryId,
                                QUANTITY            = sum.HasValue ? sum.Value : 0,
                                MEASUREMENT_UNIT_ID = ingredient.MeasurementUnitId,
                                MEASUREMENT_UNIT    = ingredient.MeasurementUnitName
                            };
                            DataContext.SummeryListDetails.InsertOnSubmit(summeryListDetail);
                        }
                    }
                    else
                    {
                        if (sum == 0)
                        {
                            DataContext.SummeryListDetails.DeleteOnSubmit(summeryListDetail);
                        }
                        else
                        {
                            summeryListDetail.QUANTITY = sum.HasValue ? sum.Value : 0;
                        }
                    }

                    DataContext.SubmitChanges();
                }
                catch (Exception)
                {
                }
            }
        }
예제 #14
0
 internal void DeleteListItem(int summeryId, int sourceId, SRL_Ingredient ingredient)
 {
     DataLayer.DataFacade.Instance.DeleteSummeryListItem(summeryId, sourceId, ingredient);
 }
예제 #15
0
 internal bool AddListItem(SRL_Ingredient ingredient, int listId, int sourceId)
 {
     return(DataLayer.DataFacade.Instance.AddSummeryListItem(ingredient, listId, sourceId));
 }