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 btnCapNhat_Click(object sender, EventArgs e) { try { Xe_DTO xe = new Xe_DTO(txtIDXe.Text, txtHangSX.Text, txtLoaiXe.Text, txtGiaThue.Text, txtGhiChu.Text, txtTrangThai.Text); BUS.SuaXe(xe); dgvXe.DataSource = BUS.GetDataXe(); MessageBox.Show("Đã cập nhật thành công!"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public Boolean SuaXe(Xe_DTO xe) { try { if (xe.IDXe == "") { throw new Exception("Field \"IDXe\" không thể trống."); } return(new Xe_DAL().SuaXe(xe)); } catch (Exception ex) { throw ex; } }
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); } } } }
public static void SuaKhachThongTinXe(Xe_DTO xe) { try { SqlConnection cnn = SQLconnectionData.HamKetNoi(); SqlCommand cmd = new SqlCommand("SuaThongTinXe", cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@BienSoXe", xe.BienSoXe); cmd.Parameters.AddWithValue("@MaLoaiXe", xe.MaLoaiXe); cmd.Parameters.AddWithValue("@MaTaiXe", xe.MaTaiXe); cnn.Open(); cmd.ExecuteNonQuery(); cnn.Close(); } catch (Exception ex) { throw ex; } }
public static void SuaThongTinXe(Xe_DTO xe) { Xe_DAO.SuaKhachThongTinXe(xe); }
public static void ThemXeMoi(Xe_DTO xe) { Xe_DAO.ThemXeMoi(xe); }
public Boolean SuaXe(Xe_DTO xe) { return(new ExecuteDB().ExecuteData("update Xe set HangSX = N'" + xe.HangSX + "', LoaiXe = N'" + xe.LoaiXe + "', GiaThue = '" + xe.GiaThue + "',GhiChu = N'" + xe.GhiChu + "',TrangThai = '" + xe.TinhTrang + "' where IDXe = N'" + xe.IDXe + "'")); }
public Boolean ThemXe(Xe_DTO xe) { return(new ExecuteDB().ExecuteData("INSERT INTO Xe values (N'" + xe.IDXe + "', N'" + xe.HangSX + "', N'" + xe.LoaiXe + "', '" + xe.GiaThue + "', N'" + xe.GhiChu + "', N'" + xe.TinhTrang + "')")); }