Beispiel #1
0
        private void CBoxKeyWord_TextChanged(object sender, EventArgs e)
        {
            ComboBox cb           = sender as ComboBox;
            string   InputKeyword = cb.Text;

            if (InputKeyword == "")
            {
                return;
            }
            MealDTO Mdto = mBll.GetMeals(InputKeyword);

            if (Mdto.Meals.Count == 0)
            {
                return;
            }
            foreach (var m in Mdto.Meals)
            {
                cb.Items.Add(m);
                cb.DisplayMember = "Name";
                cb.ValueMember   = "ID";
            }

            cb.DroppedDown = true;
            cb.Text        = "";
        }
        public void ShowMeals()
        {
            bll = new MealBLL();
            if(isSearch) dto = bll.GetMeals(keyword);
            else dto = bll.GetMeals();

            //dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;

            dataGridView1.DataSource = dto.Meals;
            dataGridView1.Columns["ID"].HeaderText = "餐點編號";
            dataGridView1.Columns["Name"].HeaderText = "餐點名稱";
            dataGridView1.Columns["Calories"].HeaderText = "卡路里";
            dataGridView1.Columns["Image"].Visible = false;
            dataGridView1.Columns["Nutrient"].Visible = false;
            dataGridView1.Columns["NutrientID"].HeaderText = "營養ID";
            dataGridView1.Columns["Fat"].Visible = false;
            dataGridView1.Columns["Protein"].Visible = false;
            dataGridView1.Columns["Carbs"].Visible = false;
            dataGridView1.Columns["Sugar"].Visible = false;
            dataGridView1.Columns["VitA"].Visible = false;
            dataGridView1.Columns["VitB"].Visible = false;
            dataGridView1.Columns["VitC"].Visible = false;
            dataGridView1.Columns["VitD"].Visible = false;
            dataGridView1.Columns["VitE"].Visible = false;
            dataGridView1.Columns["Na"].Visible = false;
            dataGridView1.Columns["K"].Visible = false;
            if (dataGridView2.DataSource != null)
            {
                dataGridView2.Columns["ID"].HeaderText = "標籤編號";
                dataGridView2.Columns["Name"].HeaderText = "標籤名稱";
            }
            isSearch = false;
        }
Beispiel #3
0
        public void ShowNutrient()
        {
            NutrientDTO   Nutdto = new NutrientDTO();
            MealDTO       dto    = new MealDTO();
            MealDetailDTO MDdto  = new MealDetailDTO();

            //dto = mbll.GetMeals();
            if (isSearch)
            {
                dto = mbll.GetMeals(keyword);
            }
            else
            {
                dto = mbll.GetMeals();
            }

            dataGridView1.DataSource = dto.Meals;
            dataGridView1.Columns["ID"].HeaderText         = "餐點編號";
            dataGridView1.Columns["Name"].HeaderText       = "食物名稱";
            dataGridView1.Columns["Calories"].HeaderText   = "卡路里";
            dataGridView1.Columns["Nutrient"].Visible      = false;
            dataGridView1.Columns["Image"].Visible         = false;
            dataGridView1.Columns["NutrientID"].HeaderText = "營養編號";
            dataGridView1.Columns["Fat"].HeaderText        = "脂肪";
            dataGridView1.Columns["Protein"].HeaderText    = "蛋白質";
            dataGridView1.Columns["Carbs"].HeaderText      = "碳水化合物";
            dataGridView1.Columns["Sugar"].HeaderText      = "醣";
            dataGridView1.Columns["VitA"].HeaderText       = "維生素A";
            dataGridView1.Columns["VitB"].HeaderText       = "維生素B";
            dataGridView1.Columns["VitC"].HeaderText       = "維生素C";
            dataGridView1.Columns["VitD"].HeaderText       = "維生素D";
            dataGridView1.Columns["VitE"].HeaderText       = "維生素E";
            dataGridView1.Columns["Na"].HeaderText         = "鈉";
            dataGridView1.Columns["K"].HeaderText          = "鉀";
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            
            DialogResult result = MessageBox.Show("你確定欲刪除該餐點 " + detail.Name + " ?" , "警告", MessageBoxButtons.YesNo);
            

            if (result == DialogResult.Yes)
            {
               
                if (bll.HasTags(detail.ID))
                {
                    bll.RemoveTags(detail.ID); // Delete tags first.
                    
                    MessageBox.Show("附帶餐點標籤已刪除");
                }
                 
                if (bll.Delete(detail.ID)) // Then delete meals.
                {
                    nbll.Delete(detail.NutrientID);
                    MessageBox.Show("餐點已刪除");
                    bll = new MealBLL();
                    dto = bll.GetMeals();
                    
                    ShowMeals();
                    this.textBox1.Clear();
                }
                
                
            }
        }
 private void LoadComboBox()
 {
     mealDTO                = mealBLL.GetMeals();
     cmbMeals.DataSource    = mealDTO.Meals;
     cmbMeals.DisplayMember = "Name";
     cmbMeals.ValueMember   = "ID";
 }
 private void btnTag_Click(object sender, EventArgs e)
 {
     BSFrmTag frm = new BSFrmTag();
     this.Hide();
     frm.ShowDialog();
     this.Visible = true;
     bll = new MealBLL();
     dto = bll.GetMeals();
     ShowMeals();
 }
 private void LoadComboBox()
 {
     categoryDTO.CommentCategories = categoryBLL.GetCommentCategories();
     cmbCategory.DataSource        = categoryDTO.CommentCategories;
     cmbCategory.DisplayMember     = "Name";
     cmbCategory.ValueMember       = "ID";
     mealDTO                = mealBLL.GetMeals();
     cmbMeals.DataSource    = mealDTO.Meals;
     cmbMeals.DisplayMember = "Name";
     cmbMeals.ValueMember   = "ID";
 }
Beispiel #8
0
 public void ShowMeals()
 {
     bll = new MealBLL();
     if (isSearch)
     {
         dto = bll.GetMeals(keyword);
     }
     else
     {
         dto = bll.GetMeals();
     }
     dataGridView1.DataSource = dto.Meals;
     dataGridView1.Columns["ID"].HeaderText       = "餐點編號";
     dataGridView1.Columns["Name"].HeaderText     = "餐點名稱";
     dataGridView1.Columns["Calories"].HeaderText = "卡路里";
     if (dataGridView2.DataSource != null)
     {
         dataGridView2.Columns["ID"].HeaderText   = "標籤編號";
         dataGridView2.Columns["Name"].HeaderText = "標籤名稱";
     }
     isSearch = false;
 }