private void bw_DoWork(object sender, DoWorkEventArgs e) { try { var dt = e.Argument as DataTable; dt2 = dt.Copy(); var dv = dt2.DefaultView; string s = string.Format("(FamilyCode like '{0}*'", s1); s += BaseDataBase.IsStringNumber(s1) ? string.Format(" or FamilyID = {0})", s1) : ")"; dv.RowFilter = s; if (!string.IsNullOrEmpty(s0)) { dv.RowFilter += string.Format(" and SpecialCardCode like '{0}*' ", s0); } if (!string.IsNullOrEmpty(s2)) { dv.RowFilter += string.Format(" and (FamilyName like '*{0}*' or Father like '*{0}*' or Mother Like '*{0}*' or Father like '*{1}*' or Mother Like '*{1}*' or Father like '*{2}*' or Mother Like '*{2}*' or Father like '*{3}*' or Mother Like '*{3}*' or Father like '*{4}*' or Mother Like '*{4}*' or Father like '*{5}*' or Mother Like '*{5}*' or Father like '*{6}*' or Mother Like '*{6}*' or Father like '*{7}*' or Mother Like '*{7}*' or Father like '*{8}*' or Mother Like '*{8}*' )", s2, s2.Replace('أ', 'ا'), s2.Replace('ا', 'أ'), s2.Replace('ى', 'ا'), s2.Replace('ا', 'ى'), s2.Replace('آ', 'ا'), s2.Replace('ا', 'آ'), s2.Replace('ة', 'ه'), s2.Replace('ه', 'ة')); } if (!string.IsNullOrEmpty(s3)) { dv.RowFilter += string.Format(" and (FatherNa like '{0}*' or MotherNa Like '{0}*')", s3); } //if (s4 != "0") // dv.RowFilter += string.Format(" and IsCanceled = {0}", s4 == "1" ? 0 : 1); if (!string.IsNullOrEmpty(s4)) { dv.RowFilter += string.Format($" and SectorName like '{s4}'"); } dt2 = dt2.DefaultView.ToTable(); } catch { bw.CancelAsync(); } }
private void Control_Changed(object sender, TextChangedEventArgs e) { if (IsFirstLoad) { IsFirstLoad = false; } else { s0 = BaseDataBase.IsStringNumber(txtSpecialCardCode.Text) ? txtSpecialCardCode.Text : ""; s1 = txtFamilyCode.Text; s2 = txtFamilyName.Text; s3 = txtPID.Text; s4 = cmboSector.SelectedIndex > 0 ? cmboSector.SelectedItem?.ToString() : ""; btnSelectFile_Click(null, null); } }
private bool FilterPredicate(object obj) { var s = obj as SpecialFamily; if (!string.IsNullOrEmpty(txtCode.Text) && BaseDataBase.IsStringNumber(txtCode.Text) && s.Id != int.Parse(txtCode.Text)) { return(false); } if (!string.IsNullOrEmpty(txtName.Text) && !s.Name.Contains(txtName.Text)) { return(false); } if (!string.IsNullOrEmpty(txtPID.Text) && !s.PID.StartsWith(txtPID.Text)) { return(false); } return(true); }
private bool CustomerFilter(object item) { var a = item as Account; if (!string.IsNullOrWhiteSpace(txtName.Text) && !a.Name.Contains(txtName.Text)) { return(false); } if (BaseDataBase.IsStringNumber(txtCode.Text) && a.Code != (int.Parse(txtCode.Text))) { return(false); } if (cmboType.SelectedIndex > 0 && (int)a.Type != cmboType.SelectedIndex - 1) { return(false); } return(true); }
private void Control1_Changed(object sender, TextChangedEventArgs e) { var dv = dgFamily.ItemsSource as DataView; try { string s = string.Format("(FamilyCode like '{0}*'", txtFamilyCode.Text); s += BaseDataBase.IsStringNumber(txtFamilyCode.Text) ? string.Format(" or FamilyID = {0})", txtFamilyCode.Text) : ")"; dv.RowFilter = s; if (!string.IsNullOrEmpty(txtFamilyName.Text)) { dv.RowFilter += string.Format(" and (FamilyName like '*{0}*' or Father like '*{0}*' or Mother Like '*{0}*' or Father like '*{1}*' or Mother Like '*{1}*' or Father like '*{2}*' or Mother Like '*{2}*' or Father like '*{3}*' or Mother Like '*{3}*' or Father like '*{4}*' or Mother Like '*{4}*' or Father like '*{5}*' or Mother Like '*{5}*' or Father like '*{6}*' or Mother Like '*{6}*' or Father like '*{7}*' or Mother Like '*{7}*' or Father like '*{8}*' or Mother Like '*{8}*' )", txtFamilyName.Text, txtFamilyName.Text.Replace('أ', 'ا'), txtFamilyName.Text.Replace('ا', 'أ'), txtFamilyName.Text.Replace('ى', 'ا'), txtFamilyName.Text.Replace('ا', 'ى'), txtFamilyName.Text.Replace('آ', 'ا'), txtFamilyName.Text.Replace('ا', 'آ'), txtFamilyName.Text.Replace('ة', 'ه'), txtFamilyName.Text.Replace('ه', 'ة')); } if (!string.IsNullOrEmpty(txtPID.Text)) { dv.RowFilter += string.Format(" and (FatherNa like '{0}*' or MotherNa Like '{0}*')", txtPID.Text); } } catch { dv.RowFilter = ""; } }
internal bool IsValidate() { bool isValid = true; this.ClearAllErrors(); if (string.IsNullOrEmpty(FirstName)) { isValid = false; this.SetError("FirstName", "يجب إدخال الاسم"); } if (string.IsNullOrEmpty(RelationShip)) { isValid = false; this.SetError("RelationShip", "يجب اختيار صفة الشخص"); } if (string.IsNullOrEmpty(this.Gender)) { isValid = false; this.SetError("Gender", "يجب اختيار الجنس"); } if (!DOB.HasValue) { isValid = false; this.SetError("DOB", "يجب إدخال تاريخ الولادة"); } /* * اضافة كود بتاريخ 16-5-2016 بفؤرض تقييد رقم الهاتف */ /* if (Mobile.Length!=10) * { * isValid = false; * // this.SetError("Mobile", "يجب التحقق من رقم الموبايل"); * } * if (Phone.Length != 7) * { * isValid = false; * //this.SetError("Phone", "يجب التحقق من رقم الهاتف"); * }*/ ///////// if (DOB.HasValue) { var diff = BaseDataBase.DateNow - DOB.Value; if (diff.Days < 0 || diff.Days / 30 / 12 > 120) { isValid = false; this.SetError("DOB", "التاريخ غير صالح يجب ادخال عمر صحيح"); } } if (!string.IsNullOrEmpty(PID)) { if (!BaseDataBase.IsStringNumber(PID)) { isValid = false; this.SetError("PID", "الرقم الوطني يجب أن يحوي أرقاماً فقط"); } else { string ExistingFamilyCode = BaseDataBase._Scalar_StoredProcedure("sp_GetFamilyCodeByParentPID", new SqlParameter("@ParenttID", null), new SqlParameter("@PID", PID)); if (!string.IsNullOrEmpty(ExistingFamilyCode)) { isValid = false; this.SetError("PID", "الرقم الوطني موجود في قاعدة البيانات برقم عائلة مثبتة " + ExistingFamilyCode); } else { ExistingFamilyCode = BaseDataBase._Scalar_StoredProcedure("sp_GetTempFamilyCodeByParentPID", new SqlParameter("@TempFamilyID", null), new SqlParameter("@PID", PID)); if (!string.IsNullOrEmpty(ExistingFamilyCode)) { isValid = false; this.SetError("PID", "الرقم الوطني موجود في قاعدة البيانات برقم عائلة مؤقتة " + ExistingFamilyCode); } else { ExistingFamilyCode = BaseDataBase._Scalar_StoredProcedure("sp_GetFamilyCodeByFamilyPersonPID", new SqlParameter("@FamilyPersonID", FamilyPersonID), new SqlParameter("@PID", PID)); if (!string.IsNullOrEmpty(ExistingFamilyCode)) { isValid = false; this.SetError("PID", "الرقم الوطني موجود في قاعدة البيانات ضمن افراد عائلة رقم " + ExistingFamilyCode); } } } } } if (!isValid) { string s = ""; foreach (var item in errors) { s += item.Value + "\n"; } MyMessageBox.Show(s); } return(isValid); }
internal bool IsValidate() { bool isValid = true; this.ClearAllErrors(); if (string.IsNullOrEmpty(FirstName)) { isValid = false; this.SetError("FirstName", "يجب إدخال الاسم"); } if (string.IsNullOrEmpty(LastName)) { isValid = false; this.SetError("LastName", "يجب إدخال الكنية"); } if (string.IsNullOrEmpty(Gender)) { isValid = false; this.SetError("Gender", "يجب إدخال الجنس"); } if (DOB.HasValue) { var diff = BaseDataBase.DateNow - DOB.Value; if (diff.Days / 30 / 12 < 12 || diff.Days / 30 / 12 > 120) { isValid = false; this.SetError("DOB", "التاريخ غير صالح يجب ادخال عمر صحيح"); } } if (PregnantDate.HasValue) { var diff = BaseDataBase.DateNow - PregnantDate.Value; if (diff.Days < 25 || diff.Days > 299) { isValid = false; this.SetError("PregnantDate", "التاريخ غير صالح يجب ادخال تاريخ بداية حمل صحيح"); } } if (string.IsNullOrEmpty(Status)) { isValid = false; this.SetError("Status", "يجب اختيار الحالة"); } if (string.IsNullOrEmpty(PID)) { isValid = false; this.SetError("PID", "يجب إدخال الرقم الوطني"); } else if (PID != "لايوجد رقم وطني") { if (!BaseDataBase.IsStringNumber(PID)) { isValid = false; this.SetError("PID", "الرقم الوطني يجب أن يحوي أرقاماً فقط"); } else if (PID.Length < 10 || PID.Length > 12) { isValid = false; this.SetError("PID", "الرقم الوطني يجب أن يحوي 10 أو 11 أو 12 رقم"); } else { string ExistingFamilyCode = BaseDataBase._Scalar_StoredProcedure("sp_GetFamilyCodeByParentPID", new SqlParameter("@ParenttID", ParentrID), new SqlParameter("@PID", PID)); if (!string.IsNullOrEmpty(ExistingFamilyCode)) { isValid = false; this.SetError("PID", "الرقم الوطني موجود في قاعدة البيانات برقم عائلة " + ExistingFamilyCode); } else { ExistingFamilyCode = BaseDataBase._Scalar_StoredProcedure("sp_GetFamilyCodeByFamilyPersonPID", new SqlParameter("@PID", PID)); if (!string.IsNullOrEmpty(ExistingFamilyCode)) { isValid = false; this.SetError("PID", "الرقم الوطني موجود في قاعدة البيانات ضمن افراد عائلة رقم " + ExistingFamilyCode); } } } } if (!isValid) { string s = ""; foreach (var item in errors) { s += item.Value + "\n"; } MyMessageBox.Show(s); } return(isValid); }
internal bool IsValidate() { bool isValid = true; this.ClearAllErrors(); if (string.IsNullOrEmpty(Name)) { isValid = false; this.SetError("Name", "يجب إدخال الاسم"); } if (string.IsNullOrEmpty(Gender)) { isValid = false; this.SetError("Gender", "يجب إدخال الجنس"); } if (DOB.HasValue) { var diff = BaseDataBase.DateNow - DOB.Value; if (diff.Days / 30 / 12 < 12 || diff.Days / 30 / 12 > 120) { isValid = false; this.SetError("DOB", "التاريخ غير صالح يجب ادخال عمر صحيح"); } } if (string.IsNullOrEmpty(PID)) { isValid = false; this.SetError("PID", "يجب إدخال الرقم الوطني"); } else { if (!BaseDataBase.IsStringNumber(PID)) { isValid = false; this.SetError("PID", "الرقم الوطني يجب أن يحوي أرقاماً فقط"); } else if (PID.Length < 10 || PID.Length > 12) { isValid = false; this.SetError("PID", "الرقم الوطني يجب أن يحوي 10 أو 11 أو 12 رقم"); } else { string ExistingFamilyCode = BaseDataBase._Scalar_StoredProcedure("sp_GetFamilyCodeByParentPID", new SqlParameter("@ParenttID", DBNull.Value), new SqlParameter("@PID", PID)); if (!string.IsNullOrEmpty(ExistingFamilyCode)) { isValid = false; this.SetError("PID", "الرقم الوطني موجود في قاعدة البيانات برقم عائلة " + ExistingFamilyCode); } } } if (!isValid) { string s = ""; foreach (var item in errors) { s += item.Value + "\n"; } MyMessageBox.Show(s); } return(isValid); }
// ------------------- internal bool IsValidate() { bool isValid = true; this.ClearAllErrors(); //if (string.IsNullOrEmpty(FamilyCode)) //{ // isValid = false; // this.SetError("FamilyCode", "يجب إدخال رمز للعائلة"); //} //else //{ // if (BaseDataBase._StoredProcedureReturnableBool("sp_IsTempFamilyCodeExists", new SqlParameter("@R", System.Data.SqlDbType.Bit), new SqlParameter("@TempFamilyID", ID), new SqlParameter("@FamilyCode", FamilyCode))) // { // isValid = false; // this.SetError("FamilyCode", "رمز العائلة موجود في قاعدة البيانات"); // } //} if (string.IsNullOrEmpty(HouseSection)) { isValid = false; this.SetError("HouseSection", "يجب إدخال منطقة السكن"); } if (string.IsNullOrEmpty(FamilyIdentityID)) { isValid = false; this.SetError("FamilyIdentityID", "يجب إدخال رقم دفتر العائلة"); } else if (FamilyIdentityID != "لايوجد دفتر عائلة") { var num = FamilyIdentityID.Split(' '); if (!BaseDataBase.IsStringNumber(num[0])) { isValid = false; this.SetError("FamilyIdentityID", "رقم دفتر العائلة يجب أن يحوي أرقاماً فقط"); } if (num.Length > 3) { isValid = false; this.SetError("FamilyIdentityID", "رقم دفتر العائلة يحوي أكثر من فراغين"); } else if (num.Length > 1) { if (num[1].Length != 1) { isValid = false; this.SetError("FamilyIdentityID", "حرف دفتر العائلة يجب أن يكون خانة واحدة"); } else if (!char.IsLetter(char.Parse(num[1]))) { isValid = false; this.SetError("FamilyIdentityID", "حرف دفتر العائلة يجب أن يكون حرفاً واحداً فقط(أ، ب/ ت/ ث/ ج)"); } if (num.Length == 3 && !BaseDataBase.IsStringNumber(num[2])) { isValid = false; this.SetError("FamilyIdentityID", "الرقم الأسري يجب أن يحوي أرقاماً فقط"); } } if (isValid) { string ExistedFamilyCode = BaseDataBase._Scalar_StoredProcedure("sp_GetFamilyCodeByFamilyIDentityID", new SqlParameter("@FamilyID", null), new SqlParameter("@FamilyIdentityID", FamilyIdentityID)); if (!string.IsNullOrEmpty(ExistedFamilyCode)) { isValid = false; this.SetError("FamilyIdentityID", "رقم دفتر العائلة موجود في قاعدة البيانات برقم عائلة مثبتة " + ExistedFamilyCode); } else { ExistedFamilyCode = BaseDataBase._Scalar_StoredProcedure("sp_GetTempFamilyCodeByFamilyIDentityID", new SqlParameter("@TempFamilyID", ID), new SqlParameter("@FamilyIdentityID", FamilyIdentityID)); if (!string.IsNullOrEmpty(ExistedFamilyCode)) { isValid = false; this.SetError("FamilyIdentityID", "رقم دفتر العائلة موجود في قاعدة البيانات برقم عائلة " + ExistedFamilyCode); } } } } if (string.IsNullOrEmpty(FamilyName)) { isValid = false; this.SetError("FamilyName", "يجب إدخال اسم العائلة"); } if (ApplyDate == null) { isValid = false; this.SetError("ApplyDate", "يجب إدخال تاريخ التسجيل"); } if (!FamilyPersonCount.HasValue) { isValid = false; this.SetError("FamilyPersonCount", "يجب ادخال عدد الأفراد"); } if (string.IsNullOrEmpty(FamilyType)) { isValid = false; this.SetError("FamilyType", "يجب إدخال نوع العائلة"); } if (!string.IsNullOrEmpty(FatherFirstName) || !string.IsNullOrEmpty(FatherLastName)) { if (string.IsNullOrEmpty(FatherFirstName)) { isValid = false; this.SetError("FatherFirstName", "يجب إدخال اسم الاب"); } if (string.IsNullOrEmpty(FatherLastName)) { isValid = false; this.SetError("FatherLastName", "يجب إدخال كنية الاب"); } if (FatherDOB.HasValue) { var diff = BaseDataBase.DateNow - FatherDOB.Value; if (diff.Days / 30 / 12 < 12 || diff.Days / 30 / 12 > 120) { isValid = false; this.SetError("FatherDOB", "التاريخ غير صالح يجب ادخال عمر صحيح"); } } if (string.IsNullOrEmpty(FatherPID)) { isValid = false; this.SetError("FatherPID", "يجب إدخال الرقم الوطني"); } else if (FatherPID != "لايوجد رقم وطني") { if (!BaseDataBase.IsStringNumber(FatherPID)) { isValid = false; this.SetError("FatherPID", "الرقم الوطني يجب أن يكون يحوي أرقاماً فقط"); } else { string ExistingFamilyCode = BaseDataBase._Scalar_StoredProcedure("sp_GetFamilyCodeByParentPID", new SqlParameter("@ParenttID", null), new SqlParameter("@PID", FatherPID)); if (!string.IsNullOrEmpty(ExistingFamilyCode)) { isValid = false; this.SetError("FatherPID", "الرقم الوطني موجود في قاعدة البيانات برقم عائلة مثبتة " + ExistingFamilyCode); } else { ExistingFamilyCode = BaseDataBase._Scalar_StoredProcedure("sp_GetTempFamilyCodeByParentPID", new SqlParameter("@TempFamilyID", ID), new SqlParameter("@PID", FatherPID)); if (!string.IsNullOrEmpty(ExistingFamilyCode)) { isValid = false; this.SetError("FatherPID", "الرقم الوطني موجود في قاعدة البيانات برقم عائلة مؤقتة " + ExistingFamilyCode); } else { ExistingFamilyCode = BaseDataBase._Scalar_StoredProcedure("sp_GetFamilyCodeByFamilyPersonPID", new SqlParameter("@PID", FatherPID)); if (!string.IsNullOrEmpty(ExistingFamilyCode)) { isValid = false; this.SetError("FatherPID", "الرقم الوطني موجود في قاعدة البيانات ضمن افراد عائلة رقم " + ExistingFamilyCode); } } } } } } if (!string.IsNullOrEmpty(MotherFirstName) || !string.IsNullOrEmpty(MotherLastName)) { if (string.IsNullOrEmpty(MotherFirstName)) { isValid = false; this.SetError("MotherFirstName", "يجب إدخال اسم الام"); } if (string.IsNullOrEmpty(MotherLastName)) { isValid = false; this.SetError("MotherLastName", "يجب إدخال كنية الام"); } if (MotherDOB.HasValue) { var diff = BaseDataBase.DateNow - MotherDOB.Value; if (diff.Days / 30 / 12 < 12 || diff.Days / 30 / 12 > 120) { isValid = false; this.SetError("MotherDOB", "التاريخ غير صالح يجب ادخال عمر صحيح"); } } if (string.IsNullOrEmpty(MotherPID)) { isValid = false; this.SetError("MotherPID", "يجب إدخال الرقم الوطني"); } else if (MotherPID != "لايوجد رقم وطني") { if (!BaseDataBase.IsStringNumber(MotherPID)) { isValid = false; this.SetError("MotherPID", "الرقم الوطني يجب أن يحوي أرقاماً فقط"); } else { string ExistingFamilyCode = BaseDataBase._Scalar_StoredProcedure("sp_GetFamilyCodeByParentPID", new SqlParameter("@ParenttID", null), new SqlParameter("@PID", MotherPID)); if (!string.IsNullOrEmpty(ExistingFamilyCode)) { isValid = false; this.SetError("MotherPID", "الرقم الوطني موجود في قاعدة البيانات برقم عائلة مثبتة " + ExistingFamilyCode); } else { ExistingFamilyCode = BaseDataBase._Scalar_StoredProcedure("sp_GetTempFamilyCodeByParentPID", new SqlParameter("@TempFamilyID", ID), new SqlParameter("@PID", MotherPID)); if (!string.IsNullOrEmpty(ExistingFamilyCode)) { isValid = false; this.SetError("MotherPID", "الرقم الوطني موجود في قاعدة البيانات برقم عائلة مؤقتة " + ExistingFamilyCode); } else { ExistingFamilyCode = BaseDataBase._Scalar_StoredProcedure("sp_GetFamilyCodeByFamilyPersonPID", new SqlParameter("@PID", MotherPID)); if (!string.IsNullOrEmpty(ExistingFamilyCode)) { isValid = false; this.SetError("MotherPID", "الرقم الوطني موجود في قاعدة البيانات ضمن افراد عائلة رقم " + ExistingFamilyCode); } } } } } } if (!isValid) { string s = ""; foreach (var item in errors) { s += item.Value + "\n"; } MyMessageBox.Show(s); } return(isValid); }
internal bool IsValidate() { bool isValid = true; this.ClearAllErrors(); if (string.IsNullOrEmpty(FamilyCode)) { isValid = false; this.SetError("FamilyCode", "يجب إدخال رمز للعائلة"); } else { if (BaseDataBase._StoredProcedureReturnableBool("sp_IsFamilyCodeExists", new SqlParameter("@R", System.Data.SqlDbType.Bit), new SqlParameter("@FamilyID", FamilyID), new SqlParameter("@FamilyCode", FamilyCode))) { isValid = false; this.SetError("FamilyCode", "رمز العائلة موجود في قاعدة البيانات"); } } if (string.IsNullOrEmpty(FamilyIdentityID)) { isValid = false; this.SetError("FamilyIdentityID", "يجب إدخال رقم دفتر العائلة"); } else if (FamilyIdentityID != "لايوجد دفتر عائلة") { var num = FamilyIdentityID.Split(' '); if (!BaseDataBase.IsStringNumber(num[0])) { isValid = false; this.SetError("FamilyIdentityID", "رقم دفتر العائلة يجب أن يحوي أرقاما"); } if (num.Length > 3) { isValid = false; this.SetError("FamilyIdentityID", "رقم دفتر العائلة يحوي أكثر من فراغين"); } else if (num.Length > 1) { if (num[1].Length != 1) { isValid = false; this.SetError("FamilyIdentityID", "حرف دفتر العائلة يجب أن يكون خانة واحدة"); } else if (!char.IsLetter(char.Parse(num[1]))) { isValid = false; this.SetError("FamilyIdentityID", "حرف دفتر العائلة يجب أن يحوي حرف واحد فقط (أ، ب، ت، ث، ج)"); } if (num.Length == 3 && !BaseDataBase.IsStringNumber(num[2])) { isValid = false; this.SetError("FamilyIdentityID", "الرقم الأسري يجب أن يحوي أرقاما"); } } if (isValid) { string ExistedFamilyCode = BaseDataBase._Scalar_StoredProcedure("sp_GetFamilyCodeByFamilyIDentityID", new SqlParameter("@FamilyID", FamilyID), new SqlParameter("@FamilyIdentityID", FamilyIdentityID)); if (!string.IsNullOrEmpty(ExistedFamilyCode)) { isValid = false; this.SetError("FamilyIdentityID", "رقم دفتر العائلة موجود في قاعدة البيانات برقم " + ExistedFamilyCode); } } } if (string.IsNullOrEmpty(FamilyName)) { isValid = false; this.SetError("FamilyName", "يجب إدخال اسم العائلة"); } if (ApplyDate == null) { isValid = false; this.SetError("ApplyDate", "يجب إدخال تاريخ التسجيل"); } if (string.IsNullOrEmpty(FamilyType)) { isValid = false; this.SetError("FamilyType", "يجب إدخال نوع العائلة"); } if (!isValid) { string s = ""; foreach (var item in errors) { s += item.Value + "\n"; } MyMessageBox.Show(s); } return(isValid); }