private void btnEdit_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtProductId.Text)) { if (string.IsNullOrEmpty(txtProducEdit.Text)) { MessageBox.Show("Type the Product Name"); } else { Datos.Entities.PRODUCTS product = new Datos.Entities.PRODUCTS(); product.ID = int.Parse(txtProductId.Text); product.PRODUCT = txtProducEdit.Text; product.QUANTITY = (int)txtQuantityEdit.Value; string result = Datos.Controllers.CRUD.EditProduct(product, product.ID); MessageBox.Show(result); BindGrid(); txtProducEdit.Text = string.Empty; txtQuantityEdit.Value = 0; txtProductId.Text = string.Empty; } } else { MessageBox.Show("Please Select Product"); } }
private void btnAdd_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtProduct.Text)) { try { Datos.Entities.PRODUCTS product = new Datos.Entities.PRODUCTS(); product.PRODUCT = txtProduct.Text; product.QUANTITY = (int)txtQuantity.Value; product.MODIFIED_DATE = DateTime.Now.ToString("MM/dd/yyyy"); string result = Datos.Controllers.CRUD.InsertProduct(product); MessageBox.Show(result); BindGrid(); tabControl1.SelectTab(1); } catch (Exception) { throw; } } else { MessageBox.Show("Missing Product Name"); } }