private void ButtonSave_Click(object sender, RoutedEventArgs e) { Properties.Settings.Default.ActiveFingerPrint = chk.IsChecked.Value; Properties.Settings.Default.Save(); MyMessage.CustomMessage(chk.IsChecked.Value ? "تم التفعيل بنجاح" : "تم الالغاء بنجاح"); this.Close(); }
private void Button_Click(object sender, RoutedEventArgs e) { Properties.Settings.Default.VoucherType = cmbo.SelectedIndex; Properties.Settings.Default.Save(); MyMessage.CustomMessage("تم الحفظ بنجاح"); this.Close(); }
private void btnSave_Click(object sender, RoutedEventArgs e) { if (radGeneral.IsChecked == true) { var lst = dg.ItemsSource as List <NextOrderCriteria>; foreach (var item in lst) { if (!item.IsValidate() || !AllValidated(lst)) { return; } } string query = "delete from NextOrderCriteria;"; foreach (var item in lst) { query += $"insert into NextOrderCriteria (FromMember,ToMember,NumberOfDays,LastUserID) Values ({item.FromMember},{item.ToMember},{item.NumberOfDays},{BaseDataBase.CurrentUser.ID});"; } if (BaseDataBase._NonQuery(query) > 0) { MyMessage.CustomMessage("تم الحفظ بنجاح"); } SystemProperties.UpdateData(SystemProperties.Property.NextOrderSpecialFamily, ""); if (nudDaysSpecialFamily.Value.HasValue) { SystemProperties.UpdateData(SystemProperties.Property.NextOrderSpecialFamily, nudDaysSpecialFamily.Value.ToString()); } SystemProperties.UpdateData(SystemProperties.Property.NextOrderGap, ""); if (nudDaysSpecialFamily.Value.HasValue) { SystemProperties.UpdateData(SystemProperties.Property.NextOrderGap, nudNextOrderGap.Value.ToString()); } DialogResult = true; } else { if (dgSector.Items.Count > 0) { var lst = dgSector.ItemsSource as List <Sector>; foreach (var item in lst) { Sector.UpdateData(item); } DialogResult = true; MyMessage.UpdateMessage(); } } }
private void Button_Click_1(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog od = new Microsoft.Win32.OpenFileDialog(); od.Filter = "Image Files|*.jpg;*.png"; if (od.ShowDialog() == true) { System.IO.FileInfo fi = new System.IO.FileInfo(od.FileName); if (fi.Length / 1024 / 1024 > 1) { MyMessageBox.Show("حجم الصورة يجب أن يكون أقل من 1 ميغا"); return; } Properties.Settings.Default.AssociationLogoPath = fi.FullName; Properties.Settings.Default.Save(); BitmapImage bi = new BitmapImage(); bi.BeginInit(); bi.UriSource = new Uri(fi.FullName, UriKind.RelativeOrAbsolute); bi.EndInit(); img.Source = bi; MyMessage.CustomMessage("تم الحفظ بنجاح"); } }
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 Button_Click_3(object sender, RoutedEventArgs e) { Properties.Settings.Default.VoucherHeaderText = txtVoucherHeader.Text; Properties.Settings.Default.Save(); MyMessage.CustomMessage("تم الحفظ بنجاح"); }
private void Button_Click_2(object sender, RoutedEventArgs e) { Properties.Settings.Default.ReportHeaderDescription = txtDescription.Text; Properties.Settings.Default.Save(); MyMessage.CustomMessage("تم الحفظ بنجاح"); }
private void btnPrintSelected_Click(object sender, RoutedEventArgs e) { if (dgFamily.SelectedIndex != -1) { if (!BaseDataBase.CurrentUser.CanPrintReports) { MyMessageBox.Show("ليس لديك صلاحية طباعة"); return; } try { Family f = Family.GetFamilyByID((int)(dgFamily.Items[dgFamily.SelectedIndex] as DataRowView)[0]); SaveFileDialog dlg = new SaveFileDialog(); dlg.FileName = "استمارة " + f.FamilyCode; dlg.DefaultExt = ".xps"; dlg.Filter = "XPS Print Documents (.xps)|*.xps"; if (dlg.ShowDialog() == true) { string filename = dlg.FileName; if (filename.Substring(filename.LastIndexOf('.'), filename.Length - filename.LastIndexOf('.')) != ".xps") { filename += ".xps"; } FixedDocument fd = new FixedDocument(); fd.DocumentPaginator.PageSize = new Size(1056, 768); 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 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 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); } } }