Esempio n. 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (SqlConnect.GetConnectionState() == ConnectionState.Closed)
     {
         try
         {
             if (SQLSrvNameTBox.Text != "" && SQLPasswdTBox.Text != "" && DBSelectCombo.Text != "")
             {
                 Cursor = Cursors.WaitCursor;
                 SqlConnect.OpenConnection(SQLSrvNameTBox.Text, DBSelectCombo.Text, SQLPasswdTBox.Text);
                 Cursor = Cursors.Default;
                 if (SqlConnect.GetConnectionState() == ConnectionState.Open)
                 {
                     StateLabel.Text = "Połączono z bazą danych\n" + SQLSrvNameTBox.Text;
                     EnableWork();
                 }
                 if (!Directory.Exists(Environment.GetEnvironmentVariable("TEMP") + "\\SQLChanger"))
                 {
                     Directory.CreateDirectory(Environment.GetEnvironmentVariable("TEMP") + "\\SQLChanger");
                 }
                 StreamWriter writer = File.CreateText(Environment.GetEnvironmentVariable("TEMP") + "\\SQLChanger\\data");
                 writer.Write(SQLSrvNameTBox.Text);
                 writer.Close();
                 writer.Dispose();
                 PowiatSelectCombo.Items.Clear();
                 PowiatSelectCombo.Text = "";
                 JEwidencyjnaSelectCombo.Items.Clear();
                 JEwidencyjnaSelectCombo.Text = "";
                 ObrebSelectCombo.Items.Clear();
                 ObrebSelectCombo.Text = "";
                 DataManip.DataManip.FillPowiatSelectCombo(PowiatSelectCombo);
                 OdbcDataReader rd = SqlConnect.ExecuteDataReader("c_ID", "ClassTbl", "c_name LIKE 'GOSZZG'");
                 rd.Read();
                 cCodeID = int.Parse(rd["c_ID"].ToString());
                 rd.Close();
                 DataManip.DataManip.initDictionaryIDs();
             }
             else
             {
                 MessageBox.Show("Wpisz nazwę serwera, nazwę bazy i hasło do konta (sa)", "Połączenie SQL", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
         catch (Exception exept)
         {
             MessageBox.Show(exept.Message, "Wystąpił błąd");
         }
     }
     else
     {
         SqlConnect.CloseConnection();
         DisableWork();
         StateLabel.Text    = "Rozłączono";
         SQLPasswdTBox.Text = "";
     }
     Cursor = Cursors.Arrow;
 }
Esempio n. 2
0
 private void button1_Click_1(object sender, EventArgs e)
 {
     SqlConnect.CloseConnection();
     Close();
 }