Selaa lähdekoodia

Summaries für alle Drucklisten abgeschlossen!

Arne Diekmann 8 vuotta sitten
vanhempi
commit
26e87b5b9f

+ 35 - 0
GreenTree.Nachtragsmanagement.Web/Controllers/AppendixController.cs

@@ -144,6 +144,7 @@ namespace GreenTree.Nachtragsmanagement.Web.Controllers
                 generator.CustomizeColumnsCollection += new CustomizeColumnsCollectionEventHandler(generator_CustomizeColumnsCollection);
                 generator.CustomizeGroupColumnSummary += new CustomizeColumnGroupSummaryEventHandler(generator_CustomizeGroupColumnSummary);
                 generator.CustomizeTotalColumnSummary += new CustomizeColumnTotalSummaryEventHandler(generator_CustomizeTotalColumnSummary);
+                generator.PageSummaryGetResult += new SummaryGetResultHandler(generator_PageSummaryGetResult);
 
                 var report = generator.GenerateMVCReport(gridViewState, appendixModels, "Nachtragsliste");
 
@@ -191,6 +192,40 @@ namespace GreenTree.Nachtragsmanagement.Web.Controllers
                 return new EmptyResult();
         }
 
+        private decimal accumulatedCustomSummaryOfferingValue = 0;
+        private decimal accumulatedCustomSummaryNegotiationValue = 0;
+        private decimal accumulatedCustomSummaryCount = 0;
+
+        /// <summary>
+        /// Set custom summary result for page
+        /// </summary>
+        /// <param name="source"></param>
+        /// <param name="e"></param>
+        private void generator_PageSummaryGetResult(object source, SummaryGetResultEventArgs e)
+        {
+            var label = (XRLabel)source;
+
+            if (label.Tag.ToString() == "OfferingValue")
+            {
+                accumulatedCustomSummaryOfferingValue += e.CalculatedValues.OfType<decimal>().Sum();
+                e.Result = accumulatedCustomSummaryOfferingValue;
+            }
+
+            if (label.Tag.ToString() == "NegotiationValue")
+            {
+                accumulatedCustomSummaryOfferingValue += e.CalculatedValues.OfType<decimal>().Sum();
+                e.Result = accumulatedCustomSummaryOfferingValue;
+            }
+
+            if (label.Tag.ToString() == "Description")
+            {
+                accumulatedCustomSummaryCount += e.CalculatedValues.Count;
+                e.Result = accumulatedCustomSummaryCount;
+            }
+
+            e.Handled = true;
+        }
+
         /// <summary>
         /// Customize formatting
         /// </summary>

+ 72 - 17
GreenTree.Nachtragsmanagement.Web/Controllers/DeviationController.cs

@@ -211,12 +211,17 @@ namespace GreenTree.Nachtragsmanagement.Web.Controllers
         }
 
         private decimal totalCustomSummaryValueDaysReceiptToAppendixOffering = 0;
+        private decimal totalCustomSummaryValueDaysReceiptToAppendixOfferingCount = 0;
         private decimal totalCustomSummaryValueDisturbanceValueSum = 0;
 
         private decimal accumulatedCustomSummaryValueDaysReceiptToAppendixOffering = 0;
+        private int accumulatedCustomSummaryValueDaysReceiptToAppendixOfferingCount = 0;
+        private decimal accumulatedCustomSummaryPercentage = 0;
+        private int accumulatedCustomSummaryPercentageCount = 0;
         private decimal accumulatedCustomSummaryValueDisturbanceValueSum = 0;
-        private decimal accumulatedValue = 0;
-        private decimal accumulatedCount = 0;
+        private decimal accumulatedCustomSummaryPercentageValue = 0;
+        private decimal accumulatedCustomSummaryValue = 0;
+        private decimal accumulatedCustomSummaryCount = 0;
 
         /// <summary>
         /// Reset custom summaries for corresponding group type
@@ -225,8 +230,14 @@ namespace GreenTree.Nachtragsmanagement.Web.Controllers
         /// <param name="e"></param>
         private void generator_SummaryReset(object source, CustomSummaryResetEventArgs e)
         {
-            totalCustomSummaryValueDaysReceiptToAppendixOffering = 0;
-            totalCustomSummaryValueDisturbanceValueSum = 0;
+            if (e.FieldName == "DaysReceiptToAppendixOffering")
+            {
+                totalCustomSummaryValueDaysReceiptToAppendixOffering = 0;
+                totalCustomSummaryValueDaysReceiptToAppendixOfferingCount = 0;
+            }
+
+            if (e.FieldName == "DisturbanceValuesDescription")
+                totalCustomSummaryValueDisturbanceValueSum = 0;
         }
 
         /// <summary>
