Skip to content

Commit

Permalink
Removed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
R0mb0 committed Oct 21, 2024
1 parent 18bb390 commit c6cc7e9
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
13 changes: 13 additions & 0 deletions FPDF/FPDF/FPDF/HistoricForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ public partial class HistoricForm : Form

//Fields
public string filePath { get; set; }
public bool loaded { get; set; }

public HistoricForm()
{
InitializeComponent();

// In the case of closing panel
loaded = false;

//Read the database for all files
/*
//string queryString = "";
Expand Down Expand Up @@ -51,6 +55,9 @@ private void bSelect_Click(object sender, EventArgs e)
try
{
File.Copy(this.filePath, this.dView.SelectedCells[0].Value.ToString());

//The file is ready
loaded = true;
}
catch //(Exception ex)
{
Expand All @@ -59,6 +66,9 @@ private void bSelect_Click(object sender, EventArgs e)
{
File.Delete(this.dView.SelectedCells[0].Value.ToString());
File.Copy(this.filePath, this.dView.SelectedCells[0].Value.ToString());

//The file is ready
loaded = true;
}
catch //(Exception ex2)
{
Expand All @@ -75,6 +85,9 @@ public void UpdateGrid()
// Load Files inside Teh data grid
if (Directory.Exists("Sent_Documents") && Directory.GetFiles("Sent_Documents").Length != 0)
{
//At first reset all rows
this.dView.Rows.Clear();

try
{
foreach (var item in Directory.GetFiles("Sent_Documents"))
Expand Down
13 changes: 11 additions & 2 deletions FPDF/FPDF/FPDF/LoadForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ private void bLoad_Click(object sender, EventArgs e)
try
{
File.Copy(this.filePath, this.dView.SelectedCells[0].Value.ToString());

//Set that the file is available and remove the old file
loaded = true;
File.Delete(this.filePath);
}
catch //(Exception ex)
{
Expand All @@ -42,14 +46,16 @@ private void bLoad_Click(object sender, EventArgs e)
{
File.Delete(this.dView.SelectedCells[0].Value.ToString());
File.Copy(this.filePath, this.dView.SelectedCells[0].Value.ToString());

//Set that the file is available and remove the old file
loaded = true;
File.Delete(this.filePath);
}
catch //(Exception ex2)
{
MessageBox.Show("Errore durante la gestione dei file", "Errore gestione file", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}

loaded = true;
File.Delete(this.filePath);
}
this.filePath = this.dView.SelectedCells[0].Value.ToString();
this.Close();
Expand Down Expand Up @@ -87,6 +93,9 @@ public void UpdateGrid()
// Load Files inside Teh data grid
if (Directory.Exists("New_Documents_Example") && Directory.GetFiles("New_Documents_Example").Length != 0)
{
//At first reset all rows
this.dView.Rows.Clear();

try
{
foreach (var item in Directory.GetFiles("Saved_Documents"))
Expand Down
24 changes: 21 additions & 3 deletions FPDF/FPDF/FPDF/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,30 @@ private void bLoad_Click(object sender, EventArgs e)

//Prepare before open form
this.PDFpath = null;
this.loadForm.loaded = false;

//Open new panel
this.loadForm.UpdateGrid();
this.loadForm.ShowDialog();
this.PDFpath = loadForm.filePath;

if (this.loadForm.loaded)
{
//Rename file for saving purpose
this.PDFpath = loadForm.filePath.Remove(0, 20);
try
{ //Try to rename
System.IO.File.Move(loadForm.filePath, this.PDFpath);
}
catch
{
//Delete old files
File.Delete(loadForm.filePath);
File.Delete(this.PDFpath);
//Now rename
System.IO.File.Move(loadForm.filePath, this.PDFpath);
}
}

//Reset boxes
EraseAll();

Expand Down Expand Up @@ -346,6 +364,7 @@ private void bHistoric_Click(object sender, EventArgs e)

//Prepare before open form
this.PDFpath = null;
this.historicForm.loaded = false;

//Open new panel
this.historicForm.UpdateGrid();
Expand All @@ -358,7 +377,7 @@ private void bHistoric_Click(object sender, EventArgs e)
EraseAll();


if (this.PDFpath != null)
if (this.historicForm.loaded && this.PDFpath != null)
{
//Set work in progress variable
this.workInProgress = false;
Expand Down Expand Up @@ -406,7 +425,6 @@ private void bSend_Click(object sender, EventArgs e)
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
HtmlConverter.ConvertToPdf(Rtf.ToHtml(this.pdfTextBox.Rtf.ToString()), new FileStream(this.PDFpath, FileMode.Create));

//MessageBox.Show("Saved_Documents\\"+DateTime.Now.ToString().Replace("/","-").Replace(" ","_").Replace(":","-")+"_"+this.PDFpath);
if (!Directory.Exists("Sent_Documents"))
{
Directory.CreateDirectory("Sent_Documents");
Expand Down

0 comments on commit c6cc7e9

Please sign in to comment.