/// <summary> /// Closes the users database /// </summary> public void CloseUsersTable() { try { ado.CloseDataBase(users); } catch (Exception e) { program.errorreport(e); } }
private void btnChange_Click(object sender, EventArgs ev) { try { int i; string tmp; hbADO.AttachDataBaseinDataSet(Data, Dabasepath + "\\" + tablename); //MessageBox.Show(cmboCells.Text + "\n" + txtCellName.Text + "\n" + Convert.ToString(Data.Tables.Count)); if ((cmboCells.Text != null) && (this.cboCellsTarget.Text != null) && (Data != null) && (Data.Tables.Count > 0)) { // hydrobaseADO hbAdo = new hydrobaseADO(); i = cmboCells.SelectedIndex; //tmp = checkandfixcellname(this.cboCellsTarget.Text); hbADO.MovePositionBetweenTwoCollumns(Data.Tables[0], this.cmboCells.Text, cboCellsTarget.Text); hbADO.SaveTable(Data, Dabasepath + "\\" + tablename, 0, ProductName + " - " + ProductVersion); hbADO.CloseDataBase(Data); MessageBox.Show("Please Reload the Table to see the changes."); } this.Close(); } catch (Exception e) { Program.errorreport(e); } }
private void btnLoad_Click(object sender, EventArgs ev) { try { hydrobaseADO ado = new hydrobaseADO(); string zipfile; string destdir; if ((MainWindow.username != null) && (MainWindow.pass != null)) { frmEdit frmedit = new frmEdit(); ado.CloseDataBase(frmedit.set); ado.RemoveTableFromDataGrid(frmedit.grid); //frmedit.IsMdiChild = true; frmedit.MdiParent = Program.Mainwnd; frmedit.Show(); frmedit.set = new DataSet(); // frmMain.grid = new DataGridView(); // MessageBox.Show(Program.client.LoadTable(BaseClass.recordtag, MainWindow.username, MainWindow.pass, lstDbs.Text, lsttables.Text)); if (Program.client.IsTableEncrypted(MainWindow.username, MainWindow.pass, lstDbs.Text, lsttables.Text) == false) { RemoteFileInfo zfile = Program.client.LoadTableAsFile(BaseClass.recordtag, MainWindow.username, MainWindow.pass, lstDbs.Text, lsttables.Text); if (zfile != null) { zipfile = Path.Combine(Program.TempPath, zfile.FileName); byte[] str = zfile.FileByteStream; util.ByteToFile(zipfile, str); FastZip z = new FastZip(); destdir = Path.Combine(Program.TempPath, Path.GetFileNameWithoutExtension(zfile.FileName)); if (!Directory.Exists(destdir)) { Directory.CreateDirectory(destdir); } z.ExtractZip(zipfile, destdir, null); string[] files = Directory.GetFiles(destdir); if (files != null) { frmedit.set.ReadXml(files[0]); } } // frmedit.set.ReadXml(util.StringToStream()); //frmedit.set.ReadXml(util.StringToStream(Program.client.LoadTable(BaseClass.recordtag, MainWindow.username, MainWindow.pass, lstDbs.Text, lsttables.Text))); // MessageBox.Show(Program.client.LoadTable(BaseClass.recordtag, MainWindow.username, MainWindow.pass, lstDbs.Text, lsttables.Text)); } else { if (MainWindow.passphrase != null) { frmedit.set.ReadXml(util.StringToStream(Program.client.Decrypt(BaseClass.tabletag, BaseClass.recordtag, MainWindow.username, lstDbs.Text, lsttables.Text, MainWindow.pass, Cryptography.CryptograhyAlgorithm.rijdael.ToString().ToString(), Cryptography.HashingAlogrithm.SHA384.ToString().ToString(), MainWindow.passphrase))); } else { MainWindow.passphrase = Microsoft.VisualBasic.Interaction.InputBox("Type your passphrase"); if (MainWindow.passphrase != null) { frmedit.set.ReadXml(util.StringToStream(Program.client.Decrypt(BaseClass.tabletag, BaseClass.recordtag, MainWindow.username, lstDbs.Text, lsttables.Text, MainWindow.pass, Cryptography.CryptograhyAlgorithm.rijdael.ToString().ToString(), Cryptography.HashingAlogrithm.SHA384.ToString().ToString(), MainWindow.passphrase))); } } } // MessageBox.Show(Program.client.LoadTable(BaseClass.recordtag,MainWindow.username, MainWindow.pass, lstDbs.Text, lsttables.Text)); if (frmedit.set.Tables.Count > 0) { frmedit.grid.DataSource = frmedit.set; frmedit.grid.DataMember = frmedit.set.Tables[frmedit.set.Tables.Count - 1].TableName; ado.ConnectEventstoDataGrid(frmedit.grid); ado.ConnectEventstoDataTable(frmedit.set.Tables[0]); frmedit.Text = frmedit.grid.DataMember; frmedit.dbname = lstDbs.Text; frmedit.tablename = lsttables.Text; frmedit.Text = String.Format("{0}\\{1}", frmedit.dbname, frmedit.tablename); } } else { Login log = new Login(); log.Show(); frmEdit frmedit = new frmEdit(); frmedit.MdiParent = Program.Mainwnd; // frmedit.IsMdiChild = true; frmedit.set = new DataSet(); frmedit.set.ReadXml(util.StringToStream(Program.client.LoadTable(BaseClass.recordtag, MainWindow.username, MainWindow.pass, lstDbs.Text, lsttables.Text))); frmedit.grid.DataSource = frmedit.set; frmedit.grid.DataMember = frmedit.set.Tables[frmedit.set.Tables.Count - 1].TableName; frmedit.Text = frmedit.grid.DataMember; frmedit.dbname = lstDbs.Text; frmedit.tablename = lsttables.Text; frmedit.Text = String.Format("{0}\\{1}", frmedit.dbname, frmedit.tablename); ado.ConnectEventstoDataGrid(frmedit.grid); ado.ConnectEventstoDataTable(frmedit.set.Tables[0]); } this.Close(); } catch (Exception e) { Program.errorreport(e); MessageBox.Show(e.ToString()); this.Close(); } }