olivier.massot 7 jaren geleden
bovenliggende
commit
a96de8a00a

+ 2 - 1
CD67.FicheCollege.Entity/ActionEdu.cs

@@ -17,13 +17,14 @@ namespace CD67.FicheCollege.Entity
         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
         public ActionEdu()
         {
-            this.Numero = "0";
+            this.Montant = 0m;
             this.ActionsEduColleges = new HashSet<ActionEduCollege>();
         }
     
         public int Id { get; set; }
         public string Numero { get; set; }
         public string Nom { get; set; }
+        public decimal Montant { get; set; }
         public string Description { get; set; }
         public bool Neutralise { get; set; }
         public int Ordre { get; set; }

+ 0 - 2
CD67.FicheCollege.Entity/ActionEduCollege.cs

@@ -18,7 +18,6 @@ namespace CD67.FicheCollege.Entity
         public ActionEduCollege()
         {
             this.NbEleves = 0;
-            this.Montant = 0;
             this.ActionEduMissions = new HashSet<ActionEduMission>();
         }
     
@@ -26,7 +25,6 @@ namespace CD67.FicheCollege.Entity
         public string CommentaireInterne { get; set; }
         public string CommentairePublic { get; set; }
         public long NbEleves { get; set; }
-        public long Montant { get; set; }
         public string TiersAstre_Code { get; set; }
         public string TiersAstre_Nom { get; set; }
         public string TiersAstre_CodeFamille { get; set; }

+ 6 - 6
CD67.FicheCollege.Entity/EntityModel.edmx

@@ -41,6 +41,7 @@
           <Property Name="Id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
           <Property Name="Numero" Type="nvarchar(max)" Nullable="false" />
           <Property Name="Nom" Type="nvarchar(max)" Nullable="false" />
+          <Property Name="Montant" Type="decimal" Precision="18" Scale="0" Nullable="false" />
           <Property Name="Description" Type="nvarchar(max)" />
           <Property Name="Neutralise" Type="bit" Nullable="false" />
           <Property Name="Ordre" Type="int" Nullable="false" />
@@ -55,7 +56,6 @@
           <Property Name="CommentaireInterne" Type="nvarchar(max)" />
           <Property Name="CommentairePublic" Type="nvarchar(max)" />
           <Property Name="NbEleves" Type="bigint" Nullable="false" />
-          <Property Name="Montant" Type="bigint" Nullable="false" />
           <Property Name="TiersAstre_Code" Type="nvarchar(max)" />
           <Property Name="TiersAstre_Nom" Type="nvarchar(max)" />
           <Property Name="TiersAstre_CodeFamille" Type="nvarchar(max)" />
@@ -74,7 +74,7 @@
           <Key>
             <PropertyRef Name="Id" />
           </Key>
-          <Property Name="Id" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
+          <Property Name="Id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
           <Property Name="Annee_Id" Type="int" Nullable="false" />
           <Property Name="CodeRne" Type="nvarchar" MaxLength="10" Nullable="false" />
           <Property Name="Libelle" Type="nvarchar" MaxLength="255" Nullable="false" />
@@ -544,8 +544,9 @@
             <PropertyRef Name="Id" />
           </Key>
           <Property Name="Id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
-          <Property Name="Numero" Type="String" Nullable="false" DefaultValue="0" MaxLength="Max" Unicode="true" FixedLength="false" />
+          <Property Name="Numero" Type="String" Nullable="false" MaxLength="Max" Unicode="true" FixedLength="false" />
           <Property Name="Nom" Type="String" Nullable="false" MaxLength="Max" Unicode="true" FixedLength="false" />
+          <Property Name="Montant" Type="Decimal" Nullable="false" DefaultValue="0" />
           <Property Name="Description" Type="String" Nullable="true" MaxLength="Max" Unicode="true" FixedLength="false" />
           <Property Name="Neutralise" Type="Boolean" Nullable="false" />
           <Property Name="Ordre" Type="Int32" Nullable="false" />
@@ -599,7 +600,6 @@
           <Property Name="CommentaireInterne" Type="String" Nullable="true" MaxLength="Max" Unicode="true" FixedLength="false" />
           <Property Name="CommentairePublic" Type="String" Nullable="true" MaxLength="Max" Unicode="true" FixedLength="false" />
           <Property Name="NbEleves" Type="Int64" Nullable="false" DefaultValue="0" />
-          <Property Name="Montant" Type="Int64" Nullable="false" DefaultValue="0" />
           <Property Name="TiersAstre_Code" Type="String" Nullable="true" MaxLength="Max" Unicode="true" FixedLength="false" />
           <Property Name="TiersAstre_Nom" Type="String" Nullable="true" MaxLength="Max" Unicode="true" FixedLength="false" />
           <Property Name="TiersAstre_CodeFamille" Type="String" Nullable="true" MaxLength="Max" Unicode="true" FixedLength="false" />
