/* Hàm load dữ liệu lớp lên CBB */ void GetCBB_Lop() { string query = "SELECT ma_lop, ten_lop FROM LOP"; DB.conn.Open(); SqlCommand cmd = new SqlCommand(query, DB.conn); SqlDataReader rd = cmd.ExecuteReader(); LopDic = new Dictionary <string, CLop>(); while (rd.Read()) { CLop l = new CLop(rd[0].ToString(), rd[1].ToString()); cbbLop.Items.Add(l); LopDic[l.Ma_lop] = l; } DB.conn.Close(); }
//Lấy dữ liệu cho combobox lớp void Get_lop() { cbbLop.DisplayMember = "Ma_lop"; cbbLop.ValueMember = "Ten_lop"; string query = "SELECT ma_lop,ten_lop FROM LOP"; DB.conn.Open(); SqlCommand cmd = new SqlCommand(query, DB.conn); SqlDataReader rd = cmd.ExecuteReader(); LopDic = new Dictionary <string, CLop>(); while (rd.Read()) { CLop gt = new CLop(rd[0].ToString(), rd[1].ToString()); cbbLop.Items.Add(gt.Ten_lop); LopDic[gt.Ma_lop] = gt; } DB.conn.Close(); }