Example #1
0
 private void cmbDishes_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cmbDishes.SelectedIndex != -1)
     {
         int i = cmbDishes.SelectedIndex;
         main = dishList[i];
     }
 }
Example #2
0
 private void revealTheDataMainCourse()
 {
     //solution link:
     #region
     //http://stackoverflow.com/questions/1346132/how-do-i-extract-data-from-a-datatable
     #endregion
     string    queryString = "SELECT * FROM MainCourse";
     DataTable dt          = GetData(queryString);
     foreach (DataRow item in dt.Rows)
     {
         var main = new MainCourse();
         main.Id    = Convert.ToInt32(item["Id"].ToString());
         main.Name  = item["MainCourseName"].ToString();
         main.Price = Convert.ToDecimal(item["Price"].ToString());
         dishList.Add(main);
     }
     cmbDishes.ValueMember   = "Id";
     cmbDishes.DisplayMember = "Name";
     cmbDishes.DataSource    = dishList;
 }
Example #3
0
        public Form1()
        {
            InitializeComponent();


            var connectionString = ConfigurationManager.ConnectionStrings["DB"].ConnectionString;

            string    queryString = "SELECT * FROM MainCourse;";
            DataTable dt          = GetData(connectionString, queryString);
            var       dishList    = new List <MainCourse>();

            foreach (DataRow item in dt.Rows)
            {
                var main = new MainCourse();
                main.Id   = Convert.ToInt32(item["Id"].ToString());
                main.Name = item["MainCourseName"].ToString();
                dishList.Add(main);
            }


            cmbDishes.ValueMember   = "Id";
            cmbDishes.DisplayMember = "Name";
            cmbDishes.DataSource    = dishList;
        }