void LoadTaiXe(ComboBox cb) { BUS_TaiXe bus_TaiXe = new BUS_TaiXe(); cb.DataSource = bus_TaiXe.getTaiXeCbb(); cb.DisplayMember = "ID_TaiXe"; }
private void dgvChuyen_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (dgvChuyen.SelectedCells.Count > 0) { int id_TaiXe = (int)dgvChuyen.SelectedCells[0].OwningRow.Cells["Tai_xe_ID_Taixe"].Value; int id_Xe = (int)dgvChuyen.SelectedCells[0].OwningRow.Cells["Xe_XeID"].Value; int id_Tuyen = (int)dgvChuyen.SelectedCells[0].OwningRow.Cells["Tuyen_ID_Tuyen"].Value; BUS_TuyenXe busTuyenXe = new BUS_TuyenXe(); BUS_Xe busxe = new BUS_Xe(); BUS_TaiXe bustaixe = new BUS_TaiXe(); TuyenXe tuyenXe = busTuyenXe.getTuyenXeByID(id_Tuyen); Xe xe = busxe.getXeByID(id_Xe); TaiXe taixe = bustaixe.getTaiXeByID(id_TaiXe); cbbTenTuyen.SelectedItem = tuyenXe; cbbxe.SelectedItem = xe; cbbTaiXe.SelectedItem = taixe; int index = -1, index1 = -1, index2 = -1; int i = 0, j = 0, k = 0; foreach (TuyenXe item in cbbTenTuyen.Items) { if (item.ID == tuyenXe.ID) { index = i; break; } i++; } foreach (Xe item in cbbxe.Items) { if (item.ID == xe.ID) { index = j; break; } j++; } foreach (TaiXe item in cbbTaiXe.Items) { if (item.ID == taixe.ID) { index = k; break; } k++; } cbbTenTuyen.SelectedIndex = index; cbbxe.SelectedIndex = index1; cbbTaiXe.SelectedIndex = index2; } } catch { } }
private void textBox1_TextChanged(object sender, EventArgs e) { BUS_TaiXe tx = new BUS_TaiXe(); if (string.IsNullOrEmpty(txtTraCuu.Text)) { dgvTraCuu.DataSource = tx.LoadTaiXe(); } else { dgvTraCuu.DataSource = tx.TimTaiXe(txtTraCuu.Text); } }
private void btnThem_Click(object sender, EventArgs e) { if (KTRONG() == false) { return; } else { TaiXe tai_xe = new TaiXe(); tai_xe.id_taixe = txtId.Text; tai_xe.tentaixe = txtHT.Text; tai_xe.banglai = txtBL.Text; BUS_TaiXe busTx = new BUS_TaiXe(); if (txtId.Enabled == true) { if (busTx.ThemTaiXe(tai_xe) == 1) { FormTaiXe qltx = new FormTaiXe(); busTx.LoadTaiXe(); this.Close(); } else if (busTx.ThemTaiXe(tai_xe) == -1) { MessageBox.Show("Không Được Trùng ID"); return; } else { MessageBox.Show("Không Thêm Được"); return; } } else { if (busTx.SuaTaiXe(tai_xe) == 1) { FormQLXe qlXe = new FormQLXe(); qlXe.LoadQLXe(); this.Close(); } else { MessageBox.Show("Không Sửa Được"); return; } } txtId.Enabled = true; } }
private void btnXoaTaiXe_Click(object sender, EventArgs e) { BUS_TaiXe bus_TaiXe = new BUS_TaiXe(); int id = (int)dgvTaiXe.SelectedCells[0].OwningRow.Cells["ID_TaiXe"].Value; if (bus_TaiXe.DeleteTaiXe(id)) { MessageBox.Show("Xóa TaiXe thành công"); LoadDSTaiXe(); if (deleteTaiXe != null) { deleteTaiXe(this, new EventArgs()); } } else { MessageBox.Show("Có lỗi khi xóa TaiXe"); } }
private void btnXoa_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(IDDangChon)) { MessageBox.Show("Click Vào Dòng muốn Xoá"); return; } BUS_TaiXe tx = new BUS_TaiXe(); if (tx.XoaTaiXe(IDDangChon) == 1) { MessageBox.Show("Xoa Thanh Cong"); LoadQLTX(); } else { MessageBox.Show("Không Xoá Được"); } }
private void btnSuaTaiXe_Click(object sender, EventArgs e) { BUS_TaiXe bus_TaiXe = new BUS_TaiXe(); TaiXe tx = new TaiXe(); tx.ID = int.Parse(txtIDTaiXe.Text); tx.Ten = txtTenTaiXe.Text.ToString(); tx.BangLai = txtBangLai.Text.ToString(); if (bus_TaiXe.UpdateTaiXe(tx)) { MessageBox.Show("Cập nhật TaiXe thành công"); LoadDSTaiXe(); if (updateTaiXe != null) { updateTaiXe(this, new EventArgs()); } } else { MessageBox.Show("Có lỗi khi Cập nhật TaiXe"); } }
private void btnThemTaiXe_Click(object sender, EventArgs e) { BUS_TaiXe bus_TaiXe = new BUS_TaiXe(); TaiXe tx = new TaiXe(); tx.Ten = txtTenTaiXe.Text.ToString(); tx.BangLai = txtBangLai.Text.ToString(); if (bus_TaiXe.InsertTaiXe(tx)) { MessageBox.Show("Thêm Tài xế thành công"); LoadDSTaiXe(); if (insertTaiXe != null) { insertTaiXe(this, new EventArgs()); } } else { MessageBox.Show("Có lỗi khi thêm TaiXe"); } }
private void frmHOTRO_TaiXe_Load(object sender, EventArgs e) { BUS_TaiXe tx = new BUS_TaiXe(); dgvTraCuu.DataSource = tx.LoadTaiXe(); }
void LoadDSTaiXe() { BUS_TaiXe bus_TaiXe = new BUS_TaiXe(); DSTaiXe.DataSource = bus_TaiXe.getTaiXe(); }
public void LoadQLTX() { BUS_TaiXe tai_xe = new BUS_TaiXe(); dgvQLTX.DataSource = tai_xe.LoadTaiXe(); }