示例#1
0
        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();
                }
            }
        }
示例#2
0
 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);
             }
         }
     }
 }
示例#3
0
        /// <summary>
        /// Phần code lập trình cho form Quan Ly xe
        /// </summary>
        ///

        public void LoadDataXe()
        {
            txtTimBangSo.Text        = string.Empty;
            dgvXe.DataSource         = Xe_BUS.LoadDanhSachTatCaXe();
            cbMaLoaiXe.DataSource    = Xe_BUS.LoadDanhSachLoaiXe();
            cbMaLoaiXe.DisplayMember = "MaLoaiXe";
            cbMaLoaiXe.ValueMember   = "MaLoaiXe";
        }
示例#4
0
        private void btXoaXe_Click(object sender, EventArgs e)
        {
            string tmpBienSo = dgvXe.Rows[dgvXe.CurrentCell.RowIndex].Cells[0].Value.ToString();

            if (MessageBox.Show("Bạn có chắc chắn muốn xóa xe biển số " + tmpBienSo + "?", "Xác nhận xóa xe", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                Xe_BUS.XoaXe(tmpBienSo);
            }
            LoadDataXe();
        }
示例#5
0
 private void btThemXe_Click(object sender, EventArgs e)
 {
     if (txtBienSoXe.Text == "")
     {
         MessageBox.Show("Bạn chưa nhập biển số xe", "Thiếu thông tin xe", MessageBoxButtons.OK, MessageBoxIcon.Information);
         txtBienSoXe.Focus();
     }
     else
     {
         if (txtMaTaiXe.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);
             txtMaTaiXe.Focus();
         }
         else
         {
             try
             {
                 if (txtBienSoXe.Text.Substring(0, 3) != "BSX")
                 {
                     MessageBox.Show("Biển số xe không hợp lệ. Vui lòng theo mẫu BSXxx", "Sai thông tin bảng số", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     txtBienSoXe.Focus();
                 }
                 else
                 {
                     if (Xe_BUS.KiemTraBienSoXe_CoTonTai(txtBienSoXe.Text.Trim()) == 1)
                     {
                         MessageBox.Show("Biển số xe đã tồn tại, vui lòng nhập lại", "Thông tin nhập không hợp lệ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                         txtBienSoXe.Focus();
                     }
                     else
                     {
                         Xe_DTO xe = new Xe_DTO(txtBienSoXe.Text.Trim(), txtMaTaiXe.Text.Trim(), cbMaLoaiXe.SelectedValue.ToString());
                         Xe_BUS.ThemXeMoi(xe);
                         LoadDataXe();
                     }
                 }
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
         }
     }
 }