private void tsb_btn_eliminar_Click(object sender, EventArgs e) { if (dtg_desplegar.SelectedRows.Count == 1) { if (MessageBox.Show("¿Realmente desea eliminar la fila seleccionada?", "Confirmar eliminar", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Obj_estados_DAL = new Cls_estados_DAL(); Obj_estados_DAL.cId_Estado = Convert.ToChar(dtg_desplegar.SelectedRows[0].Cells[0].Value); Obj_estados_BLL.eliminar_estados(ref Obj_estados_DAL); if (Obj_estados_DAL.bbandera) { MessageBox.Show("Se ha eliminado correctamente", "Eliminado correcto", MessageBoxButtons.OK, MessageBoxIcon.Information); listar(); } else { MessageBox.Show("Ha un ocurrido un error.\n\nDetalle: " + Obj_estados_DAL.smsjError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("No se ha eliminado ningún dato", "Eliminar cancelado", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Por favor selecciones una fila.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void tsb_btn_modificar_Click(object sender, EventArgs e) { if (dtg_desplegar.SelectedRows.Count == 1) { Obj_estados_DAL = new Cls_estados_DAL(); // Se obtinenen los datos del DataGridView Obj_estados_DAL.cId_Estado = Convert.ToChar(dtg_desplegar.SelectedRows[0].Cells[0].Value); Obj_estados_DAL.sDesc_Estado = dtg_desplegar.SelectedRows[0].Cells[1].Value.ToString(); // Se abre la ventana de modificación frm_editar_estados_PL frm_editar_estado = new frm_editar_estados_PL(ref Obj_estados_DAL); frm_editar_estado.ShowDialog(this); // Se evalua el resultado de la operación y se muestra el mensaje de error o de operación realizada if (Obj_estados_DAL.bbandera) { MessageBox.Show("Se ha modificado correctamente", "Modificado correcto", MessageBoxButtons.OK, MessageBoxIcon.Information); listar(); } else { if (Obj_estados_DAL.smsjError != null) { MessageBox.Show("Ha un ocurrido un error.\n\nDetalle: " + Obj_estados_DAL.smsjError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MessageBox.Show("Por favor selecciones una fila.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void listar_estados(ref Cls_estados_DAL Obj_estados_DAL) { Obj_bd_DAL = new Cls_BD_DAL(); Obj_bd_DAL.snombretabla = "estados"; Obj_bd_DAL.ssentencia = "SP_LISTAR_ESTADOS"; Obj_bd_BLL.Adapt(ref Obj_bd_DAL); if (Obj_bd_DAL.smsjerror == string.Empty) { Obj_estados_DAL.smsjError = string.Empty; Obj_estados_DAL.Ds = Obj_bd_DAL.dst; } else { Obj_estados_DAL.smsjError = Obj_bd_DAL.smsjerror; Obj_bd_DAL.dst = null; } }
public frm_editar_estados_PL(ref Cls_estados_DAL Obj_estados_DAL) { InitializeComponent(); if (Obj_estados_DAL.cId_Estado == '\0') { // Insert insert = true; btnAccion.Text = "Agregar"; } else { // Update btnAccion.Text = "Modificar"; txtDescripcion.Text = Obj_estados_DAL.sDesc_Estado; } this.Obj_estados_DAL = Obj_estados_DAL; Text = btnAccion.Text + " Estado"; }
public void filtrar_estados(ref Cls_estados_DAL Obj_estados_DAL, string sfiltro) { Obj_bd_DAL = new Cls_BD_DAL(); Obj_bd_DAL.snombretabla = "estados"; Obj_bd_DAL.ssentencia = "SP_FILTRAR_ESTADOS"; Obj_bd_BLL.crear_tabla(ref Obj_bd_DAL); Obj_bd_DAL.Obj_dtparam.Rows.Add("@Desc_Estado", "1", sfiltro); Obj_bd_BLL.Adapt(ref Obj_bd_DAL); if (Obj_bd_DAL.smsjerror == string.Empty) { Obj_estados_DAL.smsjError = string.Empty; Obj_estados_DAL.Ds = Obj_bd_DAL.dst; } else { Obj_estados_DAL.smsjError = Obj_bd_DAL.smsjerror; Obj_bd_DAL.dst = null; } }
public void eliminar_estados(ref Cls_estados_DAL Obj_estados_DAL) { Obj_bd_DAL = new Cls_BD_DAL(); Obj_bd_DAL.snombretabla = "estados"; Obj_bd_DAL.ssentencia = "SP_ELIMINAR_ESTADOS"; Obj_bd_BLL.crear_tabla(ref Obj_bd_DAL); Obj_bd_DAL.Obj_dtparam.Rows.Add("@Id_Estado", "2", Obj_estados_DAL.cId_Estado); Obj_bd_BLL.Exe_NonQuery(ref Obj_bd_DAL); if (Obj_bd_DAL.smsjerror == string.Empty) { Obj_estados_DAL.bbandera = true; Obj_estados_DAL.smsjError = string.Empty; Obj_estados_DAL.Ds = Obj_bd_DAL.dst; } else { Obj_estados_DAL.bbandera = false; Obj_estados_DAL.smsjError = Obj_bd_DAL.smsjerror; Obj_estados_DAL.Ds = null; } }
private void tsb_btn_agregar_Click(object sender, EventArgs e) { Obj_estados_DAL = new Cls_estados_DAL(); frm_editar_estados_PL frm_agregar_estado = new frm_editar_estados_PL(ref Obj_estados_DAL); frm_agregar_estado.ShowDialog(this); if (Obj_estados_DAL.bbandera) { MessageBox.Show("Se ha agregado correctamente", "Agregado correcto", MessageBoxButtons.OK, MessageBoxIcon.Information); listar(); } else { if (Obj_estados_DAL.smsjError != null) { MessageBox.Show("Ha un ocurrido un error.\n\nDetalle: " + Obj_estados_DAL.smsjError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public void insertar_estados(ref Cls_estados_DAL Obj_estados_DAL) { Obj_bd_DAL = new Cls_BD_DAL(); Obj_bd_DAL.snombretabla = "estados"; Obj_bd_DAL.ssentencia = "SP_INSERTAR_ESTADOS"; Obj_bd_BLL.crear_tabla(ref Obj_bd_DAL); Obj_bd_DAL.Obj_dtparam.Rows.Add("@Desc_Estado", 1, Obj_estados_DAL.sDesc_Estado); Obj_bd_BLL.Exe_NonQuery(ref Obj_bd_DAL); if (Obj_bd_DAL.smsjerror == string.Empty) { Obj_estados_DAL.bbandera = true; Obj_estados_DAL.smsjError = string.Empty; Obj_estados_DAL.Ds = Obj_bd_DAL.dst; Obj_estados_DAL.cAxn = 'U'; } else { Obj_estados_DAL.bbandera = false; Obj_estados_DAL.smsjError = Obj_bd_DAL.smsjerror; Obj_estados_DAL.Ds = null; Obj_estados_DAL.cAxn = 'I'; } }