public NextOrderCriteriaControl() { InitializeComponent(); try { nudDaysSpecialFamily.Value = int.Parse(SystemProperties.GetSystemPropertyValue(SystemProperties.Property.NextOrderSpecialFamily)); } catch { } try { nudNextOrderGap.Value = int.Parse(SystemProperties.GetSystemPropertyValue(SystemProperties.Property.NextOrderGap)); } catch { } var dt = BaseDataBase._Tabling("select FromMember,ToMember,NumberOfDays from NextOrderCriteria"); if (dt != null && dt.Rows.Count > 0) { var lst = new List <NextOrderCriteria>(); foreach (DataRow item in dt.Rows) { lst.Add(new NextOrderCriteria() { FromMember = (int)item[0], ToMember = (int)item[1], NumberOfDays = (int)item[2] }); } dg.ItemsSource = lst; } else { dg.ItemsSource = new List <NextOrderCriteria>(); } dgSector.ItemsSource = Sector.GetAllSector(); }
private void txtDigitalNumber_TextChanged(object sender, TextChangedEventArgs e) { var f = this.DataContext as Family; if (f != null) { if (!string.IsNullOrEmpty(txtDigitalNumber.Text)) { var dt = BaseDataBase._Tabling($@"select FamilyCode from Family where FamilyID in (select FamilyID from house where DigitalAddress like '{txtDigitalNumber.Text}'" + (f.FamilyID.HasValue ? $" and familyID <> {f.FamilyID})" : ")")); if (dt != null && dt.Rows.Count > 0) { string s = "العنوان الرقمي المدخل موجود في:"; foreach (DataRow r in dt.Rows) { s += "\n" + r.ItemArray[0].ToString(); } txtDigitalNumberFamilies.Text = s; pop.IsOpen = true; } else { pop.IsOpen = false; } } } }
public Transition_SponsorWindow(Sponsor s, FundType ft) { InitializeComponent(); txtSponsorName.Text = s.Name; var i = new Invoice(); i.AddTransition(); i.Transitions[0].LeftAccount = s.Account; if (ft == FundType.GeneralHidden) { i.Transitions[0].IsHidden = true; txtHeader.Text += " (ايداع مخفي)"; } if (ft == FundType.Private) { cmboAccounts.ItemsSource = BaseDataBase._Tabling("select Id, Name from Account where Id between 2 and 4").DefaultView; } else { cmboAccounts.ItemsSource = BaseDataBase._Tabling("select Id, Name from Account where Id = 1").DefaultView; cmboAccounts.SelectedIndex = 0; GetCurrentBalance(s.Account.Id.Value, 1); } this.DataContext = i; }
public VoucherCriteriaControl() { InitializeComponent(); VoucherGruopItems = new Dictionary <int, List <Item> >(); var dt = BaseDataBase._Tabling("Select GroupID, ItemID from VoucherCriteria order by GroupID"); int GroupID = 0; List <Item> items = null; foreach (DataRow item in dt.Rows) { int x = (int)item[0]; if (x != GroupID) { if (GroupID != 0) { VoucherGruopItems.Add(GroupID, items); } GroupID = x; items = new List <Item>(); } items.Add(Item.GetItemByID((int)item[1])); } if (GroupID != 0) { VoucherGruopItems.Add(GroupID, items); } lstMain.ItemsSource = VoucherGruopItems; }
private void btnExportPresentData_Click(object sender, RoutedEventArgs e) { var i = cmboInventory.SelectedItem as Inventory; if (i != null) { var dt1 = BaseDataBase._Tabling("select * from [Order] where InventoryID = " + i.ID); var dt2 = BaseDataBase._Tabling($"select * from Order_Item where OrderID in (select Id from [Order] where InventoryID = {i.ID})"); var dt3 = BaseDataBase._Tabling($"select * from [dbo].[FamilyNeed_ListerGroup] where OrderID in (select Id from [Order] where InventoryID = {i.ID})"); DataSet ds = new DataSet(); ds.Tables.Add(dt1); ds.Tables.Add(dt2); ds.Tables.Add(dt3); SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "Rawd DataSet File|*.ds"; if (sfd.ShowDialog() == true) { ds.WriteXml(sfd.FileName); ds.WriteXmlSchema(sfd.FileName.Substring(0, sfd.FileName.LastIndexOf('.')) + "_ds.ds"); } } else { MyMessageBox.Show("يجب اختيار المستودع المراد تصدير بيانات التسليم فيه"); } }
public FormedBasketControl() { InitializeComponent(); cmboFormedBasket.ItemsSource = BaseDataBase._Tabling("select Id,Name from FormedBasket").DefaultView; this.DataContext = new FormedBasket(); dgSelectedItems.ItemsSource = new List <FormedBasket_Item>(); lbMainItems.ItemsSource = Item.AllItems; lbSectors.ItemsSource = Sector.GetAllSector(); }
public StatisticsClass(string Query) { Items = new ObservableCollection <BaseCharClass>(); DataTable dt = BaseDataBase._Tabling(Query); foreach (DataRow row in dt.Rows) { Items.Add(new BaseCharClass() { Name = row["Name"].ToString(), Number = int.Parse(row["Number"].ToString()) }); } }
private void btnShow_Click(object sender, RoutedEventArgs e) { if (!dp1.SelectedDate.HasValue || !dp2.SelectedDate.HasValue || cmboInventory.SelectedIndex == -1) { MyMessageBox.Show("يجب اختيار تاريخ البداية وتاريخ النهاية واختيار المستودع لاظهار التقرير"); return; } Items.ItemsSource = BaseDataBase._Tabling($@"select name ItemName, Quantity, StandardUnit from Item inner join (select ItemID, SUM(Quantity) Quantity from Order_Item where OrderID in (select ID from [Order] o where (Type = 3 or Type = 4) and InventoryID = {cmboInventory.SelectedValue} and convert(date,date) between '{dp1.SelectedDate.Value.ToString("MM-dd-yyy")}' and '{dp2.SelectedDate.Value.ToString("MM-dd-yyy")}') group by ItemID) g on g.ItemID = Item.Id order by ItemName").DefaultView; //Items.ItemsSource = BaseDataBase._Tabling($@"select Inventory.Name InventoryName, Item.Name ItemName, Quantity, StandardUnit from Item //inner join //(select InventoryID, ItemID, SUM(Quantity) Quantity //from [Order] o //inner join Order_Item oi //on o.Id = oi.OrderID //and InventoryID = {cmboInventory.SelectedValue} and convert(date,date) between '{dp1.SelectedDate.Value.ToString("MM-dd-yyy")}' and '{dp2.SelectedDate.Value.ToString("MM-dd-yyy")}' //and (o.Type = 3 or o.Type = 4) //group by InventoryID, ItemID) g //on g.ItemID = Item.Id //inner join Inventory //on g.InventoryID = Inventory.ID //order by InventoryName, ItemName").DefaultView; grdToPrint.Visibility = Items.Items.Count > 0 ? Visibility.Visible : Visibility.Collapsed; txtDate1.Text = dp1.SelectedDate.Value.ToString("dd/MM/yyyy"); txtDate2.Text = dp2.SelectedDate.Value.ToString("dd/MM/yyyy"); txtInventoryHeader.Text = (cmboInventory.SelectedItem as Inventory).Name; txtHeader.Text = Properties.Settings.Default.ReportHeaderDescription; BitmapImage bitmap = new BitmapImage(); bitmap.BeginInit(); bitmap.UriSource = new Uri(Properties.Settings.Default.AssociationLogoPath, UriKind.RelativeOrAbsolute); bitmap.EndInit(); img1.Source = bitmap; img2.Source = bitmap; txtNow.Text = BaseDataBase.DateNow.ToString("dd/MM/yyyy hh:mm"); txtUser.Text = BaseDataBase.CurrentUser.Name; }
void SetCmboNameItemsSource(int TypeID) { cmboName.ItemsSource = null; switch (TypeID) { case 1: cmboName.ItemsSource = BaseDataBase._Tabling("select FamilyID ID, FamilyName Name from Family where FamilyID = " + FamilyID).DefaultView; break; case 2: cmboName.ItemsSource = BaseDataBase._Tabling("select ParentrID ID, FirstName Name from Parent where FamilyID = " + FamilyID).DefaultView; break; case 3: cmboName.ItemsSource = BaseDataBase._Tabling("select FamilyPersonID ID, FirstName Name from FamilyPerson where FamilyID = " + FamilyID).DefaultView; break; default: break; } }
public TeachingStageControl() { InitializeComponent(); cmboClass.ItemsSource = BaseDataBase._Tabling("select distinct Class from TeachingStage").DefaultView; }
internal static void printInvoiceA6(Invoice i, int Type) { try { var uc = LoadTemplate(Path.Combine(Environment.CurrentDirectory, "InvoiceReportTemplate.xaml")) as UserControl; (uc.FindName("txtHeader") as TextBlock).Text = Properties.Settings.Default.VoucherHeaderText; var img = uc.FindName("img") as Image; BitmapImage bitmap = new BitmapImage(); bitmap.BeginInit(); bitmap.UriSource = new Uri(Properties.Settings.Default.AssociationLogoPath, UriKind.RelativeOrAbsolute); bitmap.EndInit(); img.Source = bitmap; if (Type == 1) { uc.DataContext = BaseDataBase._Tabling($@"select Description, Barcode, TotalValue, Serial, Receiver, ReceiverPID, dbo.GetUserByID(LastUserID) UserName, CreateDate, (select Name from Account where ID = {i.Transitions[0].LeftAccount.Id.Value}) SponsorName from Invoice where Id = {i.ID.Value}"); (uc.FindName("grdSponsor") as Grid).Visibility = Visibility.Visible; } else if (Type == 2) { var dv = BaseDataBase._Tabling($@"select Description, Barcode, TotalValue, Serial, Receiver, ReceiverPID, dbo.GetUserByID(LastUserID) UserName, CreateDate from Invoice where Id = {i.ID.Value}"); (uc.FindName("icOrphans") as ItemsControl).ItemsSource = BaseDataBase._Tabling($@"select FirstName + ' ' + ISNULL(LastName,'') OrphanName, orphan.Type, Value, Sponsor.Name SponsorName from orphan inner join Account on Account.Type >= 2 and OwnerID = OrphanID inner join Transition on InvoiceID = {i.ID.Value} and Account.Id = RightAccount inner join (select * from Sponsorship where ID in (select Max(ID) from Sponsorship group by OrphanID)) Sponsorship on Sponsorship.OrphanID = Orphan.OrphanID inner join AvailableSponsorship on AvailableSponsorship.Id = Sponsorship.AvailableSponsorshipID inner join Sponsor on AvailableSponsorship.SponsorID = Sponsor.SponsorID").DefaultView; uc.DataContext = dv; (uc.FindName("grdOrphan") as Grid).Visibility = Visibility.Visible; var w = new ToWord(decimal.Parse(dv.Rows[0]["TotalValue"].ToString()), new CurrencyInfo(CurrencyInfo.Currencies.Syria)); (uc.FindName("TotalValueWord") as TextBlock).Text = w.ConvertToArabic(); } // Create the print dialog object and set options PrintDialog pDialog = new PrintDialog(); pDialog.PageRangeSelection = PageRangeSelection.AllPages; pDialog.UserPageRangeEnabled = true; pDialog.PrintQueue = System.Printing.LocalPrintServer.GetDefaultPrintQueue(); pDialog.PrintTicket = pDialog.PrintQueue.DefaultPrintTicket; pDialog.PrintTicket.PageScalingFactor = 1; System.Printing.PrintCapabilities capabilities = null; try { capabilities = pDialog.PrintQueue.GetPrintCapabilities(pDialog.PrintTicket); } catch { capabilities = null; } Viewbox vb = new Viewbox(); vb.Child = uc; System.Windows.Size sz = new Size(520, 380); vb.MinWidth = 1; vb.MinHeight = 1; vb.Measure(sz); vb.Arrange(new System.Windows.Rect(new System.Windows.Point(capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight), sz)); double scale = 1; vb.LayoutTransform = new ScaleTransform(scale, scale); pDialog.PrintVisual(vb, "MyViewBox"); } catch (Exception ex) { MyMessageBox.Show(ex.Message); } }
internal static void printReportA6(Order o) { try { if (o.Type < 3) { var uc = LoadTemplate(Path.Combine(Environment.CurrentDirectory, "VoucherReportTemplate.xaml")) as UserControl; uc.DataContext = o; (uc.FindName("Items") as ItemsControl).ItemsSource = from x in o.OIs select new { ItemName = x.Item.Name, Quantity = x.Quantity, StandardUnit = x.Item.StandardUnit }; (uc.FindName("txtTag") as TextBlock).Text = "1/1"; (uc.FindName("txtHeader") as TextBlock).Text = Properties.Settings.Default.VoucherHeaderText; (uc.FindName("grdFamily") as Grid).Visibility = Visibility.Collapsed; (uc.FindName("grdOrder") as Grid).Visibility = Visibility.Visible; var img = uc.FindName("img") as Image; BitmapImage bitmap = new BitmapImage(); bitmap.BeginInit(); bitmap.UriSource = new Uri(Properties.Settings.Default.AssociationLogoPath, UriKind.RelativeOrAbsolute); bitmap.EndInit(); img.Source = bitmap; // Create the print dialog object and set options PrintDialog pDialog = new PrintDialog(); pDialog.PageRangeSelection = PageRangeSelection.AllPages; pDialog.UserPageRangeEnabled = true; pDialog.PrintQueue = System.Printing.LocalPrintServer.GetDefaultPrintQueue(); pDialog.PrintTicket = pDialog.PrintQueue.DefaultPrintTicket; pDialog.PrintTicket.PageScalingFactor = 1; System.Printing.PrintCapabilities capabilities = null; try { capabilities = pDialog.PrintQueue.GetPrintCapabilities(pDialog.PrintTicket); } catch { capabilities = null; } Viewbox vb = new Viewbox(); vb.Child = uc; System.Windows.Size sz = new Size(520, 380); vb.MinWidth = 1; vb.MinHeight = 1; vb.Measure(sz); vb.Arrange(new System.Windows.Rect(new System.Windows.Point(capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight), sz)); double scale = 1; vb.LayoutTransform = new ScaleTransform(scale, scale); pDialog.PrintVisual(vb, "MyViewBox"); } else if (o.Type == 3) { var dtVoucherCriteria = BaseDataBase._Tabling($@"select IsNull(GroupID,-1) GroupID,Item.Name ItemName, Quantity, StandardUnit from (select ItemID, Quantity from Order_Item where OrderID = {o.Id}) t1 inner join Item on t1.ItemID = item.Id left outer join VoucherCriteria t2 on t1.ItemID = t2.ItemID"); if (dtVoucherCriteria != null && dtVoucherCriteria.Rows.Count > 0) { List <DataTable> subTables = dtVoucherCriteria.AsEnumerable().GroupBy(row => row.Field <int>("GroupID")).Select(g => g.CopyToDataTable()).ToList(); if (subTables.Count > 1) { MyMessageBox.Show("ستم طباعة " + subTables.Count + " وصل"); } var dt = BaseDataBase._Tabling($@"select OrderCode Id,[Order].Barcode, dbo.GetInventory(InventoryID) InventoryName,dbo.fn_getSectorByOrderID([Order].Id) Sector, Family.FamilyID FamilyCode, case when FatherName is not null then FatherName else (case when MotherName is not null then MotherName else FamilyName end) end as FatherName, case when FatherPID is not null then FatherPID else (case when MotherPID is not null then MotherPID else 'لايوجد رقم وطني' end) end as PID, NextOrderDate, Date, Users.Name Presenter from [Order] inner join Family on [Order].Id = {o.Id} and Family.FamilyID = [Order].FamilyID inner join Users on Users.Id = [Order].LastUserID left outer join (select FirstName + ' ' + IsNUll(LastName,'') FatherName ,PID FatherPID, FamilyID from Parent where Gender like N'ذكر') x on x.FamilyID = [Order].FamilyID left outer join (select FirstName + ' ' + IsNUll(LastName,'') MotherName ,PID MotherPID, FamilyID from Parent where Gender like N'أنثى') y on y.FamilyID = [Order].FamilyID"); for (int i = 0; i < subTables.Count; i++) { var uc = LoadTemplate(Path.Combine(Environment.CurrentDirectory, "VoucherReportTemplate.xaml")) as UserControl; uc.DataContext = null; uc.DataContext = dt.DefaultView; (uc.FindName("Items") as ItemsControl).ItemsSource = subTables[i].DefaultView; (uc.FindName("txtTag") as TextBlock).Text = (i + 1) + "/" + subTables.Count; (uc.FindName("txtHeader") as TextBlock).Text = Properties.Settings.Default.VoucherHeaderText; var img = uc.FindName("img") as Image; BitmapImage bitmap = new BitmapImage(); bitmap.BeginInit(); bitmap.UriSource = new Uri(Properties.Settings.Default.AssociationLogoPath, UriKind.RelativeOrAbsolute); bitmap.EndInit(); img.Source = bitmap; // Create the print dialog object and set options PrintDialog pDialog = new PrintDialog(); pDialog.PageRangeSelection = PageRangeSelection.AllPages; pDialog.UserPageRangeEnabled = true; pDialog.PrintQueue = System.Printing.LocalPrintServer.GetDefaultPrintQueue(); pDialog.PrintTicket = pDialog.PrintQueue.DefaultPrintTicket; pDialog.PrintTicket.PageScalingFactor = 1; System.Printing.PrintCapabilities capabilities = null; try { capabilities = pDialog.PrintQueue.GetPrintCapabilities(pDialog.PrintTicket); } catch { capabilities = null; } Viewbox vb = new Viewbox(); vb.Child = uc; System.Windows.Size sz = new Size(520, 380); vb.MinWidth = 1; vb.MinHeight = 1; vb.Measure(sz); vb.Arrange(new System.Windows.Rect(new System.Windows.Point(capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight), sz)); double scale = 1; vb.LayoutTransform = new ScaleTransform(scale, scale); pDialog.PrintVisual(vb, "MyViewBox"); } } } else { var dtVoucherCriteria = BaseDataBase._Tabling($@"select IsNull(GroupID,-1) GroupID,Item.Name ItemName, Quantity, StandardUnit from (select ItemID, Quantity from Order_Item where OrderID = {o.Id}) t1 inner join Item on t1.ItemID = item.Id left outer join VoucherCriteria t2 on t1.ItemID = t2.ItemID"); if (dtVoucherCriteria != null && dtVoucherCriteria.Rows.Count > 0) { List <DataTable> subTables = dtVoucherCriteria.AsEnumerable().GroupBy(row => row.Field <int>("GroupID")).Select(g => g.CopyToDataTable()).ToList(); if (subTables.Count > 1) { MyMessageBox.Show("ستم طباعة " + subTables.Count + " وصل"); } var dt = BaseDataBase._Tabling($@"select OrderCode Id,[Order].Barcode, dbo.GetInventory(InventoryID) InventoryName,'عائلة خاصة' Sector, SpecialFamily.Id FamilyCode, SpecialFamily.Name FatherName, PID, Date, Users.Name Presenter from [Order] inner join SpecialFamily on [Order].Id = {o.Id} and SpecialFamily.Id = [Order].SpecialFamilyID inner join Users on Users.Id = [Order].LastUserID"); for (int i = 0; i < subTables.Count; i++) { var uc = LoadTemplate(Path.Combine(Environment.CurrentDirectory, "VoucherReportTemplate.xaml")) as UserControl; uc.DataContext = null; uc.DataContext = dt; (uc.FindName("Items") as ItemsControl).ItemsSource = subTables[i].DefaultView; (uc.FindName("txtTag") as TextBlock).Text = (i + 1) + "/" + subTables.Count; (uc.FindName("txtHeader") as TextBlock).Text = Properties.Settings.Default.VoucherHeaderText; //(uc.FindName("Items") as ItemsControl).ItemsSource = from x in o.OIs select new { ItemName = x.Item.Name, Quantity = x.Quantity, StandardUnit = x.Item.StandardUnit }; //(uc.FindName("txtTag") as TextBlock).Text = "1/1"; var img = uc.FindName("img") as Image; BitmapImage bitmap = new BitmapImage(); bitmap.BeginInit(); bitmap.UriSource = new Uri(Properties.Settings.Default.AssociationLogoPath, UriKind.RelativeOrAbsolute); bitmap.EndInit(); img.Source = bitmap; // Create the print dialog object and set options PrintDialog pDialog = new PrintDialog(); pDialog.PageRangeSelection = PageRangeSelection.AllPages; pDialog.UserPageRangeEnabled = true; pDialog.PrintQueue = System.Printing.LocalPrintServer.GetDefaultPrintQueue(); pDialog.PrintTicket = pDialog.PrintQueue.DefaultPrintTicket; pDialog.PrintTicket.PageScalingFactor = 1; System.Printing.PrintCapabilities capabilities = null; try { capabilities = pDialog.PrintQueue.GetPrintCapabilities(pDialog.PrintTicket); } catch { capabilities = null; } Viewbox vb = new Viewbox(); vb.Child = uc; System.Windows.Size sz = new Size(520, 380); vb.MinWidth = 1; vb.MinHeight = 1; vb.Measure(sz); vb.Arrange(new System.Windows.Rect(new System.Windows.Point(capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight), sz)); double scale = 1; vb.LayoutTransform = new ScaleTransform(scale, scale); pDialog.PrintVisual(vb, "MyViewBox"); } } } } catch (Exception ex) { MyMessageBox.Show(ex.Message); } }
public OrphanImpedingControl() { InitializeComponent(); cmbo.ItemsSource = BaseDataBase._Tabling("select distinct impedingType from impeding").DefaultView; }