private void frm_Khoa_Load(object sender, EventArgs e) { load_data(); List<how_to_search> dt_source = new List<how_to_search>(); dt_source.Add(new how_to_search("Mã khoa", "makhoa")); dt_source.Add(new how_to_search("Tên khoa", "tenkhoa")); dt_source.Add(new how_to_search("Địa chỉ", "diachi")); dt_source.Add(new how_to_search("Điện thoại", "dienthoai")); cbx_option_search.DataSource = dt_source; cbx_option_search.DisplayMember = "value"; cbx_option_search.ValueMember = "key"; cbx_option_search.SelectedIndex = 1; current_page = 1; // constructed value for current_pages Update_dtg_data(); set_btn_paging(); }
private void frm_Mon_Load(object sender, EventArgs e) { load_data(); List<how_to_search> dt_source = new List<how_to_search>(); dt_source.Add(new how_to_search("Mã môn", "mamon")); dt_source.Add(new how_to_search("Tên môn", "tenmon")); cbx_option_search.DataSource = dt_source; cbx_option_search.DisplayMember = "value"; cbx_option_search.ValueMember = "key"; cbx_option_search.SelectedIndex = 1; }
private void txt_timkiem_TextChanged(object sender, EventArgs e) { var select_cbx = cbx_option_search.SelectedValue.ToString(); var temp = cl.selectByFieldsSinhVien(txt_timkiem.Text, select_cbx); switch (temp.errorCode) { case QLKhoa_ServiceReference.ErrorCode.Sucess: dtgv_khoa.DataSource = temp.data; used_for_headerclick_dtgv = temp.data.ToList(); Utils.chang_title_datagridViewCellSinhVien(dtgv_khoa); break; case QLKhoa_ServiceReference.ErrorCode.False: dtgv_khoa.DataSource = temp.data; if (Utils.switch_false()) { MessageBox.Show(temp.errorInfor); } break; case QLKhoa_ServiceReference.ErrorCode.NaN: dtgv_khoa.DataSource = temp.data; break; default: break; } }
// update data for datagridview private void load_data() { dtgv_khoa.ForeColor = System.Drawing.Color.Black; var temp = cl.selectAllSinhVien(); switch (temp.errorCode) { case QLKhoa_ServiceReference.ErrorCode.Sucess: dtgv_khoa.DataSource = temp.data; used_for_headerclick_dtgv = temp.data.ToList(); // change value of makhoa to tenkhoa var dtgv = dtgv_khoa.Rows; var dt_khoa = cl.selectAllKhoa(); foreach (DataGridViewRow item in dtgv) { foreach (var item1 in dt_khoa.data) { if (item.Cells[3].Value.ToString() == item1.makhoa) { item.Cells[3].Value = item1.tenkhoa; } } } Utils.chang_title_datagridViewCellSinhVien(dtgv_khoa); break; case QLKhoa_ServiceReference.ErrorCode.False: dtgv_khoa.DataSource = temp.data; if (Utils.switch_false()) { MessageBox.Show(temp.errorInfor); } break; case QLKhoa_ServiceReference.ErrorCode.NaN: dtgv_khoa.DataSource = null; MessageBox.Show(temp.errorInfor); break; default: break; } }
private void frm_SinhVien_Load(object sender, EventArgs e) { load_data(); cbx_makhoa.AutoCompleteMode = AutoCompleteMode.SuggestAppend; cbx_makhoa.AutoCompleteSource = AutoCompleteSource.ListItems; List<how_to_search> dt_source = new List<how_to_search>(); dt_source.Add(new how_to_search("Mã SV", "masv")); dt_source.Add(new how_to_search("Tên SV", "hoten")); dt_source.Add(new how_to_search("Nơi sinh", "noisinh")); dt_source.Add(new how_to_search("Mã khoa", "makhoa")); cbx_option_search.DataSource = dt_source; cbx_option_search.DisplayMember = "value"; cbx_option_search.ValueMember = "key"; cbx_option_search.SelectedIndex = 1; var rs = cl.selectAllKhoa(); switch (rs.errorCode) { case QLKhoa_ServiceReference.ErrorCode.Sucess: cbx_makhoa.DataSource = cl.selectAllKhoa().data.ToList(); cbx_makhoa.DisplayMember = "tenkhoa"; cbx_makhoa.ValueMember = "makhoa"; cbx_makhoa.SelectedIndex = -1; break; case QLKhoa_ServiceReference.ErrorCode.False: break; case QLKhoa_ServiceReference.ErrorCode.NaN: break; default: break; } }
private void frm_Diem_Load(object sender, EventArgs e) { load_data(); List<how_to_search> temp = new List<how_to_search>(); temp.Add(new how_to_search("Mã SV", "masv")); temp.Add(new how_to_search("Tên SV", "tensv")); temp.Add(new how_to_search("Mã môn", "mamon")); temp.Add(new how_to_search("Tên môn", "tenmon")); temp.Add(new how_to_search("Điểm", "diem")); cbx_option_search.ValueMember = "key"; cbx_option_search.DisplayMember = "value"; cbx_option_search.DataSource = temp; var dt = cl.selectAllSinhVienCbx(); switch (dt.errorCode) { case QLKhoa_ServiceReference.ErrorCode.Sucess: cbx_masv.DataSource = dt.data; cbx_masv.DisplayMember = "matensv"; cbx_masv.ValueMember = "masv"; cbx_masv.SelectedIndex = -1; break; case QLKhoa_ServiceReference.ErrorCode.False: MessageBox.Show(dt.errorInfor); break; case QLKhoa_ServiceReference.ErrorCode.NaN: break; default: break; } var dt1 = cl.selectAllMon(); switch (dt1.errorCode) { case QLKhoa_ServiceReference.ErrorCode.Sucess: cbx_mamon.DataSource = dt1.data; cbx_mamon.DisplayMember = "tenmon"; cbx_mamon.ValueMember = "mamon"; cbx_mamon.SelectedIndex = -1; break; case QLKhoa_ServiceReference.ErrorCode.False: break; case QLKhoa_ServiceReference.ErrorCode.NaN: break; default: break; } }