private void editSoHieuXe_Leave(object sender, EventArgs e) { string SoHieuXe = StringTools.TrimSpace(editSoHieuXe.Text); if (SoHieuXe.Length > 0) { if (!Xe.KiemTraTonTaiCuaSoHieuXe(editSoHieuXe.Text)) { g_boolValidate = false; errorProvider.SetError(editSoHieuXe, "Số hiệu xe này không tồn tại"); new MessageBox.MessageBoxBA().Show(this, "Số hiệu xe này không tồn tại", "Thông báo", Taxi.MessageBox.MessageBoxButtonsBA.OK, Taxi.MessageBox.MessageBoxIconBA.Warning); editTenLaiXe.Text = ""; editSoHieuXe.Focus(); return; } else { // KIEM TRA CO QUYEN CHO RA HOAT DONG XE 999 //if (SoHieuXe == "999") //{ // if (!ThongTinDangNhap.HasPermission("010299")) // { // g_boolValidate = false; // errorProvider.SetError(editSoHieuXe, "Bạn không có quyền cho xe 999 ra hoạt động, hoặc về."); // new MessageBox.MessageBox().Show(this, "Bạn không có quyền cho xe 999 ra hoạt động, hoặc về", "Thông báo", Taxi.MessageBox.MessageBoxButtons.OK, Taxi.MessageBox.MessageBoxIcon.Warning); // editSoHieuXe.Focus(); // } //} if (g_intTrangThai == 1)// xe bao haot dong { if (KiemSoatXeLienLac.CheckXeDangHoatDong(editSoHieuXe.Text)) { g_boolValidate = false; errorProvider.SetError(editSoHieuXe, "Xe đang hoạt động. Bạn cần kiểm tra lại."); new MessageBox.MessageBoxBA().Show(this, "Xe đang hoạt động, bạn không thể nhập lại trạng thái này", "Thông báo", Taxi.MessageBox.MessageBoxButtonsBA.OK, Taxi.MessageBox.MessageBoxIconBA.Warning); editSoHieuXe.Focus(); return; } else // lấy thông tin xe ở gara nào { Xe objXe = new Xe(); editViTriBao.Text = objXe.GetChiTietXe(editSoHieuXe.Text).GaraName; } } KiemSoatXeLienLac objKSXe = new KiemSoatXeLienLac(); objKSXe = KiemSoatXeLienLac.GetKSXe_BySoHieuXe(StringTools.TrimSpace(editSoHieuXe.Text)); if (StringTools.TrimSpace(editTenLaiXe.Text).Length <= 0) { editTenLaiXe.Text = objKSXe.MaLaiXe; } } errorProvider.SetError(editSoHieuXe, ""); } }
public bool ValidateData() { this.FindAllChildrenByType <IShInput>().ToList().Where(p => !(p is PopupBaseEdit)).ToList().ForEach(p => ((BaseEdit)p).Text = ((BaseEdit)p).Text.Trim()); SetError(""); if (string.IsNullOrEmpty(txtDienThoai.Text.Trim())) { SetError("Bạn chưa nhập số điện thoại"); txtDienThoai.Focus(); return(false); } else { Model.DienThoai = txtDienThoai.Text.Trim(); } if (string.IsNullOrEmpty(txtSoXe.Text.Trim())) { SetError("Bạn chưa nhập số xe"); txtSoXe.Focus(); return(false); } else { Model.SoXe = txtSoXe.Text.Trim(); } if (string.IsNullOrEmpty(deThoiGianDon.Text.Trim()) || deThoiGianDon.EditValue == null) { SetError("Bạn chưa nhập thời gian đón"); deThoiGianDon.Focus(); return(false); } else { if (ThoiDiemGoi >= deThoiGianDon.DateTime) { SetError("Thời gian đón lớn hơn thời gian gọi"); deThoiGianDon.Focus(); return(false); } Model.ThoiDiemDon = deThoiGianDon.DateTime; } if (string.IsNullOrEmpty(txtDiemDo.Text.Trim())) { SetError("Bạn chưa nhập điểm đỗ"); txtDiemDo.Focus(); return(false); } else { Model.DiemDo = txtDiemDo.Text.Trim(); } if (!Xe.KiemTraTonTaiCuaSoHieuXe(Model.SoXe)) { SetError(string.Format("Xe '{0}' không tồn tại trong danh sách xe hệ thống", Model.SoXe)); txtSoXe.Focus(); return(false); } return(true); }
private void editSoHieuXe_TextChanged(object sender, EventArgs e) { if (StringTools.TrimSpace(editSoHieuXe.Text).Length < 3) { g_boolValidate = false; errorProvider.SetError(editSoHieuXe, "Số hiệu xe có độ dài bằng 3"); editTenLaiXe.Text = ""; } else { if (!Xe.KiemTraTonTaiCuaSoHieuXe(editSoHieuXe.Text)) { g_boolValidate = false; errorProvider.SetError(editSoHieuXe, "Số hiệu xe này không tồn tại"); new MessageBox.MessageBoxBA().Show(this, "Số hiệu xe này không tồn tại", "Thông báo", Taxi.MessageBox.MessageBoxButtonsBA.OK, Taxi.MessageBox.MessageBoxIconBA.Warning); editTenLaiXe.Text = ""; return; } else { if (g_intTrangThai == 1)// xe bao haot dong { if (KiemSoatXeLienLac.CheckXeDangHoatDong(editSoHieuXe.Text)) { g_boolValidate = false; errorProvider.SetError(editSoHieuXe, "Xe đang hoạt động. Bạn cần kiểm tra lại."); new MessageBox.MessageBoxBA().Show(this, "Xe đang hoạt động, bạn không thể nhập lại trạng thái này", "Thông báo", Taxi.MessageBox.MessageBoxButtonsBA.OK, Taxi.MessageBox.MessageBoxIconBA.Warning); return; } else // lấy thông tin xe ở gara nào { Xe objXe = new Xe(); editViTriBao.Text = objXe.GetChiTietXe(editSoHieuXe.Text).GaraName; } } KiemSoatXeLienLac objKSXe = new KiemSoatXeLienLac(); objKSXe = KiemSoatXeLienLac.GetKSXe_BySoHieuXe(StringTools.TrimSpace(editSoHieuXe.Text)); if (StringTools.TrimSpace(editTenLaiXe.Text).Length <= 0) { editTenLaiXe.Text = objKSXe.MaLaiXe; } } errorProvider.SetError(editSoHieuXe, ""); } }
private void txtSoHieuXeKS_TextChanged(object sender, EventArgs e) { if (StringTools.TrimSpace(txtSoHieuXeKS.Text).Length > 0) { if (!Xe.KiemTraTonTaiCuaSoHieuXe(txtSoHieuXeKS.Text)) { errorProvider.SetError(txtSoHieuXeKS, "Số hiệu xe này không tồn tại"); //new MessageBox.MessageBox().Show(this, "Số hiệu xe này không tồn tại", "Thông báo", Taxi.MessageBox.MessageBoxButtons.OK, Taxi.MessageBox.MessageBoxIcon.Warning); return; } else { errorProvider.SetError(txtSoHieuXeKS, ""); } } }
private void editSoHieuXe_TextChanged(object sender, EventArgs e) { string SoHieuXe = StringTools.TrimSpace(editSoHieuXe.Text); if (SoHieuXe.Length <= 0) { return; } if (!Xe.KiemTraTonTaiCuaSoHieuXe(SoHieuXe)) { g_boolValidate = false; errorProvider.SetError(editSoHieuXe, "Số hiệu xe này không tồn tại"); return; } g_boolValidate = true; errorProvider.SetError(editSoHieuXe, ""); }
private void editSoHieuXe_Validating(object sender, CancelEventArgs e) { if (StringTools.TrimSpace(editSoHieuXe.Text).Length < 2) { e.Cancel = true; errorProvider.SetError(editSoHieuXe, "Số hiệu xe có độ dài > 1"); } else { if (Xe.KiemTraTonTaiCuaSoHieuXe(editSoHieuXe.Text)) { e.Cancel = true; errorProvider.SetError(editSoHieuXe, "Số hiệu xe này đã tồn tại"); return; } e.Cancel = false; errorProvider.SetError(editSoHieuXe, ""); } }
private bool validate() { bool returnValue = true; string dsXeDon = txtDSXeDon.Text; if (cbCongTy.SelectedIndex == 0) { new MessageBox.MessageBox().Show("Bạn chưa chọn Công Ty", "Thông báo", Taxi.MessageBox.MessageBoxButtons.OK, Taxi.MessageBox.MessageBoxIcon.Error); returnValue = false; } else if (cbMoiGioi.SelectedIndex == 0) { new MessageBox.MessageBox().Show("Bạn chưa chọn Đối tác", "Thông báo", Taxi.MessageBox.MessageBoxButtons.OK, Taxi.MessageBox.MessageBoxIcon.Error); returnValue = false; } else { if (!dsXeDon.Equals("")) { string[] listXeDon = dsXeDon.Split(','); foreach (string xeDon in listXeDon) { if (Xe.KiemTraTonTaiCuaSoHieuXe(xeDon) == false) { new MessageBox.MessageBox().Show("Xe : " + xeDon + " không tồn tại trong hệ thống", "Thông báo", Taxi.MessageBox.MessageBoxButtons.OK, Taxi.MessageBox.MessageBoxIcon.Error); returnValue = false; break; } } } else { new MessageBox.MessageBox().Show("Bạn chưa nhập xe đón", "Thông báo", Taxi.MessageBox.MessageBoxButtons.OK, Taxi.MessageBox.MessageBoxIcon.Error); returnValue = false; } } return(returnValue); }
private void editSoHieuXe_TextChanged(object sender, EventArgs e) { string SoHieuXe = StringTools.TrimSpace(editSoHieuXe.Text); if (SoHieuXe.Length <= 0) { return; } if (!Xe.KiemTraTonTaiCuaSoHieuXe(SoHieuXe)) { g_boolValidate = false; errorProvider.SetError(editSoHieuXe, "Số hiệu xe này không tồn tại"); // new MessageBox.MessageBox().Show(this, "Số hiệu xe này không tồn tại", "Thông báo", Taxi.MessageBox.MessageBoxButtons.OK, Taxi.MessageBox.MessageBoxIcon.Warning); editTenLaiXe.Text = ""; return; } else { KiemSoatXeLienLac objKSXe = new KiemSoatXeLienLac(); objKSXe = KiemSoatXeLienLac.GetKSXe_BySoHieuXe(SoHieuXe); // số hiệu xe này đã được khai báo trước đó. if (objKSXe != null) { if (StringTools.TrimSpace(editTenLaiXe.Text).Length <= 0) { editTenLaiXe.Text = objKSXe.MaLaiXe; } } if (KiemSoatXeLienLac.CheckXeDangHoatDong(SoHieuXe)) { if (mKieuBao == 1) // xe hoạt động { g_boolValidate = false; errorProvider.SetError(editSoHieuXe, "Xe đang hoạt động. Bạn cần kiểm tra lại."); new MessageBox.MessageBox().Show(this, "Xe đang hoạt động, bạn không thể nhập lại trạng thái này", "Thông báo", Taxi.MessageBox.MessageBoxButtons.OK, Taxi.MessageBox.MessageBoxIcon.Warning); return; } else if (mKieuBao == 4) { Xe objXe = new Xe(); editViTriBao.Text = objXe.GetChiTietXe(SoHieuXe).GaraName; if (StringTools.TrimSpace(editViTriBao.Text).Length <= 0) { editViTriBao.Text = "Gara"; } } } else { // lấy thông tin nhập cho xe haọt động if (mKieuBao == 1) // xe hoạt động { Xe objXe = new Xe(); editViTriBao.Text = objXe.GetChiTietXe(SoHieuXe).GaraName; objXe = null; } else if (mKieuBao == 2 || mKieuBao == 3 || mKieuBao == 4) // xe hoạt điểm { g_boolValidate = false; lblMessage.Text = "Xe chưa hoạt động bạn cần phải cho xe ra hoạt động"; return; } } } g_boolValidate = true; errorProvider.SetError(editSoHieuXe, ""); }
/// <summary> /// Kiểm tra giá trị trên form /// </summary> /// <returns></returns> public bool ValidateData() { // trim tự động cho tất cả các text box panelInput.FindAllChildrenByType <IShInput>().ToList().Where(p => !(p is PopupBaseEdit)).ToList().ForEach(p => ((BaseEdit)p).Text = ((BaseEdit)p).Text.Trim()); SetError(""); if (string.IsNullOrEmpty(deThoiDiemBao.Text.Trim()) || deThoiDiemBao.EditValue == null) { SetError("Bạn chưa nhập thời gian đón"); deThoiDiemBao.Focus(); return(false); } else { //if (ThoiDiemGoi >= deThoiDiemBao.DateTime) //{ // SetError("Thời gian đón lớn hơn thời gian gọi"); // deThoiDiemBao.Focus(); // return false; //} Model.ThoiDiemDon = deThoiDiemBao.DateTime; } if (string.IsNullOrEmpty(txtSoXe.Text.Trim())) { SetError("Bạn chưa nhập số xe"); txtSoXe.Focus(); return(false); } else { Model.SoXe = txtSoXe.Text.Trim(); } if (string.IsNullOrEmpty(txtDienThoai.Text.Trim())) { SetError("Bạn chưa nhập số điện thoại"); txtDienThoai.Focus(); return(false); } else { Model.DienThoai = txtDienThoai.Text.Trim(); } if (string.IsNullOrEmpty(deThoiDiemBao.Text.Trim()) || deThoiDiemBao.EditValue == null) { SetError("Bạn chưa nhập thời điểm báo"); deThoiDiemBao.Focus(); return(false); } else { //if (ThoiDiemGoi >= deThoiDiemBao.DateTime) //{ // SetError("Thời gian đón lớn hơn thời gian gọi"); // deThoiDiemBao.Focus(); // return false; //} Model.ThoiDiemDon = deThoiDiemBao.DateTime; } if (string.IsNullOrEmpty(txtDiaChi.Text.Trim())) { SetError("Bạn chưa nhập địa chỉ"); txtDiaChi.Focus(); return(false); } else { Model.DiaChiDon = txtDiaChi.Text.Trim(); } if (!Xe.KiemTraTonTaiCuaSoHieuXe(Model.SoXe)) { SetError(string.Format("Xe '{0}' không tồn tại trong danh sách xe hệ thống", Model.SoXe)); txtSoXe.Focus(); return(false); } return(true); }