Esempio n. 1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            int    ID              = int.Parse(txtProductID.Text);
            string Name            = txtProductName.Text;
            double Price           = float.Parse(txtUnitPrice.Text);
            int    productQuantity = int.Parse(txtQuantity.Text);

            Products products = new Products {
                ProductID   = ID,
                ProductName = Name,
                UnitPrice   = Price,
                Quantity    = productQuantity
            };

            frmProductDetails frmProductDetails = new frmProductDetails(false, products);
            DialogResult      r = frmProductDetails.ShowDialog();

            if (r == DialogResult.OK)
            {
                DataRow row = dataTableProduct.Rows.Find(products.ProductID);
                row["ProductName"] = products.ProductName;
                row["UnitPrice"]   = products.UnitPrice;
                row["Quantity"]    = products.Quantity;
            }
        }
Esempio n. 2
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            int    ID          = 1;
            string name        = string.Empty;
            double price       = 0;
            int    proQuantity = 0;

            if (dtProduct.Rows.Count > 0)
            {
                ID = int.Parse(dtProduct.Compute("MAX(ProductID)", "").ToString()) + 1;
            }
            Product pro = new Product
            {
                productID   = ID,
                productName = Name,
                unitPrice   = price,
                quantity    = proQuantity
            };
            frmProductDetails ProductDetail = new frmProductDetails(true, pro);
            DialogResult      r             = ProductDetail.ShowDialog();

            if (r == DialogResult.OK)
            {
                pro = ProductDetail.ProductAddOrEdit;
                dtProduct.Rows.Add(pro.productID, pro.productName, pro.unitPrice, pro.quantity);
            }
        }
Esempio n. 3
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            int     ID          = int.Parse(txtID.Text);
            string  name        = txtName.Text;
            double  price       = float.Parse(txtPrice.Text);
            int     proQuantity = int.Parse(txtQuantity.Text);
            Product pro         = new Product
            {
                productID   = ID,
                productName = Name,
                unitPrice   = price,
                quantity    = proQuantity
            };
            frmProductDetails ProductDetail = new frmProductDetails(false, pro);
            DialogResult      r             = ProductDetail.ShowDialog();

            if (r == DialogResult.OK)
            {
                DataRow row = dtProduct.Rows.Find(pro.productID);
                row["ProductName"] = pro.productName;
                row["UnitPrice"]   = pro.unitPrice;
                row["Quantity"]    = pro.quantity;
            }
        }
Esempio n. 4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            int ID = 1;

            if (dataTableProduct.Rows.Count > 0)
            {
                ID = int.Parse(dataTableProduct.Compute("MAX(BookID)", "").ToString()) + 1;
            }

            txtProductID.Text = ID.ToString();


            string Name            = txtProductName.Text;
            double Price           = double.Parse(txtUnitPrice.Text);
            int    productQuantity = int.Parse(txtQuantity.Text);


            Products products = new Products
            {
                ProductID   = ID,
                ProductName = Name,
                UnitPrice   = Price,
                Quantity    = productQuantity
            };

            frmProductDetails frmProductDetails = new frmProductDetails(true, products);

            DialogResult r = frmProductDetails.ShowDialog();

            if (r == DialogResult.OK)
            {
                products = frmProductDetails.ProducAddOrEdit;

                dataTableProduct.Rows.Add(products.ProductID, products.ProductName, products.UnitPrice, products.Quantity);
            }
        }