Esempio n. 1
0
        private void btnSearchProduct_Click(object sender, EventArgs e)
        {
            lstProduct.Columns[0].ListView.Font = new Font(lstProduct.Columns[0].ListView.Font, FontStyle.Bold); //Bold
            lstProduct.Items.Clear();
            List <ProductClass> searchProduct = new List <ProductClass>();

            searchProduct = ProductDB_Class.SearchProduct(txtSearchProduct.Text);
            foreach (ProductClass product in searchProduct)
            {
                string[] row =
                {
                    product.nameProduct,
                    product.descriptionProduct,
                    product.createdProduct.ToString("d"),
                    product.updatedProduct.ToString("d"),
                    product.costProduct.ToString(),
                    statusName,
                    statusID.ToString(),
                    product.idProduct.ToString()
                };

                ListViewItem listProduct = new ListViewItem(row);
                listProduct.Font = new Font(lstProduct.Font, FontStyle.Regular);
                lstProduct.Items.Add(listProduct);
            }
        }
Esempio n. 2
0
 private void btnDeleteProduct_Click(object sender, EventArgs e)
 {
     if (lstProduct.SelectedItems.Count > 0)
     {
         DialogResult result1 = MessageBox.Show("Delete " + "Product" + "?",
                                                "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (result1 == DialogResult.Yes)
         {
             ListViewItem item      = lstProduct.SelectedItems[0];
             int          idProduct = Convert.ToInt32(item.SubItems[7].Text);
             bool         result    = ProductDB_Class.DeleteProduct(idProduct);
             if (result)
             {
                 FillListViewProduct();
                 MessageBox.Show("Product deleted");
             }
             else
             {
                 MessageBox.Show("Error");
             }
         }
     }
     else
     {
         MessageBox.Show("Please select a product ");
     }
 }
Esempio n. 3
0
        private void FillListViewAddedOrder()
        {
            lstAddedOrder.Items.Clear();
            List <ProductClass> products = new List <ProductClass>();

            products = ProductDB_Class.GetProducts();

            List <ProductStatusClass> statuses = new List <ProductStatusClass>();

            statuses = Product_statusDBClass.GetProduct_status();

            foreach (ProductClass product in products)
            {
                string statusName = "";
                int    statusID   = 0;
                foreach (ProductStatusClass status in statuses)
                {
                    if (product.idStatusProduct == status.id)
                    {
                        statusID   = status.id;
                        statusName = status.status;
                    }
                }
                lstAddedOrder.Columns[0].ListView.Font = new Font(lstAddedOrder.Columns[0].ListView.Font, FontStyle.Bold);
                string[] row =
                {
                    product.nameProduct,
                    product.descriptionProduct,
                    product.createdProduct.ToString("d"),
                    product.updatedProduct.ToString("d"),
                    product.costProduct.ToString(),
                    statusName,
                    statusID.ToString(),
                    product.idProduct.ToString()
                };

                ListViewItem listProduct1 = new ListViewItem(row);
                listProduct1.Font = new Font(listProduct1.Font, FontStyle.Regular);
                lstAddedOrder.Items.Add(listProduct1);
            }
        }
Esempio n. 4
0
        private void btnAddProduct_Click(object sender, EventArgs e)
        {
            ProductClass modifyProduct   = new ProductClass();
            String       x               = "AddProduct";
            AddProduct   addProductClick = new AddProduct(x, modifyProduct);
            var          result          = addProductClick.ShowDialog();

            if (result == DialogResult.OK)
            {
                ProductClass AddProducts    = addProductClick.added;
                bool         returnedResult = ProductDB_Class.AddProduct(AddProducts);
                if (returnedResult)
                {
                    FillListViewProduct();
                    MessageBox.Show("Product added");
                }
                else
                {
                    MessageBox.Show("Error");
                }
            }
        }
Esempio n. 5
0
        private void btnModifyProduct_Click(object sender, EventArgs e)
        {
            ProductClass modifyProduct = new ProductClass();

            if (lstProduct.SelectedItems.Count > 0)
            {
                ListViewItem item = lstProduct.SelectedItems[0];
                modifyProduct.nameProduct        = item.SubItems[0].Text;
                modifyProduct.descriptionProduct = item.SubItems[1].Text;
                modifyProduct.createdProduct     = Convert.ToDateTime(item.SubItems[2].Text);
                modifyProduct.updatedProduct     = Convert.ToDateTime(item.SubItems[3].Text);
                modifyProduct.costProduct        = Convert.ToDouble(item.SubItems[4].Text);
                modifyProduct.idStatusProduct    = Convert.ToInt32(item.SubItems[6].Text);
                modifyProduct.idProduct          = Convert.ToInt32(item.SubItems[7].Text);

                String     x = "ModifyProduct";
                AddProduct modifyProductClick = new AddProduct(x, modifyProduct);
                var        result             = modifyProductClick.ShowDialog();
                if (result == DialogResult.OK)
                {
                    ProductClass modifyingProduct = modifyProductClick.modifiedProduct;
                    bool         returnedResult   = ProductDB_Class.ModifyProduct(modifyingProduct);
                    if (returnedResult)
                    {
                        FillListViewProduct();
                        MessageBox.Show("Product changed");
                    }
                    else
                    {
                        MessageBox.Show("Error");
                    }
                }
            }
            else
            {
                MessageBox.Show("Please select a product ");
            }
        }