public static frmIngresarCategoria GetInstancia() { if (Instancia == null) { Instancia = new frmIngresarCategoria(); } return(Instancia); }
private void btnAgregarCategoria_Click(object sender, EventArgs e) { //btnAgregarCategoria.Enabled = false; frmIngresarCategoria formIngresarCategoria = new frmIngresarCategoria(); //CAPTURADOR DE EVENTO FORMULARIO INGRESAR CATEGORIA CERRADO formIngresarCategoria.FormClosed += new FormClosedEventHandler(formIngresarCategoria_FormClosed); formIngresarCategoria.ShowDialog(); }
/*METODO GUARDAR - NO SE UTILIZA YA QUE SE GUARDA AL HACER CLICK EN EL BOTON GUARDAR DEL FORMULARIO * frmIngresarCategoria * * public void Insertar() * { * frmIngresarCategoria formIngresarCategoria = new frmIngresarCategoria(); * string agregarActualizar = ""; * agregarActualizar = NegocioCategoria.Insertar( * formIngresarCategoria.nombre, * formIngresarCategoria.descripcion); * formIngresarCategoria.MensajeOk("Categoría guardada exitosamente"); * formIngresarCategoria.Limpiar(); * dgvListado.DataSource = NegocioCategoria.Mostrar(); * Mostrar(); * } */ //BOTON INGRESAR private void btnIngresar_Click(object sender, EventArgs e) { frmIngresarCategoria formIngresarCategoria = new frmIngresarCategoria(); formIngresarCategoria.ctrlSeleccionado = 0; //CAPTURADOR DE EVENTO FORM CLOSED formIngresarCategoria.FormClosed += new FormClosedEventHandler(formIngresarCategoria_FormClosed); //CAPTURADOR DE EVENTO CLICK EN BOTON INSERTAR formIngresarCategoria.btnInsertar.Click += new EventHandler(formIngresarCategoria_btnInsertarClick); btnIngresar.Enabled = false; formIngresarCategoria.ShowDialog(); }
private void VerDetalles() { frmIngresarCategoria formIngresarCategoria = new frmIngresarCategoria(); formIngresarCategoria.ctrlSeleccionado = 2; formIngresarCategoria.IdCategoria = Convert.ToString(dgvListado.CurrentRow.Cells["IdCategoria"].Value).Trim().ToUpper(); formIngresarCategoria.Categoria = Convert.ToString(dgvListado.CurrentRow.Cells["Categoria"].Value).Trim().ToUpper(); formIngresarCategoria.Descripcion = Convert.ToString(dgvListado.CurrentRow.Cells["Descripcion"].Value).Trim(); formIngresarCategoria.FormClosed += new FormClosedEventHandler(formIngresarCategoria_FormClosed); formIngresarCategoria.btnInsertar.Click += new EventHandler(formIngresarCategoria_btnInsertarClick); btnIngresar.Enabled = false; formIngresarCategoria.ShowDialog(); }
private void frmIngresarCategoria_FormClosing(object sender, FormClosingEventArgs e) { Instancia = null; }
//BOTON ELIMINAR private void btnEliminar_Click(object sender, EventArgs e) { string idCategoria = ""; string Respuesta = ""; DialogResult Opcion; frmIngresarCategoria formIngresarCategoria = new frmIngresarCategoria(); try { //SELECCION DE VARIOS REGISTROS if (chkEliminarVarios.Checked) { Opcion = MessageBox.Show( "¿Realmente desea eliminar los registros seleccionados?", "Eliminando registro", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (Opcion == DialogResult.Yes) { foreach (DataGridViewRow row in dgvListado.Rows) { if (Convert.ToBoolean(row.Cells[0].Value)) { idCategoria = Convert.ToString(row.Cells["IdCategoria"].Value); Respuesta = NegocioCategoria.Eliminar(Convert.ToInt32(idCategoria)); } } if (Respuesta.Equals("OK")) { formIngresarCategoria.NotificacionOk("Los registros se eliminaron correctamente.", "Eliminando"); } else { formIngresarCategoria.NotificacionError("Los registros no se eliminaron.", "Error"); } Mostrar(); } } else { //SELECCION DE UN REGISTRO Opcion = MessageBox.Show( "¿Realmente desea eliminar el registro seleccionado?", "Eliminando registro", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (Opcion == DialogResult.Yes) { idCategoria = Convert.ToString(dgvListado.CurrentRow.Cells["IdCategoria"].Value); Respuesta = NegocioCategoria.Eliminar(Convert.ToInt32(idCategoria)); if (Respuesta.Equals("OK")) { formIngresarCategoria.NotificacionOk("El registro se eliminó correctamente", "Eliminando"); } else { formIngresarCategoria.NotificacionError("El registro no se eliminó", "Error"); } } } chkEliminarVarios.Checked = false; Mostrar(); } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }