Beispiel #1
0
        //FUNCION PARA INSERTAR UN REGISTRO
        private void insertarRegistro()
        {
            try
            {
                iCuenta = contarRegistros();

                if (iCuenta == -1)
                {
                    goto fin;
                }

                else if (iCuenta > 0)
                {
                    ok.LblMensaje.Text = "El código ingresado ya se encuentra registrado en el sistema.";
                    ok.ShowDialog();
                    goto fin;
                }

                //AQUI INICIA PROCESO DE ELIMINAR
                if (!conexion.GFun_Lo_Maneja_Transaccion(Program.G_INICIA_TRANSACCION))
                {
                    ok.LblMensaje.Text = "Error al abrir transacción.";
                    ok.ShowDialog();
                    goto fin;
                }

                sSql  = "";
                sSql += "insert into pos_jornada (" + Environment.NewLine;
                sSql += "codigo, descripcion, estado, fecha_ingreso, usuario_ingreso, terminal_ingreso)" + Environment.NewLine;
                sSql += "values (" + Environment.NewLine;
                sSql += "'" + txtCodigo.Text.ToString().Trim() + "', '" + txtDescripcion.Text.ToString().Trim() + "', 'A'," + Environment.NewLine;
                sSql += "GETDATE(), '" + Program.sDatosMaximo[0] + "', '" + Program.sDatosMaximo[1] + "')";

                if (!conexion.GFun_Lo_Ejecuta_SQL(sSql))
                {
                    catchMensaje.LblMensaje.Text = sSql;
                    catchMensaje.ShowDialog();
                    goto reversa;
                }

                conexion.GFun_Lo_Maneja_Transaccion(Program.G_TERMINA_TRANSACCION);
                ok.LblMensaje.Text = "Registro agregado éxitosamente.";
                ok.ShowDialog();
                limpiar();
                goto fin;
            }

            catch (Exception ex)
            {
                catchMensaje.LblMensaje.Text = ex.Message;
                catchMensaje.ShowDialog();
                goto reversa;
            }

            reversa : { conexion.GFun_Lo_Maneja_Transaccion(Program.G_REVERSA_TRANSACCION); }

            fin : { }
        }
        //FUNCION PARA INSERTAR UN  REGISTRO
        private void insertarRegistro()
        {
            try
            {
                //AQUI INICIA PROCESO DE ACTUALIZACION
                if (!conexion.GFun_Lo_Maneja_Transaccion(Program.G_INICIA_TRANSACCION))
                {
                    ok.lblMensaje.Text = "Error al abrir transacción para guardar el registro.";
                    ok.ShowDialog();
                    limpiarTodo();
                    return;
                }

                //INSTRUCCION SQL PARA INSERTAR
                sSql  = "";
                sSql += "insert into tp_localidades (" + Environment.NewLine;
                sSql += "idempresa, cg_empresa, cg_localidad, id_responsable, id_bodega," + Environment.NewLine;
                sSql += "id_lista_defecto, id_servidor, establecimiento, punto_emision," + Environment.NewLine;
                sSql += "emite_comprobante_electronico, direccion, telefono1, telefono2," + Environment.NewLine;
                sSql += "estado, fecha_ingreso, usuario_ingreso, terminal_ingreso," + Environment.NewLine;
                sSql += "id_localidad_insumo, id_auxiliar, cg_motivo_movimiento_bodega)" + Environment.NewLine;
                sSql += "values(" + Environment.NewLine;
                sSql += Convert.ToInt32(cmbEmpresa.SelectedValue) + ", " + Program.iCgEmpresa + ", ";
                sSql += Convert.ToInt32(cmbLocalidad.SelectedValue) + ", " + idResponsab + "," + Environment.NewLine;
                sSql += Convert.ToInt32(cmbBodega.SelectedValue) + ", " + Convert.ToInt32(cmbListaPrecio.SelectedValue) + "," + Environment.NewLine;
                sSql += Convert.ToInt32(cmbServidor.SelectedValue) + ", '" + txtEstablecimiento.Text.Trim() + "'," + Environment.NewLine;
                sSql += "'" + txtPuntoEmision.Text.Trim() + "', '" + comproelectro + "', '" + txtDireccion.Text.Trim() + "'," + Environment.NewLine;
                sSql += "'" + txtTelefono1.Text.Trim() + "', '" + txtTelefono2.Text.Trim() + "', 'A'," + Environment.NewLine;
                sSql += "GETDATE(), '" + Program.sDatosMaximo[0] + "', '" + Program.sDatosMaximo[1] + "'," + Environment.NewLine;
                sSql += Convert.ToInt32(cmbInsumos.SelectedValue) + ", " + sCorrelativoProveedor + "," + Environment.NewLine;
                sSql += Convert.ToInt32(cmbMotivos.SelectedValue) + " )";

                if (!conexion.GFun_Lo_Ejecuta_SQL(sSql))
                {
                    catchMensaje.lblMensaje.Text = "ERROR EN  LA INSTRUCCIÓN:" + Environment.NewLine + sSql;
                    catchMensaje.ShowDialog();
                    goto reversa;
                }

                conexion.GFun_Lo_Maneja_Transaccion(Program.G_TERMINA_TRANSACCION);
                ok.lblMensaje.Text = "Registro insertado correctamente.";
                ok.ShowDialog();

                Grb_DatoLocalidades.Enabled = false;
                btnNuevo.Text = "Nuevo";
                limpiarTodo();
                return;
            }

            catch (Exception ex)
            {
                catchMensaje.lblMensaje.Text = ex.ToString();
                catchMensaje.ShowDialog();
                goto reversa;
            }

            reversa : { conexion.GFun_Lo_Maneja_Transaccion(Program.G_REVERSA_TRANSACCION); return; }
        }
        //FUNCION PARA INSERTAR REGISTROS EN LA BASE DE DATOS
        private void insertarRegistro()
        {
            try
            {
                //AQUI INICIA TRANSACCION
                if (!conexion.GFun_Lo_Maneja_Transaccion(Program.G_INICIA_TRANSACCION))
                {
                    ok.LblMensaje.Text = "Error al abrir transacción.";
                    ok.ShowDialog();
                    limpiarTodo();
                    return;
                }

                //insert into pos_tipo_forma_cobro (codigo,descripcion,lee_propina,estado,fecha_ingreso,usuario_ingreso,terminal_ingreso)"

                sSql  = "";
                sSql += "insert into pos_tipo_forma_cobro (codigo, descripcion," + Environment.NewLine;
                sSql += "lee_propina, id_pos_metodo_pago, cg_tipo_documento, imagen, id_pos_tipo_venta," + Environment.NewLine;
                sSql += "estado, fecha_ingreso, usuario_ingreso, terminal_ingreso)" + Environment.NewLine;
                sSql += "values(" + Environment.NewLine;
                sSql += "'" + txtCodigo.Text.Trim() + "', '" + txtDescripcion.Text.Trim() + "', " + Environment.NewLine;
                sSql += iLeePropina + ", " + Convert.ToInt32(cmbMetodoPago.SelectedValue) + "," + Environment.NewLine;
                sSql += Convert.ToInt32(cmbTipoDocumento.SelectedValue) + ", '" + txtRuta.Text.Trim() + "'," + Environment.NewLine;
                sSql += Convert.ToInt32(cmbTipoVenta.SelectedValue) + ", 'A', GETDATE(), '" + Program.sDatosMaximo[0] + "', '" + Program.sDatosMaximo[1] + "')";

                if (!conexion.GFun_Lo_Ejecuta_SQL(sSql))
                {
                    catchMensaje.LblMensaje.Text = sSql;
                    catchMensaje.ShowDialog();
                    goto reversa;
                }

                conexion.GFun_Lo_Maneja_Transaccion(Program.G_TERMINA_TRANSACCION);
                ok.LblMensaje.Text = "Registro ingresado éxitosamente.";
                ok.ShowDialog();
                limpiarTodo();
                grupoDatos.Enabled = false;
                btnNuevo.Text      = "Nuevo";
                return;
            }

            catch (Exception ex)
            {
                catchMensaje.LblMensaje.Text = ex.ToString();
                catchMensaje.ShowDialog();
                goto reversa;
            }

            reversa : { conexion.GFun_Lo_Maneja_Transaccion(Program.G_REVERSA_TRANSACCION); }
        }
Beispiel #4
0
        //FUNCION PARA INSERTAR UN REGISTRO
        private void insertarRegistro()
        {
            try
            {
                //AQUI INICIA PROCESO DE ELIMINAR
                if (!conexion.GFun_Lo_Maneja_Transaccion(Program.G_INICIA_TRANSACCION))
                {
                    ok = new VentanasMensajes.frmMensajeOK();
                    ok.LblMensaje.Text = "Error al abrir transacción.";
                    ok.ShowDialog();
                    return;
                }

                sSql  = "";
                sSql += "insert into pos_metodo_pago (" + Environment.NewLine;
                sSql += "codigo, descripcion, id_sri_forma_pago, is_active, estado," + Environment.NewLine;
                sSql += "fecha_ingreso, usuario_ingreso, terminal_ingreso)" + Environment.NewLine;
                sSql += "values (" + Environment.NewLine;
                sSql += "'" + txtCodigo.Text.ToString().Trim() + "', '" + txtDescripcion.Text.ToString().Trim() + "'," + Environment.NewLine;
                sSql += Convert.ToInt32(cmbFormasPagos.SelectedValue) + ", 1, 'A'," + Environment.NewLine;
                sSql += "GETDATE(), '" + Program.sDatosMaximo[0] + "', '" + Program.sDatosMaximo[1] + "')";

                if (!conexion.GFun_Lo_Ejecuta_SQL(sSql))
                {
                    catchMensaje = new VentanasMensajes.frmMensajeCatch();
                    catchMensaje.LblMensaje.Text = "ERROR EN LA SIGUIENTE INSTRUCCIÓN:" + Environment.NewLine + sSql;
                    catchMensaje.ShowDialog();
                    goto reversa;
                }

                conexion.GFun_Lo_Maneja_Transaccion(Program.G_TERMINA_TRANSACCION);
                ok = new VentanasMensajes.frmMensajeOK();
                ok.LblMensaje.Text = "Registro agregado éxitosamente.";
                ok.ShowDialog();
                limpiar();
                return;
            }

            catch (Exception ex)
            {
                catchMensaje = new VentanasMensajes.frmMensajeCatch();
                catchMensaje.LblMensaje.Text = ex.Message;
                catchMensaje.ShowDialog();
                goto reversa;
            }

            reversa : { conexion.GFun_Lo_Maneja_Transaccion(Program.G_REVERSA_TRANSACCION); }
        }
Beispiel #5
0
        //FUNCION PARA INSERTAR REGISTROS EN LA BASE DE DATOS
        private void insertarRegistro()
        {
            try
            {
                //VERIFICAR LA EXISTENCIA DEL CODIGO
                if (consultarCodigoMesa() > 0)
                {
                    ok.LblMensaje.Text = "Ya existe un registro con el con el código de mesa ingresado.";
                    ok.ShowDialog();
                    return;
                }

                else if (consultarCodigoMesa() == -1)
                {
                    ok.LblMensaje.Text = "Ocurrió un problema al consultar la existencia del código de mesa ingresado.";
                    ok.ShowDialog();
                    return;
                }

                //VERIFICAR LA EXISTENCIA DE LA MESA
                if (consultarMesa() > 0)
                {
                    ok.LblMensaje.Text = "Ya existe un registro con el número de mesa ingresado.";
                    ok.ShowDialog();
                    return;
                }

                else if (consultarMesa() == -1)
                {
                    ok.LblMensaje.Text = "Ocurrió un problema al consultar la existencia del número de mesa ingresado.";
                    ok.ShowDialog();
                    return;
                }

                //AQUI INICIA LA TRANSACCION
                if (!conexion.GFun_Lo_Maneja_Transaccion(Program.G_INICIA_TRANSACCION))
                {
                    ok.LblMensaje.Text = "Error al abrir transacción.";
                    ok.ShowDialog();
                    limpiarTodo();
                    return;
                }

                sSql  = "";
                sSql += "insert into pos_mesa (" + Environment.NewLine;
                sSql += "codigo, descripcion, id_pos_seccion_mesa, capacidad, numero_mesa," + Environment.NewLine;
                sSql += "posicion_x, posicion_y, estado, fecha_ingreso," + Environment.NewLine;
                sSql += "usuario_ingreso, terminal_ingreso)" + Environment.NewLine;
                sSql += "values(" + Environment.NewLine;
                sSql += "'" + txtCodigo.Text.Trim().ToUpper() + "', '" + txtDescripcion.Text.Trim().ToUpper() + "'," + Environment.NewLine;
                sSql += Convert.ToInt32(cmbSeccionMesa.SelectedValue) + ", " + Convert.ToInt32(txtCapacidad.Text.Trim()) + "," + Environment.NewLine;
                sSql += Convert.ToInt32(txtNumeroMesa.Text) + ", " + Convert.ToInt32(txtX.Text.Trim()) + "," + Environment.NewLine;
                sSql += Convert.ToInt32(txtY.Text.Trim()) + ", 'A', GETDATE(), '" + Program.sDatosMaximo[0] + "'," + Environment.NewLine;
                sSql += "'" + Program.sDatosMaximo[1] + "')";

                //EJECUTA INSTRUCCION SQL
                if (!conexion.GFun_Lo_Ejecuta_SQL(sSql))
                {
                    catchMensaje.LblMensaje.Text = "ERROR EN LA INSTRUCCIÓN:" + Environment.NewLine + sSql;
                    catchMensaje.ShowDialog();
                    goto reversa;
                }

                conexion.GFun_Lo_Maneja_Transaccion(Program.G_TERMINA_TRANSACCION);
                ok.LblMensaje.Text = "Registro insertado éxitosamente.";
                ok.ShowDialog();
                limpiarTodo();
                return;
            }

            catch (Exception ex)
            {
                catchMensaje.LblMensaje.Text = ex.Message;
                catchMensaje.ShowDialog();
                goto reversa;
            }

reversa:
            {
                conexion.GFun_Lo_Maneja_Transaccion(Program.G_REVERSA_TRANSACCION);
            }
        }
