public static frmIngresarPromoDescuento GetInstancia() { if (Instancia == null) { Instancia = new frmIngresarPromoDescuento(); } return(Instancia); }
//BOTON INGRESAR private void btnIngresar_Click(object sender, EventArgs e) { frmIngresarPromoDescuento formIngresarPromoDescuento = frmIngresarPromoDescuento.GetInstancia(); formIngresarPromoDescuento.ctrlSeleccionado = 0; //CAPTURADOR DE EVENTO FORM CLOSED formIngresarPromoDescuento.FormClosed += new FormClosedEventHandler(formIngresarPromoDescuento_FormClosed); //CAPTURADOR DE EVENTO CLICK EN BOTON INSERTAR formIngresarPromoDescuento.btnInsertar.Click += new EventHandler(formIngresarPromoDescuento_btnInsertarClick); formIngresarPromoDescuento.ShowDialog(); }
//METODO DOBLE CLIC private void DgvDobleClic() { try { //frmIngresarPromoDescuento formIngresarPromoDescuento = frmIngresarPromoDescuento.GetInstancia(); frmIngresarPromoDescuento formIngresarPromoDescuento = new frmIngresarPromoDescuento(); formIngresarPromoDescuento.ctrlSeleccionado = 2; formIngresarPromoDescuento.txtNombreDescuento.Text = Convert.ToString(dgvListado.CurrentRow.Cells["NombreDescuento"].Value); formIngresarPromoDescuento.IdDescuento = Convert.ToInt32(dgvListado.CurrentRow.Cells["IdDescuento"].Value); //formIngresarPromoDescuento.IdArticulo = Convert.ToInt32(dgvListado.CurrentRow.Cells["idproducto"].Value); //formIngresarPromoDescuento.Articulo = Convert.ToString(dgvListado.CurrentRow.Cells["Articulo"].Value).Trim().ToUpper(); //formIngresarPromoDescuento.Cantidad = Convert.ToDecimal(dgvListado.CurrentRow.Cells["cantidad"].Value); //formIngresarPromoDescuento.Precio_Inversion = Convert.ToDecimal(dgvListado.CurrentRow.Cells["precio_inversion"].Value); //formIngresarPromoDescuento.Porcentaje_Ganancia = Convert.ToDecimal(dgvListado.CurrentRow.Cells["porcentaje_ganancia"].Value); //formIngresarPromoDescuento.Precio_Venta_Descuento = Convert.ToDecimal(dgvListado.CurrentRow.Cells["precio_venta_descuento"].Value); //formIngresarPromoDescuento.Actualizacion_Automatica = Convert.ToByte(dgvListado.CurrentRow.Cells["actualizacion_automatica"].Value); formIngresarPromoDescuento.Descripcion = Convert.ToString(dgvListado.CurrentRow.Cells["Descripcion"].Value).Trim(); formIngresarPromoDescuento.FormClosed += new FormClosedEventHandler(formIngresarPromoDescuento_FormClosed); formIngresarPromoDescuento.btnInsertar.Click += new EventHandler(formIngresarPromoDescuento_btnInsertarClick); btnIngresar.Enabled = false; formIngresarPromoDescuento.ShowDialog(); } catch { } }
//BOTON ELIMINAR private void btnEliminar_Click(object sender, EventArgs e) { int idDescuento; string respuesta = ""; DialogResult Opcion; frmIngresarPromoDescuento formIngresarPromoDescuento = frmIngresarPromoDescuento.GetInstancia(); 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)) { idDescuento = Convert.ToInt32(row.Cells[1].Value); respuesta = NegocioDescuento.Eliminar(idDescuento); } } if (respuesta.Equals("OK")) { formIngresarPromoDescuento.NotificacionOk("Los registros se eliminaron correctamente.", "Eliminando"); } else { formIngresarPromoDescuento.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) { idDescuento = Convert.ToInt32(dgvListado.CurrentRow.Cells[1].Value); respuesta = NegocioDescuento.Eliminar(idDescuento); if (respuesta.Equals("OK")) { formIngresarPromoDescuento.NotificacionOk("El registro se eliminó correctamente", "Eliminando"); } else { formIngresarPromoDescuento.NotificacionError("El registro no se eliminó", "Error"); } } } chkEliminarVarios.Checked = false; Mostrar(); } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
private void frmIngresarPromoDescuento_FormClosing(object sender, FormClosingEventArgs e) { Instancia = null; }