Exemplo n.º 1
0
        private void go_products(object sender, RoutedEventArgs e)
        {
            WindowProducts product = new WindowProducts();

            this.Close();
            product.Show();
        }
Exemplo n.º 2
0
        private void go_back(object sender, RoutedEventArgs e)
        {
            WindowProducts winproducts = new WindowProducts();

            this.Close();
            winproducts.Show();
        }
Exemplo n.º 3
0
        private void go_add(object sender, RoutedEventArgs e)
        {
            if (imagepath != null)
            {
                string title       = title_box.Text.Trim();
                string description = Desription_box.Text.Trim();
                string price       = cost_box.Text.Trim();
                //GenderCode



                DB         db      = new DB();
                SqlCommand command = new SqlCommand("INSERT INTO Product ( Name, Price, Description, ImagePath)"
                                                    + "VALUES (@title, @cost, @Description, @imagepath)", db.getConnection());
                command.Parameters.Add("@title", SqlDbType.VarChar).Value       = title;
                command.Parameters.Add("@Description", SqlDbType.VarChar).Value = description;
                command.Parameters.Add("@cost", SqlDbType.VarChar).Value        = price;
                command.Parameters.Add("@imagepath", SqlDbType.VarChar).Value   = imagepath;
                db.openConnection();

                if (CheckTextBoxes())
                {
                    if (command.ExecuteNonQuery() == 1)
                    {
                        WindowProducts winproducts = new WindowProducts();
                        MessageBox.Show("Продукт успешно добавлена!");
                        this.Close();
                        winproducts.Show();
                    }
                    else
                    {
                        MessageBox.Show("Проверьте правильность введеных данных");
                    }
                }
                else
                {
                    MessageBox.Show("Заполните пустые поля");
                }
            }
            else
            {
                MessageBox.Show("Выберите изображение!");
            }
        }
Exemplo n.º 4
0
        private void go_save(object sender, RoutedEventArgs e)
        {
            DB         db      = new DB();
            SqlCommand command = new SqlCommand("UPDATE Product SET Name = @title, Price = @cost, Description = @desk, ImagePath = @image Where ID = @ids", db.getConnection());

            command.Parameters.AddWithValue("@title", title_box.Text);
            command.Parameters.AddWithValue("@cost", cost_box.Text);
            command.Parameters.AddWithValue("@desk", deck_box.Text);
            command.Parameters.AddWithValue("@image", Service.MainImagePath);
            command.Parameters.AddWithValue("@ids", Service.ID);
            db.openConnection();

            if (command.ExecuteNonQuery() == 1)
            {
                WindowProducts winadm = new WindowProducts();
                MessageBox.Show("Продукт успешно отредактирована!");
                this.Close();
                winadm.Show();
            }
        }