void LoadLoaiXe(ComboBox cb) { BUS_LoaiXe bus_loaixe = new BUS_LoaiXe(); cb.DataSource = bus_loaixe.GetLoaiXe(); cb.DisplayMember = "TenLoai"; }
private void dgvXe_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (dgvXe.SelectedCells.Count > 0) { //int id_dau = (int)dgvXe.SelectedCells[0].OwningRow.Cells["ID_TramDau"].Value; //int id_cuoi = (int)dgvXe.SelectedCells[0].OwningRow.Cells["ID_TramCuoi"].Value; int id = (int)dgvXe.SelectedCells[0].OwningRow.Cells["LoaiXe_ID_LoaiXe"].Value; BUS_LoaiXe busloaixe = new BUS_LoaiXe(); LoaiXe loaixe = busloaixe.GetLoaiXeByID(id); cbbLoaiXe.SelectedItem = loaixe; int index = -1; int i = 0; foreach (LoaiXe item in cbbLoaiXe.Items) { if (item.MaLoai == loaixe.MaLoai) { index = i; break; } i++; } cbbLoaiXe.SelectedIndex = index; if (id == 1) { txtChoNgoi.Text = "30"; } else if (id == 2) { txtChoNgoi.Text = "45"; } else { txtChoNgoi.Text = "50"; } } } catch { } }