Updates for adding custom buttons
This commit is contained in:
@@ -228,22 +228,42 @@ namespace VEPROMS
|
||||
else if (MyProcedure != null)
|
||||
{
|
||||
var fileLocation = txtExport.Text;
|
||||
|
||||
if (File.Exists(fileLocation))
|
||||
{ // C2022-029 if an existing export of the same name is found, provide option to overwrite it
|
||||
DialogResult ovewriteEx = FlexibleMessageBox.Show("There is already another export file with the same name, would you like to overwrite it?\r\n\r\nSelecting 'Cancel' will cancel the export.", "Overwrite the export change", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);// == DialogResult.Yes;
|
||||
DialogResult ovewriteEx = FlexibleMessageBox.ShowCustom(null, "There is already another export file with the same name, you can either overwrite the existing file, or have the existing file renamed with it's created date appended?\r\n\r\nSelecting 'Cancel' will cancel the export.", "What would you like to do?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);// == DialogResult.Yes;
|
||||
|
||||
if (ovewriteEx == DialogResult.Cancel) btnCloseExport.Enabled = true;
|
||||
else
|
||||
if (ovewriteEx == DialogResult.Abort) btnCloseExport.Enabled = true;
|
||||
else if (ovewriteEx == DialogResult.Retry)
|
||||
{
|
||||
// Ovewrite
|
||||
// Extract directory, filename, and extension
|
||||
string directory = Path.GetDirectoryName(fileLocation);
|
||||
string filename = Path.GetFileNameWithoutExtension(fileLocation);
|
||||
string extension = Path.GetExtension(fileLocation);
|
||||
|
||||
fileLocation = $"{directory}\\{filename}{extension}";
|
||||
msg = "The export file has been overwritten. ";
|
||||
}
|
||||
else if (ovewriteEx == DialogResult.Ignore)
|
||||
{
|
||||
// Extract directory, filename, and extension
|
||||
string directory = Path.GetDirectoryName(fileLocation);
|
||||
string filename = Path.GetFileNameWithoutExtension(fileLocation);
|
||||
string extension = Path.GetExtension(fileLocation);
|
||||
|
||||
// Generate the new filename with a datestamp
|
||||
string datestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||
fileLocation = $"{directory}\\{filename}_{datestamp}{extension}";
|
||||
// Generate the new filename with a datestamp
|
||||
fileLocation = $"{directory}\\{filename}{extension}";
|
||||
|
||||
// Get the creation date of the existing file
|
||||
DateTime creationDate = File.GetCreationTime(fileLocation);
|
||||
|
||||
// Format the creation date to use it as a datestamp
|
||||
string datestamp = creationDate.ToString("yyyyMMddHHmmss");
|
||||
|
||||
string newFileLocation = $"{directory}\\{filename}_{datestamp}{extension}";
|
||||
|
||||
File.Move(fileLocation, newFileLocation);
|
||||
msg = "The previous export has been renamed, the export file has been created. ";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -734,7 +754,7 @@ namespace VEPROMS
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FlexibleMessageBox.Show("The import failed, check the error log for more information.", "Import Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
FlexibleMessageBox.Show(null, "The import failed, check the error log for more information.", "Import Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
_MyLog.Warn("Failure During Import", ex);
|
||||
}
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user