diff --git a/Fab2ApprovalSystem/Controllers/ECNController.cs b/Fab2ApprovalSystem/Controllers/ECNController.cs
index 6aba39e..7e68609 100644
--- a/Fab2ApprovalSystem/Controllers/ECNController.cs
+++ b/Fab2ApprovalSystem/Controllers/ECNController.cs
@@ -520,6 +520,7 @@ namespace Fab2ApprovalSystem.Controllers
///
public ActionResult AttachSave(IEnumerable files, int ecnNumber)
{
+ string returnString = "";
// The Name of the Upload component is "files"
if (files != null)
{
@@ -533,30 +534,44 @@ namespace Fab2ApprovalSystem.Controllers
DirectoryInfo di = new DirectoryInfo(ecnFolderPath);
if (!di.Exists)
- di.Create();
+ try
+ {
+ di.Create();
+ }
+ catch
+ {
+ returnString = "Error creating ECN directory.";
+ }
+ if (returnString == "")
+ {
+ var physicalPath = Path.Combine(ecnFolderPath, fileName);
+ if (!System.IO.File.Exists(physicalPath))
+ {
+ file.SaveAs(physicalPath);
+ ECNAttachment attach = new ECNAttachment()
+ {
+ ECNNumber = ecnNumber,
+ FileName = fileName,
+ UserID = (int)Session[GlobalVars.SESSION_USERID],
+ };
+ if (System.IO.File.Exists(physicalPath))
+ {
- var physicalPath = Path.Combine(ecnFolderPath, fileName);
-
- file.SaveAs(physicalPath);
- ECNAttachment attach = new ECNAttachment()
- {
- ECNNumber = ecnNumber,
- FileName = fileName,
- UserID = (int)Session[GlobalVars.SESSION_USERID],
- };
- if (System.IO.File.Exists(physicalPath))
- {
-
- ecnDMO.InsertECNAttachment(attach);
+ ecnDMO.InsertECNAttachment(attach);
+ }
+ else
+ {
+ returnString = "File was not uploaded to server.";
+ }
+ }
+ else
+ {
+ returnString = "Cannot have duplicate file names.";
+ }
}
- else
- {
- throw new Exception();
- }
-
}
}
- return Content("");
+ return Content(returnString);
}
///
diff --git a/Fab2ApprovalSystem/Views/ECN/Edit.cshtml b/Fab2ApprovalSystem/Views/ECN/Edit.cshtml
index dad4f10..174f8fe 100644
--- a/Fab2ApprovalSystem/Views/ECN/Edit.cshtml
+++ b/Fab2ApprovalSystem/Views/ECN/Edit.cshtml
@@ -2092,7 +2092,7 @@
grid.dataSource.read($('#txtECNNumber').val());
}
function onFileUploadError(e) {
- alert("Error Uploading File!!! Please Try Again...");
+ alert("Error Uploading File!!! " + e.XMLHttpRequest.responseText);
var grid = $("#Attachments").data("kendoGrid");
grid.dataSource.read($('#txtECNNumber').val());
}