protected void cargarDatos() { try { var dt = new dtoUM { operacion = "SelectByID", activo = true, idUm = _idUM }.CRUD().dtResult; foreach (DataRow row in dt.Rows) { txtIdUM.Text = row["idUM"].ToString(); txtUM.Text = row["UM"].ToString(); txtFechaAlta.Text = row["fechaAlta"] != DBNull.Value ? ((DateTime)row["fechaAlta"]).ToString("yyy-MM-dd HH:mm") : ""; txtNombreUM.Text = row["nombre"].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 dtoUM { operacion = txtIdUM.Text != "0" ? "Update" : "Insert", idUm = int.Parse(txtIdUM.Text), um = txtUM.Text, nombre = txtNombreUM.Text, idUsuario = LoginInfo.idUsuario, activo = true }.CRUD(); if (!bool.Parse(result.hasError.ToString())) { string msn = "Registro " + (txtIdUM.Text != "0" ? "Actualizado" : "Agregado") + " Correctamenete"; MessageBox.Show(msn); var _frm = Application.OpenForms["UM"] as Catalogos.UM; if (!((_frm) != null)) { Catalogos.UM frm = new Catalogos.UM(); 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 idUM = gvData.Rows[e.RowIndex].Cells["idUM"].FormattedValue.ToString(); if (gvData.Columns[e.ColumnIndex].Name == "Delete") { if (MessageBox.Show("¿Está seguro de que desea eliminar la UM?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { var result = new dtoUM { operacion = "Delete", idUm = int.Parse(idUM), 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); } }