예제 #1
0
        private void updateButton_Click(object sender, EventArgs e)
        {
            string title       = titleTB.Text;
            string description = descriptionTB.Text;
            string price       = priceTB.Text;
            string type        = (comboBox1.SelectedItem as string);
            int    categoryId  = catId;
            User   owner       = Arxikh.user;

            Product product = new Product
            {
                Title      = title,
                Desc       = description,
                Price      = price,
                Type       = type,
                CategoryId = categoryId,
                Date       = System.DateTime.Today.ToString("dd/MM/yy"),
                Owner      = owner
            };

            AdHandler handler = new AdHandler(product);

            if (handler.createAd())
            {
                Database.updateAd(product, productId);
                MessageBox.Show("Your ad was updated!");
                this.Close();
            }
            else
            {
                MessageBox.Show("Fill all the fields.");
            }
        }
예제 #2
0
        private void createAdButton_Click(object sender, EventArgs e)
        {
            string title       = titleTextBox.Text;
            string description = descriptionTextBox.Text;
            string price       = priceTextBox.Text;
            string type        = (typeComboBox.SelectedItem as string);
            string category    = (categoryComboBox.SelectedItem as string);
            int    categoryId  = Database.getCategoryIdByName(category);
            User   owner       = Arxikh.user;

            Product product = new Product
            {
                Title      = title,
                Desc       = description,
                Price      = price,
                Type       = type,
                CategoryId = categoryId,
                Date       = System.DateTime.Today.ToString("dd/MM/yy"),
                Owner      = owner
            };

            AdHandler handler = new AdHandler(product);

            if (handler.createAd())
            {
                Database.insertAd(product);
                MessageBox.Show("Your ad was created!");
                clearAllFields();


                this.mainForm.refreshAllAds();
                this.mainForm.getHomePage.BringToFront();
            }
            else
            {
                MessageBox.Show("Fill all the fields.");
            }
        }