Esempio n. 1
0
        private void cbCategory_SelectedIndexChanged(object sender, EventArgs e)
        {
            int      id = 0;
            ComboBox cb = sender as ComboBox;

            if (cb.SelectedItem == null)
            {
                return;
            }

            DTO.Category selected = cb.SelectedItem as DTO.Category;
            id = selected.ID;

            LoadFoodListCategoryID(id);
        }
Esempio n. 2
0
 private void txtFoodID_TextChanged(object sender, EventArgs e)
 {
     if (dtgvFood.SelectedCells.Count > 0)
     {
         int          id       = (int)dtgvFood.SelectedCells[0].OwningRow.Cells["CategoryID"].Value;
         DTO.Category category = DAO.CategoryDAO.Instance.GetCategoryByID(id);
         cbCategory.SelectedItem = category;
         int index = -1;
         int i     = 0;
         foreach (DTO.Category item in cbCategory.Items)
         {
             if (item.ID == category.ID)
             {
                 index = i;
                 break;
             }
             i++;
         }
         cbCategory.SelectedIndex = index;
     }
 }