コード例 #1
0
 private void Close_Adm()
 {
     Update.Hide();
     Delete.Hide();
     Add.Hide();
     Change.Hide();
     адресTextBox.ReadOnly       = true;
     вместимостьTextBox.ReadOnly = true;
     Адрес.Hide();
     Вместимость.Hide();
     label1.Hide();
     label2.Hide();
     button1.Hide();
     button2.Hide();
     товары_на_складахDataGridView.ReadOnly              = true;
     товары_на_складахDataGridView.AllowUserToAddRows    = false;
     товары_на_складахDataGridView.AllowUserToDeleteRows = false;
 }
コード例 #2
0
        private void Add_Click(object sender, EventArgs e)
        {
            SqlConnection connection = new SqlConnection(Utility.GetConnectionString());

            try
            {
                connection.Open();
                String     que = "INSERT INTO dbo.Склад (Адрес, Вместимость) Values('" + Адрес.Text + "'," + Вместимость.Text + ")";
                SqlCommand cmd = new SqlCommand(que, connection);
                if (cmd.ExecuteNonQuery() == 1)
                {
                    MessageBox.Show("Запись успешно добавлена.");
                }
                connection.Close();
                Update_Click(sender, e);
                Адрес.ResetText();
                Вместимость.ResetText();
            }
            catch
            {
                MessageBox.Show("Ошибка при добавлении");
            }
            складTableAdapter.Fill(товарооборот_магазинаDataSet.Склад);
        }