@@ -237,8 +248,15 @@ namespace GreenTree.Nachtragsmanagement.Web.Controllers
         private void generator_SummaryRowChanged(object source, CustomSummaryRowChangedEventArgs e)
         {
             if (e.FieldName == "DaysReceiptToAppendixOffering")
-                totalCustomSummaryValueDaysReceiptToAppendixOffering += 
-                    Convert.ToDecimal(((XtraReport)source).GetCurrentColumnValue("DaysReceiptToAppendixOffering"));
+            {
+                var val = ((XtraReport)source).GetCurrentColumnValue("DaysReceiptToAppendixOffering");
+
+                if (val != null)
+                {
+                    totalCustomSummaryValueDaysReceiptToAppendixOffering += Convert.ToDecimal(val);
+                    totalCustomSummaryValueDaysReceiptToAppendixOfferingCount++;
+                }
+            }
 
             if (e.FieldName == "DisturbanceValuesDescription")
             {
@@ -258,26 +276,58 @@ namespace GreenTree.Nachtragsmanagement.Web.Controllers
 
             if (label.Tag.ToString() == "DaysReceiptToAppendixOffering")
             {
-                accumulatedCustomSummaryValueDaysReceiptToAppendixOffering += e.CalculatedValues.OfType<int>().Sum();
-                e.Result = accumulatedCustomSummaryValueDaysReceiptToAppendixOffering;
+                accumulatedCustomSummaryValueDaysReceiptToAppendixOffering += e.CalculatedValues.OfType<int?>()
+                    .Where(c => c.HasValue)
+                    .Select(c => Convert.ToDecimal(c))
+                    .Sum();
+                accumulatedCustomSummaryValueDaysReceiptToAppendixOfferingCount += e.CalculatedValues.OfType<int?>()
+                    .Where(c => c.HasValue)
+                    .Count();
+                e.Result = accumulatedCustomSummaryValueDaysReceiptToAppendixOffering / 
+                           accumulatedCustomSummaryValueDaysReceiptToAppendixOfferingCount;
             }
 
-            if (label.Tag.ToString() == "DisturbanceValueSum")
+            if (label.Tag.ToString() == "DisturbanceValuesDescription")
             {
-                accumulatedCustomSummaryValueDisturbanceValueSum += e.CalculatedValues.OfType<decimal>().Sum();
+                var vals = e.CalculatedValues.OfType<string>()
+                    .Where(s => !String.IsNullOrEmpty(s))
+                    .SelectMany(s => s.Split(new[] { ", " }, StringSplitOptions.None))
+                    .Select(s => s.Split(new[] { " - " }, StringSplitOptions.None)[1])
+                    .Select(s => s.Take(s.Length - 2))
+                    .Select(c => String.Join("", c))
+                    .ToArray();
+
+                accumulatedCustomSummaryValueDisturbanceValueSum += vals
+                    .Select(v => Convert.ToDecimal(v))
+                    .Sum();
+
                 e.Result = accumulatedCustomSummaryValueDisturbanceValueSum;
             }
 
             if (label.Tag.ToString() == "Value")
             {
-                accumulatedValue += e.CalculatedValues.OfType<decimal>().Sum();
-                e.Result = accumulatedValue;
+                accumulatedCustomSummaryValue += e.CalculatedValues.OfType<decimal>().Sum();
+                e.Result = accumulatedCustomSummaryValue;
             }
 
             if (label.Tag.ToString() == "SiteDescription")
             {
-                accumulatedCount += e.CalculatedValues.Count;
-                e.Result = accumulatedCount;
+                accumulatedCustomSummaryCount += e.CalculatedValues.Count;
+                e.Result = accumulatedCustomSummaryCount;
+            }
+
+            if (label.Tag.ToString() == "Percentage")
+            {
+                accumulatedCustomSummaryPercentage += e.CalculatedValues.OfType<decimal>().Sum();
+                accumulatedCustomSummaryPercentageCount += e.CalculatedValues.Count;
+                e.Result = accumulatedCustomSummaryPercentage /
+                           accumulatedCustomSummaryPercentageCount;
+            }
+
+            if (label.Tag.ToString() == "PercentageValue")
+            {
+                accumulatedCustomSummaryPercentageValue += e.CalculatedValues.OfType<decimal>().Sum();
+                e.Result = accumulatedCustomSummaryPercentageValue;
             }
 
             e.Handled = true;
@@ -293,12 +343,17 @@ namespace GreenTree.Nachtragsmanagement.Web.Controllers
             var label = (XRLabel)source;
 
             if (label.Tag.ToString() == "DaysReceiptToAppendixOffering")
-                e.Result = totalCustomSummaryValueDaysReceiptToAppendixOffering;
+            {
+                e.Result = Convert.ToInt32(totalCustomSummaryValueDaysReceiptToAppendixOffering /
+                                           totalCustomSummaryValueDaysReceiptToAppendixOfferingCount);
+                e.Handled = true;
+            }
 
             if (label.Tag.ToString() == "DisturbanceValuesDescription")
+            {
                 e.Result = totalCustomSummaryValueDisturbanceValueSum;
-
-            e.Handled = true;
+                e.Handled = true;
+            }
         }
 
         /// <summary>

+ 29 - 0
GreenTree.Nachtragsmanagement.Web/Controllers/SiteController.cs

@@ -3,6 +3,7 @@ using DevExpress.Web;
 using DevExpress.Web.ASPxThemes;
 using DevExpress.Web.Mvc;
 using DevExpress.XtraPrinting;
+using DevExpress.XtraReports.UI;
 using GreenTree.Nachtragsmanagement.Core.Authentication;
 using GreenTree.Nachtragsmanagement.Core.Domain.Deviation;
 using GreenTree.Nachtragsmanagement.Core.Domain.User;
@@ -164,6 +165,7 @@ namespace GreenTree.Nachtragsmanagement.Web.Controllers
                 generator.CustomizeColumnsCollection += new CustomizeColumnsCollectionEventHandler(generator_CustomizeColumnsCollection);
                 generator.CustomizeGroupColumnSummary += new CustomizeColumnGroupSummaryEventHandler(generator_CustomizeGroupColumnSummary);
                 generator.CustomizeTotalColumnSummary += new CustomizeColumnTotalSummaryEventHandler(generator_CustomizeTotalColumnSummary);
+                generator.PageSummaryGetResult += new SummaryGetResultHandler(generator_PageSummaryGetResult);
 
                 var report = generator.GenerateMVCReport(gridViewState, siteModels, "Baustellenliste");
 
@@ -209,6 +211,33 @@ namespace GreenTree.Nachtragsmanagement.Web.Controllers
                 return new EmptyResult();
         }
 
