示例#1
0
        public void VolunteerStatisticMapperCreationTest()
        {
            VolunteerStatisticMapper  vsm    = new VolunteerStatisticMapper();
            List <VolunteerStatistic> vsList = new List <VolunteerStatistic>();

            Assert.AreEqual(0, vsList.Count);
            vsList = vsm.getList();
            int size = vsList.Count;

            Assert.AreEqual(size, vsm.getList().Count);
            vsm.ClearList();
            Assert.AreEqual(0, vsm.getList().Count);
        }
        private void GenerateVolunteerHours()
        {
            //if more than one operation selected, add a new column with operation ID
            if (Statistic.getListSize() > 1)
            {
                CreateOperationIDColumn();
            }

            foreach (VolunteerStatistic vs in vsm.getList())
            {
                //Creation of row for each new volunteer
                RowDefinition rd = new RowDefinition();
                rd.Height = new GridLength(50);
                VolunteerStats.RowDefinitions.Add(rd);
                Border border = new Border();
                border.BorderThickness = new Thickness(1, 0, 1, 1);
                border.BorderBrush     = new SolidColorBrush(Colors.Black);

                //Creation of new column for start time
                Border startBorder = new Border();
                startBorder.BorderThickness = new Thickness(1, 0, 1, 1);
                startBorder.BorderBrush     = new SolidColorBrush(Colors.Black);

                //Creation of new column for end time
                Border endBorder = new Border();
                endBorder.BorderThickness = new Thickness(0, 0, 1, 1);
                endBorder.BorderBrush     = new SolidColorBrush(Colors.Black);

                //Creation of new column for total hours
                Border totalBorder = new Border();
                totalBorder.BorderThickness = new Thickness(0, 0, 1, 1);
                totalBorder.BorderBrush     = new SolidColorBrush(Colors.Black);

                //Textblock creation for volunteer name
                TextBlock tb = new TextBlock();
                tb.FontWeight          = FontWeights.Bold;
                tb.Height              = 40;
                tb.FontSize            = 13;
                tb.Margin              = new Thickness(15, 0, 0, 0);
                tb.VerticalAlignment   = VerticalAlignment.Center;
                tb.HorizontalAlignment = HorizontalAlignment.Center;
                tb.TextWrapping        = TextWrapping.Wrap;

                //Textblock creation for start time
                TextBlock tbStart = new TextBlock();
                tbStart.FontWeight          = FontWeights.Bold;
                tbStart.Height              = 40;
                tbStart.FontSize            = 13;
                tbStart.Margin              = new Thickness(15, 0, 0, 0);
                tbStart.VerticalAlignment   = VerticalAlignment.Center;
                tbStart.HorizontalAlignment = HorizontalAlignment.Center;

                //Textblock creation for end time
                TextBlock tbEnd = new TextBlock();
                tbEnd.FontWeight          = FontWeights.Bold;
                tbEnd.Height              = 40;
                tbEnd.FontSize            = 13;
                tbEnd.Margin              = new Thickness(15, 0, 0, 0);
                tbEnd.VerticalAlignment   = VerticalAlignment.Center;
                tbEnd.HorizontalAlignment = HorizontalAlignment.Center;

                //Textblock creation for total hours
                TextBlock tbTotal = new TextBlock();
                tbTotal.FontWeight          = FontWeights.Bold;
                tbTotal.Height              = 40;
                tbTotal.FontSize            = 13;
                tbTotal.Margin              = new Thickness(15, 0, 0, 0);
                tbTotal.VerticalAlignment   = VerticalAlignment.Center;
                tbTotal.HorizontalAlignment = HorizontalAlignment.Center;

                //adding textblock to borders
                border.Child      = tb;
                startBorder.Child = tbStart;
                endBorder.Child   = tbEnd;
                totalBorder.Child = tbTotal;

                //adding borders to main grid
                VolunteerStats.Children.Add(border);
                VolunteerStats.Children.Add(startBorder);
                VolunteerStats.Children.Add(endBorder);
                VolunteerStats.Children.Add(totalBorder);

                //Getting values from DB


                //Setting strings from db values
                tb.Text      = vs.getName();
                tbStart.Text = vs.getStart().ToString();
                tbEnd.Text   = vs.getEnd().ToString();
                tbTotal.Text = vs.getTimeDiff().ToString();

                //When more than one operation
                if (Statistic.getListSize() > 1)
                {
                    //Creation of new column for operationID
                    Border operationBorder = new Border();
                    operationBorder.BorderThickness = new Thickness(0, 0, 1, 1);
                    operationBorder.BorderBrush     = new SolidColorBrush(Colors.Black);

                    //Textblock creation for opeartion ID
                    TextBlock tbOperation = new TextBlock();
                    tbOperation.FontWeight          = FontWeights.Bold;
                    tbOperation.Height              = 40;
                    tbOperation.FontSize            = 13;
                    tbOperation.Margin              = new Thickness(15, 0, 0, 0);
                    tbOperation.VerticalAlignment   = VerticalAlignment.Center;
                    tbOperation.HorizontalAlignment = HorizontalAlignment.Center;


                    tbOperation.Text      = vs.getOperationID();
                    operationBorder.Child = tbOperation;
                    VolunteerStats.Children.Add(operationBorder);

                    Grid.SetColumn(operationBorder, 4);
                    Grid.SetRow(operationBorder, rowIndexer);
                }


                Grid.SetColumn(border, 0);
                Grid.SetRow(border, rowIndexer);
                Grid.SetColumn(startBorder, 1);
                Grid.SetRow(startBorder, rowIndexer);
                Grid.SetColumn(endBorder, 2);
                Grid.SetRow(endBorder, rowIndexer);
                Grid.SetColumn(totalBorder, 3);
                Grid.SetRow(totalBorder, rowIndexer);

                rowIndexer++;
            }
            vsm.ClearList();
        }