private bool ValidObj() { try { if (string.IsNullOrEmpty(txtMau_HD.Text) || string.IsNullOrEmpty(txtKi_Hieu.Text)) { Utility.ShowMsg("[Mã hóa đơn] & [Kí hiệu] & [Số quyển] hóa đơn không được để trống"); return(false); } if (string.IsNullOrEmpty(txtSerie_Dau.Text) || string.IsNullOrEmpty(txtSerie_Cuoi.Text)) { Utility.ShowMsg("Số serie hóa đơn không được để trống"); return(false); } if (txtSerie_Dau.Text.Length != txtSerie_Cuoi.Text.Length) { Utility.ShowMsg("Số ký tự của serie đầu và serie cuối phải giống nhau"); return(false); } if (string.Compare(txtSerie_Dau.Text, txtSerie_Cuoi.Text, StringComparison.InvariantCulture) > 0) { Utility.ShowMsg("Serie đầu phải nhỏ hơn serie cuối"); return(false); } if (dtpHetHieuLuc.Value.Date - dtpHieuLuc.Value.Date < TimeSpan.FromDays(30)) { if (!Utility.AcceptQuestion("Đề nghị xác nhận sử dụng hóa đơn dưới 30 ngày", "Thông báo", false)) { return(false); } } if (currentDr == null) { if (HoadonMau.CreateQuery().WHERE(HoadonMau.Columns.MauHoadon, txtMau_HD.Text).AND(HoadonMau.Columns.KiHieu, txtKi_Hieu.Text) .AND(HoadonMau.Columns.MaQuyen, txtSoQuyen.Text) .GetRecordCount() > 0) { Utility.ShowMsg(string.Format("Tồn tại mã hóa đơn {0} - kí hiệu {1} - Số Quyển {2}", txtMau_HD.Text, txtKi_Hieu.Text, txtSoQuyen.Text)); return(false); } } } catch (Exception) { return(false); } return(true); }
private bool ValidData() { if (grdList.CurrentRow == null) { return(false); } if (HoadonMau.CreateQuery().WHERE(HoadonMau.Columns.IdHoadonMau, Utility.Int32Dbnull(grdList.GetValue(HoadonMau.Columns.IdHoadonMau))).AND(HoadonMau.Columns.TrangThai, Comparison.GreaterThan, 0).GetRecordCount() > 0) { Utility.ShowMsg("Hóa đơn đã được sử dụng. Không được sửa hoặc xóa."); return(false); } return(true); }