public void xemdulieu() { BUL_HanhKhach bUL_HanhKhach = new BUL_HanhKhach(); dGVtraCuuHK.DataSource = bUL_HanhKhach.getHK(); dGVtraCuuHK.Refresh(); dGVtraCuuHK.Columns[0].HeaderText = "Mã hành khách"; dGVtraCuuHK.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; dGVtraCuuHK.Columns[1].HeaderText = "Tên hành khách"; dGVtraCuuHK.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; dGVtraCuuHK.Columns[2].HeaderText = "CMND"; dGVtraCuuHK.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; dGVtraCuuHK.Columns[3].HeaderText = "Điện thoại"; dGVtraCuuHK.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; }
private void btnXacNhan_Click(object sender, EventArgs e) { BUL_HanhKhach bUL_HanhKhach = new BUL_HanhKhach(); if (txtMaHK.Text != "" && txtTenHK.Text != "" && txtCMND.Text != "") { HanhKhach hk = new HanhKhach(txtMaHK.Text, txtTenHK.Text, txtCMND.Text, txtDienThoai.Text); if (bUL_HanhKhach.themHanhKhach(hk)) { MessageBox.Show("Thêm thành công"); dGVhanhKhach.DataSource = bUL_HanhKhach.getHK(); // refresh datagridview } else { MessageBox.Show("Đã có lỗi xảy ra", "Lỗi"); } } else { MessageBox.Show("Xin hãy nhập đầy đủ"); } }