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; }
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(); } } }
public void InputWithMultipleError() { string sample = "night,1,2,8,10,jk,,"; var sample_processed = MealBLL.ProcessRequest(sample); Assert.Equal("steak, potato, error, error", sample_processed); }
public void SimpleInvalidInput() { string sample = " "; string result = MealBLL.ProcessRequest(sample); Assert.Equal("Invalid Meal Id", result); }
public void SimpleInvalidCharacter() { string sample = "foo"; string result = MealBLL.ProcessRequest(sample); Assert.Equal("Invalid Meal Id", result); }
public void IgnoringInvalidOptions() { string sample = "night,1,2,abcde,3,4"; var sample_processed = MealBLL.ProcessRequest(sample); Assert.Equal("steak, potato, wine, cake", sample_processed); }
public void NightInput() { string sample = "night,1,2,3"; var sample_processed = MealBLL.ProcessRequest(sample); Assert.Equal("steak, potato, wine", sample_processed); }
public void NightInputWithMultiplesAndError() { string sample = "night,1,2,2,2,2,4,5"; var sample_processed = MealBLL.ProcessRequest(sample); Assert.Equal("steak, potato(x4), cake, error", sample_processed); }
public void NightInputWithMultiples() { string sample = "night,1,2,2,2,2"; var sample_processed = MealBLL.ProcessRequest(sample); Assert.Equal("steak, potato(x4)", sample_processed); }
public void MorningInput() { string sample = "morning,1,2,3"; var sample_processed = MealBLL.ProcessRequest(sample); Assert.Equal("eggs, toast, coffee", sample_processed); }
public void MorningInputWithMultiplesAndError() { string sample = "morning,1,2,3,3,3,4"; var sample_processed = MealBLL.ProcessRequest(sample); Assert.Equal("eggs, toast, coffee(x3), error", sample_processed); }
public ActionResult <string> Get(string input) { if (!string.IsNullOrEmpty(input)) { return(MealBLL.ProcessRequest(input)); } return(new HttpResponseMessage(HttpStatusCode.BadRequest).ToString()); }
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(); }
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; }