private void UpdateBrandButton_Click(object sender, EventArgs e) { try { if (BrandDataGridView.Rows.Count != 0) { if (!string.IsNullOrEmpty(BrandNameTextBox.Text)) { if (MetroMessageBox.Show(this, $"¿Seguro que desea modificar la marca: { BrandDataGridView.CurrentRow.Cells[1].Value.ToString() }?", "Modificar Marca", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { if (BrandManagement.UpdateBrandById(int.Parse(BrandDataGridView.CurrentRow.Cells[0].Value.ToString()), BrandNameTextBox.Text)) { FrmMain.Instance.ToolStripLabel.Text = "Se agrego la Marca correctamente."; BrandNameTextBox.Text = ""; ReloadBrandsDataGridView(); } else { MetroMessageBox.Show(this, $"Ha ocurrido un error al modificar la marca: { BrandNameTextBox.Text}.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MetroMessageBox.Show(this, "No puede tener en blanco o vacio el nombre de marca.", "Campo vacío", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MetroMessageBox.Show(this, "Debe seleccionar una marca para poder modificarla.", "Campo vacío", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { } }
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; } }