private void btnSearch_Click(object sender, RoutedEventArgs e) { switch (cmboPrintType.SelectedIndex) { case 0: DGMain.ItemsSource = BaseDataBase._TablingStoredProcedure("GetTempFamilyAllTableForPrint").DefaultView; var uc1 = ucCurrent as ReportTempFamilyControlAll; if (uc1 != null) { uc1.Changing(); } DGMain_Loaded(DGMain, null); break; case 1: DGMain.ItemsSource = BaseDataBase._TablingStoredProcedure("GetFixedFamilyAllTableForPrint").DefaultView; var uc2 = ucCurrent as ReportFixedFamilyControlAll; if (uc2 != null) { uc2.Changing(); } DGMain_Loaded(DGMain, null); break; } }
private void btnSearch_Click(object sender, RoutedEventArgs e) { if (!isWorking) { isWorking = true; Storyboard sb = (App.Current.Resources["sbRotateButton"] as Storyboard).Clone(); sb.SetValue(Storyboard.TargetProperty, sender); sb.Begin(); dgOrphans.ItemsSource = BaseDataBase._TablingStoredProcedure("sp_GetOrphansTable").DefaultView; Control_Changed(null, null); sb.Pause(); isWorking = false; } }
private void RadioButton_Checked(object sender, RoutedEventArgs e) { if (IsLoaded) { var r = sender as RadioButton; if (r == null || r.Content == null) { return; } switch (r.Content.ToString()) { case "أيتام": dgTemp.ItemsSource = BaseDataBase._TablingStoredProcedure("sp_Get_All_Trainees_ByType", (new SqlParameter("@Type", 1))).DefaultView; Control_Changed(null, null); break; case "طلاب علم": dgTemp.ItemsSource = BaseDataBase._TablingStoredProcedure("sp_Get_All_Trainees_ByType", new SqlParameter("@Type", 2)).DefaultView; Control_Changed(null, null); break; case "أمهات": dgTemp.ItemsSource = BaseDataBase._TablingStoredProcedure("sp_Get_All_Trainees_ByType", new SqlParameter("@Type", 3)).DefaultView; Control_Changed(null, null); break; case "حاضنات": dgTemp.ItemsSource = BaseDataBase._TablingStoredProcedure("sp_Get_All_Trainees_ByType", new SqlParameter("@Type", 4)).DefaultView; Control_Changed(null, null); break; case "أوصياء": dgTemp.ItemsSource = BaseDataBase._TablingStoredProcedure("sp_Get_All_Trainees_ByType", new SqlParameter("@Type", 5)).DefaultView; Control_Changed(null, null); break; } } }
private void btnDeleteFamilyData_Click(object sender, RoutedEventArgs e) { if (dgFamily.SelectedIndex != -1) { if (!BaseDataBase.CurrentUser.PointAdmin) { MyMessageBox.Show("ليس لديك صلاحيات للحذف"); } else { Family f = Family.GetFamilyByID((int)(dgFamily.Items[dgFamily.SelectedIndex] as DataRowView)[0]); if (MyMessageBox.Show("هل تريد تأكيد حذف بيانات العائلة", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { if (DBMain.DeleteData(f)) { dt = BaseDataBase._TablingStoredProcedure("sp_GetFamilyAllTable"); SetItemsSource(1); Control_Changed(null, null); MyMessage.DeleteMessage(); } } } } }
private void btnPrintSelected_Click(object sender, RoutedEventArgs e) { if (cmboPrintType.SelectedIndex == 0) { if (DGMain.SelectedItems.Count > 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.SelectedItems) { 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); } if (cmboPrintType.SelectedIndex == 0) { DGMain.ItemsSource = BaseDataBase._TablingStoredProcedure("GetTempFamilyAllTableForPrint").DefaultView; } MyMessage.CustomMessage("تمت الطباعة بنجاح"); } catch (Exception ex) { MyMessageBox.Show(ex.Message); } } } } else { if (DGMain.SelectedItems.Count > 0) { 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.SelectedItems) { 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); MyMessage.CustomMessage("تمت الطباعة بنجاح"); } catch (Exception ex) { MyMessageBox.Show(ex.Message); } } } } }
private void btnCustom_Click(object sender, RoutedEventArgs e) { DataTable dt = BaseDataBase._TablingStoredProcedure("GetStatisticsItemsCount", new SqlParameter("@Date1", dtp1.SelectedDate.HasValue ? dtp1.SelectedDate.Value.ToString("MM-dd-yyyy 00:00") : "01-01-2000 00:00"), new SqlParameter("@Date2", dtp2.SelectedDate.HasValue ? dtp2.SelectedDate.Value.ToString("MM-dd-yyyy 23:59") : "01-01-2050 00:00")); grdStaMain.DataContext = new StatisticsClass(dt); }
private void btnMonth_Click(object sender, RoutedEventArgs e) { DataTable dt = BaseDataBase._TablingStoredProcedure("GetStatisticsItemsCount", new SqlParameter("@Date1", BaseDataBase.DateNow.AddYears(-1).ToString("MM-dd-yyyy 00:00")), new SqlParameter("@Date2", BaseDataBase.DateNow.ToString("MM-dd-yyyy 23:59"))); grdStaMain.DataContext = new StatisticsClass(dt); }
public static DataView GetAllSupervisorTableMethod() { return(BaseDataBase._TablingStoredProcedure("sp_GetAllSupervisorsTable").DefaultView); }
public static DataTable GetTempFamilyTable() { return(BaseDataBase._TablingStoredProcedure("sp_GetTempFamilyTable")); }