Пример #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (textBox_Name.Text == "" || textBox_Price.Text == "" || textBox_Category.Text == "")
            {
                TextNotification.Text = "Some fields are empty";
                return;
            }
            else
            {
                TextNotification.Text = "";
            }



            SqlCommand command = new SqlCommand("INSERT INTO [Products] (Name, Price, Category)VALUES(@Name, @Price, @Category)", sqlConnection);

            command.Parameters.AddWithValue("Name", textBox_Name.Text);
            command.Parameters.AddWithValue("Price", Convert.ToDecimal(textBox_Price.Text));
            command.Parameters.AddWithValue("Category", textBox_Category.Text);

            Admin_UI.GetAdmin().Command = command;
            Admin_UI.GetAdmin().DataConnect();

            Admin_UI.GetAdmin().SELECT();
        }
Пример #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (textBox_Id.Text == "" || textBox_Name.Text == "" ||
                textBox_Price.Text == "" || textBox_Category.Text == "")
            {
                TextNotification.Text = "Some fields are empty";
                return;
            }
            else
            {
                TextNotification.Text = "";
            }


            SqlCommand command = new SqlCommand("UPDATE [Products] SET [Name]=@Name, [Price]=@Price, [Category]=@Category WHERE [Id]=@Id", sqlConnection);

            command.Parameters.AddWithValue("Id", textBox_Id.Text);
            command.Parameters.AddWithValue("Name", textBox_Name.Text);
            command.Parameters.AddWithValue("Price", Convert.ToDecimal(textBox_Price.Text));
            command.Parameters.AddWithValue("Category", textBox_Category.Text);

            Admin_UI.GetAdmin().Command = command;
            Admin_UI.GetAdmin().DataConnect();

            Admin_UI.GetAdmin().SELECT();
        }
Пример #3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (textBox_Id.Text == "")
            {
                TextNotification.Text = "Some fields are empty";
                return;
            }
            else
            {
                TextNotification.Text = "";
            }


            SqlCommand command = new SqlCommand("DELETE FROM [Products] WHERE [Id]=@Id", sqlConnection);

            command.Parameters.AddWithValue("Id", textBox_Id.Text);

            Admin_UI.GetAdmin().Command = command;
            Admin_UI.GetAdmin().DataConnect();

            Admin_UI.GetAdmin().SELECT();
        }