+        private decimal accumulatedCustomSummaryDeviationValue = 0;
+        private decimal accumulatedCustomSummaryCount = 0;
+
+        /// <summary>
+        /// Set custom summary result for page
+        /// </summary>
+        /// <param name="source"></param>
+        /// <param name="e"></param>
+        private void generator_PageSummaryGetResult(object source, SummaryGetResultEventArgs e)
+        {
+            var label = (XRLabel)source;
+
+            if (label.Tag.ToString() == "DeviationValue")
+            {
+                accumulatedCustomSummaryDeviationValue += e.CalculatedValues.OfType<decimal>().Sum();
+                e.Result = accumulatedCustomSummaryDeviationValue;
+            }
+
+            if (label.Tag.ToString() == "Description")
+            {
+                accumulatedCustomSummaryCount += e.CalculatedValues.Count;
+                e.Result = accumulatedCustomSummaryCount;
+            }
+
+            e.Handled = true;
+        }
+
         /// <summary>
         /// Customize created columns
         /// </summary>

+ 6 - 6
GreenTree.Nachtragsmanagement.Web/Extensions/GridViewSettingsHelper.cs

@@ -502,13 +502,13 @@ namespace GreenTree.Nachtragsmanagement.Web.Extensions
                 column.Visible = false;
             });
 
-            s.SetDataRowTemplateContent(t =>
-            {
-                var list = t.Grid.DataSource as List<DeviationDataModel>;
-                var model = list.First(l => l.Id == (int)t.KeyValue);
+            //s.SetDataRowTemplateContent(t =>
+            //{
+            //    var list = t.Grid.DataSource as List<DeviationDataModel>;
+            //    var model = list.First(l => l.Id == (int)t.KeyValue);
 
-                html.RenderPartial("~/Views/Deviations/_DeviationDataRowPartial.cshtml", model, html.ViewData);
-            });
+            //    html.RenderPartial("~/Views/Deviations/_DeviationDataRowPartial.cshtml", model, html.ViewData);
+            //});
 
             var totalDaysReceiptToAppendixOfferingSum = 0;
             var totalDaysReceiptToAppendixOfferingCount = 0;

+ 0 - 15
GreenTree.Nachtragsmanagement.Web/Extensions/MVCxGridViewGeneratorHelper.cs

@@ -458,21 +458,6 @@ namespace GreenTree.Nachtragsmanagement.Web.Extensions
                     label.DataBindings.Add("Text", null, col.FieldName);
                     label.Tag = item.FieldName;
 
-                    if (item.SummaryType == SummaryItemType.Custom)
-                    {
-                        label.SummaryReset += (source, e) =>
-                        {
-                            if (SummaryReset != null)
-                                SummaryReset(report, new CustomSummaryResetEventArgs { FieldName = item.FieldName });
-                        };
-
-                        label.SummaryRowChanged += (source, e) =>
-                        {
-                            if (SummaryRowChanged != null)
-                                SummaryRowChanged(report, new CustomSummaryRowChangedEventArgs { FieldName = item.FieldName });
-                        };
-                    }
-
                     if (PageSummaryGetResult != null)
                         label.SummaryGetResult += PageSummaryGetResult;