async void GetTotal()
        {
            dgTotalQuantities.ItemsSource = null;
            var dt = await BaseDataBase._TablingAsync($@"select Name Item, Total from item inner join 
                    (select ItemID, SUM(Quantity) Total from Order_Item where OrderID in
                    (select id from[Order] where FamilyID = {FamilyID})
                    group by ItemID) g
                    on g.ItemId = item.id");

            dgTotalQuantities.ItemsSource = dt.DefaultView;
        }
        private async void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (tcMain.SelectedIndex == 0)
            {
                grdBottom.Visibility = System.Windows.Visibility.Collapsed;
            }
            if (tcMain.SelectedIndex > 0)
            {
                grdBottom.Visibility = System.Windows.Visibility.Visible;
                var control = tcMain.SelectedItem as TabItem;
                var DGMain  = (control.Content as FrameworkElement).FindName("dgMain") as DataGrid;
                grdBottom.DataContext = DGMain;
                if (DGMain.ItemsSource == null)
                {
                    switch (tcMain.SelectedIndex)
                    {
                    case 1:
                        DGMain.ItemsSource = (await BaseDataBase._TablingStoredProcedureAsync("GetStatistictsFamily")).DefaultView;
                        ucFamily.GetData();
                        break;

                    case 2:
                        //DGMain.ItemsSource = (await BaseDataBase._TablingStoredProcedureAsync("GetStatistictsItems")).DefaultView;
                        break;

                    case 3:
                        DGMain.ItemsSource = (await BaseDataBase._TablingStoredProcedureAsync("GetStatistictsFamilyPerson")).DefaultView;
                        ucFamilyPerson.GetData();
                        break;

                    case 4:
                        DGMain.ItemsSource = (await BaseDataBase._TablingStoredProcedureAsync("GetStatisticsFamilyNeed")).DefaultView;
                        ucFamilyNeed.GetData();
                        break;

                    case 5:
                        DGMain.ItemsSource = (await BaseDataBase._TablingAsync(@"
                            select FirstName + ' ' + LastName ListerName,FamilyCode,FamilyName,FamilyType,ApplyDate,FamilyPersonCount,IsCanceled,x.*,Family.Evaluation FamilyEvaluation from (select a.*, FamilyID,OrphanID,Date,ListerGroup.Notes ListerGroupNotes,Evaluation,CreatePerson,CreateDate,LastModifiedPerson FROM ListerGroup inner join 
                            (select Lister.*,GroupID from Lister_ListerGroup
                            inner join Lister ON Lister_ListerGroup.ListerID = Lister.ListerID) a
                            on ListerGroup.GroupID  = a.GroupID) x
                            Left outer join Family on x.FamilyID = Family.FamilyID")).DefaultView;
                        break;

                    default:
                        break;
                    }
                }
            }
        }
        async void GetData()
        {
            DataTable dt = await BaseDataBase._TablingStoredProcedureAsync("GetStatisticsItemsCount", new SqlParameter("@Date1", BaseDataBase.DateNow.ToString("MM-dd-yyyy 00:00")), new SqlParameter("@Date2", BaseDataBase.DateNow.ToString("MM-dd-yyyy 23:59")));

            //DataTable dt2 = await BaseDataBase._TablingAsync(@"select * from
            //    (select 'العوائل الكلية' Name, COUNT(*) Number,1 ID from Family
            //    Union
            //    select 'العوائل الغير ملغاة', COUNT(*), 2 from Family where IsCanceled <> 1
            //    Union
            //    select 'العوائل الملغاة', COUNT(*), 3 from Family where IsCanceled = 1
            //    ) a
            //    order by ID");
            DataTable dt2 = await BaseDataBase._TablingAsync(@"
                select Name, Number from Sector inner join
                (select SectorID,COUNT(*) Number from Family group by SectorID) g
                on g.SectorID = Sector.ID and IsActive = 1 order by Number DESC");

            grdStaMain.DataContext   = new StatisticsClass(dt);
            grdStaFamily.DataContext = new StatisticsClass(dt2);
        }