private void btTimXe_Click(object sender, EventArgs e) { if (txtTimBangSo.Text == "") { MessageBox.Show("Bạn chưa nhập nội dung cần tìm kiếm!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); txtTimBangSo.Focus(); } else { string tmpTx = txtTimBangSo.Text.Trim(); if (rdBangsoXe.Checked) { dgvXe.DataSource = Xe_BUS.TimXeTheoBangSo(tmpTx); } else { if (TaiXe_BUS.KiemTraMaTX_CoTonTai(tmpTx) == 0 || tmpTx.Length > 5) { MessageBox.Show("Mã tài xế không tồn tại", "Kết Quả Tìm Kiếm", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { dgvXe.DataSource = Xe_BUS.TimXeTheoMaTaiXe(tmpTx); } } } }
private void btSuaXe_Click(object sender, EventArgs e) { string tmpBienSo = dgvXe.CurrentRow.Cells[0].Value.ToString(); if (bienSo_CD != txtBienSoXe.Text) { MessageBox.Show("Bạn không thể thay đổi bảng số xe khi thực hiện sửa thông tin biển số xe!", "Thay đổi không phù hợp", MessageBoxButtons.OK, MessageBoxIcon.Information); txtBienSoXe.Focus(); txtBienSoXe.Text = bienSo_CD; } else { if (TaiXe_BUS.KiemTraMaTX_CoTonTai(txtMaTaiXe.Text.Trim()) == 0) { MessageBox.Show("Mã tài xế không tồn tại! Vui lòng thử lại.", "Lỗi nhập liệu", MessageBoxButtons.OK, MessageBoxIcon.Information); txtMaTaiXe.Focus(); } else { Xe_DTO xe = new Xe_DTO(txtBienSoXe.Text.Trim(), txtMaTaiXe.Text.Trim(), cbMaLoaiXe.SelectedValue.ToString()); if (MessageBox.Show("Bạn có chắc chắn muốn sửa thông tin xe biển số " + tmpBienSo + "?", "Xác nhận sửa thong tin xe", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Xe_BUS.SuaThongTinXe(xe); } LoadDataXe(); } } }
private void FormCacChuyenDiCuaTX_Load(object sender, EventArgs e) { try { dgvChuyenDiTX.DataSource = TaiXe_BUS.LayDanhSachChuyenXeTX(MainForm.tempMaTX); } catch (Exception ex) { throw ex; } }
private void btnTim_Click(object sender, EventArgs e) { if (txtTimKiem.Text == "") { MessageBox.Show("Bạn chưa nhập nội dung cần tìm kiếm!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); txtTimKiem.Focus(); } else { string TX = txtTimKiem.Text.Trim(); if (rdMaNV.Checked) { if (TaiXe_BUS.KiemTraMaTX_CoTonTai(TX) == 0 || TX.Length > 5) { MessageBox.Show("Mã Tài Xế không tồn tại.", "Kết Qủa Tìm Kiếm", MessageBoxButtons.OK, MessageBoxIcon.Information); txtTimKiem.Focus(); } else { dgvTX.DataSource = TaiXe_BUS.TimTheoMaTaiXe(TX); } } else { if (TX.Contains(" ")) { if (TaiXe_BUS.KiemTraFullnameTX(TX) == 0) { MessageBox.Show("Tên Tài Xế không tồn tại.", "Kết Qủa Tìm Kiếm", MessageBoxButtons.OK, MessageBoxIcon.Information); txtTimKiem.Focus(); } else { dgvTX.DataSource = TaiXe_BUS.TimKiemTX_Fullname(TX); } } else { if (TaiXe_BUS.KiemTraTenTX_CoTonTai(TX) == 0) { MessageBox.Show("Tên Tài Xế không tồn tại.", "Kết Qủa Tìm Kiếm", MessageBoxButtons.OK, MessageBoxIcon.Information); txtTimKiem.Focus(); } else { dgvTX.DataSource = TaiXe_BUS.TimTheoTenTaiXe(TX); } } } } }
private void btnXoa_Click(object sender, EventArgs e) { if (TaiXe_BUS.KiemTraMaTX_CoTonTai(txtMaTX.Text) == 0) { MessageBox.Show("Mã Tài Xế không tồn tại.", "Thông Báo Kết Qủa", MessageBoxButtons.OK, MessageBoxIcon.Information); txtMaTX.Focus(); } else { if (TaiXe_BUS.KiemTraTX_CoXe(txtMaTX.Text) == 1) { MessageBox.Show("Không thể xóa Tài Xế này do có ràng buộc dữ liệu giữa Tài Xế và Xe.", "Thông Báo Kết Qủa", MessageBoxButtons.OK, MessageBoxIcon.Information); txtMaTX.Focus(); } else { TaiXe_BUS.XoaTaiXe(txtMaTX.Text); LoadDataTX(); } } }
/// <summary> /// Phần code lập trình cho tab Tài Xế /// </summary> public void LoadDataTX() { txtTimKiem.Text = ""; dgvTX.DataSource = TaiXe_BUS.LoadDanhSachTatCaTaiXe(); }
private void btnSua_Click(object sender, EventArgs e) { if (tempMaTX != txtMaTX.Text) { MessageBox.Show("Bạn không được thay đồi mã Tài Xế khi thực hiện sữa thông tin Tài Xế.", "Thông Báo Không Hợp Lệ", MessageBoxButtons.OK, MessageBoxIcon.Information); txtMaTX.Focus(); txtMaTX.Text = tempMaTX; } else { if (txtHoTX.Text == "") { MessageBox.Show("Bạn chưa nhập họ tài xế", "Thiếu Thông Tin Tài Xế", MessageBoxButtons.OK, MessageBoxIcon.Information); txtHoTX.Focus(); } else { if (txtTenTX.Text == "") { MessageBox.Show("Bạn chưa nhập tên tài xế", "Thiếu Thông Tin Tài Xế", MessageBoxButtons.OK, MessageBoxIcon.Information); txtTenTX.Focus(); } else { if (txtCMND.Text == "") { MessageBox.Show("Bạn chưa nhập CMND tài xế", "Thiếu Thông Tin Tài Xế", MessageBoxButtons.OK, MessageBoxIcon.Information); txtCMND.Focus(); } else { if (txtNgaySinh.Text == "") { MessageBox.Show("Bạn chưa nhập ngày sinh tài xế", "Thiếu Thông Tin Tài Xế", MessageBoxButtons.OK, MessageBoxIcon.Information); txtNgaySinh.Focus(); } else { if (txtDienThoai.Text == "") { MessageBox.Show("Bạn chưa nhập số điện thoại của tài xế", "Thiếu Thông Tin Tài Xế", MessageBoxButtons.OK, MessageBoxIcon.Information); txtDienThoai.Focus(); } else { try { Convert.ToInt16(txtMaTX.Text.Substring(2)); Convert.ToInt64(txtCMND.Text); Convert.ToDateTime(txtNgaySinh.Text); Convert.ToInt64(txtDienThoai.Text); TaiXe_DTO TX = new TaiXe_DTO(txtMaTX.Text.Trim(), txtHoTX.Text.Trim(), txtTenTX.Text.Trim(), txtCMND.Text.Trim(), txtNgaySinh.Text.Trim(), txtDienThoai.Text.Trim()); TaiXe_BUS.SuaTaiXe(TX); LoadDataTX(); } catch (FormatException ex) { MessageBox.Show("Nhập thông tin Tài xế sai kiểu dữ liệu", "Sai Thông Tin Tài Xế", MessageBoxButtons.OK, MessageBoxIcon.Information); txtMaTX.Focus(); } } } } } } }// }
private void btnThem_Click(object sender, EventArgs e) { if (txtMaTX.Text == "") { MessageBox.Show("Bạn chưa nhập mã tài xế", "Thiếu Thông Tin Tài Xế", MessageBoxButtons.OK, MessageBoxIcon.Information); txtMaTX.Focus(); } else { if (txtHoTX.Text == "") { MessageBox.Show("Bạn chưa nhập họ tài xế", "Thiếu Thông Tin Tài Xế", MessageBoxButtons.OK, MessageBoxIcon.Information); txtHoTX.Focus(); } else { if (txtTenTX.Text == "") { MessageBox.Show("Bạn chưa nhập tên tài xế", "Thiếu Thông Tin Tài Xế", MessageBoxButtons.OK, MessageBoxIcon.Information); txtTenTX.Focus(); } else { if (txtCMND.Text == "") { MessageBox.Show("Bạn chưa nhập CMND tài xế", "Thiếu Thông Tin Tài Xế", MessageBoxButtons.OK, MessageBoxIcon.Information); txtCMND.Focus(); } else { if (txtNgaySinh.Text == "") { MessageBox.Show("Bạn chưa nhập ngày sinh tài xế", "Thiếu Thông Tin Tài Xế", MessageBoxButtons.OK, MessageBoxIcon.Information); txtNgaySinh.Focus(); } else { if (txtDienThoai.Text == "") { MessageBox.Show("Bạn chưa nhập số điện thoại của tài xế", "Thiếu Thông Tin Tài Xế", MessageBoxButtons.OK, MessageBoxIcon.Information); txtDienThoai.Focus(); } else { try { Convert.ToInt16(txtMaTX.Text.Substring(2)); Convert.ToInt64(txtCMND.Text); Convert.ToDateTime(txtNgaySinh.Text); Convert.ToInt64(txtDienThoai.Text); if (txtMaTX.Text.Substring(0, 2).ToString() != "TX") { MessageBox.Show("Mã tài xế không hợp lệ. Bạn phải nhập là TXxxx. Ví dụ:TX000", "Sai Thông Tin Tài Xế", MessageBoxButtons.OK, MessageBoxIcon.Information); txtMaTX.Focus(); } else { if (TaiXe_BUS.KiemTraMaTX_CoTonTai(txtMaTX.Text.Trim()) == 1) { MessageBox.Show("Mã tài xế đã tồn tại", "Thông Tin Tài Xế Không Hợp Lệ", MessageBoxButtons.OK, MessageBoxIcon.Information); txtMaTX.Focus(); } else { TaiXe_DTO TX = new TaiXe_DTO(txtMaTX.Text.Trim(), txtHoTX.Text.Trim(), txtTenTX.Text.Trim(), txtCMND.Text.Trim(), txtNgaySinh.Text.Trim(), txtDienThoai.Text.Trim()); TaiXe_BUS.ThemTaiXeMoi(TX); LoadDataTX(); } } } catch (FormatException ex) { MessageBox.Show("Nhập thông tin Tài xế sai kiểu dữ liệu", "Sai Thông Tin Tài Xế", MessageBoxButtons.OK, MessageBoxIcon.Information); txtMaTX.Focus(); } } } } } } }// }