Esempio n. 1
0
        private void LoadRecipe(int SelectrecipeID)
        {
            var s = Delicious.Recipe_Table.Where(A => A.RecipeID == SelectrecipeID).Select(A => new
            {
                MemberName = Delicious.Member_Table.Where(B => B.MemberID == A.MemberID).Select(C => C.MemberName).FirstOrDefault(),
                A.PostTime,
                A.RecipeName,
                A.Picture,
                A.ForHowMany,
                A.TimeNeed,
                A.RecipeDescription,
                A.Views,
                Ingredients = Delicious.Ingredient_Record_Table.Where(E => E.RecipeID == SelectrecipeID).Select(D => new
                {
                    IngredientsName = Delicious.Ingredient_Table.Where(G => G.IngredientID == D.IngredientID).Select(H => H.Ingredient).FirstOrDefault(),
                    ForUse          = Delicious.Ingredient_Record_Table.Select(I => I.IngredientAmountForUse).FirstOrDefault(),
                    Unt             = Delicious.Ingredient_Record_Table.Select(J => J.Unt).FirstOrDefault()
                }),
                Steps = Delicious.Steps_Table.Where(K => K.RecipeID == SelectrecipeID).Select(L => new
                {
                    StepNumber = L.StepsNumber,
                    Step       = L.Steps
                })
            }).FirstOrDefault();

            if (s.Picture != null)
            {
                MemoryStream memory = new MemoryStream(s.Picture);
                pb_RecipeIMG.Image = Image.FromStream(memory);
            }
            lb_Recipename.Text        = s.RecipeName;
            lb_member.Text            = s.MemberName;
            lb_Posttime.Text          = $"{s.PostTime}";
            lb_Howmany.Text           = $"{s.ForHowMany}";
            lb_Time.Text              = $"{(s.TimeNeed / 60)}分";
            tb_RecipeDescription.Text = $"{s.RecipeDescription}";
            tb_Ingredients.Text       = "";
            foreach (var item in s.Ingredients)
            {
                tb_Ingredients.Text += $"{item.IngredientsName}{item.ForUse}{item.Unt} ";
            }
            dgv_Step.DataSource = s.Steps.ToList();
            Delicious.Recipe_Table.Single(r => r.RecipeID == SelectrecipeID).Views++;
            Delicious.SaveChanges();
            lb_View.Text = $"👁{s.Views}";

            CCustomerMsg Img = new CCustomerMsg(); //給予Picturebox拖拉

            Img.setPicturebox(pb_UploadIMG);
        }
Esempio n. 2
0
        private void LoadElement()
        {
            var RecipeCategoryName = from n in Delicious.RecipeCategory_Table
                                     select n.RecipeCategory;
            var Now = Delicious.Recipe_Table.Where(A => A.RecipeID == NowID).Select(A => A.RecipeCategory_Table.RecipeCategory).FirstOrDefault();


            this.cb_RecipeCategory.DataSource   = RecipeCategoryName.ToList(); //食譜類別欄資料
            this.cb_RecipeCategory.SelectedItem = Now;

            var IngredientCategoryName = Delicious.IngredientCategory_Table.Select(N => N.IngredientCategory);

            this.cb_IngredientCategory.DataSource   = IngredientCategoryName.ToList(); //食材類別欄
            this.cb_IngredientCategory.SelectedItem = 1;

            CCustomerMsg Img  = new CCustomerMsg();
            CCustomerMsg Img2 = new CCustomerMsg();//給予Picturebox拖拉

            Img.setPicturebox(pb_RecipeIMG);
            Img2.setPicturebox(pb_StepIMG);
        }