Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

Commit

Permalink
fix: updated change detection
Browse files Browse the repository at this point in the history
  • Loading branch information
prahladyeri committed Jul 14, 2020
1 parent d4cb058 commit a24db43
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]
24 changes: 19 additions & 5 deletions frmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,25 @@ private void frmMain_Load(object sender, EventArgs e)
new ToolTip().SetToolTip(this.btnSave, "Commit Changes");
}

private bool havePendingChanges() {
foreach (TabPage tab in tabControl1.TabPages)
{
DataTable changes = datasets[tab.Name].Tables[0].GetChanges();
if (changes != null && changes.Rows.Count > 0)
{
return true;
}
}
return false;
}

private void btnBrowse_Click(object sender, EventArgs e)
{
if (havePendingChanges())
{
MessageBox.Show("You have pending changes, commit them before opening a new database.");
return;
}
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "SQLITE Database Files|*.db;*.sqlite3;*.sqlite";
DialogResult dr = ofd.ShowDialog();
Expand Down Expand Up @@ -149,11 +166,8 @@ private void deleteToolStripMenuItem_Click(object sender, EventArgs e)

private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
{
if (tabControl1.SelectedTab == null) return;
string currentTab = tabControl1.SelectedTab.Name;
DataTable changes = datasets[currentTab].Tables[0].GetChanges();
if (changes != null && changes.Rows.Count > 0) {
DialogResult result= MessageBox.Show("You have pending changes. Are you sure you want to exit sqlite-qui?", null, MessageBoxButtons.YesNo);
if (havePendingChanges()) {
DialogResult result = MessageBox.Show("You have pending changes. Are you sure you want to exit sqlite-qui?", null, MessageBoxButtons.YesNo);
if (result == DialogResult.No) e.Cancel = true;
}
}
Expand Down

0 comments on commit a24db43

Please sign in to comment.