private void btnDelete_Click(object sender, EventArgs e) { DataGridViewRow row = null; if (dgvCurrenciesTypes.SelectedRows.Count == 1) { row = dgvCurrenciesTypes.SelectedRows[0]; } else if (dgvCurrenciesTypes.SelectedCells.Count == 1) { int i = dgvCurrenciesTypes.SelectedCells[0].RowIndex; row = dgvCurrenciesTypes.Rows[i]; } else { MessageBox.Show( "Debes seleccionar solo 1 tipo de moneda a eliminar", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information ); } if (row != null) { int id = Int32.Parse(row.Cells[0].Value.ToString()); currencies_types currencyType = (from em in entities.currencies_types where em.id == id select em).First(); if (currencyType == null) { MessageBox.Show( "El Tipo de Moneda seleccionado no existe", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error ); loadCurrenciesTypes(""); } else { DialogResult deleteIt = MessageBox.Show( "¿Estás seguro que quieres eliminar este tipo de moneda?", "Confirmar", MessageBoxButtons.YesNo, MessageBoxIcon.Question ); if (deleteIt == DialogResult.Yes) { entities.currencies_types.Remove(currencyType); try { entities.SaveChanges(); MessageBox.Show( "¡Tipo de Moneda eliminada con éxito!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information ); } catch (Exception ex) { MessageBox.Show( "¡Este tipo de moneda se encuentra en uso!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error ); ConnectionDB.getInstance().resetConnection(); } } loadCurrenciesTypes(""); } } }
private void btnDelete_Click(object sender, EventArgs e) { DataGridViewRow row = null; if (dgvCountablesAccounts.SelectedRows.Count == 1) { row = dgvCountablesAccounts.SelectedRows[0]; } else if (dgvCountablesAccounts.SelectedCells.Count == 1) { int i = dgvCountablesAccounts.SelectedCells[0].RowIndex; row = dgvCountablesAccounts.Rows[i]; } else { MessageBox.Show( "Debe seleccionar solo 1 tipo de cuenta a modificar", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information ); } if (row != null) { DialogResult deleteIt = MessageBox.Show( "¿Estás seguro de eliminar esta cuenta?", "Confirmar", MessageBoxButtons.YesNo, MessageBoxIcon.Question ); if (deleteIt == DialogResult.Yes) { int id = Int32.Parse(row.Cells[0].Value.ToString()); countables_accounts countableAccount = (from em in entities.countables_accounts where em.id == id select em).First(); if (countableAccount == null) { MessageBox.Show( "¡Cuenta no encontrada!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information ); } else { try { entities.countables_accounts.Remove(countableAccount); entities.SaveChanges(); MessageBox.Show( "¡Cuenta Eliminada con éxito!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information ); loadCountablesAccounts(""); } catch (Exception ex) { MessageBox.Show( "La cuenta no pudo ser eliminada porque se encuentra en uso", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error ); ConnectionDB.getInstance().resetConnection(); } } } } }
private Contabilidad() { InitializeComponent(); entities = ConnectionDB.getInstance().getEntities(); }
private CuentaContable() { InitializeComponent(); entities = ConnectionDB.getInstance().getEntities(); initialize(); }
private MnjUsers() { InitializeComponent(); entities = ConnectionDB.getInstance().getEntities(); loadUsers(""); }