private void btnAprobar_Click(object sender, EventArgs e)
        {
            DialogResult resp;
            string       temporalId = "";
            List <DataDB_ELR_NET.Parametro> parms = new List <DataDB_ELR_NET.Parametro>();
            int resultado = 0;

            WinControl_ELR_NET.ELRFormMensajeErrores frmError = new WinControl_ELR_NET.ELRFormMensajeErrores();
            try
            {
                resp = objUtil.MostrarMensajePregunta("Esta Seguro que desea Aprobar y Generar Contractos?");
                if (resp == DialogResult.Yes)
                {
                    Cursor = Cursors.WaitCursor;

                    temporalId = objUtil.GetTemporalID();
                    parms.Add(new DataDB_ELR_NET.Parametro("IdentificadorId", solicitudId));
                    parms.Add(new DataDB_ELR_NET.Parametro("tipo", "SC"));
                    parms.Add(new DataDB_ELR_NET.Parametro("autor", nombreUsuario));
                    parms.Add(new DataDB_ELR_NET.Parametro("IdentificadorTemp", temporalId));

                    db.NOMBRE_USUARIO = nombreUsuario;
                    db.iniciarTransaccion();
                    resultado = db.EjecutarSP("SP_PRESTAMOS_APROBAR_GENERAR_CONTRACTOS", parms);
                    if (resultado > 0)
                    {
                        db.confirmarTransaccion();
                        Cursor = Cursors.Default;
                        objUtil.MostrarMensajeInformacion("CREDITO APROBADO DE FORMA SATISFACTORIA...");

                        Close();
                    }
                    else
                    {
                        Cursor = Cursors.Default;

                        //Mostramos mensaje error
                        frmError.objDB      = db;
                        frmError.TemporalId = temporalId;
                        frmError.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
                objUtil.MostrarMensajeError(ex.Message);
            }
            finally
            {
                db.cancelarTransaccion();
            }
        }
        public override int GrabarDatos()
        {
            //return base.GrabarDatos();
            List <DataDB_ELR_NET.Parametro> MyParametros = new List <DataDB_ELR_NET.Parametro>();
            string       comentario        = "";
            string       identificadorTemp = "";
            DialogResult resp;


            WinControl_ELR_NET.ELRFormMensajeErrores objMsgERRORES = new WinControl_ELR_NET.ELRFormMensajeErrores();


            int resultado = -1;

            try
            {
                comentario = txtComentario.Text.Trim();
                if (comentario.Length < 15)
                {
                    objUtil.MostrarMensajeAdvertencia("Debe Indicar un Comentario Minimo 15 Caracteres");
                    txtComentario.Focus();
                }
                else
                {
                    //EJECUTAMOS EL SP QUE PASA DEL TEMPORAL A LA TABLA DE OPERACIONES
                    resp = objUtil.MostrarMensajePregunta("Esta Seguro que desea Rechazar El Prestamo No.: " + prestamoId.ToString().PadLeft(8, '0') + "?");

                    if (resp == System.Windows.Forms.DialogResult.Yes)
                    {
                        identificadorTemp = objUtil.GetTemporalID();

                        MyParametros.Add(new DataDB_ELR_NET.Parametro("IdentificadorTemp", identificadorTemp));
                        MyParametros.Add(new DataDB_ELR_NET.Parametro("PrestamoId", prestamoId));
                        MyParametros.Add(new DataDB_ELR_NET.Parametro("Concepto", comentario));
                        MyParametros.Add(new DataDB_ELR_NET.Parametro("Autor", nombreUsuario));

                        objDB.iniciarTransaccion();
                        resultado = objDB.EjecutarSP("SP_PRESTAMOS_RECHAZAR", MyParametros);
                        if (resultado < 0)
                        {
                            objMsgERRORES.TemporalId = identificadorTemp;
                            objMsgERRORES.objDB      = objDB;

                            objMsgERRORES.ShowDialog();
                        }
                        else
                        {
                            objDB.confirmarTransaccion();
                            lOK = true;
                            Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                objUtil.MostrarMensajeError(ex.Message);
                objDB.cancelarTransaccion();
            }

            return(resultado);
        }
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            string       valorUnico     = "0";
            int          entidadId      = 0;
            string       documentoId    = "0";
            string       tipoGarantiaId = "";
            string       temporalId     = "";
            DialogResult resp;
            int          resultado = 0, index = 0;
            List <DataDB_ELR_NET.Parametro> parametros = new List <DataDB_ELR_NET.Parametro>();

            DataRow MyFila = null;

            FormSolicitudCreditoR         frmGPersonal = new FormSolicitudCreditoR();
            FormSolicitudGarantiaVehiculo frmGVehiculo = new FormSolicitudGarantiaVehiculo();

            WinControl_ELR_NET.ELRFormMensajeErrores frmMensajeErrores = new WinControl_ELR_NET.ELRFormMensajeErrores();

            try
            {
                this.Cursor = Cursors.WaitCursor;
                temporalId  = objUtil.GetTemporalID();

                var senderGrid = (DataGridView)sender;
                if (MyData == null)
                {
                    return;
                }
                if (MyData.Rows.Count <= 0)
                {
                    return;
                }
                if (e.RowIndex < 0)
                {
                    return;
                }

                valorUnico = senderGrid["unico", senderGrid.CurrentRow.Index].Value.ToString();
                index      = senderGrid.CurrentRow.Index;

                //ELIMINAMOS UN REGISTRO DE GARANTIA
                if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0)
                {
                    resp = objUtil.MostrarMensajePregunta("Esta Seguro que desea Eliminar el Registro de Esta Garantia?");

                    if (resp == System.Windows.Forms.DialogResult.Yes)
                    {
                        parametros.Add(new DataDB_ELR_NET.Parametro("IdentificadorTemp", temporalId));
                        parametros.Add(new DataDB_ELR_NET.Parametro("Unico", valorUnico));
                        parametros.Add(new DataDB_ELR_NET.Parametro("Autor", nombreUsuario));

                        objDB.iniciarTransaccion();
                        resultado = objDB.EjecutarSP("SP_PRESTAMOS_ELIMINA_GARANTIA", parametros);

                        if (resultado > 0)
                        {
                            objDB.confirmarTransaccion();
                            RealizarBusquedaSencilla();
                        }
                        else
                        {
                            frmMensajeErrores.TemporalId = temporalId;
                            frmMensajeErrores.objDB      = objDB;

                            frmMensajeErrores.ShowDialog();
                        }
                    }
                }

                if (senderGrid.Columns[e.ColumnIndex] is DataGridViewLinkColumn &&
                    e.RowIndex >= 0)
                {
                    //TODO - Button Clicked - Execute Code Here
                    valorUnico = senderGrid["unico", senderGrid.CurrentRow.Index].Value.ToString();

                    //BUSCO LA FILA SELECCIONADA POS SU UNICO
                    MyFila         = MyData.Select("Unico = " + valorUnico.ToString())[0];
                    entidadId      = objUtil.GetAsInt("Entidad_Id", MyFila);
                    documentoId    = objUtil.GetAsString("Documento_Id", MyFila);
                    tipoGarantiaId = objUtil.GetAsString("Tipo_Garantia_Id", MyFila).Trim().ToUpper();

                    parametros.Clear();

                    if (tipoGarantiaId == "P")
                    {
                        parametros.Add(new DataDB_ELR_NET.Parametro("Id", entidadId));
                        parametros.Add(new DataDB_ELR_NET.Parametro("IdentificadorTemp", temporalId));
                        parametros.Add(new DataDB_ELR_NET.Parametro("autor", nombreUsuario));
                        objDB.iniciarTransaccion();
                        resultado = objDB.EjecutarSP("SP_TEMPORAL_CLASIFICADOR_ENTIDADES", parametros);
                        if (resultado < 0)
                        {
                            MostrarErrorTemporal(temporalId);
                            objDB.cancelarTransaccion();
                        }
                        else
                        {
                            objDB.confirmarTransaccion();

                            frmGPersonal.nombreUsuario      = nombreUsuario;
                            frmGPersonal.solicitudId        = solicitudId;
                            frmGPersonal.entidadId          = entidadId;
                            frmGPersonal.VALOR_ID           = entidadId.ToString();
                            frmGPersonal.DTVariablesSYS     = DTVariablesSYS;
                            frmGPersonal.DSGlobal           = DSGlobal;
                            frmGPersonal.EnEjecusion        = true;
                            frmGPersonal.temporalID         = temporalId;
                            frmGPersonal.EMPRESA_ID         = empresaID;
                            frmGPersonal.OFICINA_ID         = oficinaID;
                            frmGPersonal.esGarantiaPersonal = true;

                            frmGPersonal.ShowDialog();

                            if (frmGPersonal.lOK)
                            {
                                this.GetData();
                            }
                        }
                    }

                    if (tipoGarantiaId == "V")
                    {
                        parametros.Add(new DataDB_ELR_NET.Parametro("Id", valorUnico));
                        parametros.Add(new DataDB_ELR_NET.Parametro("IdentificadorTemp", temporalId));
                        parametros.Add(new DataDB_ELR_NET.Parametro("autor", nombreUsuario));
                        objDB.iniciarTransaccion();
                        resultado = objDB.EjecutarSP("SP_TEMPORAL_GARANTIA_VEHICULO", parametros);
                        if (resultado < 0)
                        {
                            MostrarErrorTemporal(temporalId);
                            objDB.cancelarTransaccion();
                        }
                        else
                        {
                            objDB.confirmarTransaccion();

                            frmGVehiculo.nombreUsuario  = nombreUsuario;
                            frmGVehiculo.solicitudId    = solicitudId;
                            frmGVehiculo.VALOR_ID       = valorUnico;
                            frmGVehiculo.DTVariablesSYS = DTVariablesSYS;
                            frmGVehiculo.DSGlobal       = DSGlobal;
                            frmGVehiculo.EnEjecusion    = true;
                            frmGVehiculo.temporalID     = temporalId;
                            frmGVehiculo.EMPRESA_ID     = empresaID;
                            frmGVehiculo.OFICINA_ID     = oficinaID;

                            frmGVehiculo.ShowDialog();

                            if (frmGVehiculo.lOK)
                            {
                                RealizarBusquedaSencilla();
                            }
                        }
                    }

                    //Buscamos el Unico Para Ubicar sobre la fila
                    senderGrid.CurrentCell          = senderGrid["btnEliminar", index];
                    senderGrid.CurrentCell.Selected = true;
                }
            }
            catch (Exception ex)
            {
                objUtil.MostrarMensajeError(ex.Message);
            }
            finally
            {
                this.Cursor = Cursors.Default;
                frmGPersonal.Dispose();
                frmGVehiculo.Dispose();
                frmMensajeErrores.Dispose();

                objDB.cancelarTransaccion();
            }
        }
Beispiel #4
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            bool   esValido   = false;
            string valorId    = "0";
            string temporalId = "";
            List <DataDB_ELR_NET.Parametro> MyParametros = new List <DataDB_ELR_NET.Parametro>();
            int spReturn = 0;

            try
            {
                var senderGrid = (DataGridView)sender;
                if (senderGrid.RowCount <= 0)
                {
                    return;
                }

                if (senderGrid.Columns[e.ColumnIndex] is DataGridViewLinkColumn)
                {
                    esValido = Valida();
                    if (!esValido)
                    {
                        return;
                    }

                    valorId    = senderGrid["Entidad_Id", senderGrid.CurrentRow.Index].Value.ToString();
                    temporalId = objUtil.GetTemporalID();
                    //Agregamos Parametros Para Ejecutar el SP PARA CARGAR A TEMPORAL
                    MyParametros.Add(new DataDB_ELR_NET.Parametro("Id", valorId));
                    MyParametros.Add(new DataDB_ELR_NET.Parametro("IdentificadorTemp", temporalId));
                    MyParametros.Add(new DataDB_ELR_NET.Parametro("Autor", nombreUsuario));

                    this.Cursor = Cursors.WaitCursor;

                    objDB.iniciarTransaccion();
                    spReturn = objDB.EjecutarSP("SP_CXP_PAGO_ATEMPORAL", MyParametros);
                    if (spReturn < 0)
                    {
                        //MOSTRAMOS ERRORES DEL SISTEMA
                        WinControl_ELR_NET.ELRFormMensajeErrores objMsgERRORES = new WinControl_ELR_NET.ELRFormMensajeErrores();

                        objMsgERRORES.TemporalId = temporalId;
                        objMsgERRORES.objDB      = objDB;

                        objMsgERRORES.ShowDialog();
                    }
                    else
                    {
                        objDB.confirmarTransaccion();
                    }

                    if (spReturn > 0)
                    {
                        FormCXPPagoR frm = new FormCXPPagoR();

                        frm.VALOR_ID       = valorId;
                        frm.EMPRESA_ID     = empresaID;
                        frm.OFICINA_ID     = oficinaID;
                        frm.nombreUsuario  = nombreUsuario;
                        frm.DSGlobal       = DSGlobal;
                        frm.esNuevo        = false;
                        frm.temporalID     = temporalId;
                        frm.DTVariablesSYS = DTVariablesSYS;

                        frm.EnEjecusion = true;

                        frm.ShowDialog();

                        RealizarBusquedaSencilla();
                    }
                }
            }
            catch (Exception ex)
            {
                objUtil.MostrarMensajeError(ex.Message);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            FormCerrarCaja frm        = new FormCerrarCaja();
            string         valorUnico = "0";
            DataRow        myFila     = null;
            string         aperturaNo = "0";
            int            spReturn   = -1;
            List <DataDB_ELR_NET.Parametro> myParametros = new List <DataDB_ELR_NET.Parametro>();
            string temporalId = "";

            try
            {
                this.Cursor = Cursors.WaitCursor;

                var senderGrid = (DataGridView)sender;

                if (senderGrid.Columns[e.ColumnIndex] is DataGridViewLinkColumn &&
                    e.RowIndex >= 0)
                {
                    //TODO - Button Clicked - Execute Code Here
                    valorUnico = senderGrid["unico", senderGrid.CurrentRow.Index].Value.ToString();

                    //BUSCO LA FILA SELECCIONADA POS SU UNICO
                    myFila     = MyData.Select("Unico = " + valorUnico)[0];
                    aperturaNo = myFila["Apertura_No"].ToString();
                    cajaNo     = objUtil.GetAsInt("Caja_Id", myFila);

                    //Vamos a Ejecutar el SP PARA CARGAR AL TEMPORAL
                    temporalId = objUtil.GetTemporalID();
                    myParametros.Add(new DataDB_ELR_NET.Parametro("Id", aperturaNo));
                    myParametros.Add(new DataDB_ELR_NET.Parametro("IdentificadorTemp", temporalId));
                    myParametros.Add(new DataDB_ELR_NET.Parametro("Autor", nombreUsuario));

                    objDB.iniciarTransaccion();
                    spReturn = objDB.EjecutarSP("SP_TEMPORAL_CIERRE_CAJA", myParametros);
                    if (spReturn < 0)
                    {
                        //MOSTRAMOS ERRORES DEL SISTEMA
                        WinControl_ELR_NET.ELRFormMensajeErrores objMsgERRORES = new WinControl_ELR_NET.ELRFormMensajeErrores();

                        objMsgERRORES.TemporalId = temporalId;
                        objMsgERRORES.objDB      = objDB;

                        objMsgERRORES.ShowDialog();
                    }
                    else
                    {
                        objDB.confirmarTransaccion();
                    }

                    if ((frm != null) && (spReturn > 0))
                    {
                        frm.nombreUsuario = nombreUsuario;
                        frm.EMPRESA_ID    = empresaID;
                        frm.OFICINA_ID    = oficinaID;
                        frm.VALOR_ID      = aperturaNo;
                        frm.temporalID    = temporalId;
                        frm.cajaId        = cajaNo;

                        frm.EnEjecusion = true;

                        frm.ShowDialog();

                        if (frm.lOK)
                        {
                            GetData();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                objUtil.MostrarMensajeError(ex.Message);
            }
            finally
            {
                this.Cursor = Cursors.Default;
                frm.Dispose();
            }
        }
        void validarRestrinciones()
        {
            List <DataDB_ELR_NET.Parametro> parms = new List <DataDB_ELR_NET.Parametro>();
            string temporalId = "", pathReporte, SSQL = "";
            int    result = 0, conteo = 0;

            WinControl_ELR_NET.ELRFormMensajeErrores frmError = new WinControl_ELR_NET.ELRFormMensajeErrores();
            WinControl_ELR_NET.ELRFormPreviewRDLC    frmRPT   = new WinControl_ELR_NET.ELRFormPreviewRDLC();
            DataTable DTData;

            try
            {
                Cursor = Cursors.WaitCursor;

                temporalId = objUtil.GetTemporalID();
                parms.Add(new DataDB_ELR_NET.Parametro("solicitudId", solicitudId));
                parms.Add(new DataDB_ELR_NET.Parametro("autor", nombreUsuario));
                parms.Add(new DataDB_ELR_NET.Parametro("IdentificadorTemp", temporalId));
                db.iniciarTransaccion();
                result = db.EjecutarSP("SP_SISTEMA_VALIDAR_SOLICITUD", parms);
                if (result > 0)
                {
                    db.confirmarTransaccion();

                    //Mostramos el Reporte de la Validacion Realizada
                    SSQL   = "SELECT * FROM TSISTEMA_VALIDACION_RESTRINCIONES WHERE IdentificadorTemp ='" + temporalId + "' Order by Unico ";
                    DTData = db.GetSQL(SSQL);

                    //Mostramos los puntos a favor y en contra
                    conteo = (Int32)objUtil.GetSum("Valor", DTData, "Valor > 0");
                    lblPuntosAFavor.Text = "PUNTOS A FAVOR: " + conteo.ToString();

                    //Mostramos los puntos a favor y en contra
                    conteo = (Int32)objUtil.GetSum("Valor", DTData, "Valor < 0");
                    lblPuntosNegativos.Text = "PUNTOS NEGATIVOS: " + Math.Abs(conteo).ToString();

                    pathReporte = objUtil.GetPathReportRDLC("RptValidaciones");
                    frmRPT.AddDS("DSData", DTData);
                    frmRPT.pathReporte   = pathReporte;
                    frmRPT.oficinaId     = oficinaId;
                    frmRPT.empresaId     = empresaId;
                    frmRPT.nombreUsuario = nombreUsuario;
                    frmRPT.titulo        = "SOLICITUD NO.: " + solicitudId.ToString();

                    frmRPT.ShowDialog();
                    Cursor = Cursors.Default;
                }
                else
                {
                    Cursor = Cursors.Default;

                    //Mostramos mensaje error
                    frmError.objDB      = db;
                    frmError.TemporalId = temporalId;
                    frmError.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                objUtil.MostrarMensajeError(ex.Message);
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }
        private void btnGenerar_Click(object sender, EventArgs e)
        {
            DialogResult resp;
            DataTable    myData;
            string       nombreSP;
            string       descripcion;
            List <DataDB_ELR_NET.Parametro> parametros = new List <DataDB_ELR_NET.Parametro>();
            string temporalId;
            bool   resultado   = false;
            int    cantErrores = 0;
            string mensaje     = "";

            WinControl_ELR_NET.ELRFormMensajeErrores frmErrores = new WinControl_ELR_NET.ELRFormMensajeErrores();

            try
            {
                fecha                 = dtpFecha.Value.Date;
                cantErrores           = 0;
                resultado             = false;
                lblProcesoActual.Text = "PROCESO EN EJECUSION...";

                //VALIDAMOS LA FECHA DE CIERRE NO PUEDE SER MAYOR A LA ACTUAL
                if (objDB.DateToInt(fecha) > objDB.DateToInt(DateTime.Now.Date))
                {
                    resultado = false;
                    objUtil.MostrarMensajeAdvertencia("LA FECHA A CERRAR NO PUEDE SER MAYOR A LA FECHA ACTUAL");
                    return;
                }

                cantErrores = 0;
                temporalId  = objUtil.GetTemporalID();

                progressBar1.Value = 0;
                progressBar1.Step  = 1;
                progressBar1.Refresh();

                resultado = true;


                if ((DTData.Rows.Count > 0) && (resultado == true))
                {
                    resultado = false;
                    if (objDB.DateToInt(fechaUltGenerado) < objDB.DateToInt(fecha))
                    {
                        resultado = true;
                    }
                }

                if (resultado)
                {
                    resp = objUtil.MostrarMensajePregunta("ESTA SEGURO DE REALIZAR EL CIERRE DE FECHA " + fecha.ToShortDateString() + "?");
                    if (resp != DialogResult.Yes)
                    {
                        resultado = false;
                    }
                }


                if (resultado)
                {
                    objDB.iniciarTransaccion();

                    parametros.Add(new DataDB_ELR_NET.Parametro("Fecha", objDB.DateToInt(fecha).ToString()));
                    parametros.Add(new DataDB_ELR_NET.Parametro("Autor", nombreUsuario));
                    parametros.Add(new DataDB_ELR_NET.Parametro("IdentificadorTemp", temporalId));

                    foreach (DataRow item in DTData.Rows)
                    {
                        if (cantErrores == 0)
                        {
                            this.Cursor = Cursors.WaitCursor;
                            resultado   = false;

                            nombreSP              = item["Nombre_SP"].ToString();
                            descripcion           = item["Descripcion"].ToString();
                            lblProcesoActual.Text = descripcion;

                            //EJECUTAMOS EL STORE PROCEDURE

                            if (objDB.EjecutarSP(nombreSP, parametros) < 0)
                            {
                                cantErrores++;
                                resultado = false;
                                break;
                            }


                            progressBar1.PerformStep();
                            this.Cursor = Cursors.Default;
                            resultado   = true;
                        }
                    }
                }


                //MOSTRAMOS LA VENTANA DE ERRORES
                if (cantErrores > 0)
                {
                    frmErrores.objDB      = objDB;
                    frmErrores.TemporalId = temporalId;
                    frmErrores.ShowDialog();
                }

                if (resultado)
                {
                    fechaUltGenerado = fecha;
                    objDB.confirmarTransaccion();

                    mensaje = "PROCESO REALIZADO DE FORMA SATISFACTORIA";
                    if (contabilidadId > 0)
                    {
                        mensaje += ", A CONTINUACION EL SISTEMA GENERARA LOS MOVIMIENTOS CONTABLES";
                    }

                    objUtil.MostrarMensajeInformacion(mensaje);

                    //GENERAMOS LA CONTABILIDAD
                    if (contabilidadId > 0)
                    {
                        GenerarContabilidad();
                    }
                }
                else
                {
                    objDB.cancelarTransaccion();
                }

                this.Cursor = Cursors.Default;
            }

            catch (Exception ex)
            {
                objDB.cancelarTransaccion();
                objUtil.MostrarMensajeError(ex.Message);
            }
            finally
            {
                this.Cursor = Cursors.Default;
                frmErrores.Dispose();
                myData = null;
            }
        }