private void loadAccountBtn_Click(object sender, EventArgs e) { FoodRepository accRepo = new FoodRepository(); List <Food> accList = accRepo.GetAllFoods(); this.FoodGridView.DataSource = accList; }
private void button2_Click(object sender, EventArgs e) { // this.panel1.Hide(); FoodRepository f = new FoodRepository(); this.dataGridView1.DataSource = f.GetAllFoods(); }
public void TestGetAllFood() { using (var context = new FoodContext(ContextOptions)) { var repo = new FoodRepository(context); repo.CreateFood(new Food { Calories = 300, Carbohydrates = 34, Fats = 33, Name = "Chocolate", Protein = 5 }); Assert.Single(repo.GetAllFoods()); repo.Dispose(); } }
private void button1_Click(object sender, EventArgs e) { FoodRepository accRepo = new FoodRepository(); List <Food> accList = accRepo.GetAllFoods(); this.dataGridView1.DataSource = accList; SqlConnection cs = new SqlConnection(@"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename =C:\Users\ra_sh\OneDrive\C#\Pro\pro v2\RestuarantManagementSystemForm\RestuarantManagementSystemRepo\RMSDB.mdf; Integrated Security = True"); SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM FoodTable", cs); DataTable dt = new DataTable(); da.Fill(dt); for (int i = 0; i < dt.Rows.Count; i++) { comboBox1.Items.Add(dt.Rows[i]["FoodName"]); } }