public List <Cafeteria> ViewAllCafeteria() { List <Cafeteria> cafeterias = new List <Cafeteria>(); //MySqlDataAdapter 클래스를 이용하여 비연결 모드로 데이터 가져오기 DataSet ds = new DataSet(); //string sql = "SELECT * FROM Cafeteria"; string sql = "SELECT * FROM Cafe"; MySqlDataAdapter adpt = new MySqlDataAdapter(sql, conn); adpt.Fill(ds, "Cafeteria"); foreach (DataRow row in ds.Tables[0].Rows) { Cafeteria cafe = new Cafeteria((string)row[0], (string)row[1], (string)row[2], (string)row[3], (string)row[4]); cafeterias.Add(cafe); } return(cafeterias); }
public Cafeteria GetCafeteria(string primaryKey) { DataSet ds = new DataSet(); string sql = string.Format("SELECT * FROM Menu WHERE ID={0}", primaryKey); // View Cafe 불러옴 MySqlDataAdapter adpt = new MySqlDataAdapter(sql, conn); adpt.Fill(ds, "Menu"); List <string> menuList = new List <string>(); string pk = ""; foreach (DataRow row in ds.Tables[0].Rows) { pk = (string)row[0]; string menu = (string)row[1] + (string)row[2]; menuList.Add(menu); } Cafeteria cafe = new Cafeteria(pk, menuList); return(cafe); }
private void btn_cafeteriaAllMenu_Click(object sender, EventArgs e) { Cafeteria cafe = dbm.GetCafeteria(tb_cafeteriaPK.Text); }