//update data for dtgv private void load_data() { var dt = nhaxuatban_ctrl.select_all_nhaxuatban(); switch (dt.errcode) { case Models.ErrorCode.NaN: dtgv.DataSource = dt.data; break; case Models.ErrorCode.sucess: dtgv.DataSource = dt.data; Utils.chang_title_datagridViewCell(dtgv, new List <string> { "Mã NXB", "Tên NXB", "Địa chỉ", "Điện thoại" }); break; case Models.ErrorCode.fail: if (Utils.switch_false()) { MessageBox.Show(dt.errInfor); } break; default: break; } }
private void frm_capnhat_sach_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("Tên sách", "tensach")); dt_source.Add(new how_to_search("Tác giả", "tacgia")); dt_source.Add(new how_to_search("Lĩnh vực", "linhvuc")); dt_source.Add(new how_to_search("Nhà xuất bản", "nxb")); cbx_option_search.DataSource = dt_source; cbx_option_search.DisplayMember = "value"; cbx_option_search.ValueMember = "key"; tacgia_ctrl tacgia = new tacgia_ctrl(); linhvuc_ctrl linhvuc = new linhvuc_ctrl(); nhaxuatban_ctrl nxb = new nhaxuatban_ctrl(); var dt_cbx_tacgia = tacgia.select_all_tacgia(); switch (dt_cbx_tacgia.errcode) { case ErrorCode.NaN: break; case ErrorCode.sucess: cbx_tacgia.DisplayMember = "tentacgia"; cbx_tacgia.ValueMember = "matacgia"; cbx_tacgia.DataSource = dt_cbx_tacgia.data; cbx_tacgia.SelectedIndex = -1; break; case ErrorCode.fail: break; default: break; } var dt_cbx_nxb = nxb.select_all_nhaxuatban(); switch (dt_cbx_nxb.errcode) { case ErrorCode.NaN: break; case ErrorCode.sucess: cbx_nxb.DisplayMember = "tennxb"; cbx_nxb.ValueMember = "manxb"; cbx_nxb.DataSource = dt_cbx_nxb.data; cbx_nxb.SelectedIndex = -1; break; case ErrorCode.fail: break; default: break; } var dt_cbx_linhvuc = linhvuc.select_all_linhvuc(); switch (dt_cbx_linhvuc.errcode) { case ErrorCode.NaN: break; case ErrorCode.sucess: cbx_linhvuc.DisplayMember = "tenlinhvuc"; cbx_linhvuc.ValueMember = "malinhvuc"; cbx_linhvuc.DataSource = dt_cbx_linhvuc.data; cbx_linhvuc.SelectedIndex = -1; break; case ErrorCode.fail: break; default: break; } }