Pārlūkot izejas kodu

Erste Probeversion veröffentlicht!

Arne Diekmann 8 gadi atpakaļ
vecāks
revīzija
943034fb57

+ 5 - 2
GreenTree.Nachtragsmanagement.Web/Controllers/AppendixController.cs

@@ -147,8 +147,11 @@ namespace GreenTree.Nachtragsmanagement.Web.Controllers
         {
             var site = _siteService.GetSiteById(siteId);
 
-            var lastCustomNumber = site.Appendices
-                .Max(d => StaticHelper.TryParseInt(d.CustomNumber));
+            var lastCustomNumber = 0;
+
+            if (site.Appendices.Any())
+                lastCustomNumber = site.Appendices
+                    .Max(d => StaticHelper.TryParseInt(d.CustomNumber));
 
             var appendixModel = new AppendixDataModel
             {

+ 5 - 2
GreenTree.Nachtragsmanagement.Web/Controllers/DeviationController.cs

@@ -162,8 +162,11 @@ namespace GreenTree.Nachtragsmanagement.Web.Controllers
             allDeviations.AddRange(
                 site.Deviations);
 
-            var lastCustomNumber = allDeviations
-                .Max(d => StaticHelper.TryParseInt(d.CustomNumber));
+            var lastCustomNumber = 0;
+
+            if (allDeviations.Any())
+                lastCustomNumber = allDeviations
+                    .Max(d => StaticHelper.TryParseInt(d.CustomNumber));
 
             var deviationModel = new DeviationDataModel
             {

+ 8 - 0
GreenTree.Nachtragsmanagement.Web/Controllers/LoginController.cs

@@ -40,12 +40,20 @@ namespace GreenTree.Nachtragsmanagement.Web.Controllers
             var user = _userService.GetUserByCustomNumber(model.Username);
 
             if (user == null)
+            {
+                ViewData["LoginFailed"] = true;
+
                 return Index();
+            }
 
             var password = StaticHelper.GetMD5Hash(model.Password);
 
             if (!String.Equals(user.Password, password, StringComparison.InvariantCulture))
+            {
+                ViewData["LoginFailed"] = true;
+
                 return Index();
+            }
 
             user.CurrentRole = user.Roles.First(r1 => r1.Level == user.Roles.Max(r2 => r2.Level));
 

+ 28 - 6
GreenTree.Nachtragsmanagement.Web/Controllers/SiteController.cs

@@ -301,20 +301,39 @@ namespace GreenTree.Nachtragsmanagement.Web.Controllers
         public ActionResult AssignDeviationToEntity(int siteId, string sourceKey, string targetKey)
         {
             if (!sourceKey.StartsWith("d"))
+                return new EmptyResult();
+
+            if (sourceKey == targetKey)
+                return new EmptyResult();
+
+            var determinedTargetKey = targetKey;
+
+            if (targetKey.StartsWith("d"))
             {
-                return new JsonResult
-                {
-                    Data = "invalidSourceKey"
-                };
+                return new EmptyResult();
+                //var targetDeviationId = Convert.ToInt32(sourceKey.Replace("d_", String.Empty));
+                //var targetDeviation = _deviationService.GetDeviationById(targetDeviationId);
+
+                //if (targetDeviation == null)
+                //    return new EmptyResult();
+
+                //if (targetDeviation.Site != null)
+                //    determinedTargetKey = "a_0";
+
+                //if (targetDeviation.Appendix != null)
+                //    determinedTargetKey = String.Format("a_{0}", targetDeviation.AppendixId);
             }
 
             var deviationId = Convert.ToInt32(sourceKey.Replace("d_", String.Empty));
             var deviation = _deviationService.GetDeviationById(deviationId);
 
-            if (targetKey == "a_0")
+            if (determinedTargetKey == "a_0")
             {
                 var site = _siteService.GetSiteById(siteId);
 
+                if (deviation.Site != null)
+                    return new EmptyResult();
+
                 deviation.Appendix = null;
                 deviation.AppendixId = null;
 
@@ -325,9 +344,12 @@ namespace GreenTree.Nachtragsmanagement.Web.Controllers
             }
             else
             {
-                var appendixId = Convert.ToInt32(targetKey.Replace("a_", String.Empty));
+                var appendixId = Convert.ToInt32(determinedTargetKey.Replace("a_", String.Empty));
                 var appendix = _appendixService.GetAppendixById(appendixId);
 
+                if (deviation.AppendixId == appendixId)
+                    return new EmptyResult();
+
                 deviation.Site = null;
                 deviation.SiteId = null;
 

+ 9 - 0
GreenTree.Nachtragsmanagement.Web/Extensions/GridViewSettingsHelper.cs

@@ -171,6 +171,9 @@ namespace GreenTree.Nachtragsmanagement.Web.Extensions
             s.TotalSummary.Add(DevExpress.Data.SummaryItemType.Sum, "DeviationValue");
             s.GroupSummary.Add(DevExpress.Data.SummaryItemType.Sum, "DeviationValue");
 
+            s.TotalSummary.Add(DevExpress.Data.SummaryItemType.Count, "CustomNumber");
+            s.GroupSummary.Add(DevExpress.Data.SummaryItemType.Count, "CustomNumber");
+
             s.ClientLayout = (sender, e) =>
             {
                 if (e.LayoutMode == ClientLayoutMode.Loading)
@@ -387,6 +390,9 @@ namespace GreenTree.Nachtragsmanagement.Web.Extensions
             s.TotalSummary.Add(DevExpress.Data.SummaryItemType.Sum, "PercentageValue");
             s.GroupSummary.Add(DevExpress.Data.SummaryItemType.Sum, "PercentageValue");
 
+            s.TotalSummary.Add(DevExpress.Data.SummaryItemType.Count, "CustomNumber");
+            s.GroupSummary.Add(DevExpress.Data.SummaryItemType.Count, "CustomNumber");
+
             s.TotalSummary.Add(new ASPxSummaryItem
             {
                 FieldName = "DaysReceiptToAppendixOffering",
@@ -597,6 +603,9 @@ namespace GreenTree.Nachtragsmanagement.Web.Extensions
                 column.Width = new Unit(14, UnitType.Percentage);
             });
 
+            s.TotalSummary.Add(DevExpress.Data.SummaryItemType.Count, "CustomNumber");
+            s.GroupSummary.Add(DevExpress.Data.SummaryItemType.Count, "CustomNumber");
+
             s.TotalSummary.Add(new ASPxSummaryItem
             {
                 SummaryType = DevExpress.Data.SummaryItemType.Sum,

+ 3 - 3
GreenTree.Nachtragsmanagement.Web/Global.asax.cs

@@ -290,9 +290,9 @@ namespace GreenTree.Nachtragsmanagement.Web
                 var states = new[]
                 {
                     new State { Description = "Offen", IsDefault = true, HexColor = "#FFFFFF" },
-                    new State { Description = "Erinnerung Verhandlung", IsDefault = false, HexColor = "#D90800" },
-                    new State { Description = "Verhandelt", IsDefault = false, HexColor = "#CECECE" },
-                    new State { Description = "Erledigt / Entfällt", IsDefault = false, HexColor = "#00A800" }
+                    new State { Description = "Erinnerung Verhandlung", IsDefault = false, HexColor = "#FF817F" },
+                    new State { Description = "Verhandelt", IsDefault = false, HexColor = "#E5E5E5" },
+                    new State { Description = "Erledigt / Entfällt", IsDefault = false, HexColor = "#8ECC8E" }
                 };
 
                 foreach (var state in states)

+ 5 - 2
GreenTree.Nachtragsmanagement.Web/Models/Appendix/AppendixDataModel.cs

@@ -81,11 +81,14 @@ namespace GreenTree.Nachtragsmanagement.Web.Models.Appendix
                 OfferingDate = appendixEntity.OfferingDate,
                 OfferingValue = appendixEntity.Value.Value,
                 RelationOfferingToDeviations =
-                    appendixEntity.Value.HasValue
+                    appendixEntity.Value.HasValue && appendixEntity.Deviations.Any()
                         ? (decimal?)Convert.ToDecimal(
                             appendixEntity.Value / 
                                 (appendixEntity.Deviations
-                                    .Sum(r => r.Value.HasValue && r.Percentage.HasValue ? r.Value.Value * r.Percentage.Value : 0)))
+                                    .Sum(r => r.Value.HasValue && r.Percentage.HasValue ? r.Value.Value * r.Percentage.Value : 0) != 0 
+                                        ? appendixEntity.Deviations
+                                            .Sum(r => r.Value.HasValue && r.Percentage.HasValue ? r.Value.Value * r.Percentage.Value : 0)
+                                        : 1))
                         : null,
                 NegotiationDate = appendixEntity.NegotiationDate,
                 NegotiationValue = appendixEntity.NegotiationValue,

+ 1 - 1
GreenTree.Nachtragsmanagement.Web/Views/Appendices/_AppendixEditPartial.cshtml

@@ -106,7 +106,7 @@
 			var allItems = CategoryEntities.GetItemCount();
 			for (var i = 0; i < allItems; i++) {
 				var item = CategoryEntities.GetItem(i);
-				if (item.text.startsWith(description)) {
+				if (item.text.indexOf(description) != -1) {
 					CategoryEntities.RemoveItem(i);
 				}
 			}

+ 1 - 1
GreenTree.Nachtragsmanagement.Web/Views/Deviations/View.cshtml

@@ -7,7 +7,7 @@
 <script>
 	var deleteId;
 	var gridScrollHeight;
-	var gridScrollOffset = 280;
+	var gridScrollOffset = 350;
 	var resizeFinished;
 
 	$(document).ready(function () {

+ 1 - 1
GreenTree.Nachtragsmanagement.Web/Views/Deviations/_DeviationEditPartial.cshtml

@@ -125,7 +125,7 @@
 			var allItems = DisturbanceEntities.GetItemCount();
 			for (var i = 0; i < allItems; i++) {
 				var item = DisturbanceEntities.GetItem(i);
-				if (item.text.startsWith(description)) {
+				if (item.text.indexOf(description) != -1) {
 					DisturbanceEntities.RemoveItem(i);
 				}
 			}

+ 6 - 0
GreenTree.Nachtragsmanagement.Web/Views/Login/Index.cshtml

@@ -36,6 +36,12 @@
 				s.ControlStyle.CssClass += "devExCenter";
 			}).GetHtml()
 			<br />
+			if (ViewData["LoginFailed"] != null && (bool)ViewData["LoginFailed"] == true)
+			{
+				<span style="color: indianred">Benutzername oder Passwort falsch.</span>
+				<br />
+				<br />
+			}
 			@Html.DevExpress().Button(s =>
 		    {
 			    s.Name = "devButtonLogin";

+ 6 - 4
GreenTree.Nachtragsmanagement.Web/Views/Sites/_SiteEditPartial.cshtml

@@ -86,6 +86,7 @@
 				data: { SiteId: siteId },
 				success: function (response) {
 					setTimeout(function () {
+						$(".deviationEditContainer").remove();
 						$(".appendixEditContainer").remove();
 						$("body").append(response);
 					}, 200);
@@ -104,6 +105,7 @@
 				success: function (response) {
 					setTimeout(function () {
 						$(".deviationEditContainer").remove();
+						$(".appendixEditContainer").remove();
 						$("body").append(response);
 					}, 200);
 				},
@@ -121,6 +123,7 @@
 				success: function (response) {
 					setTimeout(function () {
 						$(".deviationEditContainer").remove();
+						$(".appendixEditContainer").remove();
 						$("body").append(response);
 					}, 200);
 				},
@@ -138,6 +141,7 @@
 				success: function (response) {
 					setTimeout(function () {
 						$(".deviationEditContainer").remove();
+						$(".appendixEditContainer").remove();
 						$("body").append(response);
 					}, 200);
 				},
@@ -190,6 +194,7 @@
 				data: { Id: id },
 				success: function (response) {
 					setTimeout(function () {
+						$(".deviationEditContainer").remove();
 						$(".appendixEditContainer").remove();
 						$("body").append(response);
 					}, 200);
@@ -238,7 +243,7 @@
 
 		function startSiteTreeNodeDrag(s, e) {
 			if (!s || !e) return;
-			if (e.nodeKey.startsWith("a")) {
+			if (e.nodeKey[0] == "a") {
 				e.cancel = true;
 				return;
 			}
@@ -263,9 +268,6 @@
 							devTreeListSiteDeviationAppendices.PerformCallback();
 						}, 200);
 					}
-				},
-				error: function () {
-					 alert("error occured");
 				}
 			});
 		}