Skip to content

Commit

Permalink
correction for rename on import
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisheib committed Jan 30, 2018
1 parent 865eaa5 commit 22b8f91
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
9 changes: 8 additions & 1 deletion NW-Spendenmonitor/DonationImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace NW_Spendenmonitor

static class DonationImporter
{
public static int ImportCSVToInput(SQLiteConnection dbConnect, string path, bool rename, int language)
public static int ImportCSVToInput(SQLiteConnection dbConnect, string path, bool rename, int language, string oldpath)
{

List<DonationDataLine> donationList = CSVReader.ReadCSV(path);
Expand Down Expand Up @@ -59,12 +59,19 @@ public static int ImportCSVToInput(SQLiteConnection dbConnect, string path, bool
changedLines++;
}


// find last date
if (string.Compare(donationLine.Time, maxDateInFile) > 0)
{
maxDateInFile = donationLine.Time;
}
}


if (oldpath != "")
{
System.IO.File.Delete(path);
path = oldpath;
}

if (rename)
Expand Down
4 changes: 3 additions & 1 deletion NW-Spendenmonitor/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ private void Button3_Click(object sender, EventArgs e)
SetStatus("Importiere " + openFileDialog1.FileName + ", bitte warten!");

string path = openFileDialog1.FileName;
string oldpath = "";

ConfigClass.ImportLanguage = cbLanguage.SelectedIndex;

Expand All @@ -80,13 +81,14 @@ private void Button3_Click(object sender, EventArgs e)
case 0:
break;
case 1:
oldpath = path;
ImportLanguageManager.PrepareFileGerman(ref path);
break;
default:
break;
}

string changedLines = Convert.ToString(DonationImporter.ImportCSVToInput(dbConnection, path, checkBox1.Checked, cbLanguage.SelectedIndex));
string changedLines = Convert.ToString(DonationImporter.ImportCSVToInput(dbConnection, path, checkBox1.Checked, cbLanguage.SelectedIndex, oldpath));
SetStatus("Import von " + openFileDialog1.FileName + " abgeschlossen, " + changedLines + " Einträge hinzugefügt!");
StatementToGrid("select * from input order by time desc limit " + changedLines, true);
}
Expand Down
Binary file modified NW-Spendenmonitor/bin/Release/NW-Spendenmonitor.exe
Binary file not shown.

0 comments on commit 22b8f91

Please sign in to comment.