private void cleanForm() { txtName.Clear(); btnSaveModify.Text = "Guardar"; chbStatus.Checked = true; selectedFunction = null; errorProvider.Clear(); }
private void dgvFunctions_CellClick(object sender, DataGridViewCellEventArgs e) { try { int index = e.RowIndex; if (index >= 0) { selectedFunction = functions[index]; btnSaveModify.Text = "Modificar"; fillSelectedData(selectedFunction); } } catch (Exception ex) { FormUtils.defaultErrorMessage(ex); } }
private void updateData(Funcione currentFunction) { Operation <Funcione> operation = functionController.updateRecord(currentFunction); if (operation.State) { MessageBox.Show("Función actualizada con éxito", "OPERACIÓN EXITOSA", MessageBoxButtons.OK, MessageBoxIcon.Information); loadTable(); cleanForm(); } else { MessageBox.Show("Ocurrió un error inesperado al actualizar la función: " + operation.Error, "ERROR AL ACTUALIZAR DATOS", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void saveData() { Funcione tempFunc = new Funcione { nombre = txtName.Text, baja = chbStatus.Checked, idNivel = 0 }; Operation <Funcione> operation = functionController.addRecord(tempFunc); if (operation.State) { MessageBox.Show("Función registrada con éxito", "OPERACIÓN EXITOSA", MessageBoxButtons.OK, MessageBoxIcon.Information); loadTable(); cleanForm(); } else { MessageBox.Show("Ocurrió un error inesperado al registrar la función: " + operation.Error, "ERROR AL INGRESAR DATOS", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void fillSelectedData(Funcione currentFunction) { txtName.Text = currentFunction.nombre; chbStatus.Checked = currentFunction.baja; }