private void updateSubCategoryButton_Click(object sender, EventArgs e) { string id = subCategoryGridView.CurrentRow.Cells[0].Value.ToString(); string category = cmbCategory.Text; string subcategory = txtNameSub.Text; try { if (SubCategoryManagement.UpdateSubCategoryById(id, category, subcategory)) { FrmMain.Instance.ToolStripLabel.Text = "Se modificó la subcategoría de manera correcta."; Clear(); subCategoryModels = SubCategoryManagement.SelectAllSubCategories(); WireUpSubCategoryGridView(); } else { FrmMain.Instance.ToolStripLabel.Text = "Ha ocurrido un error al modificar la subcategoría, inténtelo nuevamente."; } } catch (Exception) { throw; } }
private void UcProduct_Load(object sender, EventArgs e) { categoryModels = CategoryManagement.SelectAllCategories(); subCategoryModels = SubCategoryManagement.SelectAllSubCategories(); dgvProduct.DataSource = ProductManagement.SelectAllProducts(); cmbBrand.DataSource = BrandManagement.SelectAllBrands(); cmbBrand.DisplayMember = "Name"; WireUpCategoryComboBox(); WireUpSubCategoryComboBox(); }
private void UcCategory_Load(object sender, EventArgs e) { try { if (CategoryManagement.SelectAllCategories() != null && SubCategoryManagement.SelectAllSubCategories() != null) { categoryModels = CategoryManagement.SelectAllCategories(); FrmMain.Instance.ToolStripLabel.Text = "Los registros de la base de datos fueron cargados."; WireUpCategoryGridView(); WireUpSubCategoryGridView(); WireUpCategoryComboBox(); } } catch (Exception ex) { throw; } }
//---------CRUD---------// private void createSubCategoryButton_Click(object sender, EventArgs e) { CategoryModel categoryModel = (CategoryModel)cmbCategory.SelectedItem; string subcategory = txtNameSub.Text; try { if (SubCategoryManagement.InsertSubCategory(subcategory, categoryModel.IdCategory.ToString())) { FrmMain.Instance.ToolStripLabel.Text = "Se agregó la subcategoría de manera correcta."; Clear(); subCategoryModels = SubCategoryManagement.SelectAllSubCategories(); WireUpSubCategoryGridView(); } else { FrmMain.Instance.ToolStripLabel.Text = "Ha ocurrido un error al agregar la subcategoría, inténtelo nuevamente."; } } catch (Exception) { throw; } }