protected void cargarDatos() { try { var dt = new dtoGrupo { operacion = "SelectByID", activo = true, idGrupo = _idGrupo }.CRUD().dtResult; foreach (DataRow row in dt.Rows) { txtIdGrupo.Text = row["idGrupo"].ToString(); txtGrupo.Text = row["grupo"].ToString(); txtFechaAlta.Text = row["fechaAlta"].ToString(); btnGuardar.Text = "Actualizar"; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnGuardar_Click(object sender, EventArgs e) { try { if (!validaCampos()) { return; } var result = new dtoGrupo { operacion = txtIdGrupo.Text != "0" ? "Update" : "Insert", idGrupo = int.Parse(txtIdGrupo.Text), grupo = txtGrupo.Text, idUsuario = LoginInfo.idUsuario, activo = true }.CRUD(); if (!bool.Parse(result.hasError.ToString())) { string msn = "Registro " + (txtIdGrupo.Text != "0" ? "Actualizado" : "Agregado") + " Correctamenete"; MessageBox.Show(msn); var _frm = Application.OpenForms["Grupos"] as Catalogos.Grupos; if (!((_frm) != null)) { Catalogos.Grupos frm = new Catalogos.Grupos(); inicializaForm(frm); } else { _frm.Show(); _frm.btnActualizar_Click(null, null); } this.Hide(); } else { MessageBox.Show(result.messageError); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void gvData_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex == -1 || e.ColumnIndex == -1) { return; } string idGrupo = gvData.Rows[e.RowIndex].Cells["idGrupo"].FormattedValue.ToString(); if (gvData.Columns[e.ColumnIndex].Name == "Delete") { if (MessageBox.Show("¿Está seguro de que desea eliminar el grupo?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { var result = new dtoGrupo { operacion = "Delete", idGrupo = int.Parse(idGrupo), activo = false, idUsuario = LoginInfo.idUsuario }.CRUD(); if (!bool.Parse(result.hasError.ToString())) { string msn = "Registro Eliminado Correctamenete"; MessageBox.Show(msn); OnLoad(); } else { MessageBox.Show(result.messageError); } } } else { } } catch (Exception ex) { MessageBox.Show(ex.Message); } }