Esempio n. 1
0
 public Start()
 {
     try
     {
         this.InitializeComponent();
         this.Text = "Kalkulator (" + Kalkulator1.instalClass.Version.getVersion().ToString() + ")";
         Start.listaPlikow.Add("START");
         this.path = System.IO.Path.GetTempPath() + "KBW";
         if (!System.IO.Directory.Exists(this.path))
         {
             try
             {
                 System.IO.Directory.CreateDirectory(this.path);
             }
             catch (System.ArgumentNullException)
             {
                 MessageBox.Show("Nieprawidłowa ścieżka. Nie można utworzyć katalogu \"KBW\"", "Error");
             }
             catch (System.ArgumentException)
             {
                 MessageBox.Show("Nieprawidłowa ścieżka. Nie można utworzyć katalogu \"KBW\"", "Error");
             }
             catch (System.UnauthorizedAccessException)
             {
                 MessageBox.Show("Nie masz uprawnień do tworzenia katalogów. Otwórz aplikacje jako adnimistrator.", "Uwaga");
             }
             catch (System.IO.PathTooLongException)
             {
                 MessageBox.Show("Nieprawidłowa ścieżka. Nie można utworzyć katalogu \"KBW\"", "Error");
             }
             catch (System.IO.DirectoryNotFoundException)
             {
                 MessageBox.Show("Nieprawidłowa ścieżka. Nie można utworzyć katalogu \"KBW\"", "Error");
             }
             catch (System.NotSupportedException)
             {
                 MessageBox.Show("Nieprawidłowy format ścieżki. Nie można utworzyć katalogu \"KBW\"", "Error");
             }
             catch (System.IO.IOException)
             {
                 MessageBox.Show("Nieprawidłowa ścieżka. Nie można utworzyć katalogu \"KBW\"", "Error");
             }
         }
         if (!System.IO.Directory.Exists(this.path + "\\tmp"))
         {
             Instal inst = new Instal(this.path);
         }
         if (System.IO.Directory.Exists(System.IO.Path.GetTempPath() + "KBW\\tmp"))
         {
             if (!System.IO.File.Exists(System.IO.Path.GetTempPath() + "KBW\\tmp\\eksport.xml"))
             {
                 System.IO.File.Create(System.IO.Path.GetTempPath() + "KBW\\tmp\\eksport.xml");
             }
             if (!System.IO.File.Exists(System.IO.Path.GetTempPath() + "KBW\\tmp\\import.xml"))
             {
                 System.IO.File.Create(System.IO.Path.GetTempPath() + "KBW\\tmp\\import.xml");
             }
             if (!System.IO.File.Exists(System.IO.Path.GetTempPath() + "KBW\\tmp\\eksportCode.xml"))
             {
                 System.IO.File.Create(System.IO.Path.GetTempPath() + "KBW\\tmp\\eksportCode.xml");
             }
         }
         this.logged = false;
         this.certificate = new Certificate();
         this.con = new Connection();
         this.LicencesTable.CellClick += new DataGridViewCellEventHandler(this.LicencesTable_CellClick);
         this.waitLicenses.CellClick += new DataGridViewCellEventHandler(this.waitLicenses_CellClick);
         this.wait = new WaitPanel("Wait1", base.Width, base.Height);
         base.Controls.Add(this.wait.getPanel());
         base.Controls[this.wait.getName()].BringToFront();
         this.getActiveLicense();
         this.getOtherLicense();
         if (!Kalkulator1.instalClass.Version.newApp())
         {
             MessageBox.Show("Twoja wersja kalkulatora wyborczego jest nieaktualna.", "Uwaga");
         }
     }
     catch (System.Exception)
     {
     }
 }
Esempio n. 2
0
 private void btnDeleteTemp_Click(object sender, System.EventArgs e)
 {
     DialogResult dr = MessageBox.Show("Wszystkie zapisane wcześniej dane zostaną usunięte. Czy kontynuować?", "Usuwanie danych tymczasowych", MessageBoxButtons.YesNo);
     DialogResult dialogResult = dr;
     if (dialogResult != DialogResult.No)
     {
         try
         {
             System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(this.path + "\\ProtocolsDef");
             if (dir.Exists)
             {
                 dir.Delete(true);
             }
             dir = new System.IO.DirectoryInfo(this.path + "\\electoralEampaign");
             if (dir.Exists)
             {
                 dir.Delete(true);
             }
             dir = new System.IO.DirectoryInfo(this.path + "\\saves");
             if (dir.Exists)
             {
                 dir.Delete(true);
             }
             dir = new System.IO.DirectoryInfo(this.path + "\\tmp");
             if (dir.Exists)
             {
                 dir.Delete(true);
             }
             Start.listaPlikow.Clear();
         }
         catch (System.Exception)
         {
             MessageBox.Show("Brak danych tymczasowych.", "Usuwanie danych tymczasowych", MessageBoxButtons.OK);
         }
         if (!System.IO.Directory.Exists(this.path + "\\tmp"))
         {
             Instal inst = new Instal(this.path);
         }
         if (System.IO.Directory.Exists(System.IO.Path.GetTempPath() + "KBW\\tmp"))
         {
             if (!System.IO.File.Exists(System.IO.Path.GetTempPath() + "KBW\\tmp\\eksport.xml"))
             {
                 System.IO.File.Create(System.IO.Path.GetTempPath() + "KBW\\tmp\\eksport.xml");
             }
             if (!System.IO.File.Exists(System.IO.Path.GetTempPath() + "KBW\\tmp\\import.xml"))
             {
                 System.IO.File.Create(System.IO.Path.GetTempPath() + "KBW\\tmp\\import.xml");
             }
             if (!System.IO.File.Exists(System.IO.Path.GetTempPath() + "KBW\\tmp\\eksportCode.xml"))
             {
                 System.IO.File.Create(System.IO.Path.GetTempPath() + "KBW\\tmp\\eksportCode.xml");
             }
         }
         MessageBox.Show("Dane tymczasowe zostały pomyślnie usunięte.", "Usuwanie danych tymczasowych", MessageBoxButtons.OK);
     }
 }