private void DeleteFamilyPerson_CommandExecuted(object sender, ExecutedRoutedEventArgs e) { if (!BaseDataBase.CurrentUser.CanUpdateFamily) { MyMessageBox.Show("ليس لديك صلاحية حذف"); return; } FamilyPerson fp = dgChild.SelectedCells[0].Item as FamilyPerson; if (fp != null) { if (MyMessageBox.Show("هل تريد حذف السجل؟", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { var fps = dgChild.ItemsSource as List <FamilyPerson>; if (fp != null) { dgChild.ItemsSource = null; if (fp.FamilyPersonID.HasValue) { DBMain.DeleteData(fp); } fps.Remove(fp); dgChild.ItemsSource = fps; } } } }
private void btnNew_Click(object sender, RoutedEventArgs e) { svMain.ScrollToHome(); Keyboard.Focus(txtFirstName); var x = this.DataContext as FamilyPerson; if (x.FamilyPersonID.HasValue) { var fp = new FamilyPerson(); fp.FamilyID = FamilyID; this.DataContext = fp; } }
async void FillData(Family f) { var hs = House.GetHouseAllByFamilyID(f.FamilyID); if (hs != null && hs.Count() > 0) { f.FamilyHouse = hs.Last(); } else { f.FamilyHouse = new House(); } if (f.FamilyID.HasValue) { cFamily.dgChild.ItemsSource = (from x in FamilyPerson.GetFamilyPersonByFamilyID(f.FamilyID.Value) orderby x.DOB select x).ToList(); } else { cFamily.dgChild.ItemsSource = new List <FamilyPerson>(); } cFamilyNeed.FamilyID = f.FamilyID; cExternalFamilySupport.FamilyID = f.FamilyID; //cFamilyProperty.FamilyID = FamilyID; cSpecialCard.FamilyID = f.FamilyID; cListerGroup.FamilyID = f.FamilyID; cAdminEvaluation.FamilyID = f.FamilyID; cOrders.FamilyID = f.FamilyID; cFamily.txtFamilyCode.IsReadOnly = true; var lst = cOrders?.lvOrders?.ItemsSource as List <Order>; if (lst != null && lst.Count > 0 && lst.Where(x => x.NextOrderDate.HasValue).Count() > 0) { var MaxNextOrderDate = lst.Where(x => x.NextOrderDate.HasValue).Select(x => x.NextOrderDate.Value).Max(); if (MaxNextOrderDate > BaseDataBase.DateNow) { MyMessageBox.Show("متبقي " + (MaxNextOrderDate - BaseDataBase.DateNow).Days + " ايام للاستلام القادم\nتاريخ الاستلام القادم " + MaxNextOrderDate.ToShortDateString()); } } }
public static List <FamilyPerson> GetFamilyPersonByFamilyID(int FamilyID) { List <FamilyPerson> fps = new List <FamilyPerson>(); SqlConnection con = new SqlConnection(BaseDataBase.ConnectionString); SqlCommand com = new SqlCommand("sp_GetFamilyPersonAllByFamilyID", con); com.CommandType = System.Data.CommandType.StoredProcedure; SqlParameter pr = new SqlParameter("@FamilyID", FamilyID); com.Parameters.Add(pr); try { con.Open(); SqlDataReader rd = com.ExecuteReader(); while (rd.Read()) { FamilyPerson x = new FamilyPerson(); if (!(rd["FamilyPersonID"] is DBNull)) { x.FamilyPersonID = System.Int32.Parse(rd["FamilyPersonID"].ToString()); } if (!(rd["FamilyID"] is DBNull)) { x.FamilyID = System.Int32.Parse(rd["FamilyID"].ToString()); } x.FirstName = rd["FirstName"].ToString(); x.LastName = rd["LastName"].ToString(); x.Nationality = rd["Nationality"].ToString(); x.BirthPlace = rd["BirthPlace"].ToString(); if (!(rd["DOB"] is DBNull)) { x.DOB = System.DateTime.Parse(rd["DOB"].ToString()); } x.Gender = rd["Gender"].ToString(); x.Job = rd["Job"].ToString(); if (!(rd["IsStudyCutOff"] is DBNull)) { x.IsStudyCutOff = System.Boolean.Parse(rd["IsStudyCutOff"].ToString()); } x.Salary = rd["Salary"].ToString(); x.SalaryCurrency = rd["SalaryCurrency"].ToString(); if (!(rd["IsImpeded"] is DBNull)) { x.IsImpeded = System.Boolean.Parse(rd["IsImpeded"].ToString()); } x.impededType = rd["impededType"].ToString(); x.ImpededKind = rd["ImpededKind"].ToString(); if (!(rd["impededDate"] is DBNull)) { x.impededDate = System.DateTime.Parse(rd["impededDate"].ToString()); } if (!(rd["IsWantToCompleteStudy"] is DBNull)) { x.IsWantToCompleteStudy = System.Boolean.Parse(rd["IsWantToCompleteStudy"].ToString()); } x.StudyCuttOffReason = rd["StudyCuttOffReason"].ToString(); if (!(rd["LostDate"] is DBNull)) { x.LostDate = System.DateTime.Parse(rd["LostDate"].ToString()); } x.BackDetailes = rd["BackDetailes"].ToString(); if (!(rd["BackDate"] is DBNull)) { x.BackDate = System.DateTime.Parse(rd["BackDate"].ToString()); } x.Phone = rd["Phone"].ToString(); x.Mobile = rd["Mobile"].ToString(); x.Email = rd["Email"].ToString(); x.PID = rd["PID"].ToString(); if (!(rd["DeathDate"] is DBNull)) { x.DeathDate = System.DateTime.Parse(rd["DeathDate"].ToString()); } x.DeathReason = rd["DeathReason"].ToString(); x.DeathReportID = rd["DeathReportID"].ToString(); if (!(rd["DeathReportDate"] is DBNull)) { x.DeathReportDate = System.DateTime.Parse(rd["DeathReportDate"].ToString()); } x.BondPlace = rd["BondPlace"].ToString(); x.BondNumber = rd["BondNumber"].ToString(); x.IdentityID = rd["IdentityID"].ToString(); if (!(rd["IdentityGivinDate"] is DBNull)) { x.IdentityGivinDate = System.DateTime.Parse(rd["IdentityGivinDate"].ToString()); } if (!(rd["Tall"] is DBNull)) { x.Tall = System.Int32.Parse(rd["Tall"].ToString()); } if (!(rd["Wieght"] is DBNull)) { x.Wieght = System.Int32.Parse(rd["Wieght"].ToString()); } x.PsychicalSituation = rd["PsychicalSituation"].ToString(); x.EthicsSituation = rd["EthicsSituation"].ToString(); x.HomePlace = rd["HomePlace"].ToString(); x.HomeBasePlace = rd["HomeBasePlace"].ToString(); x.MaritalStatus = rd["MaritalStatus"].ToString(); x.ChildrenCount = rd["ChildrenCount"].ToString(); x.Property = rd["Property"].ToString(); x.PersonalImage = rd["PersonalImage"].ToString(); x.IdentityImage = rd["IdentityImage"].ToString(); x.DeathReportImage = rd["DeathReportImage"].ToString(); x.RelationShip = rd["RelationShip"].ToString(); x.StudyStatus = rd["StudyStatus"].ToString(); x.HealthStatus = rd["HealthStatus"].ToString(); if (!(rd["IsCancel"] is DBNull)) { x.IsCancel = System.Boolean.Parse(rd["IsCancel"].ToString()); } x.CancelReason = rd["CancelReason"].ToString(); x.Notes = rd["Notes"].ToString(); fps.Add(x); } rd.Close(); } catch { fps = new List <FamilyPerson>(); } finally { con.Close(); } return(fps); }
private void btnPrintAll_Click(object sender, RoutedEventArgs e) { if (cmboPrintType.SelectedIndex == 0) { SaveFileDialog dlg = new SaveFileDialog(); dlg.DefaultExt = ".xps"; dlg.Filter = "XPS Print Documents (.xps)|*.xps"; if (dlg.ShowDialog() == true) { tfs = new List <TempFamily>(); FileName = dlg.FileName; if (FileName.Substring(FileName.LastIndexOf('.'), FileName.Length - FileName.LastIndexOf('.')) != ".xps") { FileName += ".xps"; } foreach (DataRowView item in dgmain.ItemsSource as DataView) { tfs.Add(TempFamily.GetTempFamilyByID((int)item[0])); } try { FixedDocument fd = new FixedDocument(); fd.DocumentPaginator.PageSize = new Size(1056, 768); int index = 0; foreach (var f in tfs) { index++; var pc = LoadTemplate(Path.Combine(Environment.CurrentDirectory, "TempFamilyReportTemplate.xaml")) as PageContent; if (pc != null) { pc.Child.Margin = new Thickness(25); var img = pc.FindName("img") as Image; if (img != null) { img.Stretch = Stretch.Fill; BitmapImage bi = new BitmapImage(); bi.BeginInit(); bi.UriSource = new Uri(Properties.Settings.Default.AssociationLogoPath, UriKind.RelativeOrAbsolute); bi.EndInit(); img.Source = bi; } var txtUser = pc.FindName("txtUser") as TextBlock; if (txtUser != null) { txtUser.Text = BaseDataBase.CurrentUser.Name; } var txt = pc.FindName("txtMainDescription") as TextBlock; if (txt != null) { txt.Text = Properties.Settings.Default.ReportHeaderDescription; } var gridChild = pc.Child.FindName("grdChilds") as Grid; if (gridChild != null) { int i = 1; foreach (var tc in f.TempChilds) { TextBlock tb1 = new TextBlock(); tb1.Text = tc.Name; tb1.SetValue(Grid.ColumnProperty, 1); tb1.SetValue(Grid.RowProperty, i); TextBlock tb2 = new TextBlock(); tb2.Text = tc.Gender; tb2.SetValue(Grid.ColumnProperty, 2); tb2.SetValue(Grid.RowProperty, i); TextBlock tb3 = new TextBlock(); tb3.Text = tc.DOB.Value.ToString("dd/MM/yyyy"); tb3.SetValue(Grid.ColumnProperty, 4); tb3.SetValue(Grid.RowProperty, i); gridChild.Children.Add(tb1); gridChild.Children.Add(tb2); gridChild.Children.Add(tb3); i++; } } pc.Child.DataContext = null; pc.Child.DataContext = f; fd.Pages.Add(pc); } } CreateXPSDocument(fd.DocumentPaginator, FileName); foreach (var item in tfs) { item.Printer = BaseDataBase.CurrentUser.Name; item.IsPrinted = true; TempFamily.UpadteData(item); } MyMessageBox.Show("تمت الطباعة بنجاح"); } catch (Exception ex) { MyMessageBox.Show(ex.Message); } } } else { SaveFileDialog dlg = new SaveFileDialog(); dlg.DefaultExt = ".xps"; dlg.Filter = "XPS Print Documents (.xps)|*.xps"; if (dlg.ShowDialog() == true) { fs = new List <Family>(); FileName = dlg.FileName; if (FileName.Substring(FileName.LastIndexOf('.'), FileName.Length - FileName.LastIndexOf('.')) != ".xps") { FileName += ".xps"; } foreach (DataRowView item in dgmain.ItemsSource as DataView) { fs.Add(Family.GetFamilyByID((int)item[0])); } try { FixedDocument fd = new FixedDocument(); fd.DocumentPaginator.PageSize = new Size(1056, 768); int index = 0; foreach (var f in fs) { index++; var pc = LoadTemplate(Path.Combine(Environment.CurrentDirectory, "FamilyReportTemplate.xaml")) as PageContent; if (pc != null) { pc.Child.Margin = new Thickness(25); var img = pc.FindName("img") as Image; if (img != null) { img.Stretch = Stretch.Fill; BitmapImage bi = new BitmapImage(); bi.BeginInit(); bi.UriSource = new Uri(Properties.Settings.Default.AssociationLogoPath, UriKind.RelativeOrAbsolute); bi.EndInit(); img.Source = bi; } var txt = pc.FindName("txtMainDescription") as TextBlock; if (txt != null) { txt.Text = Properties.Settings.Default.ReportHeaderDescription; } var gridHouse = pc.Child.FindName("grdHouse") as Grid; if (gridHouse != null) { var hs = House.GetHouseAllByFamilyID(f.FamilyID); if (hs != null && hs.Count > 0) { gridHouse.DataContext = hs.Last(); } } var gridChild = pc.Child.FindName("grdChilds") as Grid; if (gridChild != null) { int i = 1; foreach (var tc in FamilyPerson.GetFamilyPersonByFamilyID(f.FamilyID.Value)) { TextBlock tb1 = new TextBlock(); tb1.Text = tc.FirstName; tb1.SetValue(Grid.ColumnProperty, 1); tb1.SetValue(Grid.RowProperty, i); TextBlock tb2 = new TextBlock(); tb2.Text = tc.Gender; tb2.SetValue(Grid.ColumnProperty, 2); tb2.SetValue(Grid.RowProperty, i); TextBlock tb3 = new TextBlock(); tb3.Text = tc.RelationShip; tb3.SetValue(Grid.ColumnProperty, 3); tb3.SetValue(Grid.RowProperty, i); TextBlock tb4 = new TextBlock(); tb4.Text = tc.DOB.Value.ToString("dd/MM/yyyy"); tb4.SetValue(Grid.ColumnProperty, 4); tb4.SetValue(Grid.RowProperty, i); TextBlock tb5 = new TextBlock(); tb5.Text = tc.StudyStatus; tb5.SetValue(Grid.ColumnProperty, 5); tb5.SetValue(Grid.RowProperty, i); TextBlock tb6 = new TextBlock(); tb6.Text = tc.HealthStatus; tb6.SetValue(Grid.ColumnProperty, 6); tb6.SetValue(Grid.RowProperty, i); TextBlock tb7 = new TextBlock(); tb7.Text = tc.MaritalStatus; tb7.SetValue(Grid.ColumnProperty, 7); tb7.SetValue(Grid.RowProperty, i); TextBlock tb8 = new TextBlock(); tb8.Text = tc.Job; tb8.SetValue(Grid.ColumnProperty, 8); tb8.SetValue(Grid.RowProperty, i); gridChild.Children.Add(tb1); gridChild.Children.Add(tb2); gridChild.Children.Add(tb3); gridChild.Children.Add(tb4); gridChild.Children.Add(tb5); gridChild.Children.Add(tb6); gridChild.Children.Add(tb7); gridChild.Children.Add(tb8); i++; } } pc.Child.DataContext = null; pc.Child.DataContext = f; fd.Pages.Add(pc); } } CreateXPSDocument(fd.DocumentPaginator, FileName); MyMessageBox.Show("تمت الطباعة بنجاح"); } catch (Exception ex) { MyMessageBox.Show(ex.Message); } } } }
private void bw2_DoWork(object sender, DoWorkEventArgs e) { var bw = sender as BackgroundWorker; DataTable dt = e.Argument as DataTable; Family f = new Family(); f.FamilyType = dt.TableName; House h = new House(); for (int i = 0; i < dt.Rows.Count; i++) { f.FamilyCode = dt.DefaultView[i]["ID"].ToString(); f.FamilyName = dt.DefaultView[i]["Name"].ToString() != "" ? dt.DefaultView[i]["Name"].ToString() : dt.DefaultView[i]["WifeName"].ToString(); f.FamilyFather.FirstName = dt.DefaultView[i]["Name"].ToString(); f.FamilyFather.PID = dt.DefaultView[i]["PID"].ToString(); f.FamilyMother.FirstName = dt.DefaultView[i]["WifeName"].ToString(); f.FamilyMother.PID = dt.DefaultView[i]["WifePID"].ToString(); f.FamilyIdentityID = dt.DefaultView[i]["FamilyBookID"].ToString() + ((dt.DefaultView[i]["FamilyBookChar"].ToString() == "") ? "" : ((" " + dt.DefaultView[i]["FamilyBookChar"].ToString()) + ((dt.DefaultView[i]["FamilyNumber"].ToString() == "") ? "" : " " + dt.DefaultView[i]["FamilyNumber"].ToString()))); if (f.FamilyIdentityID == "") { f.FamilyIdentityID = "لايوجد دفتر عائلة"; } f.FamilyPersonCount = dt.DefaultView[i]["FamilyMemberCount"].ToString(); f.FamilyFather.Phone = dt.DefaultView[i]["Phone"].ToString(); f.FamilyFather.Mobile = dt.DefaultView[i]["Mobile"].ToString(); f.FamilyStatus = dt.DefaultView[i]["FamilyStatus"].ToString(); h.OldAddress = dt.DefaultView[i]["BasePlace"].ToString(); h.Address = dt.DefaultView[i]["CurrentPlace"].ToString(); f.Notes = dt.DefaultView[i]["Notes"].ToString(); f.Evaluation = dt.DefaultView[i]["Evaluation"].ToString(); f.ApplyDate = BaseDataBase.DateNow; List <FamilyPerson> fps = new List <FamilyPerson>(); int b1 = dt.DefaultView[i]["Baby1"] is DBNull ? 0 : (int)dt.DefaultView[i]["Baby1"]; int b2 = dt.DefaultView[i]["Baby2"] is DBNull ? 0 : (int)dt.DefaultView[i]["Baby2"]; int b3 = dt.DefaultView[i]["Baby3"] is DBNull ? 0 : (int)dt.DefaultView[i]["Baby3"]; int m1 = dt.DefaultView[i]["Male1"] is DBNull ? 0 : (int)dt.DefaultView[i]["Male1"]; int m2 = dt.DefaultView[i]["Male2"] is DBNull ? 0 : (int)dt.DefaultView[i]["Male2"] - 1; int f1 = dt.DefaultView[i]["Female1"] is DBNull ? 0 : (int)dt.DefaultView[i]["Female1"]; int f2 = dt.DefaultView[i]["Female2"] is DBNull ? 0 : (int)dt.DefaultView[i]["Female2"]; int f3 = dt.DefaultView[i]["Female3"] is DBNull ? 0 : (int)dt.DefaultView[i]["Female3"]; if (f3 > 0) { f3--; f.FamilyMother.DOB = BaseDataBase.DateNow.AddYears(-50); f.FamilyFather.DOB = BaseDataBase.DateNow.AddYears(-55); } else { f2--; f.FamilyMother.DOB = BaseDataBase.DateNow.AddYears(-30); f.FamilyFather.DOB = BaseDataBase.DateNow.AddYears(-40); } int index = 0; while (b1 > 0) { b1--; FamilyPerson fp = new FamilyPerson(); fp.FirstName = "الابن " + ++index; fp.DOB = BaseDataBase.DateNow.AddMonths(-2); if (m1 > 0) { m1--; fp.Gender = "ذكر"; } else { f1--; fp.Gender = "أنثى"; } fps.Add(fp); } while (b2 > 0) { b2--; FamilyPerson fp = new FamilyPerson(); fp.FirstName = "الابن " + ++index; fp.DOB = BaseDataBase.DateNow.AddMonths(-10); if (m1 > 0) { m1--; fp.Gender = "ذكر"; } else { f1--; fp.Gender = "أنثى"; } fps.Add(fp); } while (b3 > 0) { b3--; FamilyPerson fp = new FamilyPerson(); fp.FirstName = "الابن " + ++index; fp.DOB = BaseDataBase.DateNow.AddMonths(-18); if (m1 > 0) { m1--; fp.Gender = "ذكر"; } else { f1--; fp.Gender = "أنثى"; } fps.Add(fp); } while (m1 > 0) { m1--; FamilyPerson fp = new FamilyPerson(); fp.FirstName = "الابن " + ++index; fp.DOB = BaseDataBase.DateNow.AddYears(-8); fp.Gender = "ذكر"; fps.Add(fp); } while (m2 > 0) { m2--; FamilyPerson fp = new FamilyPerson(); fp.FirstName = "الابن " + ++index; fp.DOB = BaseDataBase.DateNow.AddYears(-15); fp.Gender = "ذكر"; fps.Add(fp); } while (f1 > 0) { f1--; FamilyPerson fp = new FamilyPerson(); fp.FirstName = "الابن " + ++index; fp.DOB = BaseDataBase.DateNow.AddYears(-8); fp.Gender = "أنثى"; fps.Add(fp); } while (f2 > 0) { f2--; FamilyPerson fp = new FamilyPerson(); fp.FirstName = "الابن " + ++index; fp.DOB = BaseDataBase.DateNow.AddYears(-15); fp.Gender = "أنثى"; fps.Add(fp); } while (f3 > 0) { f3--; FamilyPerson fp = new FamilyPerson(); fp.FirstName = "الابن " + ++index; fp.DOB = BaseDataBase.DateNow.AddYears(-50); fp.Gender = "أنثى"; fps.Add(fp); } f.FamilyID = BaseDataBase._StoredProcedureReturnable("sp_Add2FamilyHilal" , new SqlParameter("@FamilyID", SqlDbType.Int) , new SqlParameter("@FamilyCode", f.FamilyCode) , new SqlParameter("@FamilyName", f.FamilyName) , new SqlParameter("@FamilyType", f.FamilyType) , new SqlParameter("@FamilyIdentityID", f.FamilyIdentityID) , new SqlParameter("@ApplyDate", f.ApplyDate) , new SqlParameter("@FamilyPersonCount", f.FamilyPersonCount) , new SqlParameter("@FamilyStatus", f.FamilyStatus) , new SqlParameter("@Evaluation", f.Evaluation) , new SqlParameter("@Notes", f.Notes) , new SqlParameter("@Phone", f.FamilyFather.Phone) , new SqlParameter("@Mobile", f.FamilyFather.Mobile) , new SqlParameter("@FirstNameF", f.FamilyFather.FirstName) , new SqlParameter("@DOBF", f.FamilyFather.DOB) , new SqlParameter("@PIDF", f.FamilyFather.PID) , new SqlParameter("@FirstNameM", f.FamilyMother.FirstName) , new SqlParameter("@DOBM", f.FamilyMother.DOB) , new SqlParameter("@PIDM", f.FamilyMother.PID) , new SqlParameter("@OldAddress", h.OldAddress) , new SqlParameter("@Address", h.Address)); int ChildID = int.Parse(BaseDataBase._Scalar("select IsNull(Max(FamilyPersonID)+1,1) from FamilyPerson")); for (int j = 0; j < fps.Count; j++) { string s = string.Format("insert into FamilyPerson(FamilyPersonID,FamilyID,FirstName,Gender,DOB) values ({0},{1},'{2}','{3}',", ChildID + j, f.FamilyID, fps[j].FirstName, fps[j].Gender); if (fps[j].DOB.HasValue) { s += "'" + fps[j].DOB.Value.ToString("MM/dd/yyyy") + "')"; } else { s += "null)"; } BaseDataBase._NonQuery(s); } bw.ReportProgress(i); } }
private void btnSaveTable_Click(object sender, RoutedEventArgs e) { if (dgExcelFile.ItemsSource != null && dgExcelFile.Items.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { Family f = new Family(); House h = new House(); List <FamilyPerson> fps = new List <FamilyPerson>(); try { if (dt.DefaultView[i][1].ToString() == "") { continue; } f.FamilyCode = dt.DefaultView[i][1].ToString(); f.FamilyType = dt.DefaultView[i][2].ToString(); f.FamilyIdentityID = dt.DefaultView[i][3].ToString(); if (dt.DefaultView[i][4].ToString() != "") { f.FamilyIdentityID += " " + dt.DefaultView[i][4].ToString(); if (dt.DefaultView[i][5].ToString() != "") { f.FamilyIdentityID += " " + dt.DefaultView[i][5].ToString(); } } f.ApplyDate = GetDate(dt.DefaultView[i][6].ToString()); f.FamilyPersonCount = dt.DefaultView[i][7].ToString(); f.FamilyName = dt.DefaultView[i][8].ToString(); f.Notes = dt.DefaultView[i][9].ToString(); f.FamilyFather.FirstName = dt.DefaultView[i][10].ToString(); f.FamilyFather.FatherName = dt.DefaultView[i][11].ToString(); f.FamilyFather.LastName = dt.DefaultView[i][12].ToString(); f.FamilyFather.BirthPlace = dt.DefaultView[i][13].ToString(); f.FamilyFather.DOB = GetDate(dt.DefaultView[i][14].ToString()); f.FamilyFather.PID = dt.DefaultView[i][15].ToString(); f.FamilyMother.FirstName = dt.DefaultView[i][16].ToString(); f.FamilyMother.FatherName = dt.DefaultView[i][17].ToString(); f.FamilyMother.LastName = dt.DefaultView[i][18].ToString(); f.FamilyMother.BirthPlace = dt.DefaultView[i][19].ToString(); f.FamilyMother.DOB = GetDate(dt.DefaultView[i][20].ToString()); f.FamilyMother.PID = dt.DefaultView[i][21].ToString(); h.Address = dt.DefaultView[i][22].ToString() + ((dt.DefaultView[i][23].ToString().Trim() == "") ? "" : (" بناء " + dt.DefaultView[i][23].ToString())) + ((dt.DefaultView[i][24].ToString().Trim() == "") ? "" : " طابق " + dt.DefaultView[i][24].ToString()); h.HouseType = dt.DefaultView[i][25].ToString(); f.FamilyFather.Phone = dt.DefaultView[i][26].ToString(); f.FamilyFather.Mobile = dt.DefaultView[i][27].ToString(); h.OldAddress = dt.DefaultView[i][28].ToString(); int j = 29; while (dt.DefaultView[i][j].ToString().Trim() != "") { FamilyPerson c = new FamilyPerson(); c.FirstName = dt.DefaultView[i][j].ToString(); c.DOB = GetDate(dt.DefaultView[i][j + 1].ToString()); c.Gender = (dt.DefaultView[i][j + 2].ToString() == "ذ") ? "ذكر" : "أنثى"; j += 3; fps.Add(c); } string temp = BaseDataBase._Scalar("select FamilyID from Family where FamilyCode = '" + f.FamilyCode + "'"); if (string.IsNullOrEmpty(temp)) { f.FamilyID = null; f.FamilyID = BaseDataBase._StoredProcedureReturnable("sp_Add2Family4Aleppo" , new SqlParameter("@FamilyID", SqlDbType.Int) , new SqlParameter("@FamilyCode", f.FamilyCode) , new SqlParameter("@FamilyName", f.FamilyName) , new SqlParameter("@FamilyType", f.FamilyType) , new SqlParameter("@FamilyIdentityID", f.FamilyIdentityID) , new SqlParameter("@ApplyDate", f.ApplyDate) , new SqlParameter("@FamilyPersonCount", f.FamilyPersonCount) , new SqlParameter("@FamilyStatus", f.FamilyStatus) , new SqlParameter("@Evaluation", f.Evaluation) , new SqlParameter("@Notes", f.Notes) , new SqlParameter("@Phone", f.FamilyFather.Phone) , new SqlParameter("@Mobile", f.FamilyFather.Mobile) , new SqlParameter("@FirstNameFF", f.FamilyFather.FirstName) , new SqlParameter("@FirstNameFFa", f.FamilyFather.FatherName) , new SqlParameter("@FirstNameFL", f.FamilyFather.LastName) , new SqlParameter("@BirthPlaceF", f.FamilyFather.BirthPlace) , new SqlParameter("@DOBF", f.FamilyFather.DOB) , new SqlParameter("@PIDF", f.FamilyFather.PID) , new SqlParameter("@FirstNameMF", f.FamilyMother.FirstName) , new SqlParameter("@FirstNameMFa", f.FamilyMother.FatherName) , new SqlParameter("@FirstNameML", f.FamilyMother.LastName) , new SqlParameter("@BirthPlaceM", f.FamilyMother.BirthPlace) , new SqlParameter("@DOBM", f.FamilyMother.DOB) , new SqlParameter("@PIDM", f.FamilyMother.PID) , new SqlParameter("@OldAddress", h.OldAddress) , new SqlParameter("@Address", h.Address)); if (!f.FamilyID.HasValue) { MessageBox.Show("خطأ في بيانات العائلة " + f.FamilyName + "\nذات الرقم " + f.FamilyCode); continue; } } else { f.FamilyID = int.Parse(temp); if (!BaseDataBase._StoredProcedure("sp_Add2Family4Aleppo1" , new SqlParameter("@FamilyID", f.FamilyID) , new SqlParameter("@FamilyCode", f.FamilyCode) , new SqlParameter("@FamilyName", f.FamilyName) , new SqlParameter("@FamilyType", f.FamilyType) , new SqlParameter("@FamilyIdentityID", f.FamilyIdentityID) , new SqlParameter("@ApplyDate", f.ApplyDate) , new SqlParameter("@FamilyPersonCount", f.FamilyPersonCount) , new SqlParameter("@FamilyStatus", f.FamilyStatus) , new SqlParameter("@Evaluation", f.Evaluation) , new SqlParameter("@Notes", f.Notes) , new SqlParameter("@Phone", f.FamilyFather.Phone) , new SqlParameter("@Mobile", f.FamilyFather.Mobile) , new SqlParameter("@FirstNameFF", f.FamilyFather.FirstName) , new SqlParameter("@FirstNameFFa", f.FamilyFather.FatherName) , new SqlParameter("@FirstNameFL", f.FamilyFather.LastName) , new SqlParameter("@BirthPlaceF", f.FamilyFather.BirthPlace) , new SqlParameter("@DOBF", f.FamilyFather.DOB) , new SqlParameter("@PIDF", f.FamilyFather.PID) , new SqlParameter("@FirstNameMF", f.FamilyMother.FirstName) , new SqlParameter("@FirstNameMFa", f.FamilyMother.FatherName) , new SqlParameter("@FirstNameML", f.FamilyMother.LastName) , new SqlParameter("@BirthPlaceM", f.FamilyMother.BirthPlace) , new SqlParameter("@DOBM", f.FamilyMother.DOB) , new SqlParameter("@PIDM", f.FamilyMother.PID) , new SqlParameter("@OldAddress", h.OldAddress) , new SqlParameter("@Address", h.Address))) { MessageBox.Show("خطأ في بيانات العائلة " + f.FamilyName + "\nذات الرقم " + f.FamilyCode); continue; } } BaseDataBase._NonQuery("delete from child where FamilyID = " + f.FamilyID); foreach (var item in fps) { item.FamilyID = f.FamilyID; DBMain.InsertData(item); } } catch { } } } }
async void FillData(Orphan o) { Family f = o.OrphanFamily; var hs = House.GetHouseAllByFamilyID(f.FamilyID); if (hs != null && hs.Count() > 0) { f.FamilyHouse = hs.Last(); } else { f.FamilyHouse = new House(); } if (f.FamilyID.HasValue) { cOrphanFamily.dgChild.ItemsSource = (from x in FamilyPerson.GetFamilyPersonByFamilyID(f.FamilyID.Value) orderby x.DOB select x).ToList(); } else { cOrphanFamily.dgChild.ItemsSource = new List <FamilyPerson>(); } cFamilyNeed.FamilyID = f.FamilyID; cExternalFamilySupport.FamilyID = f.FamilyID; cSpecialCard.FamilyID = f.FamilyID; cListerGroup.FamilyID = f.FamilyID; cTrainings.FamilyID = f.FamilyID; if (o.OrphanID.HasValue) { cSponsor.OrphanID = o.OrphanID; } cOrders.FamilyID = f.FamilyID; cOrphanFamily.txtFamilyCode.IsReadOnly = true; if (o.OrphanID.HasValue) { o.Account = Account.GetAccountByOwnerID(Account.AccountType.Student, o.OrphanID.Value); cAccount.Account = o.Account; } Guardian.GetAllGuardianByFamily(f); if (f.OrphanNursemaid == null) { f.OrphanNursemaid = new Guardian() { Gender = "أنثى" } } ; if (f.OrphanGuardian == null) { f.OrphanGuardian = new Guardian() { Gender = "ذكر" } } ; f.FamilyOrphans = await Orphan.GetAllOrphanByFamily(f, o, true); cOrphanFamily.Orphans = await Orphan.GetAllOrphanByFamily(f, o); }