private void ChangeUser(object sender, EventArgs e) { Login FormLogin = new Login(); FormLogin.ShowDialog(); }
private void StartupForm_Load(object sender, EventArgs e) { Login FormLogin = new Login(); FormLogin.ShowDialog(); }
private void SysExitToolStripMenuItem_Click(object sender, EventArgs e) { DBExchange.Inst.StartupLogoff(); Login FormLogin = new Login(); FormLogin.ShowDialog(); }
private void StartupForm_Load(object sender, EventArgs e) { Login FormLogin = new Login(); FormLogin.ShowDialog(); if (DBExchange.Inst.connectDb.State == ConnectionState.Open && DBExchange.Inst.CheckProgramVersion() == true) { if ((MessageBox.Show("Провести обновление сейчас?", "Есть обновленная версия программы", MessageBoxButtons.YesNo)) == DialogResult.Yes) { if (File.Exists(Application.StartupPath + @"\setup.exe")) { File.Delete(Application.StartupPath + @"\setup.exe"); } try { //newcon.Open(); //NpgsqlTransaction t = newcon.BeginTransaction(); //LargeObjectManager lbm = new LargeObjectManager(newcon); //int noid = lbm.Create(LargeObjectManager.READWRITE); //LargeObject lo = lbm.Open(noid,LargeObjectManager.READWRITE); //FileStream fs = File.OpenRead(args[0]); //byte[] buf = new byte[fs.Length]; //fs.Read(buf,0,(int)fs.Length); //lo.Write(buf); //lo.Close(); //t.Commit(); //t = newcon.BeginTransaction(); //lo = lbm.Open(noid,LargeObjectManager.READWRITE); //FileStream fsout = File.OpenWrite(args[0] + "database"); //buf = lo.Read(lo.Size()); //fsout.Write(buf, 0, (int)lo.Size()); //fsout.Flush(); //fsout.Close(); //lo.Close(); //t.Commit(); NpgsqlCommand geetO = new NpgsqlCommand("Select MAX(prog_oid) from settings", DBExchange.Inst.connectDb); long getOid = (long)geetO.ExecuteScalar(); SaveFileDialog sf1 = new SaveFileDialog(); sf1.FileName = Application.StartupPath + @"\setup.exe"; sf1.Filter = "exe (*.exe)|*.exe"; sf1.ShowDialog(); // FileStream fs = new FileStream(sf1.FileName, FileMode.OpenOrCreate, FileAccess.ReadWrite, lo.Size()); FileStream fs = new FileStream(sf1.FileName, FileMode.OpenOrCreate, FileAccess.ReadWrite); NpgsqlConnection cdb = DBExchange.Inst.connectDb; // cdb.Open(); NpgsqlTransaction t = cdb.BeginTransaction(); LargeObjectManager lbm = new LargeObjectManager(cdb); LargeObject lo = lbm.Open(Convert.ToInt32(getOid), LargeObjectManager.READ); byte[] buf = new byte[lo.Size()]; buf = lo.Read(lo.Size()); // MemoryStream ms = new MemoryStream(); // ms.Write(buf, 0, lo.Size()); // StreamWriter s = new StreamWriter(fs); fs.Write(buf, 0, lo.Size()); // s.Write(buf, 0, lo.Size()); // s.Close(); fs.Close(); lo.Close(); t.Commit(); // cdb.Close(); System.Diagnostics.Process.Start(sf1.FileName); Application.Exit(); } catch (Exception exception) { Warnings.WarnLog log = new Warnings.WarnLog(); log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString()); try { System.Net.WebClient Client = new System.Net.WebClient(); Client.DownloadFile("http://medx.spb.ru/latest/setup.exe", Application.StartupPath + @"\setup.exe"); System.Diagnostics.Process.Start(Application.StartupPath + @"\setup.exe"); Application.Exit(); } catch (Exception exception1) { Warnings.WarnLog log1 = new Warnings.WarnLog(); log1.writeLog(MethodBase.GetCurrentMethod().Name, exception1.Message.ToString(), exception1.StackTrace.ToString()); } } //Client.DownloadFileCompleted += new AsyncCompletedEventHandler(AppUpdate); } } }