@@ -776,7 +776,8 @@
     <EntitySetMapping Name="ActionsEdu">
       <EntityTypeMapping TypeName="IsTypeOf(CD67.FicheCollege.ActionEdu)">
         <MappingFragment StoreEntitySet="ActionsEdu">
-          <ScalarProperty Name="Id" ColumnName="Id" />
+                <ScalarProperty Name="Montant" ColumnName="Montant" />
+                <ScalarProperty Name="Id" ColumnName="Id" />
           <ScalarProperty Name="Numero" ColumnName="Numero" />
           <ScalarProperty Name="Nom" ColumnName="Nom" />
           <ScalarProperty Name="Description" ColumnName="Description" />
@@ -794,7 +795,6 @@
           <ScalarProperty Name="CommentaireInterne" ColumnName="CommentaireInterne" />
           <ScalarProperty Name="CommentairePublic" ColumnName="CommentairePublic" />
           <ScalarProperty Name="NbEleves" ColumnName="NbEleves" />
-          <ScalarProperty Name="Montant" ColumnName="Montant" />
           <ScalarProperty Name="TiersAstre_Code" ColumnName="TiersAstre_Code" />
           <ScalarProperty Name="TiersAstre_Nom" ColumnName="TiersAstre_Nom" />
           <ScalarProperty Name="TiersAstre_CodeFamille" ColumnName="TiersAstre_CodeFamille" />

+ 13 - 0
CD67.FicheCollege.Entity/Extend/ActionEdu.cs

@@ -1,4 +1,5 @@
 using System.ComponentModel.DataAnnotations;
+using System.Linq;
 
 namespace CD67.FicheCollege.Entity
 {
@@ -8,6 +9,13 @@ namespace CD67.FicheCollege.Entity
     [MetadataType(typeof(ActionEdu_Metadata))]
     public partial class ActionEdu
     {
+        public long totalEleves
+        {
+            get
+            {
+                return this.ActionsEduColleges.Sum(mbox=>mbox.NbEleves);
+            }
+        }
     }
 
     /// <summary>
@@ -34,6 +42,11 @@ namespace CD67.FicheCollege.Entity
         [Display(Name = "Nom")]
         public string Nom { get; set; }
 
+        [Required]
+        [DataType(DataType.Currency)]
+        [Display(Name = "Montant")]
+        public decimal Montant { get; set; }
+
         [Display(Name = "Description")]
         [DataType(DataType.MultilineText)]
         public string Description { get; set; }

+ 0 - 3
CD67.FicheCollege.Entity/Extend/ActionEduCollege.cs

@@ -29,9 +29,6 @@ namespace CD67.FicheCollege.Entity
         [Display(Name = "Nombre d'élèves")]
         public int NbEleves { get; set; }
 
-        [Display(Name = "Montant")]
-        public int Montant { get; set; }
-
         [DataType(DataType.MultilineText)]
         [Display(Name = "Commentaire (interne)")]
         public int CommentaireInterne { get; set; }

+ 2 - 1
CD67.FicheCollege.MVC/App_Start/BundleConfig.cs

@@ -12,7 +12,8 @@ namespace CD67.FicheCollege.MVC
                         "~/Scripts/jquery-{version}.js"));
 
             bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
-                        "~/Scripts/jquery.validate*",
+                        "~/Scripts/jquery.validate.*",
+                        "~/Scripts/jquery.validate-*",
                         "~/Scripts/jquery.unobtrusive-ajax.js"));
 
             bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(

+ 1 - 0
CD67.FicheCollege.MVC/CD67.FicheCollege.MVC.csproj

@@ -327,6 +327,7 @@
     <Content Include="Scripts\colorbox\i18n\jquery.colorbox-zh-CN.js" />
     <Content Include="Scripts\colorbox\jquery.colorbox-min.js" />
     <Content Include="Scripts\colorbox\jquery.colorbox.js" />
+    <Content Include="Scripts\jquery.validate-french.js" />
     <Content Include="Scripts\less.min.js" />
     <Content Include="Scripts\jquery-3.2.1.js" />
     <Content Include="Scripts\jquery-3.2.1.min.js" />

+ 5 - 0
CD67.FicheCollege.MVC/Controllers/ActionsEduController.cs

@@ -109,6 +109,11 @@ namespace CD67.FicheCollege.MVC.Controllers
                 fact.update(ref actionEdu);
                 return RedirectToAction("Index", new { annee_id = actionEdu.AnneeId });
             }
