private void tsb_btn_modificar_Click(object sender, EventArgs e) { if (dtg_desplegar.SelectedRows.Count == 1) { Obj_marcaactivo_DAL = new Cls_marcaactivo_DAL(); // Se obtinenen los datos del DataGridView Obj_marcaactivo_DAL.iId_MarcaActivo = Convert.ToInt32(dtg_desplegar.SelectedRows[0].Cells[0].Value); Obj_marcaactivo_DAL.sDesc_MarcaActivo = dtg_desplegar.SelectedRows[0].Cells[1].Value.ToString(); string sEstado = dtg_desplegar.SelectedRows[0].Cells[2].Value.ToString(); // Se abre la ventana de modificación frm_editar_marcaactivo_PL frm_editar_marcaactivo = new frm_editar_marcaactivo_PL(ref Obj_marcaactivo_DAL, sEstado); frm_editar_marcaactivo.ShowDialog(this); // Se evalua el resultado de la operación y se muestra el mensaje de error o de operación realizada if (Obj_marcaactivo_DAL.bbandera) { MessageBox.Show("Se ha modificado correctamente", "Modificado correcto", MessageBoxButtons.OK, MessageBoxIcon.Information); listar(); } else { if (Obj_marcaactivo_DAL.smsjError != null) { MessageBox.Show("Ha un ocurrido un error.\n\nDetalle: " + Obj_marcaactivo_DAL.smsjError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MessageBox.Show("Por favor selecciones una fila.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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_marcaactivo_DAL = new Cls_marcaactivo_DAL(); Obj_marcaactivo_DAL.iId_MarcaActivo = Convert.ToInt32(dtg_desplegar.SelectedRows[0].Cells[0].Value); Obj_marcaactivo_BLL.eliminar_marcaactivo(ref Obj_marcaactivo_DAL); if (Obj_marcaactivo_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_marcaactivo_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); } }
public void modificar_marcaactivo(ref Cls_marcaactivo_DAL Obj_marcaactivo_DAL) { Obj_bd_DAL = new Cls_BD_DAL(); Obj_bd_DAL.snombretabla = "marcaactivo"; Obj_bd_DAL.ssentencia = "SP_MODIFICAR_MARCAACTIVO"; Obj_bd_BLL.crear_tabla(ref Obj_bd_DAL); Obj_bd_DAL.Obj_dtparam.Rows.Add("@Id_MarcaActivo", 3, Obj_marcaactivo_DAL.iId_MarcaActivo); Obj_bd_DAL.Obj_dtparam.Rows.Add("@Desc_MarcaActivo", 1, Obj_marcaactivo_DAL.sDesc_MarcaActivo); Obj_bd_DAL.Obj_dtparam.Rows.Add("@Id_Estado", 2, Obj_marcaactivo_DAL.cId_Estado); Obj_bd_BLL.Exe_NonQuery(ref Obj_bd_DAL); if (Obj_bd_DAL.smsjerror == string.Empty) { Obj_marcaactivo_DAL.bbandera = true; Obj_marcaactivo_DAL.smsjError = string.Empty; Obj_marcaactivo_DAL.Ds = Obj_bd_DAL.dst; Obj_marcaactivo_DAL.cAxn = 'U'; } else { Obj_marcaactivo_DAL.bbandera = false; Obj_marcaactivo_DAL.smsjError = Obj_bd_DAL.smsjerror; Obj_marcaactivo_DAL.Ds = null; Obj_marcaactivo_DAL.cAxn = 'I'; } }
public void listar_marcaactivo(ref Cls_marcaactivo_DAL Obj_marcaactivo_DAL) { Cls_BD_DAL Obj_bd_DAL = new Cls_BD_DAL(); Cls_BD_BLL Obj_bd_BLL = new Cls_BD_BLL(); Obj_bd_DAL.snombretabla = "marcaactivo"; Obj_bd_DAL.ssentencia = "SP_LISTAR_MARCAACTIVO"; Obj_bd_BLL.Adapt(ref Obj_bd_DAL); if (Obj_bd_DAL.smsjerror == string.Empty) { Obj_marcaactivo_DAL.smsjError = string.Empty; Obj_marcaactivo_DAL.Ds = Obj_bd_DAL.dst; } else { Obj_marcaactivo_DAL.smsjError = Obj_bd_DAL.smsjerror; Obj_bd_DAL.dst = null; } }
private void tsb_btn_agregar_Click(object sender, EventArgs e) { Obj_marcaactivo_DAL = new Cls_marcaactivo_DAL(); frm_agregar_marcaactivo = new frm_editar_marcaactivo_PL(ref Obj_marcaactivo_DAL, null); frm_agregar_marcaactivo.ShowDialog(this); if (Obj_marcaactivo_DAL.bbandera) { MessageBox.Show("Se ha agregado correctamente", "Agregado correcto", MessageBoxButtons.OK, MessageBoxIcon.Information); listar(); } else { if (Obj_marcaactivo_DAL.smsjError != null) { MessageBox.Show("Ha un ocurrido un error.\n\nDetalle: " + Obj_marcaactivo_DAL.smsjError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public void filtrar_marcaactivo(ref Cls_marcaactivo_DAL Obj_marcaactivo_DAL, string sfiltro) { Cls_BD_DAL Obj_bd_DAL = new Cls_BD_DAL(); Cls_BD_BLL Obj_bd_BLL = new Cls_BD_BLL(); Obj_bd_DAL.snombretabla = "marcaactivo"; Obj_bd_DAL.ssentencia = "SP_FILTRAR_MARCAACTIVO"; Obj_bd_BLL.crear_tabla(ref Obj_bd_DAL); Obj_bd_DAL.Obj_dtparam.Rows.Add("@Desc_MarcaActivo", "1", sfiltro); Obj_bd_BLL.Adapt(ref Obj_bd_DAL); if (Obj_bd_DAL.smsjerror == string.Empty) { Obj_marcaactivo_DAL.smsjError = string.Empty; Obj_marcaactivo_DAL.Ds = Obj_bd_DAL.dst; } else { Obj_marcaactivo_DAL.smsjError = Obj_bd_DAL.smsjerror; Obj_bd_DAL.dst = null; } }
public void eliminar_marcaactivo(ref Cls_marcaactivo_DAL Obj_marcaactivo_DAL) { Cls_BD_DAL Obj_bd_DAL = new Cls_BD_DAL(); Cls_BD_BLL Obj_bd_BLL = new Cls_BD_BLL(); Obj_bd_DAL.snombretabla = "marcaactivo"; Obj_bd_DAL.ssentencia = "SP_ELIMINAR_MARCAACTIVO"; Obj_bd_BLL.crear_tabla(ref Obj_bd_DAL); Obj_bd_DAL.Obj_dtparam.Rows.Add("@Id_MarcaActivo", "3", Obj_marcaactivo_DAL.iId_MarcaActivo); Obj_bd_BLL.Exe_NonQuery(ref Obj_bd_DAL); if (Obj_bd_DAL.smsjerror == string.Empty) { Obj_marcaactivo_DAL.bbandera = true; Obj_marcaactivo_DAL.smsjError = string.Empty; Obj_marcaactivo_DAL.Ds = Obj_bd_DAL.dst; } else { Obj_marcaactivo_DAL.bbandera = false; Obj_marcaactivo_DAL.smsjError = Obj_bd_DAL.smsjerror; Obj_marcaactivo_DAL.Ds = null; } }
public frm_editar_marcaactivo_PL(ref Cls_marcaactivo_DAL Obj_marcaactivo_DAL, string sEstado) { InitializeComponent(); #region Cargar combobox marcaactivo Obj_estados_BLL.listar_estados(ref Obj_estados_DAL); if (Obj_estados_DAL.smsjError == string.Empty) { cmbEstado.DisplayMember = "Descripción"; cmbEstado.ValueMember = "Código"; cmbEstado.DataSource = Obj_estados_DAL.Ds.Tables[0]; } else { MessageBox.Show(" Se presento el siguiente error " + Obj_estados_DAL.smsjError, "Error", MessageBoxButtons.OK); Close(); } #endregion _sEstado = sEstado; #region Valida insert o Update if (Obj_marcaactivo_DAL.iId_MarcaActivo == 0) { // Insert insert = true; btnAccion.Text = "Agregar"; } else { // Update btnAccion.Text = "Modificar"; txtDescripcion.Text = Obj_marcaactivo_DAL.sDesc_MarcaActivo; cmbEstado.SelectedValue = Obj_marcaactivo_DAL.cId_Estado; cmbEstado.Refresh(); } this.Obj_marcaactivo_DAL = Obj_marcaactivo_DAL; #endregion Text = btnAccion.Text + " Marca de Activo"; }