//--------METODOS DE RECARGA DE DATOS DE LOS ATRIBUTOS---------------- private void ReloadBrandsDataGridView() { brandModels = BrandManagement.SelectAllBrands(); BrandDataGridView.MultiSelect = false; BrandDataGridView.DataSource = brandModels; BrandDataGridView.Columns["Id_Brand"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; BrandDataGridView.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; BrandDataGridView.Columns["Id_Brand"].HeaderText = "Id"; BrandDataGridView.Columns["Name"].HeaderText = "Nombre"; BrandDataGridView.Columns["Id_Brand"].Visible = false; }
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(); }
//Carga datos de inicio private void UcProduct_Load(object sender, EventArgs e) { ReloadProduct(); brandModels = BrandManagement.SelectAllBrands(); BrandComboBox.DataSource = brandModels; BrandComboBox.DisplayMember = "Name"; categoryModels = CategoryManagement.SelectAllCategories(); CategoryComboBox.DataSource = categoryModels; CategoryComboBox.DisplayMember = "Name"; gravadoRadioButton.Checked = true; }
private void FrmBrand_Load(object sender, EventArgs e) { try { if (BrandManagement.SelectAllBrands() != null) { brandModels = BrandManagement.SelectAllBrands(); WireUpBrandsGridView(); toolStripStatusLabel1.Text = "Los registros de la base de datos fueron cargados."; } else { toolStripStatusLabel1.Text = "No se encontraron registros en la base de datos."; } } catch (Exception ex) { throw; } }
private void deleteButton_Click(object sender, EventArgs e) { string id = idBrandTextBox.Text; try { if (BrandManagement.DeleteBrandById(id)) { Clear(); brandModels = BrandManagement.SelectAllBrands(); WireUpBrandsGridView(); toolStripStatusLabel1.Text = "Se eliminó la marca de manera correcta"; } else { toolStripStatusLabel1.Text = "Ha ocurrido un error al eliminar la marca, inténtelo nuevamente."; } } catch (Exception ex) { throw; } }
private void updateButton_Click(object sender, EventArgs e) { string id = idBrandTextBox.Text; //dgvBrand.CurrentRow.Cells[0].Value.ToString(); string brand = brandNameTextBox.Text; try { if (BrandManagement.UpdateBrandById(id, brand)) { Clear(); brandModels = BrandManagement.SelectAllBrands(); WireUpBrandsGridView(); toolStripStatusLabel1.Text = "Se modificó la marca de manera correcta."; } else { toolStripStatusLabel1.Text = "Ha ocurrido un error al modificar la marca, inténtelo nuevamente."; } } catch (Exception ex) { throw; } }
//---------CRUD---------// private void createButton_Click(object sender, EventArgs e) { string id = idBrandTextBox.Text; string brand = brandNameTextBox.Text; try { if (BrandManagement.InsertBrand(brand)) { toolStripStatusLabel1.Text = "Se agregó la marca de manera correcta."; Clear(); brandModels = BrandManagement.SelectAllBrands(); WireUpBrandsGridView(); } else { toolStripStatusLabel1.Text = "Ha ocurrido un error al agregar la marca, inténtelo nuevamente."; } } catch (Exception ex) { throw; } }