Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            String        commandText = "INSERT INTO ProductSet VALUES(@productname, @antidesease, @manufacturer, @qty, @mainingr)";
            string        sConnection = Properties.Settings.Default.BD2ConnectionString;
            SqlConnection conn        = new SqlConnection();

            conn.ConnectionString = sConnection;
            conn.Open();
            try
            {
                SqlCommand command = new SqlCommand(commandText, conn);
                command.Parameters.AddWithValue("@productname", textBox1.Text.ToString());
                command.Parameters.AddWithValue("@antidesease", comboBox1.Text.ToString());
                if (comboBox2.Text.ToString().Equals("---OTHER---"))
                {
                    command.Parameters.AddWithValue("@manufacturer", textBox2.Text.ToString());
                }
                else
                {
                    command.Parameters.AddWithValue("@manufacturer", comboBox2.Text.ToString());
                }
                command.Parameters.AddWithValue("@qty", numericUpDown1.Value);
                command.Parameters.AddWithValue("@mainingr", textBox3.Text.ToString());
                command.ExecuteNonQuery();
                conn.Close();
                ProductCatalog powrot = new ProductCatalog();
                powrot.Show();
                this.Hide();
            }
            catch (SqlException er)
            {
                String text = "There was an error reported by SQL Server, " + er.Message;
                MessageBox.Show(text, "ERROR");
            }
        }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            String        commandText = "UPDATE ProductSet SET ProductName=@productname, AntiDisease=@ad, Manufacturer=@manufacturer, QtyPerCase=@qty, MIngredient=@mi WHERE ProductID=@param";
            string        sConnection = Properties.Settings.Default.BD2ConnectionString;
            SqlConnection conn        = new SqlConnection();

            conn.ConnectionString = sConnection;
            conn.Open();
            try
            {
                SqlCommand command = new SqlCommand(commandText, conn);
                command.Parameters.AddWithValue("@param", ProductCatalog.pomoc);
                command.Parameters.AddWithValue("@productname", textBox1.Text.ToString());
                command.Parameters.AddWithValue("@ad", comboBox1.Text.ToString());
                if (textBox2.Enabled == true)
                {
                    command.Parameters.AddWithValue("@manufacturer", textBox2.Text.ToString());
                }
                else
                {
                    command.Parameters.AddWithValue("@manufacturer", comboBox2.Text.ToString());
                }
                command.Parameters.AddWithValue("@qty", numericUpDown1.Value);
                command.Parameters.AddWithValue("@mi", textBox3.Text.ToString());
                command.ExecuteNonQuery();
                conn.Close();
                ProductCatalog powrot = new ProductCatalog();
                powrot.Show();
                this.Hide();
            }
            catch (SqlException er)
            {
                String text = "There was an error reported by SQL Server, " + er.Message;
                MessageBox.Show(text, "ERROR");
            }
        }
Exemple #3
0
        private void button5_Click(object sender, EventArgs e)
        {
            ProductCatalog katalogproduktow = new ProductCatalog();

            katalogproduktow.ShowDialog();
        }