Exemple #1
0
 public ProductDataAdminControl(Product productDataObject)
 {
     InitializeComponent();
     kek2         = new InterfaceToDataBaseProductMethods();
     this.product = productDataObject;
     GetCategories();
     SetProductData();
 }
Exemple #2
0
        async private void saveChangesButton_Click(object sender, EventArgs e)
        {
            int    state;
            Bitmap image;

            if (productPictureBox.Image == Properties.Resources.NoPicture)
            {
                image = null;
            }
            else
            {
                image = (Bitmap)productPictureBox.Image;
            }
            if (radioButton1.Checked)
            {
                state = 0;
            }
            else if (radioButton2.Checked)
            {
                state = 1;
            }
            else
            {
                state = 2;
            }
            decimal discount;
            decimal?discoun2 = null;

            if (decimal.TryParse(textBox1.Text, out discount))
            {
                discoun2 = discount;
            }
            long cat_id = categoriesList.Find(x => x.Name == categoryComboBox.SelectedItem.ToString()).CategoryID;
            await kek2.ProductModification(
                product.ProductID,
                nameTextbox.Text,
                decimal.Parse(priceTextbox.Text),
                state,
                discoun2,
                decimal.Parse(amountTextbox.Text),
                descriptionTextBox.Text,
                image,
                cat_id
                );

            InterfaceToDataBaseProductMethods methods = new InterfaceToDataBaseProductMethods();
            List <Product> products = await methods.CatalogProducts();

            foreach (var product in products)
            {
                this.Parent.Controls.Add(new ProductMiniDataAdminControl(product));
            }
            this.Parent.Controls.Remove(this);
        }
Exemple #3
0
        private async void SearchHistory()
        {
            HistoryUserControl history = null;

            int category = ReverseCategory(categoryBox.SelectedItem.ToString());

            if (category == 0)
            {
                InterfaceToDataBaseUserMethods Methods = new InterfaceToDataBaseUserMethods();
                User userData = await Methods.GetUserData(long.Parse(searchBox.Text));

                if (userData != null)
                {
                    history = new HistoryUserControl(userData, true);
                }
            }
            else if (category == 1)
            {
                InterfaceToDataBaseUserMethods Methods = new InterfaceToDataBaseUserMethods();
                User userData = await Methods.GetUserData(searchBox.Text);

                if (userData != null)
                {
                    history = new HistoryUserControl(userData, true);
                }
            }
            else if (category == 2)
            {
                history = new HistoryUserControl(long.Parse(searchBox.Text), true);
            }
            else if (category == 3)
            {
                InterfaceToDataBaseProductMethods Methods = new InterfaceToDataBaseProductMethods();
                history = new HistoryUserControl(await Methods.GetProductId(searchBox.Text), true);
            }
            else if (category > 3 && category < 9)
            {
                history = new HistoryUserControl(MakeDate(category - 3), category - 3, true);
            }
            else
            {
                throw new ArgumentException();
            }
            if (history != null)
            {
                history.Dock = DockStyle.Fill;
                histPanel.Controls.Add(history);
            }
        }
Exemple #4
0
        async private void deleteButton_Click(object sender, EventArgs e)
        {
            InterfaceToDataBaseProductMethods kek = new InterfaceToDataBaseProductMethods();
            await kek.DeleteProduct(product.ProductName);

            product = await kek.GetProductData(product.ProductID);

            if (product == null)
            {
                this.Parent.Controls.Remove(this);
            }
            if (product.State == 1)
            {
                label3.Text = "AKTYWNY";
            }
            if (product.State == 2)
            {
                label3.Text = "ARCHIWALNY";
            }
        }
Exemple #5
0
        async private void deleteButton_Click(object sender, EventArgs e)
        {
            await kek2.DeleteProduct(product.ProductName);

            if (product.State == 0)
            {
                InterfaceToDataBaseProductMethods methods = new InterfaceToDataBaseProductMethods();
                List <Product> products = await methods.CatalogProducts();

                foreach (var product in products)
                {
                    this.Parent.Controls.Add(new ProductMiniDataAdminControl(product));
                }
                this.Parent.Controls.Remove(this);
            }
            if (product.State == 1)
            {
                product.State        = 2;
                radioButton1.Checked = false;
                radioButton2.Checked = true;
                deleteButton.Visible = false;
                this.stateLabel.Text = "ARCHIWALNY";
            }
        }
Exemple #6
0
 public ProductsAdminControl()
 {
     InitializeComponent();
     methods = new InterfaceToDataBaseProductMethods();
 }