private void InsertarActualizar(string modo) { try { if (modo == "INSERT") { Nivel nivel = new Nivel(); nivel.Nombre = TxtNombre.Text.Trim(); if (CtrlNiveles.Insertar(nivel) > 0) { XtraMessageBox.Show("Nivel insertado con exito.", Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2); } } else { Nivel nivel = new Nivel(); nivel.Id = Id; nivel.Nombre = TxtNombre.Text.Trim(); if (CtrlNiveles.Actualizar(nivel) > 0) { XtraMessageBox.Show("Nivel actualizado con exito.", Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2); } } } catch (Exception ex) { XtraMessageBox.Show(ex.Message, Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button2); } }
public void Eliminar() { if (DgvGeneral.RowCount > 0 && DgvGeneral.GetFocusedRow() != null) { int idGeneral = Convert.ToInt32(DgvGeneral.GetFocusedRowCellValue("Id")); Nivel nivel = new Nivel(); nivel.Id = idGeneral; if (XtraMessageBox.Show("¿Esta seguro que desea eliminar el nivel?", "Eliminar", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { CtrlNiveles.Eliminar(nivel); if (!BkgwBuscar.IsBusy) { PrgBuscar.Visible = true; BkgwBuscar.RunWorkerAsync(); } } } else { XtraMessageBox.Show("Debe seleccionar un registro.", Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void CargarDatos(int id) { Nivel nv = new Nivel(); nv.Id = id; DataSet ds = CtrlNiveles.GetAreaOne(nv); DataRow dr = ds.Tables[0].Rows[0]; TxtNombre.Text = dr["Nombre"].ToString(); }
public void LlenarDsConsulta() { try { DataSet ds = CtrlNiveles.GetAreaAll(); dtConsulta = ds.Tables[0].Copy(); dsConsulta.Tables.Clear(); if (dsConsulta.Tables.Count == 0) { dsConsulta.Tables.Add(dtConsulta); } } catch (Exception ex) { XtraMessageBox.Show(ex.Message); } }