protected void IngredientsGrid_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "Insert")
     {
         DataTable dt            = new DataTable();
         DataTable newIngredient = new DataTable();
         dt = (DataTable)ViewState["Ingredients"];
         if (dt.Rows.Count < 15)
         {
             Ingridients ing = new Ingridients();
             ing.RecipeId    = Convert.ToInt32(recipeGrid.DataKey.Value.ToString());
             ing.name        = ((TextBox)IngredientsGrid.FooterRow.FindControl("txtName")).Text;
             ing.Quantity    = Convert.ToInt32(((TextBox)IngredientsGrid.FooterRow.FindControl("txtQuantity")).Text);
             ing.measureUnit = ((TextBox)IngredientsGrid.FooterRow.FindControl("txtMeasureUnits")).Text;
             DataRow newIng = dt.NewRow();
             newIng[1] = ing.name;
             newIng[2] = ing.Quantity;
             newIng[3] = ing.measureUnit;
             newIng[4] = ing.RecipeId;
             dt.Rows.Add(newIng);
             ViewState["Ingredients"]   = dt;
             ViewState["NewIngredient"] = ing;
             IngredientsGrid.DataSource = dt;
             IngredientsGrid.DataBind();
         }
         else
         {
             update.Text = "Can't add more than 15 Ingredients ";
         }
     }
 }
    //Brinderjit Singh StudentId=300918321

    protected void Page_PreRender(object sender, EventArgs e)
    {
        int recipeId = Convert.ToInt32(Request.QueryString["ID"]);

        if (recipeId == 0)
        {
            Response.Redirect("Recipes.aspx");
        }
        DataTable dr = _objrepositry.getDetails(recipeId);

        recipeGrid.HeaderText = dr.Rows[0]["Name"].ToString().ToUpper();
        string selecteditem = dr.Rows[0]["Category"].ToString();

        if (!Page.IsPostBack)
        {
            ViewState["Recipe"]   = dr;
            recipeGrid.DataSource = dr;
            DataTable dr1 = _objrepositry.getDIngredientDetails(recipeId);
            recipeGrid.DataBind();
            ViewState["Ingredients"]   = dr1;
            IngredientsGrid.DataSource = dr1;
            IngredientsGrid.DataBind();
        }
        else
        {
            recipeGrid.DataSource      = (DataTable)ViewState["Recipe"];
            IngredientsGrid.DataSource = (DataTable)ViewState["Ingredients"];
            recipeGrid.DataBind();
            IngredientsGrid.DataBind();
        }
    }
Exemple #3
0
        private void addImage_Tapped(object sender, TappedRoutedEventArgs e)
        {
            numIngredients++;
            TextBox newTxtBox = new TextBox();

            newTxtBox.Name   = "Ingredient" + numIngredients;
            newTxtBox.Margin = new Thickness(10, 0, 0, 0);
            if (!flagColumn)
            {
                newTxtBox.SetValue(Grid.RowProperty, addImage.GetValue(Grid.RowProperty));
                newTxtBox.SetValue(Grid.ColumnProperty, 0);
                IngredientsGrid.RowDefinitions.Add(new RowDefinition());
                addImage.SetValue(Grid.RowProperty, ((int)addImage.GetValue(Grid.RowProperty) + 1));
            }
            else
            {
                newTxtBox.SetValue(Grid.RowProperty, lastRow);
                newTxtBox.SetValue(Grid.ColumnProperty, 1);
                lastRow++;
            }
            IngredientsGrid.Children.Remove(addImage);
            IngredientsGrid.UpdateLayout();
            IngredientsGrid.Children.Add(newTxtBox);
            IngredientsGrid.UpdateLayout();
            IngredientsGrid.Children.Add(addImage);
            IngredientsGrid.UpdateLayout();
            IngredientsPanel.UpdateLayout();
            numberTxtBox++;
            if (numberTxtBox % 4 == 0)
            {
                flagColumn = !flagColumn;
            }
            // IngredientsPanel.Children.Add(addImage);
        }
Exemple #4
0
        public void Ingredients()
        {
            List <String[]> ingredients = Model.recipe.ingredients;

            IngredientsQty.Children.Clear();
            IngredientsName.Children.Clear();
            foreach (string[] ingredientPair in ingredients)
            {
                Button qty  = new Button();
                Button name = new Button();
                Style  thin = this.FindResource("ButtonThin") as Style;
                qty.Style    = thin;
                name.Style   = thin;
                qty.Click   += new RoutedEventHandler(Btn_Ingredient);
                name.Click  += new RoutedEventHandler(Btn_Ingredient);
                qty.Tag      = ingredientPair[1]; //associate name with object
                name.Tag     = ingredientPair[1]; //associate name with object
                name.Content = ingredientPair[1];
                qty.Content  = " " + ingredientPair[0];
                IngredientsQty.Children.Add(qty);
                IngredientsName.Children.Add(name);
            }
            IngredientsGrid.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
            double col0_width = (IngredientsGrid.Children[0]).DesiredSize.Width;
            double col2_width = (IngredientsGrid.Children[2]).DesiredSize.Width;

            for (int i = 0; i < IngredientsName.Children.Count; i++)
            {
                Button name = (Button)IngredientsName.Children[i];
                Button qty  = (Button)IngredientsQty.Children[i];

                name.MaxWidth = col2_width * .9;
                qty.Width     = col0_width + 5;
                name.Measure(new Size(col2_width, double.PositiveInfinity));
                TextBlock text = new TextBlock
                {
                    FontSize     = 24,
                    MaxWidth     = col2_width * .85,
                    Text         = name.Content.ToString(),
                    TextWrapping = TextWrapping.Wrap,
                    //Height = Double.NaN
                };
                name.Content = text;
                text.Measure(new Size(col2_width, double.PositiveInfinity));
                name.Height = text.DesiredSize.Height + 5;
                qty.Height  = name.Height;
                name.Measure(new Size(col2_width, double.PositiveInfinity));
            }
        }
Exemple #5
0
        private void addImage_Tapped(object sender, TappedRoutedEventArgs e)
        {
            numIngredients++;
            TextBox newTxtBox = new TextBox();

            newTxtBox.Name   = "AIngredient" + numIngredients;
            newTxtBox.Margin = new Thickness(10, 0, 0, 0);
            newTxtBox.SetValue(Grid.RowProperty, addImage.GetValue(Grid.RowProperty));
            newTxtBox.SetValue(Grid.ColumnProperty, 0);
            IngredientsGrid.RowDefinitions.Add(new RowDefinition());
            addImage.SetValue(Grid.RowProperty, ((int)addImage.GetValue(Grid.RowProperty) + 1));
            IngredientsGrid.Children.Remove(addImage);
            IngredientsGrid.UpdateLayout();
            IngredientsGrid.Children.Add(newTxtBox);
            IngredientsGrid.UpdateLayout();
            IngredientsGrid.Children.Add(addImage);
            IngredientsGrid.UpdateLayout();
            IngredientsPanel.UpdateLayout();
        }
 private void DeselectFoodIngredient(object sender, DataGridViewBindingCompleteEventArgs e)
 {
     IngredientsGrid.ClearSelection();
 }