Ejemplo n.º 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     label5.Text = "Проверка соединения...";
     this.Update();
     ConnectConfig.server = comboBox1.Text;
     ConnectConfig.database = comboBox2.Text;
     ConnectConfig.uid = textBox1.Text;
     ConnectConfig.password = textBox2.Text;
     SqlServerShort testConnect = new SqlServerShort();
     testConnect.SqlCommand = "SELECT * FROM author";
     if (testConnect.ExecuteNonQuery())
     {
         label5.Text = "Проверка прошла успешно.";
         ConnectConfig.test = true;
         this.Close();
     }
     else
     {
         ConnectConfig.test = false;
         label5.Text = "Ошибка проверки соединения!";
     }
 }
Ejemplo n.º 2
0
        private void dataSave()
        {
            if (this.Text == "Создать билет.")
            {
                SqlServerShort _sqlServerShort = new SqlServerShort();
                _sqlServerShort.SqlCommand = "INSERT INTO ticket (ticket_spectacle, ticket_place, ticket_order, ticket_subscription) "+
                    "VALUES (" + comboBox1.Text + ", " + comboBox2.Text + ", " + comboBox3.Text + ", " + comboBox4.Text + ")";
                if (_sqlServerShort.ExecuteNonQuery())
                {
                    try
                    {
                        fTickets.TableUpdate();
                        this.Close();
                    }
                    catch
                    {
                        this.Close();
                    }
                }
                else MessageBox.Show("Произошла ошибка сохранения новых данных.");

            }

            if (this.Text == "Изменить билет.")
            {
                SqlServerShort _sqlServerShort = new SqlServerShort();
                _sqlServerShort.SqlCommand = "UPDATE ticket SET ticket_spectacle = " + comboBox1.Text +
                    ", ticket_place = " + comboBox2.Text +
                    ", ticket_order = " + comboBox3.Text +
                    ", ticket_subscription = " + comboBox4.Text +
                    " WHERE (ticket_id = " + ID.ToString() + ")";
                if (_sqlServerShort.ExecuteNonQuery())
                {
                    try
                    {
                        fTickets.TableUpdate();
                        this.Close();
                    }
                    catch
                    {
                        this.Close();
                    }
                }
                else MessageBox.Show("Произошла ошибка сохранения изменённых данных.");
            }
        }