Beispiel #6
0
        private void BtnNuevoPosCobro_Click(object sender, EventArgs e)
        {
            try
            {
                string T_st_query   = "";
                string T_st_mensaje = "";

                //SI EL BOTON ESTA EN OPCION NUEVO
                if (btnNuevoPosCobro.Text == "Nuevo")
                {
                    limpiarTodo();
                    Grb_DatoPosCobro.Enabled = true;
                    btnNuevoPosCobro.Text    = "Guardar";
                    cmbOrdCobro.Focus();
                }

                //SI EL BOTON ESTA EN OPCION GUARDAR
                else if (btnNuevoPosCobro.Text == "OK")
                {
                    dgvPosCobro.Rows.Clear();
                    btnAgregarCobro.Enabled  = true;
                    btnGuardDetaCobr.Enabled = true;
                    //dgvPosCobro.Rows.Clear();
                    if (txtFechCobro.Text == "")
                    {
                        MessageBox.Show("Favor llenar la fecha de cobro");
                        txtFechCobro.Focus();
                    }

                    else
                    {
                        string t_st_fecha = (DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + " "
                                             + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second).ToString();
                        //llamo a la funcion que iniciara un begin transAction (se graba en una tabla temporal) y Program.G_INICIA_TRANSACCION devuelve true si abrio bn la transaccion
                        if (!conexion.GFun_Lo_Maneja_Transaccion(Program.G_INICIA_TRANSACCION))
                        {
                            ok.LblMensaje.Text = "Error al abrir transacción";
                            ok.ShowInTaskbar   = false;
                            ok.ShowDialog();
                            goto fin;
                            //limpiarTodo();
                        }
                        else
                        {
                            T_st_sql = "insert into pos_cobro (id_pos_orden,fecha_cobro,estado,fecha_ingreso,usuario_ingreso," +
                                       "terminal_ingreso)values('" + cmbOrdCobro.SelectedValue.ToString() + "', '" + txtFechCobro.Text.ToString().Trim() + "', " +
                                       "'A', GETDATE(), '" + Program.sDatosMaximo[0] + "', '" + Program.sDatosMaximo[1] + "')";
                            //sisque no me ejuta el query
                            if (!conexion.GFun_Lo_Ejecuta_SQL(T_st_sql))
                            {
                                catchMensaje.LblMensaje.Text = T_st_sql;
                                catchMensaje.ShowInTaskbar   = false;
                                catchMensaje.ShowDialog();
                                goto reversa;
                            }
                            else
                            {
                                //si no se ejecuta bien hara un commit
                                conexion.GFun_Lo_Maneja_Transaccion(Program.G_TERMINA_TRANSACCION);
                                Grb_DatoPosCobro.Enabled = true;

                                //PROCEDIMINTO PARA EXTRAER EL ID DE LA TABLA POS_COBRO
                                dtConsulta = new DataTable();
                                dtConsulta.Clear();

                                sTabla = "pos_cobro";
                                sCampo = "id_pos_cobro";

                                iMaximo = conexion.GFun_Ln_Saca_Maximo_ID(sTabla, sCampo, "", Program.sDatosMaximo);

                                if (iMaximo == -1)
                                {
                                    ok.LblMensaje.Text = "No se pudo obtener el codigo de la tabla " + sTabla;
                                    ok.ShowInTaskbar   = false;
                                    ok.ShowDialog();
                                    goto reversa;
                                }

                                else
                                {
                                    iId_pos_cobro = Convert.ToInt32(iMaximo);
                                }


                                dgvPosCobro.Rows.Add(iId_pos_cobro);
                                Grb_DatoPosCobro.Enabled  = false;
                                Grb_opcioPosCobro.Enabled = false;
                            }
                        }
                    }
                }
            }

            catch (Exception ex)
            {
            }

reversa:
            {
                conexion.GFun_Lo_Maneja_Transaccion(Program.G_REVERSA_TRANSACCION);
            }

            fin : { }
        }
Beispiel #7
0
        private void BtnNuevoCajero_Click(object sender, EventArgs e)
        {
            btnAgregar.Enabled      = true;
            btnGuardDetaOrd.Enabled = true;
            string T_st_Max     = "";
            string T_st_query   = "";
            string T_st_mensaje = "";

            //SI EL BOTON ESTA EN OPCION NUEVO
            if (btnNuevoPosOrd.Text == "Nuevo")
            {
                limpiarTodo();

                btnNuevoPosOrd.Text = "Guardar";
                cmbLocaliPosOrd.Focus();
            }

            //SI EL BOTON ESTA EN OPCION GUARDAR
            else if (btnNuevoPosOrd.Text == "OK")
            {
                dgvPosOrd.Rows.Clear();
                if (txtFecha.Text == "")
                {
                    MessageBox.Show("Favor llenar la fecha de la orden");
                    txtFecha.Focus();
                }
                else
                {
                    string feha_ingreso = txtFecha.Text.ToString().Trim();
                    string t_st_fecha   = (DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + " " + DateTime.Now.Hour + ":"
                                           + DateTime.Now.Minute + ":" + DateTime.Now.Second).ToString();
                    //llamo a la funcion que iniciara un begin transAction (se graba en una tabla temporal) y Program.G_INICIA_TRANSACCION devuelve true si abrio bn la transaccion
                    if (!conexion.GFun_Lo_Maneja_Transaccion(Program.G_INICIA_TRANSACCION))
                    {
                        MessageBox.Show("Error al abrir transacción");
                        limpiarTodo();
                    }
                    else
                    {
                        T_st_sql = "insert into pos_orden (id_localidad,id_pos_jornada,id_pos_mesa,id_pos_mesero,id_pos_cajero,id_pos_origen_orden," +
                                   "id_persona,estado,fecha_ingreso,usuario_ingreso,terminal_ingreso)values('" + cmbLocaliPosOrd.SelectedValue.ToString() + "', " +
                                   "'" + cmbJornaPosOrd.SelectedValue.ToString() + "', '" + cmbMesaPosOrd.SelectedValue.ToString() + "'," +
                                   "'" + cmbMesPosOrd.SelectedValue.ToString() + "','" + cmbCajPosOrd.SelectedValue.ToString() + "'," +
                                   "'" + cmbOriOrdPosOrd.SelectedValue.ToString() + "','" + cmbClientPosOrd.SelectedValue.ToString() + "', " +
                                   "'" + estado + "', GETDATE(), '" + Program.sDatosMaximo[0] + "', '" + Program.sDatosMaximo[1] + "')";
                        //sisque no me ejuta el query
                        if (!conexion.GFun_Lo_Ejecuta_SQL(T_st_sql))
                        {
                            //hara el rolBAck
                            conexion.GFun_Lo_Maneja_Transaccion(Program.G_REVERSA_TRANSACCION);
                        }
                        else
                        {
                            //si ejecuta bien hara un commit
                            conexion.GFun_Lo_Maneja_Transaccion(Program.G_TERMINA_TRANSACCION);
                            //MessageBox.Show("Registro ingresado correctamente");
                            Grb_listRePosMesa.Enabled = true;



                            //PROCEDIMINTO PARA EXTRAER EL ID DE LA TABLA POS_ORDEN
                            dtConsulta = new DataTable();
                            dtConsulta.Clear();

                            sTabla = "cv402_cabecera_movimientos";
                            sCampo = "Id_Movimiento_Bodega";

                            iMaximo = conexion.GFun_Ln_Saca_Maximo_ID(sTabla, sCampo, "", Program.sDatosMaximo);

                            if (iMaximo == -1)
                            {
                                ok.LblMensaje.Text = "No se pudo obtener el codigo de la tabla " + sTabla;
                                ok.ShowInTaskbar   = false;
                                ok.ShowDialog();
                            }

                            else
                            {
                                resp = Convert.ToInt32(iMaximo);

                                dgvPosOrd.Rows.Add(inId_pos_orden);
                                groupB_PosOrd.Enabled   = false;
                                Grb_opcioCajero.Enabled = false;
                            }
                        }
                    }
                }
            }
        }
