void checkOut_Button_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            productDbUtils = new ProductDbUtils();
            transaction    = new Transaction();
            if (quantity_Textbox.Text == "" || firstname_TextBox.Text == "" ||
                lastname_TextBox.Text == "" || contact_Textbox.Text == "" || address_Textbox.Text == "")
            {
                MessageBox.Show("Dont leave blank!");
            }
            else
            {
                try {
                    product = new Product();

                    product = productDbUtils.getProduct(productcode_Textbox.Text);
                    if (product.getProductQuantity() < Int32.Parse(quantity_Textbox.Text))
                    {
                        MessageBox.Show("There is no enough stock!");
                    }
                    else
                    {
                        transaction.setQuantityToOut(Int32.Parse(quantity_Textbox.Text));
                        transaction.setProductPrice(product.getProductPrice());

                        total_Reciept.Text    = "P " + transaction.getTotal().ToString();
                        quantity_Reciept.Text = quantity_Textbox.Text;
                    }
                } catch (Exception) {
                    MessageBox.Show("Digits only in Quantity!");
                }
            }
        }
        void buy_Button_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            productDbUtils = new ProductDbUtils();
            product        = new Product();

            var product2        = new Product();
            var productDbUtils2 = new ProductDbUtils();

            if (name_Reciept.Text == "" || contact_Reciept.Text == "" ||
                name_Reciept.Text == "" || brand_Reciept.Text == "" ||
                description_Reciept.Text == "" || type_Reciept.Text == "" ||
                price_Reciept.Text == "" || quantity_Reciept.Text == "" || total_Reciept.Text == "")
            {
                MessageBox.Show("Verify first before buying!");
            }
            else
            {
                try {
                    product = productDbUtils.getProduct(productcode_Textbox.Text);

                    transaction.setProductQuantityInDb(product.getProductQuantity());
                    transaction.setQuantityToOut(Int32.Parse(quantity_Textbox.Text));

                    product2.setProductCode(productcode_Textbox.Text);
                    product2.setProductQuantity(transaction.getCurrentQuantity());
                    productDbUtils2.updateCurrentQuantity(product2);
                    Hide();
                } catch (Exception) {
                    MessageBox.Show("Digits only Quantity!");
                }
            }
        }
        void search_Button_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            var productDbUtils1        = new ProductDbUtils();
            var productDbUtils2        = new ProductDbUtils();
            var productCategoryDbUtils = new ProductCategoryDbUtils();

            if (productcode_Textbox.Text == "")
            {
                MessageBox.Show("Dont leave empty!");
            }
            else
            {
                if (productDbUtils1.getProductByCode(productcode_Textbox.Text) == true)
                {
                    product         = new Product();
                    productCategory = new ProductCategory();
                    product         = productDbUtils2.getProduct(productcode_Textbox.Text);
                    productCategory = productCategoryDbUtils.getProductCategory(product.getProductCategoryCode());

                    costumer_Reciept.Text    = firstname_TextBox.Text + " " + lastname_TextBox.Text;
                    contact_Reciept.Text     = contact_Textbox.Text;
                    name_Reciept.Text        = product.getProductName();
                    brand_Reciept.Text       = product.getProductBrand();
                    description_Reciept.Text = productCategory.getCategoryDescription();
                    type_Reciept.Text        = productCategory.getCategoryType();
                    price_Reciept.Text       = product.getProductPrice().ToString();
                }
                else
                {
                    MessageBox.Show("No Product found!");
                }
            }
        }
Ejemplo n.º 4
0
        public OperationWindow(String productCode)
        {
            product        = new Product();
            productDbUtils = new ProductDbUtils();

            InitializeComponent();
            this.productCode  = productCode;
            code_Textbox.Text = this.productCode;

            product = productDbUtils.getProduct(this.productCode);

            name_Textbox.Text       = product.getProductName();
            brand_Textbox.Text      = product.getProductBrand();
            quantity_Textbox.Text   = product.getProductQuantity().ToString();
            price_Textbox.Text      = product.getProductPrice().ToString();
            categoryid_Textbox.Text = product.getProductCategoryCode();
        }