Example #1
0
        private void Button1_Click(object sender, EventArgs e)
        {
            bool result = false;

            ProductAddOrEdit.ProductID   = int.Parse(txtBookID.Text);
            ProductAddOrEdit.ProductName = txtBookTitle.Text;
            ProductAddOrEdit.UnitPrice   = float.Parse(txtBookPrice.Text);
            ProductAddOrEdit.Quantity    = int.Parse(txtBookQuantity.Text);


            if (addOrEdit)
            {
                result = productDb.AddProduct(ProductAddOrEdit);
            }
            else
            {
                result = productDb.UpdateProduct(ProductAddOrEdit);
            }

            if (result)
            {
                MessageBox.Show("Save successful");
            }
            else
            {
                MessageBox.Show("Save fail.");
            }
        }
Example #2
0
 private void BtnEdit_Click(object sender, EventArgs e)
 {
     fromTxt();
     if (validData())
     {
         bool updated = db.UpdateProduct(product);
         MessageBox.Show("Updated");
         loadList();
     }
     else
     {
         MessageBox.Show("Invalid Data Input");
     }
 }
Example #3
0
        private void BtnUpdate_Click(object sender, EventArgs e)
        {
            int     ID       = int.Parse(txtBookID.Text);
            string  Title    = txtBookTitle.Text;
            float   Price    = float.Parse(txtBookPrice.Text);
            int     Quantity = int.Parse(txtBookQuantity.Text);
            Product p        = new Product
            {
                ProductID   = ID,
                ProductName = Title,
                UnitPrice   = Price,
                Quantity    = Quantity
            };
            //goi phuong thuc cap nhat
            bool   r = productDb.UpdateProduct(p);
            string s = (r == true ? "successful" : "fail");

            MessageBox.Show("Update " + s);
            GetData();
        }