Beispiel #8
0
        private void btnSubAgregar_Click(object sender, EventArgs e)
        {
            if (btnSubAgregar.Text == "Nuevo")
            {
                grpDatoIngreProduc.Enabled    = true;
                Grb_DatoCategoria.Enabled     = false;
                Grb_listReProCategori.Enabled = true;
                txtCodigCategoria.Focus();
                btnSubAgregar.Text = "Agregar";
            }
            else
            {
                if (btnSubAgregar.Text == "Agregar")
                {
                    if (chkPagaIva.Checked == true)
                    {
                        iPagIva = 1;
                    }
                    else
                    {
                        iPagIva = 0;
                    }

                    if (chkPreModifProductos.Checked == true)
                    {
                        iPreModific = 1;
                    }
                    else
                    {
                        iPreModific = 0;
                    }

                    if (chkExpiraProductos.Checked == true)
                    {
                        iExpira = 1;
                    }
                    else
                    {
                        iExpira = 0;
                    }

                    dbId_Lista_Precio = 1;
                    dgvProdCategoria.Columns.Remove("columna1");

                    sValReco                   = txtCodigCategoria.Text.ToString();
                    btnSubAgregar.Text         = "Nuevo";
                    grpDatoIngreProduc.Enabled = false;


                    string t_st_fecha = (DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + " " + DateTime.Now.Hour + ":"
                                         + DateTime.Now.Minute + ":" + DateTime.Now.Second).ToString();
                    //llamo a la funcion que iniciara un begin transAction (se graba en una tabla temporal) y Program.G_INICIA_TRANSACCION
                    //devuelve true si abrio bn la transaccion
                    if (!conexion.GFun_Lo_Maneja_Transaccion(Program.G_INICIA_TRANSACCION))
                    {
                        MessageBox.Show("Error al abrir transacción");
                        Limpiar();
                        goto reversa;
                    }
                    else
                    {
                        sSql = "insert into cv401_productos (idempresa,codigo,id_Producto_padre,estado,Nivel,modificable,precio_modificable,paga_iva,secuencia," +
                               "id_color,ultimo_nivel,stock_min,stock_max,Expira,fecha_ingreso,usuario_ingreso,terminal_ingreso)values('" + iId_Empresa + "','" + sValReco + "', " +
                               "'" + iId_Padre + "','A','" + iNivel + "','" + iModiChe + "','" + iPreModific + "','" + iPagIva + "', " +
                               "'" + txtSecuencia.Text.ToString().Trim() + "','" + cmbColoSubProductos.SelectedValue.ToString() + "','" + iUltimoNivel + "','" + txtStockMin.Text.ToString().Trim() + "'," +
                               "'" + txtStockMax.Text.ToString().Trim() + "','" + iExpira + "', 'A', '" + Program.sDatosMaximo[0] + "', " +
                               " '" + Program.sDatosMaximo[1] + "')";

                        //sisque no me ejuta el query
                        if (!conexion.GFun_Lo_Ejecuta_SQL(sSql))
                        {
                            //hara el rolBAck
                            MessageBox.Show("Ha ingresado un código que ya ha sido registrado anteriormente. Por Favor introduzca uno nuevo", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            goto reversa;
                        }
                        else
                        {
                            dtConsulta = new DataTable();
                            dtConsulta.Clear();


                            //PROCEDIMINTO PARA EXTRAER EL ID DE LA TABLA CV401_PRODUCTOS
                            dtConsulta = new DataTable();
                            dtConsulta.Clear();

                            sTabla = "cv401_productos";
                            sCampo = "id_producto";

                            iMaximo = conexion.GFun_Ln_Saca_Maximo_ID(sTabla, sCampo, "", Program.sDatosMaximo);

                            if (iMaximo == -1)
                            {
                                ok.LblMensaje.Text = "No se pudo obtener el codigo de la tabla " + sTabla;
                                ok.ShowInTaskbar   = false;
                                ok.ShowDialog();
                                goto reversa;
                            }

                            else
                            {
                                iId_Producto = Convert.ToInt32(iMaximo);
                            }
                        }

                        sSql = "insert into cv401_nombre_productos (id_Producto,cg_tipo_nombre,nombre,nombre_interno,estado,numero_replica_trigger," +
                               "numero_control_replica,fecha_ingreso,usuario_ingreso,terminal_ingreso)values('" + iId_Producto + "','" + iCg_tipoNombre + "'," +
                               "'" + txtNombreCategoria.Text.ToString().Trim() + "','" + iNombInterno + "', 'A', '" + iNumRepliTrig + "','" + iNumControRepli + "', " +
                               "GETDATE(), '" + Program.sDatosMaximo[0] + "', '" + Program.sDatosMaximo[1] + "')";

                        if (!conexion.GFun_Lo_Ejecuta_SQL(sSql))
                        {
                            //hara el rolBAck
                            goto reversa;
                        }
                        else
                        {
                        }

                        int numero_replica_tri = 1, numero_control_repli = 0;
                        //1 es el dbId_Lista_Precio de la lista base
                        dbId_Lista_Precio = 1;
                        sSql = "insert into cv403_precios_productos (id_Lista_Precio,id_Producto,valor_Porcentaje,valor,fecha_inicio,fecha_final," +
                               "estado,numero_replica_trigger,numero_control_replica,fecha_ingreso,usuario_ingreso,terminal_ingreso)values('" + dbId_Lista_Precio + "'," +
                               "'" + iId_Producto + "','" + iValor_Porcentaje + "','" + txtPrecioCompra.Text.ToString().Trim() + "', GETDATE(), " +
                               "GETDATE(), 'A', '" + numero_replica_tri + "','" + numero_control_repli + "', GETDATE(), " +
                               " '" + Program.sDatosMaximo[0] + "', '" + Program.sDatosMaximo[1] + "')";

                        if (!conexion.GFun_Lo_Ejecuta_SQL(sSql))
                        {
                            //hara el rolBAck
                            //conexion.GFun_Lo_Maneja_Transaccion(Program.G_REVERSA_TRANSACCION);
                            goto reversa;
                        }
                        else
                        {
                        }
                        //4 es el dbId_Lista_Precio de la lista minorista
                        dbId_Lista_Precio = 4;
                        Double dMinorista = Convert.ToDouble(txtPrecioMinorista.Text) / (1 + Program.iva + Program.servicio);
                        sSql = "insert into cv403_precios_productos (id_Lista_Precio,id_Producto,valor_Porcentaje,valor,fecha_inicio,fecha_final,estado," +
                               "numero_replica_trigger,numero_control_replica,fecha_ingreso,usuario_ingreso,terminal_ingreso)values('" + dbId_Lista_Precio + "'," +
                               "'" + iId_Producto + "','" + iValor_Porcentaje + "','" + dMinorista + "', GETDATE()," +
                               " GETDATE(), 'A', '" + numero_replica_tri + "','" + numero_control_repli + "', GETDATE(), " +
                               " '" + Program.sDatosMaximo[0] + "', '" + Program.sDatosMaximo[1] + "')";

                        if (!conexion.GFun_Lo_Ejecuta_SQL(sSql))
                        {
                            goto reversa;
                        }
                        else
                        {
                        }

                        int cg_tipo_unidad = 6142, unidad_compra = 1, numero_replica_tri2 = 1, numero_control_repli2 = 0;
                        sSql = "insert into cv401_unidades_productos (id_Producto,cg_tipo_unidad,cg_unidad,unidad_compra,estado,usuario_creacion," +
                               "terminal_creacion,fecha_creacion,numero_replica_trigger,numero_control_replica,fecha_ingreso,usuario_ingreso," +
                               "terminal_ingreso)values('" + iId_Producto + "','" + cg_tipo_unidad + "','" + cmbCompraSubCategoria.SelectedValue.ToString() + "'," +
                               "'" + unidad_compra + "', 'A', '" + Program.sDatosMaximo[0] + "','" + Program.sDatosMaximo[1] + "', GETDATE()," +
                               "'" + numero_replica_tri2 + "','" + numero_control_repli2 + "', GETDATE(), '" + Program.sDatosMaximo[0] + "', " +
                               "'" + Program.sDatosMaximo[1] + "')";

                        if (!conexion.GFun_Lo_Ejecuta_SQL(sSql))
                        {
                            goto reversa;
                        }
                        else
                        {
                        }

                        cg_tipo_unidad++; unidad_compra--;
                        sSql = "insert into cv401_unidades_productos (id_Producto,cg_tipo_unidad,cg_unidad,unidad_compra,estado,usuario_creacion," +
                               "terminal_creacion,fecha_creacion,numero_replica_trigger,numero_control_replica,fecha_ingreso,usuario_ingreso," +
                               "terminal_ingreso)values('" + iId_Producto + "','" + cg_tipo_unidad + "','" + cmbConsumoSubCategoria.SelectedValue.ToString() + "', " +
                               "'" + unidad_compra + "', 'A', '" + Program.sDatosMaximo[0] + "','" + Program.sDatosMaximo[1] + "', GETDATE(), " +
                               "'" + numero_replica_tri2 + "','" + numero_control_repli2 + "', GETDATE(), '" + Program.sDatosMaximo[0] + "', " +
                               " '" + Program.sDatosMaximo[1] + "')";

                        if (!conexion.GFun_Lo_Ejecuta_SQL(sSql))
                        {
                            //hara el rolBAck
                            goto reversa;
                        }
                        else
                        {
                            //si se ejecuta bien hara un commit
                            conexion.GFun_Lo_Maneja_Transaccion(Program.G_TERMINA_TRANSACCION);
                            MessageBox.Show("Registro ingresado correctamente");
                            Limpiar();
                            btnOK_Click(sender, e);

                            //goto fin;
                        }
                    }
                }


                //SI EL BOTON ESTA EN OPCION ACTUALIZAR
                else if (btnSubAgregar.Text == "Actualizar")
                {
                    if (chkPagaIva.Checked == true)
                    {
                        iPagIva = 1;
                    }
                    else
                    {
                        iPagIva = 0;
                    }
                    if (chkPreModifProductos.Checked == true)
                    {
                        iPreModific = 1;
                    }
                    else
                    {
                        iPreModific = 0;
                    }

                    if (chkExpiraProductos.Checked == true)
                    {
                        iExpira = 1;
                    }
                    else
                    {
                        iExpira = 0;
                    }

                    sValReco2 = txtCodigCategoria.Text.ToString();

                    sSql = "update cv401_productos set codigo = '" + sValReco2 + "' , secuencia = '" + txtSecuencia.Text.ToString().Trim() + "' , " +
                           "paga_iva = '" + iPagIva + "', id_color = '" + cmbColoSubProductos.SelectedValue.ToString() + "', stock_min = '" + txtStockMin.Text.ToString().Trim() + "', " +
                           "stock_max = '" + txtStockMax.Text.ToString().Trim() + "', precio_modificable = '" + iPreModific + "', Expira = '" + iExpira + "' " +
                           " where id_Producto = '" + iId_Producto + "'";

                    //AQUI INICIA PROCESO DE ACTUALIZACION
                    if (!conexion.GFun_Lo_Maneja_Transaccion(Program.G_INICIA_TRANSACCION))
                    {
                        MessageBox.Show("Error al abrir transacción");
                        Limpiar();
                        goto reversa;
                    }
                    else
                    {
                        string t_st_fecha = (DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + " " + DateTime.Now.Hour + ":"
                                             + DateTime.Now.Minute + ":" + DateTime.Now.Second).ToString();
                        int numero_replica_tri = 1, numero_control_repli = 0;

                        //AQUI EMEPZAMOS A ACTUALIZAR LA TABLA cv401_productos
                        //SOLO EN ESTA TABLA SE ACTUALIZA, NO SE VUELVE A INSERTAR

                        sSql = "update cv401_productos set codigo = '" + sValReco2 + "' , secuencia = '" + txtSecuencia.Text.ToString().Trim() + "' ," +
                               " paga_iva = '" + iPagIva + "', id_color = '" + cmbColoSubProductos.SelectedValue.ToString() + "', " +
                               "stock_min = '" + txtStockMin.Text.ToString().Trim() + "', stock_max = '" + txtStockMax.Text.ToString().Trim() + "', " +
                               "precio_modificable = '" + iPreModific + "', Expira = '" + iExpira + "' where id_Producto = '" + iId_Producto + "'";

                        //SI NO SE EJECUTA LA INSTRUCCION SALTA A REVERSA
                        if (!conexion.GFun_Lo_Ejecuta_SQL(sSql))
                        {
                            //HARÁ EL ROLLBACK
                            goto reversa;
                        }

                        //AQUI ACTUALIZAMOS LA TABLA cv401_nombre_productos A sEstado ELIMINADO
                        //=================================================================================================
                        if (txtNombreCategoria.Text != sNombreCategoria)
                        {
                            //T_st_sql = "update cv401_nombre_productos set nombre = '" + txtNombreCategoria.Text.ToString().Trim() + "' where iId_Producto = '" + iId_Producto + "'";
                            sSql = "update cv401_nombre_productos set estado = 'E', fecha_anula = GETDATE(), usuario_anula = '" + Program.sDatosMaximo[0] + "'," +
                                   " terminal_anula = '" + Program.sDatosMaximo[1] + "' where id_Producto = '" + iId_Producto + "'";

                            if (!conexion.GFun_Lo_Ejecuta_SQL(sSql))
                            {
                                //HARÁ EL ROLLBACK
                                goto reversa;
                            }

                            else
                            {
                                //AQUI VAMOS A INSERTAR EL NUEVO REGISTRO
                                //=================================================================================================

                                sSql = "insert into cv401_nombre_productos (id_Producto,cg_tipo_nombre,nombre,nombre_interno,estado,numero_replica_trigger," +
                                       "numero_control_replica,fecha_ingreso,usuario_ingreso,terminal_ingreso)values('" + iId_Producto + "','" + iCg_tipoNombre + "', " +
                                       "'" + txtNombreCategoria.Text.ToString().Trim() + "','" + iNombInterno + "', 'A', '" + iNumRepliTrig + "'," +
                                       " '" + iNumControRepli + "', GETDATE(), '" + Program.sDatosMaximo[0] + "', '" + Program.sDatosMaximo[1] + "')";
                                if (!conexion.GFun_Lo_Ejecuta_SQL(sSql))
                                {
                                    //HARÁ EL ROLLBACK
                                    goto reversa;
                                }
                            }
                        }

                        //AQUI ACTUALIZAMOS LA TABLA cv403_precios_productos A sEstado ELIMINADO
                        //=================================================================================================
                        //verificamos si se modifico el precio de compra
                        if (txtPrecioCompra.Text != sPrecioCompra)
                        {
                            sSql = "update cv403_precios_productos set estado = 'E', fecha_anula = GETDATE(), usuario_anula = '" + Program.sDatosMaximo[0] + "', " +
                                   " terminal_anula = '" + Program.sDatosMaximo[1] + "' where id_Producto = '" + iId_Producto + "' and id_Lista_Precio = 1";
                            if (!conexion.GFun_Lo_Ejecuta_SQL(sSql))
                            {
                                //HARÁ EL ROLLBACK
                                goto reversa;
                            }

                            else
                            {
                                //AQUI VAMOS A INSERTAR UN NUEVO REGISTROS

                                //1 es el dbId_Lista_Precio de la lista base
                                dbId_Lista_Precio = 1;
                                sSql = "insert into cv403_precios_productos (id_Lista_Precio,id_Producto,valor_Porcentaje,valor,fecha_inicio,fecha_final, " +
                                       "estado,numero_replica_trigger,numero_control_replica,fecha_ingreso,usuario_ingreso,terminal_ingreso)values('" + dbId_Lista_Precio + "', " +
                                       "'" + iId_Producto + "','" + iValor_Porcentaje + "','" + txtPrecioMinorista.Text.ToString().Trim() + "', GETDATE(), " +
                                       "GETDATE(), 'A', '" + numero_replica_tri + "','" + numero_control_repli + "', GETDATE(), " +
                                       "'" + Program.sDatosMaximo[0] + "', '" + Program.sDatosMaximo[1] + "')";
                                if (!conexion.GFun_Lo_Ejecuta_SQL(sSql))
                                {
                                    //hara el rolBAck
                                    //conexion.GFun_Lo_Maneja_Transaccion(Program.G_REVERSA_TRANSACCION);
                                    goto reversa;
                                }
                            }
                        }

                        //AQUI ACTUALIZAMOS LA TABLA cv403_precios_productos A sEstado ELIMINADO
                        //=================================================================================================
                        //verificamos si se modifico el precio monorista
                        if (txtPrecioMinorista.Text != sPrecioMinorista)
                        {
                            //T_st_sql = "update cv403_precios_productos set valor = '" + txtPrecCosto.Text.ToString().Trim() + "' where iId_Producto = '" + iId_Producto + "' and dbId_Lista_Precio = '4'";
                            sSql = "update cv403_precios_productos set estado = 'E', fecha_anula = GETDATE(), usuario_anula = '" + Program.sDatosMaximo[0] + "'," +
                                   " terminal_anula = '" + Program.sDatosMaximo[1] + "' where id_Producto = '" + iId_Producto + "' and id_Lista_Precio = 4";
                            if (!conexion.GFun_Lo_Ejecuta_SQL(sSql))
                            {
                                //HARÁ EL ROLLBACK
                                goto reversa;
                            }

                            else
                            {
                                //AQUI INSERTAMOS EL NUEVO REGISTRO
                                //4 es el dbId_Lista_Precio de la lista minorista
                                dbId_Lista_Precio = 4;
                                Double dMinorista = Convert.ToDouble(txtPrecioMinorista.Text) / (1 + Program.iva + Program.servicio);
                                sSql = "insert into cv403_precios_productos (id_Lista_Precio,id_Producto,valor_Porcentaje,valor,fecha_inicio,fecha_final," +
                                       "estado,numero_replica_trigger,numero_control_replica,fecha_ingreso,usuario_ingreso,terminal_ingreso)values('" + dbId_Lista_Precio + "'," +
                                       "'" + iId_Producto + "','" + iValor_Porcentaje + "','" + dMinorista + "', GETDATE(), " +
                                       "GETDATE(), 'A', '" + numero_replica_tri + "','" + numero_control_repli + "', GETDATE(), " +
                                       "'" + Program.sDatosMaximo[0] + "', '" + Program.sDatosMaximo[1] + "')";
                                if (!conexion.GFun_Lo_Ejecuta_SQL(sSql))
                                {
                                    goto reversa;
                                }
                            }
                        }
                    }

                    //si se ejecuta bien hara un commit
                    conexion.GFun_Lo_Maneja_Transaccion(Program.G_TERMINA_TRANSACCION);
                    MessageBox.Show("Registro actualizado correctamente");
                    Limpiar();
                    btnOK_Click(sender, e);
                    //goto fin;
                }
            }

            goto fin;

            #region FUNCIONES ADICIONALES REVERSA Y FIN
reversa:

            try
            {
                //aqui va la instruccion para hacer el rollback
                conexion.GFun_Lo_Maneja_Transaccion(Program.G_REVERSA_TRANSACCION);
                MessageBox.Show("Ocurriò un problema en la transacciòn");
                Limpiar();
                btnOK_Click(sender, e);
            }
            catch (Exception)
            {
            }


fin:
            try
            {
            }
            catch (Exception)
            {
            }
            #endregion
        }
Beispiel #9
0
        private void btnNuevoListPrecios_Click(object sender, EventArgs e)
        {
            if (btnNuevoListPrecios.Text == "Nuevo")
            {
                btnNuevoListPrecios.Text = "Agregar";
            }
            else
            {
                if (btnNuevoListPrecios.Text == "Guardar")
                {
                    //string t_st_fecha = (DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + " " + DateTime.Now.Hour + ":"
                    //                        + DateTime.Now.Minute + ":" + DateTime.Now.Second).ToString();
                    //sFecha = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");

                    //llamo a la funcion que iniciara un begin transAction (se graba en una tabla temporal) y Program.G_INICIA_TRANSACCION
                    //devuelve true si abrio bn la transaccion
                    if (!conexion.GFun_Lo_Maneja_Transaccion(Program.G_INICIA_TRANSACCION))
                    {
                        MessageBox.Show("Error al abrir transacción");
                        limpiar();
                        goto reversa;
                    }
                    else
                    {
                        foreach (DataGridViewRow row2 in dgvListPreciosProductos.Rows)
                        {
                            bool iActivo = Convert.ToBoolean(row2.Cells[9].Value);
                            if (iActivo == true)
                            {
                                iIdPrecioProducto     = Convert.ToInt32(row2.Cells[0].Value.ToString());
                                iIdProductoActualizar = Convert.ToInt32(row2.Cells[1].Value.ToString());
                                dbValorNuevo          = Convert.ToDouble(row2.Cells[6].Value.ToString());

                                T_st_sql = "update cv403_precios_productos set estado = 'E', fecha_anula = GETDATE(), " +
                                           "usuario_anula = '" + Program.sDatosMaximo[0] + "', terminal_anula = '" + Program.sDatosMaximo[1] + "' " +
                                           "where id_precio_producto = '" + iIdPrecioProducto + "' and id_Lista_Precio = 4 and id_producto = " + iIdProductoActualizar + "";
                                if (!conexion.GFun_Lo_Ejecuta_SQL(T_st_sql))
                                {
                                    //HARÁ EL ROLLBACK
                                    goto reversa;
                                }

                                else
                                {
                                    //AQUI VAMOS A INSERTAR UN NUEVO REGISTRO

                                    //1 es el dbId_Lista_Precio de la lista base
                                    dbId_Lista_Precio = 4;
                                    T_st_sql          = "insert into cv403_precios_productos (id_Lista_Precio,id_Producto,valor_Porcentaje,valor,fecha_inicio,fecha_final, " +
                                                        "estado,numero_replica_trigger,numero_control_replica,fecha_ingreso,usuario_ingreso,terminal_ingreso)values('" + dbId_Lista_Precio + "', " +
                                                        "'" + iIdProductoActualizar + "','" + iValor_Porcentaje + "','" + dbValorNuevo + "', GETDATE(), " +
                                                        "GETDATE(), 'A', '" + numero_replica_tri + "','" + numero_control_repli + "', GETDATE(), " +
                                                        "'" + Program.sDatosMaximo[0] + "', '" + Program.sDatosMaximo[1] + "')";
                                    if (!conexion.GFun_Lo_Ejecuta_SQL(T_st_sql))
                                    {
                                        //hara el rolBAck
                                        //conexion.GFun_Lo_Maneja_Transaccion(Program.G_REVERSA_TRANSACCION);
                                        goto reversa;
                                    }
                                }
                            }
                        }
                        //si se ejecuta bien hara un commit
                        conexion.GFun_Lo_Maneja_Transaccion(Program.G_TERMINA_TRANSACCION);
                        MessageBox.Show("Registros actualizados correctamente");
                        limpiar();
                        //btnOK_Click(sender, e);
                        //goto fin;
                    }
                }
                goto fin;

                #region FUNCIONES ADICIONALES REVERSA Y FIN
reversa:
                try
                {
                    //aqui va la instruccion para hacer el rollback
                    conexion.GFun_Lo_Maneja_Transaccion(Program.G_REVERSA_TRANSACCION);
                    MessageBox.Show("Ocurriò un problema en la transacciòn");
                    //Limpiar();
                    //btnOK_Click(sender, e);
                }
                catch (Exception)
                {
                }


fin:
                try
                {
                }
                catch (Exception)
                {
                }
                #endregion
            }
        }
Beispiel #10
0
        private void BtnNuevoCanImpre_Click(object sender, EventArgs e)
        {
            if (chkAbrirCajon.Checked == true)
            {
                iAbrirCajon = 1;
            }

            else
            {
                iAbrirCajon = 0;
            }


            if (chkCortarPapel.Checked == true)
            {
                iCortarPapel = 1;
            }

            else
            {
                iCortarPapel = 0;
            }

            //SI EL BOTON ESTA EN OPCION NUEVO
            if (btnNuevoCanImpre.Text == "Nuevo")
            {
                limpiarCajasTexto();
                Grb_DatoCanImpre.Enabled = true;
                btnNuevoCanImpre.Text    = "Guardar";
                txtCodigoCanImpre.Focus();
                goto fin;
            }

            //SI EL BOTON ESTA EN OPCION GUARDAR
            else if (btnNuevoCanImpre.Text == "Guardar")
            {
                if ((txtCodigoCanImpre.Text == "") && (txtDescripCanImpre.Text == ""))
                {
                    ok.LblMensaje.Text = "Debe rellenar todos los campos obligatorios.";
                    ok.ShowDialog();
                    txtCodigoCanImpre.Focus();
                }

                else if (txtCodigoCanImpre.Text == "")
                {
                    ok.LblMensaje.Text = "Favor ingrese el código del canal de impresión.";
                    ok.ShowDialog();
                    txtCodigoCanImpre.Focus();
                }

                else if (txtDescripCanImpre.Text == "")
                {
                    ok.LblMensaje.Text = "Favor ingrese la descripción del canal de impresión.";
                    ok.ShowDialog();
                    txtDescripCanImpre.Focus();
                }

                else if (TxtCantidadImpresiones.Text == "")
                {
                    ok.LblMensaje.Text = "Favor ingrese la cantidad de impresiones que desea obtener.";
                    ok.ShowDialog();
                    txtDescripCanImpre.Focus();
                }

                else
                {
                    sFecha = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                    //llamo a la funcion que iniciara un begin transAction (se graba en una tabla temporal) y Program.G_INICIA_TRANSACCION devuelve true si abrio bn la transaccion
                    if (!conexion.GFun_Lo_Maneja_Transaccion(Program.G_INICIA_TRANSACCION))
                    {
                        ok.LblMensaje.Text = "Error al abrir transacción.";
                        ok.ShowDialog();
                        limpiarTodo();
                    }
                    else
                    {
                        //CONSULTAMOS SI EL CODIGO YA FUE INGRESADO
                        sSql       = "";
                        sSql       = sSql + "select * from pos_canal_impresion where codigo = '" + txtCodigoCanImpre.Text.Trim() + "'" + Environment.NewLine;
                        sSql       = sSql + "and id_pos_terminal = " + Convert.ToInt32(cmbTerminales.SelectedValue) + " and estado = 'A'";
                        dtConsulta = new DataTable();
                        dtConsulta.Clear();

                        bRespuesta = conexion.GFun_Lo_Busca_Registro(dtConsulta, sSql);

                        if (bRespuesta == true)
                        {
                            if (dtConsulta.Rows.Count == 0)
                            {
                                sSql = "";
                                sSql = sSql + "insert into pos_canal_impresion (" + Environment.NewLine;
                                sSql = sSql + "codigo, descripcion, numero_impresion, nombre_impresora," + Environment.NewLine;
                                sSql = sSql + "puerto_impresora, ip_impresora, id_pos_terminal," + Environment.NewLine;
                                sSql = sSql + "cortar_papel, abrir_cajon, estado, fecha_ingreso," + Environment.NewLine;
                                sSql = sSql + "usuario_ingreso, terminal_ingreso, id_localidad) " + Environment.NewLine;
                                sSql = sSql + "values(" + Environment.NewLine;
                                sSql = sSql + "'" + txtCodigoCanImpre.Text.Trim() + "', '" + txtDescripCanImpre.Text.Trim() + "'," + Environment.NewLine;
                                sSql = sSql + "'" + TxtCantidadImpresiones.Text.Trim() + "', '" + cmbImpresoras.Text.Trim() + "'," + Environment.NewLine;
                                sSql = sSql + "'" + TxtPuertoImpresora.Text.Trim() + "', '" + TxtIPAsignada.Text.Trim() + "'," + Environment.NewLine;
                                sSql = sSql + Convert.ToInt32(cmbTerminales.SelectedValue) + ", " + iCortarPapel + "," + Environment.NewLine;
                                sSql = sSql + iAbrirCajon + ", 'A', '" + sFecha + "', '" + Program.sNombreUsuario + "'," + Environment.NewLine;
                                sSql = sSql + "'" + Environment.MachineName.ToString() + "', " + cmbLocalidad.SelectedValue + ")";

                                if (!conexion.GFun_Lo_Ejecuta_SQL(sSql))
                                {
                                    catchMensaje.LblMensaje.Text = sSql;
                                    catchMensaje.ShowDialog();
                                }

                                else
                                {
                                    //si no se ejecuta bien hara un commit
                                    conexion.GFun_Lo_Maneja_Transaccion(Program.G_TERMINA_TRANSACCION);
                                    ok.LblMensaje.Text = "Registro ingresado correctamente.";
                                    ok.ShowDialog();
                                    btnNuevoCanImpre.Text    = "Nuevo";
                                    Grb_DatoCanImpre.Enabled = false;
                                    limpiarGuardar();
                                    goto fin;
                                }
                            }

                            else
                            {
                                ok.LblMensaje.Text = "Ya existe un registro con el código ingresado. Favor verifique los datos.";
                                ok.ShowDialog();
                                txtCodigoCanImpre.Clear();
                                txtCodigoCanImpre.Focus();
                            }
                        }
                    }
                }
            }

            //SI EL BOTON ESTA EN OPCION ACTUALIZAR
            else if (btnNuevoCanImpre.Text == "Actualizar")
            {
                try
                {
                    if (!conexion.GFun_Lo_Maneja_Transaccion(Program.G_INICIA_TRANSACCION))
                    {
                        ok.LblMensaje.Text = "Error al abrir transacción.";
                        ok.ShowDialog();
                        limpiarTodo();
                    }
                    else
                    {
                        sSql = "";
                        sSql = sSql + "update pos_canal_impresion set" + Environment.NewLine;
                        sSql = sSql + "codigo = '" + txtCodigoCanImpre.Text.Trim() + "'," + Environment.NewLine;
                        sSql = sSql + "descripcion = '" + txtDescripCanImpre.Text.Trim() + "'," + Environment.NewLine;
                        sSql = sSql + "numero_impresion = " + Convert.ToInt32(TxtCantidadImpresiones.Text.Trim()) + "," + Environment.NewLine;
                        sSql = sSql + "nombre_impresora = '" + cmbImpresoras.Text.Trim() + "'," + Environment.NewLine;
                        sSql = sSql + "puerto_impresora = '" + TxtPuertoImpresora.Text.Trim() + "'," + Environment.NewLine;
                        sSql = sSql + "ip_impresora = '" + TxtIPAsignada.Text.Trim() + "'," + Environment.NewLine;
                        sSql = sSql + "id_localidad = " + cmbLocalidad.SelectedValue + "," + Environment.NewLine;
                        sSql = sSql + "id_pos_terminal = " + Convert.ToInt32(cmbTerminales.SelectedValue) + "," + Environment.NewLine;
                        sSql = sSql + "cortar_papel = " + iCortarPapel + "," + Environment.NewLine;
                        sSql = sSql + "abrir_cajon = " + iAbrirCajon + Environment.NewLine;
                        sSql = sSql + "where id_pos_canal_impresion = " + Convert.ToInt32(lblId.Text.Trim());

                        if (!conexion.GFun_Lo_Ejecuta_SQL(sSql))
                        {
                            catchMensaje.LblMensaje.Text = sSql;
                            catchMensaje.ShowDialog();
                            goto reversa;
                        }
                        else
                        {
                            //si no se ejecuta bien hara un commit
                            conexion.GFun_Lo_Maneja_Transaccion(Program.G_TERMINA_TRANSACCION);
                            ok.LblMensaje.Text = "Registro actualizado éxitosamente.";
                            ok.ShowDialog();
                            btnNuevoCanImpre.Text    = "Nuevo";
                            Grb_DatoCanImpre.Enabled = false;
                            limpiarCajasTexto();
                            limpiarGuardar();
                            goto fin;
                        }
                    }
                }
                catch (Exception)
                {
                    goto reversa;
                }
            }

reversa:
            {
                conexion.GFun_Lo_Maneja_Transaccion(Program.G_REVERSA_TRANSACCION);
                Grb_DatoCanImpre.Enabled = false;
                btnNuevoCanImpre.Text    = "Nuevo";
                limpiarCajasTexto();
                limpiarTodo();
            }

            fin : { }
        }
Beispiel #11
0
        private void BtnNuevoReserva_Click(object sender, EventArgs e)
        {
            string T_st_query   = "";
            string T_st_mensaje = "";

            //SI EL BOTON ESTA EN OPCION NUEVO
            if (btnNuevoReserva.Text == "Nuevo")
            {
                limpiarTodo();
                Grb_DatoReserva.Enabled = true;
                btnNuevoReserva.Text    = "Guardar";
                cmbJornaReserva.Text    = "Seleccionar item...";
                cmbLocaliReserva.Text   = "Seleccionar item...";
            }

            //SI EL BOTON ESTA EN OPCION GUARDAR
            else if (btnNuevoReserva.Text == "Guardar")
            {
                if ((txtFechaReserva.Text == "") && (txtHoraReserva.Text == "") && (txtNumPersReserva.Text == "") && (txtDescripReserva.Text == "") && (cmbJornaReserva.Text == "Seleccionar item...") && (cmbLocaliReserva.Text == "Seleccionar item..."))
                {
                    MessageBox.Show("Debe rellenar todos los campos obligatorios.", "Aviso", MessageBoxButtons.OK);
                    txtFechaReserva.Focus();
                }

                else if (txtFechaReserva.Text == "")
                {
                    MessageBox.Show("Favor ingrese la fecha de la reserva.", "Aviso", MessageBoxButtons.OK);
                    txtFechaReserva.Focus();
                }

                else if (txtHoraReserva.Text == "")
                {
                    MessageBox.Show("Favor ingrese la hora de la reserva.", "Aviso", MessageBoxButtons.OK);
                    txtHoraReserva.Focus();
                }
                else if (txtNumPersReserva.Text == "")
                {
                    MessageBox.Show("Favor ingrese el numero de personas.", "Aviso", MessageBoxButtons.OK);
                    txtNumPersReserva.Focus();
                }
                else if (txtDescripReserva.Text == "")
                {
                    MessageBox.Show("Favor ingrese la descripción de la reserva.", "Aviso", MessageBoxButtons.OK);
                    txtDescripReserva.Focus();
                }
                else if (cmbJornaReserva.Text == "Seleccionar item...")
                {
                    MessageBox.Show("Favor selecione una opcion de la jornada.", "Aviso", MessageBoxButtons.OK);
                    cmbJornaReserva.Focus();
                }
                else if (cmbLocaliReserva.Text == "Seleccionar item...")
                {
                    MessageBox.Show("Favor selecione una opcion de la localidad.", "Aviso", MessageBoxButtons.OK);
                    cmbJornaReserva.Focus();
                }
                else
                {
                    //llamo a la funcion que iniciara un begin transAction (se graba en una tabla temporal) y Program.G_INICIA_TRANSACCION devuelve true si abrio bn la transaccion
                    if (!conexion.GFun_Lo_Maneja_Transaccion(Program.G_INICIA_TRANSACCION))
                    {
                        MessageBox.Show("Error al abrir transacción");
                        limpiarTodo();
                    }
                    else
                    {
                        T_st_sql = "insert into pos_reserva (id_persona,id_localidad,id_pos_jornada,fecha_hora,descripcion,numero_pax," +
                                   "estado,fecha_ingreso,usuario_ingreso,terminal_ingreso)values('" + iIdPersona + "'," +
                                   "'" + cmbLocaliReserva.SelectedValue.ToString() + "','" + cmbJornaReserva.SelectedValue.ToString() + "'," +
                                   "'" + txtFechaReserva.Text.ToString().Trim() + "','" + txtDescripReserva.Text.ToString().Trim() + "', " +
                                   "'" + txtNumPersReserva.Text.ToString().Trim() + "','A', GETDATE(), '" + Program.sDatosMaximo[0] + "'," +
                                   " '" + Program.sDatosMaximo[1] + "')";

                        //sisque no me ejuta el query
                        if (!conexion.GFun_Lo_Ejecuta_SQL(T_st_sql))
                        {
                            //hara el rolBAck
                            conexion.GFun_Lo_Maneja_Transaccion(Program.G_REVERSA_TRANSACCION);
                        }
                        else
                        {
                            //si no se ejecuta bien hara un commit
                            conexion.GFun_Lo_Maneja_Transaccion(Program.G_TERMINA_TRANSACCION);
                            MessageBox.Show("Registro ingresado correctamente");
                            btnNuevoReserva.Text    = "Nuevo";
                            Grb_DatoReserva.Enabled = false;
                            limpiarTodo();
                        }
                    }
                }
            }

            //SI EL BOTON ESTA EN OPCION ACTUALIZAR
            else if (btnNuevoReserva.Text == "Actualizar")
            {
                if ((txtFechaReserva.Text == "") && (txtHoraReserva.Text == "") && (txtNumPersReserva.Text == "") && (txtDescripReserva.Text == "") && (cmbJornaReserva.Text == "Seleccionar item...") && (cmbLocaliReserva.Text == "Seleccionar item..."))
                {
                    MessageBox.Show("Debe rellenar todos los campos obligatorios.", "Aviso", MessageBoxButtons.OK);
                    txtFechaReserva.Focus();
                }

                else if (txtFechaReserva.Text == "")
                {
                    MessageBox.Show("Favor ingrese la fecha de la reserva.", "Aviso", MessageBoxButtons.OK);
                    txtFechaReserva.Focus();
                }

                else if (txtHoraReserva.Text == "")
                {
                    MessageBox.Show("Favor ingrese la hora de la reserva.", "Aviso", MessageBoxButtons.OK);
                    txtHoraReserva.Focus();
                }
                else if (txtNumPersReserva.Text == "")
                {
                    MessageBox.Show("Favor ingrese el numero de personas.", "Aviso", MessageBoxButtons.OK);
                    txtNumPersReserva.Focus();
                }
                else if (txtDescripReserva.Text == "")
                {
                    MessageBox.Show("Favor ingrese la descripción de la reserva.", "Aviso", MessageBoxButtons.OK);
                    txtDescripReserva.Focus();
                }
                else if (cmbJornaReserva.Text == "Seleccionar item...")
                {
                    MessageBox.Show("Favor selecione una opcion de la jornada.", "Aviso", MessageBoxButtons.OK);
                    cmbJornaReserva.Focus();
                }
                else if (cmbLocaliReserva.Text == "Seleccionar item...")
                {
                    MessageBox.Show("Favor selecione una opcion de la localidad.", "Aviso", MessageBoxButtons.OK);
                    cmbJornaReserva.Focus();
                }
                else
                {
                    T_st_query = "update pos_reserva set id_persona = '" + iIdPersona + "', " +
                                 "id_localidad = '" + cmbLocaliReserva.SelectedValue.ToString() + "', id_pos_jornada = '" + cmbJornaReserva.SelectedValue.ToString() + "', " +
                                 "fecha_hora = '" + txtFechaReserva.Text.ToString().Trim() + "', descripcion = '" + txtDescripReserva.Text.ToString().Trim() + "', " +
                                 "numero_pax = '" + txtNumPersReserva.Text.ToString().Trim() + "' where id_pos_reserva = " + iIdPosReserva;

                    T_st_mensaje = "Registro Actualizado Ëxitosamente";
                    actualizarRegistro(T_st_query, T_st_mensaje);
                }
            }
        }
        private void btnNuevoCategori_Click(object sender, EventArgs e)
        {
            //llenarGrid();
            string T_st_query   = "";
            string T_st_query2  = "";
            string T_st_query3  = "";
            string T_st_sql3    = "";
            string T_st_sql4    = "";
            string T_st_mensaje = "";

            //SI EL BOTON ESTA EN OPCION NUEVO
            if (btnNuevoCategori.Text == "Nuevo")
            {
                //limpiarTodo();
                Grb_DatoCategori.Enabled  = true;
                txtSecuencia.Text         = "";
                chkModificable.Checked    = false;
                chkPreModificable.Checked = false;
                chkPagaIva.Checked        = false;
                btnNuevoCategori.Text     = "Guardar";
            }

            //SI EL BOTON ESTA EN OPCION GUARDAR
            else if (btnNuevoCategori.Text == "Guardar")
            {
                dtConsulta = new DataTable();
                dtConsulta.Clear();

                bool bRespuesta = false;

                T_st_sql = "select codigo from cv401_productos where id_producto = " + cmbPadre.SelectedValue;

                bRespuesta = conexion.GFun_Lo_Busca_Registro(dtConsulta, T_st_sql);

                if (bRespuesta == true)
                {
                    valor = dtConsulta.Rows[0].ItemArray[0].ToString();
                }


                valor = valor + "." + txtCodigoCatego.Text;


                if (chkModificable.Checked == true)
                {
                    modiChe = 1;
                }
                else
                {
                    modiChe = 0;
                }
                if (chkPreModificable.Checked == true)
                {
                    preModChe = 1;
                }
                else
                {
                    preModChe = 0;
                }
                if (chkPagaIva.Checked == true)
                {
                    pagIva = 1;
                }
                else
                {
                    pagIva = 0;
                }



                string t_st_fecha = (DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + " " + DateTime.Now.Hour + ":"
                                     + DateTime.Now.Minute + ":" + DateTime.Now.Second).ToString();
                //llamo a la funcion que iniciara un begin transAction (se graba en una tabla temporal) y Program.G_INICIA_TRANSACCION devuelve true si abrio bn la transaccion
                if (!conexion.GFun_Lo_Maneja_Transaccion(Program.G_INICIA_TRANSACCION))
                {
                    MessageBox.Show("Error al abrir transacción");
                    limpiarTodo();
                }
                else
                {
                    T_st_sql = "insert into cv401_productos (idempresa,codigo,id_producto_padre,estado,nivel,modificable,precio_modificable," +
                               "paga_iva,secuencia,modificador,subcategoria,ultimo_nivel,fecha_ingreso,usuario_ingreso,terminal_ingreso)" +
                               "values('" + cmbEmpresa.SelectedValue.ToString() + "','" + valor + "'," + Convert.ToInt32(cmbPadre.SelectedValue) + "," +
                               "'" + estado + "','" + nivel + "','" + modiChe + "','" + preModChe + "','" + pagIva + "'," +
                               "'" + txtSecuencia.Text.ToString().Trim() + "','" + iModificador + "','" + iSubcategoria + "','" + iUltimo + "', " +
                               "GETDATE(), '" + Program.sDatosMaximo[0] + "', '" + Program.sDatosMaximo[1] + "')";

                    //sisque no me ejuta el query
                    if (!conexion.GFun_Lo_Ejecuta_SQL(T_st_sql))
                    {
                        MessageBox.Show("Ha ingresado un código que ya ha sido registrado anteriormente. Por Favor introduzca uno nuevo", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        goto reversa;
                    }
                    else
                    {
                        //PROCEDIMINTO PARA EXTRAER EL ID DE LA TABLA CV401_PRODUCTOS
                        dtConsulta = new DataTable();
                        dtConsulta.Clear();

                        sTabla = "cv401_productos";
                        sCampo = "id_producto";

                        iMaximo = conexion.GFun_Ln_Saca_Maximo_ID(sTabla, sCampo, "", Program.sDatosMaximo);

                        if (iMaximo == -1)
                        {
                            ok.LblMensaje.Text = "No se pudo obtener el codigo de la tabla " + sTabla;
                            ok.ShowInTaskbar   = false;
                            ok.ShowDialog();
                            goto reversa;
                        }

                        else
                        {
                            resp = Convert.ToInt32(iMaximo);
                        }
                    }

                    T_st_sql2 = "insert into cv401_nombre_productos (id_producto,cg_tipo_nombre,nombre,nombre_interno,estado,numero_replica_trigger," +
                                "numero_control_replica,fecha_ingreso,usuario_ingreso,terminal_ingreso)values('" + resp + "','" + cg_tipoNombre + "'," +
                                "'" + txtDescripCateg.Text.ToString().Trim() + "','" + nombInterno + "', 'A', '" + numRepliTrig + "'," +
                                "'" + numControRepli + "', GETDATE(), '" + Program.sDatosMaximo[0] + "', '" + Program.sDatosMaximo[1] + "')";

                    if (!conexion.GFun_Lo_Ejecuta_SQL(T_st_sql2))
                    {
                        goto reversa;
                    }

                    int cg_tipo_unidad = 6142, unidad_compra = 1, numero_replica_tri = 1, numero_control_repli = 0;
                    T_st_sql3 = "insert into cv401_unidades_productos (id_producto,cg_tipo_unidad,cg_unidad,unidad_compra,estado,usuario_creacion," +
                                "terminal_creacion,fecha_creacion,numero_replica_trigger,numero_control_replica,fecha_ingreso,usuario_ingreso,terminal_ingreso)" +
                                "values('" + resp + "','" + cg_tipo_unidad + "','" + cmbCompra.SelectedValue.ToString() + "','" + unidad_compra + "', " +
                                "'A', '" + Program.sDatosMaximo[0] + "','" + Program.sDatosMaximo[1] + "', GETDATE()," +
                                "'" + numero_replica_tri + "','" + numero_control_repli + "', GETDATE(), '" + Program.sDatosMaximo[0] + "', " +
                                "'" + Program.sDatosMaximo[1] + "')";

                    if (!conexion.GFun_Lo_Ejecuta_SQL(T_st_sql3))
                    {
                        goto reversa;
                    }
                    else
                    {
                    }

                    cg_tipo_unidad++; unidad_compra--;
                    T_st_sql4 = "insert into cv401_unidades_productos (id_producto,cg_tipo_unidad,cg_unidad,unidad_compra,estado,usuario_creacion," +
                                "terminal_creacion,fecha_creacion,numero_replica_trigger,numero_control_replica,fecha_ingreso,usuario_ingreso,terminal_ingreso)" +
                                "values('" + resp + "','" + cg_tipo_unidad + "','" + cmbConsumo.SelectedValue.ToString() + "','" + unidad_compra + "', " +
                                "'A', '" + Program.sDatosMaximo[0] + "','" + Program.sDatosMaximo[1] + "', GETDATE()," +
                                "'" + numero_replica_tri + "','" + numero_control_repli + "', GETDATE()', '" + Program.sDatosMaximo[0] + "'," +
                                "'" + Program.sDatosMaximo[1] + "')";

                    if (!conexion.GFun_Lo_Ejecuta_SQL(T_st_sql4))
                    {
                        goto reversa;
                    }
                    else
                    {
                        //si no se ejecuta bien hara un commit
                        conexion.GFun_Lo_Maneja_Transaccion(Program.G_TERMINA_TRANSACCION);
                        MessageBox.Show("Registro ingresado correctamente");
                        Grb_DatoCategori.Enabled = false;
                        btnNuevoCategori.Text    = "Nuevo";
                        limpiarTodo();
                        goto fin;
                    }
                }
            }


            //SI EL BOTON ESTA EN OPCION ACTUALIZAR
            else if (btnNuevoCategori.Text == "Actualizar")
            {
                if (chkPagaIva.Checked == true)
                {
                    pagIva = 1;
                }
                else
                {
                    pagIva = 0;
                }

                //if (txtDescripCateg.Text == "")
                //{
                //    MessageBox.Show("Favor ingrese la descripción y la seccion mesa del pos_mesa.", "Aviso", MessageBoxButtons.OK);
                //    txtDescripCateg.Focus();
                //}

                //else
                //{
                if (cmbPadre.Text == "2")
                {
                    valor2 = "2." + txtCodigoCatego.Text;
                }

                T_st_query = "update cv401_productos set codigo = '" + valor2 + "' , secuencia = '" + txtSecuencia.Text.ToString().Trim() + "' , " +
                             "paga_iva = '" + pagIva + "' where id_producto = '" + codigoID + "'";

                T_st_query2 = "update cv401_nombre_productos set nombre = '" + txtDescripCateg.Text.ToString().Trim() + "' " +
                              "where id_producto = '" + codigoID + "'";

                //T_st_query3 = "update cv401_nombre_productos set nombre = '" + txtDescripCateg.Text.ToString().Trim() + "' where id_producto = '" + codigoID + "'";
                T_st_mensaje = "Registro Actualizado Ëxitosamente";
                actualizarRegistro(T_st_query, T_st_mensaje);
                actualizarRegistro2(T_st_query2, T_st_mensaje);
                goto fin;
                //}
            }

reversa:

            try
            {
                //aqui va la instruccion para hacer el rollback
                conexion.GFun_Lo_Maneja_Transaccion(Program.G_REVERSA_TRANSACCION);
                //MessageBox.Show("Ocurriò un problema en la transacciòn");
                limpiarTodo();
            }
            catch (Exception)
            {
            }

fin:
            try
            {
            }
            catch (Exception)
            {
            }
        }
        private void btnNuevoListPrecios_Click(object sender, EventArgs e)
        {
            string T_st_query   = "";
            string T_st_mensaje = "";

            //SI EL BOTON ESTA EN OPCION NUEVO
            if (btnNuevoListPrecios.Text == "Nuevo")
            {
                limpiarTodo();
                grpDatoListPrecios.Enabled = true;
                btnNuevoListPrecios.Text   = "Guardar";
                txtNombreCrear.Focus();
            }

            //SI EL BOTON ESTA EN OPCION GUARDAR
            else if (btnNuevoListPrecios.Text == "Guardar")
            {
                if (rdbLisBasCrear.Checked == true)
                {
                    listBase = 1;
                }
                else
                {
                    listBase = 0;
                }

                if (rdbLisComCrear.Checked == true)
                {
                    listCombo = 1;
                }
                else
                {
                    listCombo = 0;
                }

                if (rdbLisEspCrear.Checked == true)
                {
                    listEspecial = 1;
                }
                else
                {
                    listEspecial = 0;
                }

                if (chkListModiCrear.Checked == true)
                {
                    listModifi = 1;
                }
                else
                {
                    listModifi = 0;
                }

                if (chkRestrLocalidad.Checked == true)
                {
                    restrLocali = 1;
                }
                else
                {
                    restrLocali = 0;
                }

                //if (rdbListMinorista.Checked == true)
                //    listMinorista = 1;
                //else listMinorista = 0;


                //if ((txtNombreCrear.Text == "") && (cmbMonedaCrear.Text == "Seleccionar item...") && (cmbTipClieCrear.Text == "Seleccionar item...") && (txtFecIniVaCrear.Text == "") && (txtFecFinVaCrear.Text == ""))
                //{
                //    MessageBox.Show("Debe rellenar todos los campos obligatorios.", "Aviso", MessageBoxButtons.OK);
                //    txtCodigoCajero.Focus();
                //}

                //else if (txtCodigoCajero.Text == "")
                //{
                //    MessageBox.Show("Favor ingrese el código del cajero.", "Aviso", MessageBoxButtons.OK);
                //    txtCodigoCajero.Focus();
                //}

                //else if (txtDescripCajero.Text == "")
                //{
                //    MessageBox.Show("Favor ingrese la descripción del cajero.", "Aviso", MessageBoxButtons.OK);
                //    txtDescripCajero.Focus();
                //}

                //else
                //{
                string t_st_fecha = (DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second).ToString();
                //llamo a la funcion que iniciara un begin transAction (se graba en una tabla temporal) y Program.G_INICIA_TRANSACCION devuelve true si abrio bn la transaccion
                if (!conexion.GFun_Lo_Maneja_Transaccion(Program.G_INICIA_TRANSACCION))
                {
                    MessageBox.Show("Error al abrir transacción");
                    limpiarTodo();
                }
                else
                {
                    T_st_sql = "insert into cv403_listas_precios (descripcion,cg_moneda,cg_tipo_cliente,fecha_inicio_validez," +
                               "fecha_fin_validez,lista_base,lista_minorista,lista_combo,lista_especial,restriccion_localidad," +
                               "lista_modificable,lista_diferenciada,cg_estado_lista,estado,numero_replica_trigger," +
                               "numero_control_replica,fecha_ingreso,usuario_ingreso,terminal_ingreso)values" +
                               "('" + txtNombreCrear.Text.ToString().Trim() + "', " + Convert.ToInt32(cmbMoneda.SelectedValue) + "," +
                               " " + Convert.ToInt32(cmbCliente.SelectedValue) + ", '" + Convert.ToDateTime(txtFecIniVaCrear.Text.ToString()) + "'," +
                               " '" + Convert.ToDateTime(txtFecFinVaCrear.Text.ToString()) + "', '" + listBase + "'," +
                               " '" + listMinorista + "' , '" + listCombo + "' , '" + listEspecial + "' , '" + restriccion_localidad + "', " +
                               "'" + listModifi + "','" + lista_diferenciada + "','" + cg_estado_lista + "', 'A' , " +
                               "'" + numero_replica_trigger + "','" + numero_control_replica + "' , " +
                               " GETDATE()', '" + Program.sDatosMaximo[0] + "', '" + Program.sDatosMaximo[1] + "')";


                    //sisque no me ejuta el query
                    if (!conexion.GFun_Lo_Ejecuta_SQL(T_st_sql))
                    {
                        //hara el rolBAck
                        conexion.GFun_Lo_Maneja_Transaccion(Program.G_REVERSA_TRANSACCION);
                    }
                    else
                    {
                        //si no se ejecuta bien hara un commit
                        conexion.GFun_Lo_Maneja_Transaccion(Program.G_TERMINA_TRANSACCION);
                        MessageBox.Show("Registro ingresado correctamente");
                        btnNuevoListPrecios.Text   = "Nuevo";
                        grpDatoListPrecios.Enabled = false;

                        limpiarTodo();
                    }
                }
                //}
            }

            //SI EL BOTON ESTA EN OPCION ACTUALIZAR
            else if (btnNuevoListPrecios.Text == "Actualizar")
            {
                if (rdbLisBasCrear.Checked == true)
                {
                    listBase = 1;
                }
                else
                {
                    listBase = 0;
                }

                if (rdbLisComCrear.Checked == true)
                {
                    listCombo = 1;
                }
                else
                {
                    listCombo = 0;
                }

                if (rdbLisEspCrear.Checked == true)
                {
                    listEspecial = 1;
                }
                else
                {
                    listEspecial = 0;
                }

                if (chkListModiCrear.Checked == true)
                {
                    listModifi = 1;
                }
                else
                {
                    listModifi = 0;
                }

                if (chkRestrLocalidad.Checked == true)
                {
                    restrLocali = 1;
                }
                else
                {
                    restrLocali = 0;
                }

                //if (rdbListMinorista.Checked == true)
                //    listMinorista = 1;
                //else listMinorista = 0;

                //if (txtDescripCajero.Text == "")
                //{
                //    MessageBox.Show("Favor ingrese la descripción del cajero.", "Aviso", MessageBoxButtons.OK);
                //    txtDescripCajero.Focus();
                //}

                //else
                //{
                T_st_query   = "update cv403_listas_precios set descripcion = '" + txtNombreCrear.Text.Trim() + "', cg_moneda = '" + cmbMoneda.SelectedValue.ToString() + "',  cg_tipo_cliente = '" + cmbCliente.SelectedValue.ToString() + "',  fecha_inicio_validez = '" + txtFecIniVaCrear.Text.ToString().Trim() + "',  fecha_fin_validez = '" + txtFecFinVaCrear.Text.ToString().Trim() + "',  lista_base = '" + listBase + "',  lista_combo = '" + listCombo + "',  lista_especial = '" + listEspecial + "',  lista_modificable = '" + listModifi + "',  restriccion_localidad = '" + restrLocali + "' where id_lista_precio = '" + id_lista_precio + "'";
                T_st_mensaje = "Registro Actualizado Ëxitosamente";
                actualizarRegistro(T_st_query, T_st_mensaje);
                //}
            }
        }
        private void BtnNuevoProductos_Click(object sender, EventArgs e)
        {
            string T_st_query   = "";
            string T_st_mensaje = "";

            //SI EL BOTON ESTA EN OPCION NUEVO
            if (btnNuevoProductos.Text == "Nuevo")
            {
                limpiarTodo();
                Grb_DatoProductos.Enabled = true;
                btnNuevoProductos.Text    = "Guardar";
                txtCodigoProductos.Focus();
                cmbColoProductos.Text     = "Seleccionar item...";
                cmbProPadreProductos.Text = "Seleccionar item...";
            }

            //SI EL BOTON ESTA EN OPCION GUARDAR
            else if (btnNuevoProductos.Text == "Guardar")
            {
                if (chkModifiProductos.Checked == true)
                {
                    modiChe = 1;
                }
                else
                {
                    modiChe = 0;
                }
                if (chkPagIceProductos.Checked == true)
                {
                    pagIceChe = 1;
                }
                else
                {
                    pagIceChe = 0;
                }
                if (chkPagIvaProductos.Checked == true)
                {
                    pagIvaChe = 1;
                }
                else
                {
                    pagIvaChe = 0;
                }
                if (chkPreModifProductos.Checked == true)
                {
                    preModChe = 1;
                }
                else
                {
                    preModChe = 0;
                }
                if (chkExpiraProductos.Checked == true)
                {
                    ExirChe = 1;
                }
                else
                {
                    ExirChe = 0;
                }

                if ((txtCodigoProductos.Text == "") && (txtDescripProductos.Text == "") && (cmbProPadreProductos.Text == "Seleccionar item") && (cmbColoProductos.Text == "Seleccionar item") && (txtNivProProductos.Text == "") && (txtStockMax.Text == "") && (txtStockMin.Text == ""))
                {
                    MessageBox.Show("Debe rellenar todos los campos obligatorios.", "Aviso", MessageBoxButtons.OK);
                    txtCodigoProductos.Focus();
                }

                else if (txtCodigoProductos.Text == "")
                {
                    MessageBox.Show("Favor ingrese el código del producto.", "Aviso", MessageBoxButtons.OK);
                    txtCodigoProductos.Focus();
                }

                else if (txtDescripProductos.Text == "")
                {
                    MessageBox.Show("Favor ingrese la descripción del producto.", "Aviso", MessageBoxButtons.OK);
                    txtDescripProductos.Focus();
                }
                else if (cmbProPadreProductos.Text == "0")
                {
                    MessageBox.Show("Favor selecione una opcion del producto padre.", "Aviso", MessageBoxButtons.OK);
                    cmbProPadreProductos.Focus();
                }
                else if (cmbColoProductos.Text == "Seleccionar item")
                {
                    MessageBox.Show("Favor selecione una opcion de color.", "Aviso", MessageBoxButtons.OK);
                    cmbColoProductos.Focus();
                }
                else if (txtStockMax.Text == "")
                {
                    MessageBox.Show("Favor ingrese el Stock_Max del producto.", "Aviso", MessageBoxButtons.OK);
                    txtStockMax.Focus();
                }
                else if (txtStockMin.Text == "")
                {
                    MessageBox.Show("Favor ingrese el Stock_Min del producto.", "Aviso", MessageBoxButtons.OK);
                    txtStockMin.Focus();
                }
                else
                {
                    string t_st_fecha = (DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + " " + DateTime.Now.Hour + ":"
                                         + DateTime.Now.Minute + ":" + DateTime.Now.Second).ToString();
                    //llamo a la funcion que iniciara un begin transAction (se graba en una tabla temporal) y Program.G_INICIA_TRANSACCION devuelve true si abrio bn la transaccion
                    if (!conexion.GFun_Lo_Maneja_Transaccion(Program.G_INICIA_TRANSACCION))
                    {
                        MessageBox.Show("Error al abrir transacción");
                        limpiarTodo();
                    }
                    else
                    {
                        T_st_sql = "insert into cv401_productos (idempresa,codigo,id_producto_padre,descripcion_uso,expira,id_color,estado," +
                                   "nivel,modificable,paga_ice,paga_iva,precio_modificable,stock_min,stock_max,id_mascara,fecha_ingreso,usuario_ingreso," +
                                   "terminal_ingreso)values('" + id_empresa + "', '" + txtCodigoProductos.Text.ToString().Trim() + "', " +
                                   "'" + cmbProPadreProductos.SelectedValue.ToString() + "', '" + txtDescripProductos.Text.ToString().Trim() + "'," +
                                   " '" + ExirChe + "', '" + cmbColoProductos.SelectedValue.ToString() + "','" + estado + "', " +
                                   "'" + txtNivProProductos.Text.ToString().Trim() + "','" + modiChe + "','" + pagIceChe + "','" + pagIvaChe + "'," +
                                   "'" + preModChe + "', '" + txtStockMin.Text.ToString().Trim() + "','" + txtStockMax.Text.ToString().Trim() + "', " +
                                   "'" + id_mascara + "', '" + t_st_fecha + "', '" + Program.sNombreUsuario + "', '" + Environment.MachineName.ToString() + "')";

                        //sisque no me ejuta el query
                        MessageBox.Show(T_st_sql);
                        if (!conexion.GFun_Lo_Ejecuta_SQL(T_st_sql))
                        {
                            //hara el rolBAck
                            conexion.GFun_Lo_Maneja_Transaccion(Program.G_REVERSA_TRANSACCION);
                        }
                        else
                        {
                            //si no se ejecuta bien hara un commit
                            conexion.GFun_Lo_Maneja_Transaccion(Program.G_TERMINA_TRANSACCION);
                            MessageBox.Show("Registro ingresado correctamente");
                            btnNuevoProductos.Text    = "Nuevo";
                            Grb_DatoProductos.Enabled = false;
                            limpiarTodo();
                        }
                    }
                }
            }

            //SI EL BOTON ESTA EN OPCION ACTUALIZAR
            else if (btnNuevoProductos.Text == "Actualizar")
            {
                if (chkModifiProductos.Checked == true)
                {
                    modiChe = 1;
                }
                else
                {
                    modiChe = 0;
                }
                if (chkPagIceProductos.Checked == true)
                {
                    pagIceChe = 1;
                }
                else
                {
                    pagIceChe = 0;
                }
                if (chkPagIvaProductos.Checked == true)
                {
                    pagIvaChe = 1;
                }
                else
                {
                    pagIvaChe = 0;
                }
                if (chkPreModifProductos.Checked == true)
                {
                    preModChe = 1;
                }
                else
                {
                    preModChe = 0;
                }
                if (chkExpiraProductos.Checked == true)
                {
                    ExirChe = 1;
                }
                else
                {
                    ExirChe = 0;
                }

                if (txtDescripProductos.Text == "")
                {
                    MessageBox.Show("Favor ingrese la descripción del producto.", "Aviso", MessageBoxButtons.OK);
                    txtDescripProductos.Focus();
                }

                else
                {
                    T_st_query = "update cv401_productos set idempresa = '" + id_empresa + "', codigo = '" + txtCodigoProductos.Text.ToString().Trim() + "'," +
                                 " id_producto_padre = '" + cmbProPadreProductos.SelectedValue.ToString() + "' , descripcion_uso = '" + txtDescripProductos.Text.ToString().Trim() + "', " +
                                 "expira = '" + ExirChe + "', id_color = '" + cmbColoProductos.SelectedValue.ToString() + "', estado = '" + estado + "'," +
                                 " nivel = '" + txtNivProProductos.Text.ToString().Trim() + "', modificable = '" + modiChe + "', paga_ice = '" + pagIceChe + "', " +
                                 "paga_iva = '" + pagIvaChe + "', precio_modificable = '" + preModChe + "', stock_min = '" + txtStockMin.Text.ToString().Trim() + "', " +
                                 "stock_max = '" + txtStockMax.Text.ToString().Trim() + "', id_mascara = '" + id_mascara + "' " +
                                 "where codigo = '" + txtCodigoProductos.Text.ToString().Trim() + "'";

                    T_st_mensaje = "Registro Actualizado Ëxitosamente";
                    actualizarRegistro(T_st_query, T_st_mensaje);
                }
            }
        }
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            string T_st_query = "";
            string T_st_query2 = "";
            string T_st_query3 = "";
            string T_st_query4 = "";
            string T_st_sql3 = "";
            string T_st_sql4 = "";
            string T_st_mensaje = "";
            double precioVenta = 0, iva, porcien10;


            if (btnAgregar.Text == "Nuevo")
            {
                grpDatolocalidad.Enabled = true;
                //Grb_Dato.Enabled = false;
                Grb_listReProCategori.Enabled = true;
                cmbLocalidad.Focus();
                btnAgregar.Text = "Guardar";
            }
            else
            {
                if (btnAgregar.Text == "Guardar")
                {
                    string t_st_fecha = (DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + " "
                                         + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second).ToString();
                    //llamo a la funcion que iniciara un begin transAction (se graba en una tabla temporal) y Program.G_INICIA_TRANSACCION devuelve true si abrio bn la transaccion
                    if (!conexion.GFun_Lo_Maneja_Transaccion(Program.G_INICIA_TRANSACCION))
                    {
                        MessageBox.Show("Error al abrir transacción");
                        Limpiar();
                    }
                    else
                    {
                        T_st_sql = "insert into tp_localidades_impresoras (Id_localidad,id_localidad_secuencia,Nombre_Impresora," +
                                   "Puerto_Impresora,Numero_Cotizacion,Numero_Pedido,Numero_Factura,Numero_Nota_Credito,Numero_Pago," +
                                   "Numero_Nota_Debito,Numero_Guia_Remision,NumeroAnticipoCliente,numeropagoserieb,numeronotaventa," +
                                   "numeronotaentrega,numero_replica_trigger,numero_control_replica,estado,fecha_ingreso,usuario_ingreso," +
                                   "terminal_ingreso)values('" + cmbLocalidad.SelectedValue.ToString() + "','" + id_localidad_secuencia + "'," +
                                   "'" + txtNomEmpresa.Text.ToString().Trim() + "','" + txtPuertoEmpresa.Text.ToString().Trim() + "'," +
                                   "'" + txtCotizacion.Text.ToString().Trim() + "', '" + txtPedido.Text.ToString().Trim() + "', " +
                                   "'" + txtFactura.Text.ToString().Trim() + "', '" + txtCredito.Text.ToString().Trim() + "'," +
                                   " '" + txtPago.Text.ToString().Trim() + "', '" + txtDebito.Text.ToString().Trim() + "'," +
                                   " '" + txtRemision.Text.ToString().Trim() + "', '" + txtAnticipo.Text.ToString().Trim() + "'," +
                                   " '" + txtSerieB.Text.ToString().Trim() + "', '" + numeronotaventa + "', '" + numeronotaentrega + "', " +
                                   "'" + numero_replica_trigger + "', '" + numero_control_replica + "','A', GETDATE(), " +
                                   "'" + Program.sDatosMaximo[0] + "', '" + Program.sDatosMaximo[1] + "')";
                        //sisque no me ejuta el query
                        if (!conexion.GFun_Lo_Ejecuta_SQL(T_st_sql))
                        {
                            //hara el rolBAck
                            conexion.GFun_Lo_Maneja_Transaccion(Program.G_REVERSA_TRANSACCION);
                        }
                        else
                        {
                            //si no se ejecuta bien hara un commit
                            conexion.GFun_Lo_Maneja_Transaccion(Program.G_TERMINA_TRANSACCION);
                            MessageBox.Show("Registro ingresado correctamente");
                            btnAgregar.Text = "Nuevo";
                            //Grb_Dat.Enabled = false;
                            Limpiar();
                        }
                    }
                }

                //SI EL BOTON ESTA EN OPCION ACTUALIZAR
                else if (btnAgregar.Text == "Actualizar")
                {
                    T_st_query = "update tp_localidades_impresoras set Id_localidad  = '" + cmbLocalidad.SelectedValue.ToString() + "', " +
                                 " id_localidad_secuencia = '" + id_localidad_secuencia + "', Nombre_Impresora = " +
                                 "'" + txtNomEmpresa.Text.ToString().Trim() + "', Puerto_Impresora = '" + txtPuertoEmpresa.Text.ToString().Trim() + "', " +
                                 " Numero_Cotizacion = '" + txtCotizacion.Text.ToString().Trim() + "'," +
                                 " Numero_Pedido = '" + txtPedido.Text.ToString().Trim() + "', Numero_Factura = " +
                                 "'" + txtFactura.Text.ToString().Trim() + "', Numero_Nota_Credito = '" + txtCredito.Text.ToString().Trim() + "', " +
                                 "Numero_Pago = '" + txtPago.Text.ToString().Trim() + "', Numero_Nota_Debito = '" + txtDebito.Text.ToString().Trim() + "'," +
                                 " Numero_Guia_Remision = '" + txtRemision.Text.ToString().Trim() + "', NumeroAnticipoCliente = " +
                                 "'" + txtAnticipo.Text.ToString().Trim() + "', numeropagoserieb = '" + txtSerieB.Text.ToString().Trim() + "'," +
                                 " numeronotaventa = '" + numeronotaventa + "', numeronotaentrega = '" + numeronotaentrega + "'," +
                                 " numero_replica_trigger = '" + numero_replica_trigger + "', numero_control_replica = " +
                                 " '" + numero_control_replica + "' where id_localidad_impresora = " + idImpresora + "";

                    T_st_mensaje = "Registro Actualizado Ëxitosamente";
                    actualizarRegistro(T_st_query, T_st_mensaje);
                }
            }
        }
Beispiel #16
0
        //FUNCION PARA INSERTAR REGISTROS EN LA BASE DE DATOS
        private void insertarRegistro()
        {
            try
            {
                //INICIAMOS UNA NUEVA TRANSACCION
                if (!conexion.GFun_Lo_Maneja_Transaccion(Program.G_INICIA_TRANSACCION))
                {
                    ok.LblMensaje.Text = "Error al abrir transacción";
                    ok.ShowDialog();
                    return;
                }

                sSql  = "";
                sSql += "insert into pos_origen_orden (" + Environment.NewLine;
                sSql += "codigo, descripcion, genera_factura, id_pos_modo_delivery," + Environment.NewLine;
                sSql += "presenta_opcion_delivery, repartidor_externo, imagen, id_pos_tipo_forma_cobro," + Environment.NewLine;
                sSql += "id_persona, maneja_servicio, cuenta_por_cobrar, estado, fecha_ingreso," + Environment.NewLine;
                sSql += "usuario_ingreso, terminal_ingreso)" + Environment.NewLine;
                sSql += "values(" + Environment.NewLine;
                sSql += "'" + txtCodigo.Text.Trim() + "', '" + txtDescripcion.Text.Trim() + "'," + Environment.NewLine;
                sSql += iGeneraFactura + ", " + Convert.ToInt32(cmbModoDelivery.SelectedValue) + ", " + Environment.NewLine;
                sSql += iDelivery + ", " + iRepartidor + ", '" + txtRuta.Text.Trim() + "'," + Environment.NewLine;

                if (iGeneraFactura == 1)
                {
                    sSql += "null, null," + Environment.NewLine;
                }

                else
                {
                    if (dbAyudaPersona.iId == 0)
                    {
                        sSql += Convert.ToInt32(cmbFormasCobros.SelectedValue) + ", null," + Environment.NewLine;
                    }

                    else
                    {
                        sSql += Convert.ToInt32(cmbFormasCobros.SelectedValue) + "," + dbAyudaPersona.iId + "," + Environment.NewLine;
                    }
                }

                sSql += iIdManejaServicio + ", " + iCuentaPorCobrar + ", 'A', GETDATE()," + Environment.NewLine;
                sSql += "'" + Program.sDatosMaximo[0] + "', '" + Program.sDatosMaximo[1] + "')";

                //EJECUTAR INSTRUCCION SQL
                if (!conexion.GFun_Lo_Ejecuta_SQL(sSql))
                {
                    catchMensaje.LblMensaje.Text = sSql;
                    catchMensaje.ShowDialog();
                    goto reversa;
                }

                conexion.GFun_Lo_Maneja_Transaccion(Program.G_TERMINA_TRANSACCION);
                ok.LblMensaje.Text = "Registro ingresado éxitosamente";
                ok.ShowDialog();
                grupoDatos.Enabled = false;
                btnNuevo.Text      = "Nuevo";
                limpiarTodo();
                return;
            }

            catch (Exception ex)
            {
                catchMensaje.LblMensaje.Text = ex.ToString();
                catchMensaje.ShowDialog();
                goto reversa;
            }

reversa:
            {
                conexion.GFun_Lo_Maneja_Transaccion(Program.G_REVERSA_TRANSACCION);
            }
        }
Beispiel #17
0
        //FUNCION PARA INSERTAR REGISTROS EN LA BASE DE DATOS
        private void insertarRegistro()
        {
            try
            {
                //AQUI INICIA TRANSACCION
                if (!conexion.GFun_Lo_Maneja_Transaccion(Program.G_INICIA_TRANSACCION))
                {
                    ok = new VentanasMensajes.frmMensajeNuevoOk();
                    ok.lblMensaje.Text = "Error al abrir transacción.";
                    ok.ShowDialog();
                    limpiarTodo();
                    return;
                }

                sSql  = "";
                sSql += "insert into pos_tipo_forma_cobro (" + Environment.NewLine;
                sSql += "codigo, descripcion, lee_propina, id_pos_metodo_pago," + Environment.NewLine;
                sSql += "cg_tipo_documento, imagen_base_64, id_pos_tipo_venta, is_active, " + Environment.NewLine;
                sSql += "mostrar_seccion_cobros, texto_visualizar_boton, estado," + Environment.NewLine;
                sSql += "fecha_ingreso, usuario_ingreso, terminal_ingreso)" + Environment.NewLine;
                sSql += "values(" + Environment.NewLine;
                sSql += "@codigo, @descripcion, @lee_propina, @id_pos_metodo_pago," + Environment.NewLine;
                sSql += "@cg_tipo_documento, @imagen_base_64, @id_pos_tipo_venta, @is_active, " + Environment.NewLine;
                sSql += "@mostrar_seccion_cobros, @texto_visualizar_boton, @estado," + Environment.NewLine;
                sSql += "getdate(), @usuario_ingreso, @terminal_ingreso)";

                #region PARAMETROS

                int a = 0;
                parametro    = new SqlParameter[13];
                parametro[a] = new SqlParameter();
                parametro[a].ParameterName = "@codigo";
                parametro[a].SqlDbType     = SqlDbType.VarChar;
                parametro[a].Value         = txtCodigo.Text.Trim();
                a++;

                parametro[a] = new SqlParameter();
                parametro[a].ParameterName = "@descripcion";
                parametro[a].SqlDbType     = SqlDbType.VarChar;
                parametro[a].Value         = txtDescripcion.Text.Trim().ToUpper();
                a++;

                parametro[a] = new SqlParameter();
                parametro[a].ParameterName = "@lee_propina";
                parametro[a].SqlDbType     = SqlDbType.Int;
                parametro[a].Value         = iLeePropina;
                a++;

                parametro[a] = new SqlParameter();
                parametro[a].ParameterName = "@id_pos_metodo_pago";
                parametro[a].SqlDbType     = SqlDbType.Int;
                parametro[a].Value         = Convert.ToInt32(cmbMetodoPago.SelectedValue);
                a++;

                parametro[a] = new SqlParameter();
                parametro[a].ParameterName = "@cg_tipo_documento";
                parametro[a].SqlDbType     = SqlDbType.VarChar;
                parametro[a].Value         = Convert.ToInt32(cmbTipoDocumento.SelectedValue);
                a++;

                parametro[a] = new SqlParameter();
                parametro[a].ParameterName = "@imagen_base_64";
                parametro[a].SqlDbType     = SqlDbType.VarChar;
                parametro[a].Value         = txtBase64.Text.Trim();
                a++;

                parametro[a] = new SqlParameter();
                parametro[a].ParameterName = "@id_pos_tipo_venta";
                parametro[a].SqlDbType     = SqlDbType.Int;
                parametro[a].Value         = Convert.ToInt32(cmbTipoVenta.SelectedValue);
                a++;

                parametro[a] = new SqlParameter();
                parametro[a].ParameterName = "@is_active";
                parametro[a].SqlDbType     = SqlDbType.Int;
                parametro[a].Value         = 1;
                a++;

                parametro[a] = new SqlParameter();
                parametro[a].ParameterName = "@mostrar_seccion_cobros";
                parametro[a].SqlDbType     = SqlDbType.Int;
                parametro[a].Value         = iMostrarSeccionCobros;
                a++;

                parametro[a] = new SqlParameter();
                parametro[a].ParameterName = "@texto_visualizar_boton";
                parametro[a].SqlDbType     = SqlDbType.VarChar;
                parametro[a].Value         = txtVisualizarBoton.Text.Trim();
                a++;

                parametro[a] = new SqlParameter();
                parametro[a].ParameterName = "@estado";
                parametro[a].SqlDbType     = SqlDbType.VarChar;
                parametro[a].Value         = "A";
                a++;

                parametro[a] = new SqlParameter();
                parametro[a].ParameterName = "@usuario_ingreso";
                parametro[a].SqlDbType     = SqlDbType.VarChar;
                parametro[a].Value         = Program.sDatosMaximo[0];
                a++;

                parametro[a] = new SqlParameter();
                parametro[a].ParameterName = "@terminal_ingreso";
                parametro[a].SqlDbType     = SqlDbType.VarChar;
                parametro[a].Value         = Program.sDatosMaximo[1];

                #endregion

                if (!conexion.GFun_Lo_Ejecutar_SQL_Parametros(sSql, parametro))
                {
                    catchMensaje = new VentanasMensajes.frmMensajeNuevoCatch();
                    catchMensaje.lblMensaje.Text = conexion.sMensajeError;
                    catchMensaje.ShowDialog();
                    goto reversa;
                }

                conexion.GFun_Lo_Maneja_Transaccion(Program.G_TERMINA_TRANSACCION);

                ok = new VentanasMensajes.frmMensajeNuevoOk();
                ok.lblMensaje.Text = "Registro ingresado éxitosamente.";
                ok.ShowDialog();
                limpiarTodo();
                grupoDatos.Enabled = false;
                btnNuevo.Text      = "Nuevo";
                return;
            }

            catch (Exception ex)
            {
                catchMensaje = new VentanasMensajes.frmMensajeNuevoCatch();
                catchMensaje.lblMensaje.Text = ex.Message;
                catchMensaje.ShowDialog();
                goto reversa;
            }

            reversa : { conexion.GFun_Lo_Maneja_Transaccion(Program.G_REVERSA_TRANSACCION); }
        }