private void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(txtCategoryName.Text)) { return; } if (lblCategoryId.Text == "XX") { Category addCategory = new Category { Description = txtCategoryName.Text.Trim().ToUpper() }; var result = _categoryLogic.Add(addCategory); if (result) { MessageBox.Show("Categoria Agregada..."); } else { MessageBox.Show("Error Al Agregar La Categoria..."); } } else { int categoryId = int.Parse(lblCategoryId.Text); var editCategory = _categoryLogic.GetById(categoryId); editCategory.Description = txtCategoryName.Text.Trim(); editCategory.Disabled = !chkEnabled.Checked; var result = _categoryLogic.Edit(editCategory); if (result) { MessageBox.Show("Categoria Actualizada..."); } else { MessageBox.Show("Error Al Actualizar La Categoria..."); } } if (this.Owner != null && this.Owner.Name == "frmProducts") { Close(); } Clear(); FillDatagrid(); }