+            if (actionEdu.Annee == null)
+            {
+                db.ActionsEdu.Attach(actionEdu);
+                db.Entry(actionEdu).Reference(i => i.Annee).Load();
+            }
             ActionEduViewModel model = new ActionEduViewModel(actionEdu, db, ModeAcces.Modification);
             return View(model);
         }

+ 52 - 0
CD67.FicheCollege.MVC/Scripts/jquery.validate-french.js

@@ -0,0 +1,52 @@
+/*!
+** Support des formats français pour la validation des nombres et des dates
+*/
+
+(function ($) {
+    // Sauvegarde les méthodes de base
+    var originalMethods = {
+        min: $.validator.methods.min,
+        max: $.validator.methods.max,
+        range: $.validator.methods.range
+    };
+
+    // Analyse un nombre
+    var parseFrenchNum = function (str) {
+        str = str.replace(",", ".").replace(" ", "");
+        return parseFloat(str);
+    };
+
+    // Analyse une date
+    var parseFrenchDate = function (str) {
+        return new Date(str);
+    };
+
+    // Traitement des nombres
+    $.validator.methods.number = function (value, element) {
+        var val = parseFrenchNum(value);
+        return this.optional(element) || ($.isNumeric(val));
+    };
+
+    // Traitement des dates
+    $.validator.methods.date = function (value, element) {
+        var val = parseFrenchDate(value);
+        return this.optional(element) || (val instanceof Date);
+    };
+
+    // Traitement des règles sur les nombres
+    $.validator.methods.min = function (value, element, param) {
+        var val = parseFrenchNum(value);
+        return originalMethods.min.call(this, val, element, param);
+    };
+
+    $.validator.methods.max = function (value, element, param) {
+        var val = parseFrenchNum(value);
+        return originalMethods.max.call(this, val, element, param);
+    };
+
+    $.validator.methods.range = function (value, element, param) {
+        var val = parseFrenchNum(value);
+        return originalMethods.range.call(this, val, element, param);
+    };
+
+}(jQuery));

+ 8 - 0
CD67.FicheCollege.MVC/Views/ActionsEdu/Create.cshtml

@@ -45,6 +45,14 @@
                 @Html.ValidationMessageFor(model => actionEdu.Nom, "", new { @class = "text-danger" })
             </div>
         </div>
+        
+        <div class="form-group">
+            @Html.LabelFor(model => actionEdu.Montant, htmlAttributes: new { @class = "control-label col-md-2" })
+            <div class="col-md-10">
+                @Html.EditorFor(model => actionEdu.Montant, new { htmlAttributes = new { @class = "form-control" } })
+                @Html.ValidationMessageFor(model => actionEdu.Montant, "", new { @class = "text-danger" })
+            </div>
+        </div>
 
         <div class="form-group">
             @Html.LabelFor(model => actionEdu.Description, htmlAttributes: new { @class = "control-label col-md-2" })

+ 6 - 2
CD67.FicheCollege.MVC/Views/ActionsEdu/Details.cshtml

@@ -35,6 +35,12 @@
         <dt>@Html.DisplayNameFor(model => actionEdu.Nom)</dt>
         <dd>@Html.DisplayFor(model => actionEdu.Nom)</dd>
 
+        <dt>@Html.DisplayNameFor(model => actionEdu.Montant)</dt>
+        <dd>@Html.DisplayFor(model => actionEdu.Montant)</dd>
+        
+        <dt>Elèves concernés </dt>
+        <dd>@actionEdu.totalEleves</dd>
+
         <dt>@Html.DisplayNameFor(model => actionEdu.Description)</dt>
         <dd>@Html.DisplayFor(model => actionEdu.Description)</dd>
 
@@ -57,7 +63,6 @@
             <tr>
                 <th>Collège</th>
                 <th>Nombre d'élèves</th>
-                <th>Montant</th>
                 <th>Tiers</th>
                 <th>Commentaire interne</th>
                 <th>Commentaire public</th>
@@ -69,7 +74,6 @@
             <tr data-url="@Url.Action("Details", "ActionsEduCollege", new { Id = item.Id })">
                 <td>@Html.DisplayFor(model => item.College.Libelle)</td>
                 <td>@Html.DisplayFor(model => item.NbEleves)</td>
-                <td>@Html.DisplayFor(model => item.Montant)</td>
                 <td>@Html.DisplayFor(model => item.TiersAstre_Nom)</td>
                 <td>@Html.DisplayFor(model => item.CommentaireInterne)</td>
                 <td>@Html.DisplayFor(model => item.CommentairePublic)</td>

+ 8 - 0
CD67.FicheCollege.MVC/Views/ActionsEdu/Edit.cshtml

@@ -45,6 +45,14 @@
             </div>
         </div>
 
