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!");
                }
            }
        }
        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!");
                }
            }
        }
Esempio n. 4
0
 void add_Button_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (supplier_Summary.Text == "" ||
         contact_Summary.Text == "" ||
         code_Summary.Text == "" ||
         name_Summary.Text == "" ||
         brand_Summary.Text == "" ||
         quantity_Summary.Text == "" ||
         price_Summary.Text == "" ||
         categoryid_Summary.Text == ""
         )
     {
         MessageBox.Show("Verfify first before cheking!");
     }
     else
     {
         try {
             var productDbutils = new ProductDbUtils();
             var product        = new Product();
             product.setProductCode(code_Textbox.Text);
             product.setProductName(name_Textbox.Text);
             product.setProductBrand(brand_Textbox.Text);
             product.setProductPrice(Int32.Parse(price_Textbox.Text));
             product.setProductQuantity(Int32.Parse(quantity_Textbox.Text));
             product.setProductCategoryCode(categoryid_Textbox.Text);
             productDbutils.createProduct(product);
             Hide();
         } catch (Exception) {
             MessageBox.Show("Digits only in Quantity and Price");
         }
     }
 }
Esempio n. 5
0
        void update_Button_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            try {
                productCategoryDbUtils = new ProductCategoryDbUtils();
                productDbUtils         = new ProductDbUtils();
                product         = new Product();
                productCategory = new ProductCategory();


                productCategory.setCategoryCode(categoryid_Textbox.Text);

                if (productCategoryDbUtils.getCategoryByCode(productCategory) == false)
                {
                    MessageBox.Show("No Category Found! Create First.");
                    categoryid_Textbox.Text = "";
                }
                else
                {
                    product.setProductCode(code_Textbox.Text);
                    product.setProductName(name_Textbox.Text);
                    product.setProductBrand(brand_Textbox.Text);
                    product.setProductQuantity(Int32.Parse(quantity_Textbox.Text));
                    product.setProductPrice(Int32.Parse(price_Textbox.Text));
                    product.setProductCategoryCode(categoryid_Textbox.Text);
                    productDbUtils.updateProduct(product);

                    var productWindow = new ProductWindow();
                    productWindow.Show();
                    Hide();
                }
            } catch (Exception) {
                MessageBox.Show("Digits only in Quantity and Price!");
            }
        }
Esempio n. 6
0
        void delete_Button_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            productDbUtils = new ProductDbUtils();
            productDbUtils.deleteProduct(code_Textbox.Text);

            var productWindow = new ProductWindow();

            productWindow.Show();
            Hide();
        }
Esempio n. 7
0
        public DashboardControl()
        {
            InitializeComponent();
            productDbutils       = new ProductDbUtils();
            productCategoryUtils = new ProductCategoryDbUtils();
            long product  = productDbutils.productCounter();
            long category = productCategoryUtils.categoryCounter();

            productCount.Content  = product.ToString();
            categoryCount.Content = category.ToString();
        }
Esempio n. 8
0
 public void updateCounter(int connection)
 {
     if (connection == 1)
     {
         productDbutils       = new ProductDbUtils();
         productCategoryUtils = new ProductCategoryDbUtils();
         long product  = productDbutils.productCounter();
         long category = productCategoryUtils.categoryCounter();
         productCount.Content  = product.ToString();
         categoryCount.Content = category.ToString();
     }
 }
Esempio n. 9
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();
        }
Esempio n. 10
0
        void search_Button_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (productCode_Textbox.Text == "")
            {
                MessageBox.Show("Dont leave blank");
            }
            else
            {
                productDbUtils = new ProductDbUtils();

                if (productDbUtils.getProductByCode(productCode_Textbox.Text) == false)
                {
                    MessageBox.Show("Product not found!");
                }
                else
                {
                    var operationWindow = new OperationWindow(productCode_Textbox.Text);
                    Close();
                    operationWindow.Show();
                }
            }
        }
Esempio n. 11
0
 public ProductWindow()
 {
     InitializeComponent();
     productDbUtils = new ProductDbUtils();
     product_DataGrid.ItemsSource = productDbUtils.getAllProducts().DefaultView;
 }