private async void button1_Click(object sender, EventArgs e)
        {
            DataBank.AddressApartment = textBox1.Text;
            DataBank.ValueApartment   = textBox2.Text;
            DataBank.AreaApartment    = textBox3.Text;
            DataBank.RoomsApartment   = textBox4.Text;
            DataBank.FloorApartment   = textBox5.Text;
            DataBank.SqaureApartment  = textBox6.Text;
            InsertTransactionsClients insertTransactions = new InsertTransactionsClients(sqlConnection);

            insertTransactions.Show();

            SqlCommand insertApartmentsCommand = new SqlCommand("INSERT INTO [Apartments] (Address, Value, Area, Rooms, Floor, Sqaure) VALUES(@Address, @Value, @Area, @Rooms, @Floor, @Sqaure)", sqlConnection);

            insertApartmentsCommand.Parameters.AddWithValue("Address", Convert.ToString(textBox1.Text));
            insertApartmentsCommand.Parameters.AddWithValue("Value", Convert.ToDecimal(textBox2.Text));
            insertApartmentsCommand.Parameters.AddWithValue("Area", Convert.ToString(textBox3.Text));
            insertApartmentsCommand.Parameters.AddWithValue("Rooms", Convert.ToInt32(textBox4.Text));
            insertApartmentsCommand.Parameters.AddWithValue("Floor", Convert.ToInt32(textBox5.Text));
            insertApartmentsCommand.Parameters.AddWithValue("Sqaure", Convert.ToDecimal(textBox6.Text));
            try
            {
                await insertApartmentsCommand.ExecuteNonQueryAsync();//выполняет действие, при этом не возвращая никаких данных

                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
        private async void button1_Click(object sender, EventArgs e)
        {
            DataBank.SNMClients    = textBox1.Text + " " + textBox2.Text + " " + textBox3.Text;
            DataBank.BudgetClients = textBox4.Text;
            DataBank.AreaClients   = textBox5.Text;
            DataBank.RoomsClients  = textBox6.Text;
            DataBank.FloorClients  = textBox7.Text;
            DataBank.SqaureClients = textBox8.Text;
            DataBank.EmailClients  = textBox9.Text;
            InsertTransactionsClients insertTransactions = new InsertTransactionsClients(sqlConnection);

            insertTransactions.Show();

            SqlCommand insertClientsCommand = new SqlCommand("INSERT INTO [Clients] (Surname, Name, MiddleName, Budget, Area, Rooms, Floor, Sqaure, Email) VALUES(@Surname, @Name, @MiddleName, @Budget, @Area, @Rooms, @Floor, @Sqaure, @Email)", sqlConnection);

            insertClientsCommand.Parameters.AddWithValue("Surname", Convert.ToString(textBox1.Text));
            insertClientsCommand.Parameters.AddWithValue("Name", Convert.ToString(textBox2.Text));
            insertClientsCommand.Parameters.AddWithValue("Middlename", Convert.ToString(textBox3.Text));
            insertClientsCommand.Parameters.AddWithValue("Budget", Convert.ToDecimal(textBox4.Text));
            insertClientsCommand.Parameters.AddWithValue("Area", Convert.ToString(textBox5.Text));
            insertClientsCommand.Parameters.AddWithValue("Rooms", Convert.ToInt32(textBox6.Text));
            insertClientsCommand.Parameters.AddWithValue("Floor", Convert.ToInt32(textBox7.Text));
            insertClientsCommand.Parameters.AddWithValue("Sqaure", Convert.ToDecimal(textBox8.Text));
            insertClientsCommand.Parameters.AddWithValue("Email", Convert.ToString(textBox9.Text));
            try
            {
                await insertClientsCommand.ExecuteNonQueryAsync();//выполняет действие, при этом не возвращая никаких данных

                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }