diff --git a/Fab2ApprovalSystem/Controllers/ECNController.cs b/Fab2ApprovalSystem/Controllers/ECNController.cs index 01f4b0a..b0541e4 100644 --- a/Fab2ApprovalSystem/Controllers/ECNController.cs +++ b/Fab2ApprovalSystem/Controllers/ECNController.cs @@ -883,6 +883,8 @@ public class ECNController : PdfViewController { string outputFileName = ""; ecn = ecnDMO.GetECNPdf(ecnNumber); + ViewBag.Category = ecnDMO.GetCategoryID(ecn); + ViewBag.TrainingNotificationTo = ecnDMO.GetTrainingNotificationTo(ecn, trainingDMO); outputFileName = ecnNumber.ToString() + ".pdf"; string ecnFolderPath = _AppSettings.AttachmentFolder + "ECN\\" + ecnNumber.ToString(); @@ -910,6 +912,8 @@ public class ECNController : PdfViewController { string outputFileName = ""; ecn = ecnDMO.GetECNPdf(ecnNumber); + ViewBag.Category = ecnDMO.GetCategoryID(ecn); + ViewBag.TrainingNotificationTo = ecnDMO.GetTrainingNotificationTo(ecn, trainingDMO); outputFileName = ecnNumber.ToString() + ".pdf"; string ecnFolderPath = _AppSettings.AttachmentFolder + "ECN\\" + folderName.ToString(); @@ -935,13 +939,15 @@ public class ECNController : PdfViewController { ECNPdf ecn; try { ecn = ecnDMO.GetECNPdf(ecnNumber); + ViewBag.Category = ecnDMO.GetCategoryID(ecn); + ViewBag.TrainingNotificationTo = ecnDMO.GetTrainingNotificationTo(ecn, trainingDMO); // To render a PDF instead of an HTML, all we need to do is call ViewPdf instead of View. This // requires the controller to be inherited from MyController instead of MVC's Controller. return this.ViewPdf("", "ECNPdf", ecn); } catch (Exception ex) { EventLogDMO.Add(new WinEventLog() { IssueID = ecnNumber, UserID = @User.Identity.Name, DocumentType = "ECN", OperationType = "Print PDF", Comments = ex.Message }); ecn = null; - return Content(""); + return Content("An unexpected error has occurred!"); } } diff --git a/Fab2ApprovalSystem/DMO/ECN_DMO.cs b/Fab2ApprovalSystem/DMO/ECN_DMO.cs index e7cf0b6..b58ffbc 100644 --- a/Fab2ApprovalSystem/DMO/ECN_DMO.cs +++ b/Fab2ApprovalSystem/DMO/ECN_DMO.cs @@ -356,14 +356,17 @@ public class ECN_DMO { List affectedAreas = multipleResultItems.Read().ToList(); List affectedTechnologies = multipleResultItems.Read().ToList(); List acknowledgementBy = multipleResultItems.Read().ToList(); - List trainingBy = multipleResultItems.Read().ToList(); + List trainingby = multipleResultItems.Read().ToList(); + if (ecnItem != null && trainingby != null) { + if (trainingby.Count > 0) + ecnItem.TrainingByIDs.AddRange(trainingby); + } List productfamilies = multipleResultItems.Read().ToList(); ecnItem.AffectedModules = string.Join(", ", modules); ecnItem.AffectedDepartments = string.Join(", ", departments); ecnItem.AffectedAreas = string.Join(",", affectedAreas); ecnItem.AffectedTechnologies = string.Join(",", affectedTechnologies); - ecnItem.TrainingBy = string.Join(",", trainingBy); ecnItem.AcknowledgementBy = string.Join(",", acknowledgementBy); ecnItem.AffectedProductFamilies = string.Join(",", productfamilies); @@ -714,4 +717,26 @@ public class ECN_DMO { return r; } + internal string GetCategoryID(ECNPdf ecn) { + string result; + if (ecn.CategoryID is null) { + result = string.Empty; + } else { + List categories = GetCategories(); + result = (from l in categories where l.CategoryID == ecn.CategoryID.Value select l.CategoryName).FirstOrDefault(); + } + return result; + } + + internal string GetTrainingNotificationTo(ECNPdf ecn, TrainingDMO trainingDMO) { + string result; + if (ecn.TrainingByIDs is null) { + result = string.Empty; + } else { + List trainingGroups = trainingDMO.GetTrainingGroups(); + result = string.Join(", ", (from l in trainingGroups where ecn.TrainingByIDs.Contains(l.TrainingGroupID) select l.TrainingGroupName).ToArray()); + } + return result; + } + } \ No newline at end of file diff --git a/Fab2ApprovalSystem/ViewModels/PdfViewModel.cs b/Fab2ApprovalSystem/ViewModels/PdfViewModel.cs index 4df6c90..08a4fc1 100644 --- a/Fab2ApprovalSystem/ViewModels/PdfViewModel.cs +++ b/Fab2ApprovalSystem/ViewModels/PdfViewModel.cs @@ -30,7 +30,7 @@ public class ECNPdf { public string AffectedDepartments { get; set; } public string AffectedAreas { get; set; } public string AffectedTechnologies { get; set; } - public string TrainingBy { get; set; } + public List TrainingByIDs { get; set; } public string AcknowledgementBy { get; set; } public bool IsECN { get; set; } public bool IsTECN { get; set; } @@ -79,6 +79,7 @@ public class ECNPdf { public int? ConvertedToNumber { get; set; } public int? ConvertedFromNumber { get; set; } public int WorkFlowNumber { get; set; } + public int? CategoryID { get; set; } public bool FIChangeRequired { get; set; } public string NumberOfLotsAffected { get; set; } public string RecipeChange { get; set; } @@ -87,6 +88,7 @@ public class ECNPdf { public ECNPdf() { Approvalog = new List(); Attachments = new List(); + TrainingByIDs = new List(); } } diff --git a/Fab2ApprovalSystem/Views/ECN/ECNPdf.cshtml b/Fab2ApprovalSystem/Views/ECN/ECNPdf.cshtml index 89d5f4b..dccd03b 100644 --- a/Fab2ApprovalSystem/Views/ECN/ECNPdf.cshtml +++ b/Fab2ApprovalSystem/Views/ECN/ECNPdf.cshtml @@ -29,12 +29,12 @@ } @if (@Model.ConvertedFromNumber == null && @Model.ConvertedToNumber == null) - { - - - ECN# @Model.ECNNumber - - + { + + + ECN# @Model.ECNNumber + + } @@ -57,20 +57,20 @@ - + @* - + *@ @@ -84,6 +84,16 @@ + + +
- - Affected Department:  - - - @Model.AffectedDepartments - - + + Affected Department:  + + + @Model.AffectedDepartments + +
+ + Category:  + + + @(ViewBag.Category) + +
@@ -97,11 +107,11 @@
- + - + @@ -141,7 +151,7 @@ Expiration Date: - + @Convert.ToString(string.Format("{0:MM/dd/yyyy}", Model.ExpirationDate)) @@ -150,7 +160,7 @@ Extension Date: - + @Convert.ToString(string.Format("{0:MM/dd/yyyy}", @Model.ExtensionDate)) @@ -191,7 +201,7 @@
- + @@ -216,15 +226,15 @@
- - + + - +
@@ -245,33 +255,33 @@ @* - *@ - - + +
Description of Change Reason for Change
+ - - - - - - - -
Training Notification
- - - - -
- - Training: - @(Model.TrainingRequired ? "Yes" : "No") - - - - @(Model.TrainingBy.Length > 0 ? "(" + Model.TrainingBy + ")" : Model.TrainingBy) - -
-
+ + + + + + + +
Training Notification
+ + + + + @(Model.TrainingBy.Length > 0 ? "(" + Model.TrainingBy + ")" : Model.TrainingBy) + + + +
+ + Training: + @(Model.TrainingRequired ? "Yes" : "No") + -
+
+ +
@@ -286,7 +296,7 @@ PCRB: - @(Model.PCRBRequired ? "Yes": "No") + @(Model.PCRBRequired ? "Yes" : "No") @@ -300,7 +310,7 @@ Metrology Change:    - @(Model.MetrologyChangeRequired ? "Yes": "No") + @(Model.MetrologyChangeRequired ? "Yes" : "No") @@ -308,7 +318,7 @@ SPC Change: - @(Model.SPCChangeRequired ? "Yes": "No") + @(Model.SPCChangeRequired ? "Yes" : "No") @@ -316,7 +326,7 @@ FI Change: - @(Model.FIChangeRequired ? "Yes" : "No") + @(Model.FIChangeRequired ? "Yes" : "No") @@ -327,9 +337,37 @@ @(Model.SPNChangeRequired ? "Yes" : "No")
+ + + + + + + + + + + + + + + +
Training Notification
+ + Training: + + + @(Model.TrainingRequired ? "Yes" : "No") + + + + Training Notification to:   + @(ViewBag.TrainingNotificationTo) + +
@@ -355,11 +393,11 @@ @: Positive } else if (Model.ImpactOnEnvironment == 2) - { + { @: Negative } else - { + { @: N/A } @@ -369,7 +407,7 @@ @Html.Raw(@Model.ImpactOnEnvironmentDescription) - + @@ -390,23 +428,23 @@ @Html.Raw(@Model.ImpactOnCapacityDescription) - + @* - - - + + +
- - RH(ITAR): - - - @(Model.IsRH ? "Yes" : "No") - -
+ + RH(ITAR): + + + @(Model.IsRH ? "Yes" : "No") + +
*@ @@ -483,15 +521,15 @@ - + - - - - + + + +