+        <div class="form-group">
+            @Html.LabelFor(model => actionEdu.Montant, htmlAttributes: new { @class = "control-label col-md-2" })
+            <div class="col-md-10">
+                @Html.EditorFor(model => actionEdu.Montant, new { htmlAttributes = new { @class = "form-control" } })
+                @Html.ValidationMessageFor(model => actionEdu.Montant, "", new { @class = "text-danger" })
+            </div>
+        </div>
+
         <div class="form-group">
             @Html.LabelFor(model => actionEdu.Description, htmlAttributes: new { @class = "control-label col-md-2" })
             <div class="col-md-10">

+ 0 - 8
CD67.FicheCollege.MVC/Views/ActionsEduCollege/Create.cshtml

@@ -36,14 +36,6 @@
             </div>
         </div>
 
-        <div class="form-group">
-            @Html.LabelFor(model => actionEduCollege.Montant, htmlAttributes: new { @class = "control-label col-md-2" })
-            <div class="col-md-10">
-                @Html.EditorFor(model => actionEduCollege.Montant, new { htmlAttributes = new { @class = "form-control" } })
-                @Html.ValidationMessageFor(model => actionEduCollege.Montant, "", new { @class = "text-danger" })
-            </div>
-        </div>
-
         <div class="form-group">
             @Html.LabelFor(model => actionEduCollege.CommentaireInterne, htmlAttributes: new { @class = "control-label col-md-2" })
             <div class="col-md-10">

+ 0 - 3
CD67.FicheCollege.MVC/Views/ActionsEduCollege/Details.cshtml

@@ -27,9 +27,6 @@
         <dt>@Html.DisplayNameFor(model => actionEduCollege.NbEleves)</dt>
         <dd>@Html.DisplayFor(model => actionEduCollege.NbEleves)</dd>
 
-        <dt>@Html.DisplayNameFor(model => actionEduCollege.Montant)</dt>
-        <dd>@Html.DisplayFor(model => actionEduCollege.Montant)</dd>
-
         <dt>@Html.DisplayNameFor(model => actionEduCollege.CommentaireInterne)</dt>
         <dd>@Html.DisplayFor(model => actionEduCollege.CommentaireInterne)</dd>
 

+ 0 - 8
CD67.FicheCollege.MVC/Views/ActionsEduCollege/Edit.cshtml

@@ -38,14 +38,6 @@
             </div>
         </div>
 
-        <div class="form-group">
-            @Html.LabelFor(model => actionEduCollege.Montant, htmlAttributes: new { @class = "control-label col-md-2" })
-            <div class="col-md-10">
-                @Html.EditorFor(model => actionEduCollege.Montant, new { htmlAttributes = new { @class = "form-control" } })
-                @Html.ValidationMessageFor(model => actionEduCollege.Montant, "", new { @class = "text-danger" })
-            </div>
-        </div>
-
         <div class="form-group">
             @Html.LabelFor(model => actionEduCollege.CommentaireInterne, htmlAttributes: new { @class = "control-label col-md-2" })
             <div class="col-md-10">

+ 5 - 1
CD67.FicheCollege.MVC/Views/Shared/_AdminLayout.cshtml

@@ -25,6 +25,10 @@
     @Styles.Render("~/Content/css")
     @Styles.Render("~/Content/datatables")
     
+    <link rel="stylesheet/less" type="text/css" href="~/content/cd67-model.less" />
+    <link rel="stylesheet/less" type="text/css" href="~/content/cd67-custom.less" />
+    <script src="~/scripts/less.min.js" ></script>
+
     @Scripts.RenderFormat("<script src=\"{0}\" defer></script>", "~/bundles/jqueryval")
     @Scripts.RenderFormat("<script src=\"{0}\" defer></script>", "~/bundles/jquery-ui")
     @Scripts.RenderFormat("<script src=\"{0}\" defer></script>", "~/bundles/bootstrap")
@@ -51,7 +55,7 @@
                 @* Titre et année en cours *@
                 <span id="titre" class="nav navbar">
                     <h1 id="app-title" style="color:rgb(150,150,150)">Fiches collège: Administration</h1>
-                    <a id="goback" href="@Request.UrlReferrer.ToString()">Retour</a>
+                    <a id="goback" href="@Url.Action("Index", "Home");">Retour</a>
                 </span>
                 
                 <ul class="nav navbar-nav navbar-right">

+ 2 - 0
CD67.FicheCollege.MVC/Web.config

@@ -39,6 +39,8 @@
       </system.Web>
   -->
   <system.web>
+    <globalization uiCulture="fr" culture="fr-FR" />
+
     <siteMap defaultProvider="MvcSiteMapProvider">
       <providers>
         <clear />