Exemplo n.º 1
0
        //---------------------------------
        // Get y Ins PerCuenta si no existe
        //---------------------------------
        public int Ins_Get_PerCuenta(string cPerCodigo, string cPerJurCodigo, int nPerCtaTipo = 16)
        {
            int nPerCtaCodigo = 0;

            BL_PerCuenta ObjPerCta = new BL_PerCuenta();

            DataTable dt = new DataTable();

            BE_ReqPerCuenta Request = new BE_ReqPerCuenta();
            DA_PerCuenta    Obj     = new DA_PerCuenta();

            Request.cPerCodigo    = cPerCodigo;
            Request.cPerJurCodigo = cPerJurCodigo;
            dt = Obj.Get_PerCuenta(Request);

            //Si existe
            if (dt.Rows.Count > 0)
            {
                nPerCtaCodigo = Convert.ToInt32(dt.Rows[0]["nPerCtaCodigo"]);
            }
            else
            {
                //Creando PerCuenta
                if (!ObjPerCta.Ins_PerCuenta(cPerCodigo, nPerCtaTipo, cPerJurCodigo))
                {
                    throw new ApplicationException("Se encontraron errores al Crear Cuenta Persona. [Ins_PerCuenta].!");
                }
                else
                {
                    dt = ObjPerCta.Get_PerCuenta(cPerCodigo, cPerJurCodigo);
                    if (dt.Rows.Count > 0)
                    {
                        nPerCtaCodigo = Convert.ToInt32(dt.Rows[0]["nPerCtaCodigo"]);
                    }
                    else
                    {
                        throw new ApplicationException("Se encontro Cuenta Registra Persona. [Get_PerCuenta].!");
                    }
                }
            }

            return(nPerCtaCodigo);
        }
        //------------------------------------
        // Insert CtaCtePago / CtaCtePagDatos
        //------------------------------------
        public bool Ins_CtaCtePago_PagDatos(string cPerCodigo, string cPerJurCodigo, string cCtaCteRecibo, int nCaja, int nForPago, string cCtaCtePagNroOperacion, DateTime dCtaCtePagfecha, string CtaCtePagGlosa, double fCtaCtePagImporte, string cPerCodigoBanco, string cDescrBanco, string cNroTarjCta, string NroTrasacVoucher)
        {
            bool exito = false;

            try
            {
                using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required))
                {
                    int nCtaCtePagcodigo = 0;
                    int nPerCtaCodigo = 0;
                    //int vnCtaCteTipo = 0;

                    //-------------
                    //Get PerCuenta
                    //-------------
                    BL_PerCuenta ObjPerCta = new BL_PerCuenta();
                    DataTable dt = new DataTable();
                    dt = ObjPerCta.Get_PerCuenta(cPerCodigo, cPerJurCodigo);

                    if (dt.Rows.Count > 0)
                    {
                        nPerCtaCodigo = Convert.ToInt32(dt.Rows[0]["nPerCtaCodigo"]);
                        //vnCtaCteTipo = Convert.ToInt32(dt.Rows[0]["nPerCtaTipo"]);
                    }
                    else {
                        throw new ApplicationException("Persona <NO> tiene Numero Cuenta en. [PerCuenta].!");
                    }

                    //-------------------
                    //Insert: CtaCtePago
                    //-------------------
                    BL_CtaCtePago ObjPago = new BL_CtaCtePago();

                    //OUTPUT inserted.nCtaCtaPagCodigo (cm.ExecuteScalar())
                    nCtaCtePagcodigo = ObjPago.Ins_CtaCtePago(cCtaCteRecibo, cPerCodigo, nPerCtaCodigo, nCaja, nForPago, cCtaCtePagNroOperacion, dCtaCtePagfecha, CtaCtePagGlosa, fCtaCtePagImporte);

                    if (nCtaCtePagcodigo == 0) {
                        throw new ApplicationException("Se encontraron errores en la transaccion: [Ins_CtaCtePago].!");
                    }

                    //----------------------------------------------------------
                    //Insert CtaCtePagDatos.- (Solo es diferente de 1-Efectivo)
                    //----------------------------------------------------------
                    if (nForPago != 1)
                    {
                        BL_CtaCtePagDatos ObjPagDatos = new BL_CtaCtePagDatos();
                        exito = ObjPagDatos.Ins_CtaCtePagDatos(nCtaCtePagcodigo, cPerCodigoBanco, cDescrBanco, cNroTarjCta, dCtaCtePagfecha, NroTrasacVoucher, fCtaCtePagImporte);
                        if (!exito)
                        {
                            throw new ApplicationException("Se encontraron errores en la transaccion: [Ins_CtaCtePagDatos].!");
                        }
                    }
                    tx.Complete();
                }
            }
            catch (Exception)
            {
                throw;
            }
            return exito;
        }
Exemplo n.º 3
0
        //----------------------------------------------------------------------------
        // Insert PerCuenta / CuentaCorriente / Ins_CtaCteDetalle / Upd-FichaAtencion
        //----------------------------------------------------------------------------
        public bool Ins_CuentaCorriente_ProgracionPago(string cPerCodigo, string cPerJurCodigo, string nSolAdmNumero, int nAdmSolEstado, int nPerCtaTipo, double fCtaCteImporte, DateTime dCtaCteFecVence, DateTime dCtaCteFecEmis, string cGlosa, int nPrdCodigo, int nMonCodigo, List<BE_ReqCtaCteDetalle> ReqCCDetalle, string cPerCodigoAut)
        {
            bool exito = false;

            try
            {
                using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required))
                {
                    string cNroRecibo = "";
                    int nPerCtaCodigo = 0;
                    int vnCtaCteTipo = 0;

                    //Get PerCuenta
                    BL_PerCuenta ObjPerCta = new BL_PerCuenta();
                    DataTable dt = new DataTable();
                    dt = ObjPerCta.Get_PerCuenta(cPerCodigo, cPerJurCodigo);

                    if (dt.Rows.Count > 0)
                    {
                        nPerCtaCodigo = Convert.ToInt32(dt.Rows[0]["nPerCtaCodigo"]);
                        vnCtaCteTipo = Convert.ToInt32(dt.Rows[0]["nPerCtaTipo"]);
                    }
                    else
                    {
                        //Creando PerCuenta
                        if (!ObjPerCta.Ins_PerCuenta(cPerCodigo, nPerCtaTipo, cPerJurCodigo))
                        {
                            throw new ApplicationException("Se encontraron errores al Crear Cuenta Persona. [Ins_PerCuenta].!");
                        }
                        else
                        {
                            dt = ObjPerCta.Get_PerCuenta(cPerCodigo, cPerJurCodigo);
                            if (dt.Rows.Count > 0)
                            {
                                nPerCtaCodigo = Convert.ToInt32(dt.Rows[0]["nPerCtaCodigo"]);
                                vnCtaCteTipo = Convert.ToInt32(dt.Rows[0]["nPerCtaTipo"]);
                            }
                            else
                            {
                                throw new ApplicationException("Se encontro Cuenta Registra Persona. [Get_PerCuenta].!");
                            }
                        }
                    }

                    //Generar New Id Recibo
                    cNroRecibo = Get_NewCorrelativoRecCtaCteItem(cPerJurCodigo);

                    //para CuentaCorriente
                    BE_ReqCuentaCorriente ReqCtaCte = new BE_ReqCuentaCorriente();
                    DA_CuentaCorriente ObjCtaCte = new DA_CuentaCorriente();

                    ReqCtaCte.cCtaCteRecibo = cNroRecibo;
                    ReqCtaCte.nPerCtaCodigo = nPerCtaCodigo;
                    ReqCtaCte.nCtaCteTipo = vnCtaCteTipo;
                    ReqCtaCte.fCtaCteImporte = fCtaCteImporte;
                    ReqCtaCte.nCtaCteCuota = 0;
                    ReqCtaCte.nCtaCteEstado = 1;
                    ReqCtaCte.dCtaCteFecVence = dCtaCteFecVence;
                    //ReqCtaCte.dCtaCteFecPago = dCtaCteFecPago; //Para actualizar campo cuando realiza el pago.
                    ReqCtaCte.dCtaCteFecEmis = dCtaCteFecEmis;
                    ReqCtaCte.cCtaCteGlosa = cGlosa;  //"Programación Pago Ficha Atención";
                    ReqCtaCte.nPrdCodigo = nPrdCodigo;
                    ReqCtaCte.nMonCodigo = nMonCodigo;  //Periodo actual
                    ReqCtaCte.fCtaCteIgv = 0; //fCtaCteIgv;
                    ReqCtaCte.dCtaCteFecProg = dCtaCteFecEmis; //dCtaCteFecProg;
                    ReqCtaCte.cSerDescripcion = ""; //cSerDescripcion;
                    ReqCtaCte.fCtaCteSaldo = 0; //fCtaCteSaldo;

                    if (!ObjCtaCte.Ins_CuentaCorriente(ReqCtaCte))
                    {
                        throw new ApplicationException("Se encontraron errores en la transaccion: BL-Ins_CuentaCorriente.!");
                    }
                    else exito = true;

                    //------------------------------------------------
                    //Insert Ins_CtaCteDetalle: recorre todo la "List"
                    //------------------------------------------------
                    DA_CtaCteDetalle daCCDet = new DA_CtaCteDetalle();
                    foreach (BE_ReqCtaCteDetalle Item in ReqCCDetalle)
                    {
                        Item.cCtaCteRecibo = cNroRecibo; //Id. Recibo
                        exito = daCCDet.Ins_CtaCteDetalle(Item);
                        if (!exito)
                        {
                            break;
                            throw new ApplicationException("Se encontraron errores en la transaccion: [Ins_CtaCteDetalle].!");
                        }
                    }

                    //-------------------------------------------
                    //Actualizando AdmSolAtencion (cCtaCteRecibo)
                    //-------------------------------------------
                    BL_FichaAtencion.BL_FichaAtencion Obj_UpdFichaAtencion = new BL_FichaAtencion.BL_FichaAtencion();

                    if (!Obj_UpdFichaAtencion.Upd_AdmSolAtencion_for_cPerJuridica_nSolAdmNumero(cPerJurCodigo, nSolAdmNumero, cNroRecibo, nAdmSolEstado, cPerCodigoAut)) {
                        throw new ApplicationException("Se encontraron errores en la transaccion: BL-Upd_AdmSolAtencion_for_cPerJuridica_nSolAdmNumero.!");
                    }

                    tx.Complete();
                }
            }
            catch (Exception)
            {
                throw;
            }
            return exito;
        }
        //----------------------------------------------------------------------------
        // Insert PerCuenta / CuentaCorriente / Ins_CtaCteDetalle / Upd-FichaAtencion
        //----------------------------------------------------------------------------
        public bool Ins_CuentaCorriente_ProgracionPago(string cPerCodigo, string cPerJurCodigo, string nSolAdmNumero, int nAdmSolEstado, int nPerCtaTipo, int nIntClase, int nCtaCteCuota, double fCtaCteImporte, DateTime dCtaCteFecVence, DateTime dCtaCteFecEmis, string cGlosa, int nPrdCodigo, int nMonCodigo, List <BE_ReqCtaCteDetalle> ReqCCDetalle, string cPerCodigoAut)
        {
            bool exito = false;

            try
            {
                using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required))
                {
                    string cNroRecibo    = "";
                    int    nPerCtaCodigo = 0;
                    int    vnCtaCteTipo  = 0;

                    //Get PerCuenta
                    BL_PerCuenta ObjPerCta = new BL_PerCuenta();
                    DataTable    dt        = new DataTable();
                    dt = ObjPerCta.Get_PerCuenta(cPerCodigo, cPerJurCodigo);

                    if (dt.Rows.Count > 0)
                    {
                        nPerCtaCodigo = Convert.ToInt32(dt.Rows[0]["nPerCtaCodigo"]);
                        vnCtaCteTipo  = Convert.ToInt32(dt.Rows[0]["nPerCtaTipo"]);
                    }
                    else
                    {
                        //Creando PerCuenta
                        if (!ObjPerCta.Ins_PerCuenta(cPerCodigo, nPerCtaTipo, cPerJurCodigo))
                        {
                            throw new ApplicationException("Se encontraron errores al Crear Cuenta Persona. [Ins_PerCuenta].!");
                        }
                        else
                        {
                            dt = ObjPerCta.Get_PerCuenta(cPerCodigo, cPerJurCodigo);
                            if (dt.Rows.Count > 0)
                            {
                                nPerCtaCodigo = Convert.ToInt32(dt.Rows[0]["nPerCtaCodigo"]);
                                vnCtaCteTipo  = Convert.ToInt32(dt.Rows[0]["nPerCtaTipo"]);
                            }
                            else
                            {
                                throw new ApplicationException("Se encontro Cuenta Registra Persona. [Get_PerCuenta].!");
                            }
                        }
                    }


                    //Generar New Id Recibo
                    cNroRecibo = Get_NewCorrelativoRecCtaCteItem(cPerJurCodigo);

                    //para CuentaCorriente
                    BE_ReqCuentaCorriente ReqCtaCte = new BE_ReqCuentaCorriente();
                    DA_CuentaCorriente    ObjCtaCte = new DA_CuentaCorriente();

                    ReqCtaCte.cCtaCteRecibo   = cNroRecibo;
                    ReqCtaCte.nPerCtaCodigo   = nPerCtaCodigo;
                    ReqCtaCte.nCtaCteTipo     = vnCtaCteTipo;
                    ReqCtaCte.fCtaCteImporte  = fCtaCteImporte;
                    ReqCtaCte.nCtaCteCuota    = nCtaCteCuota;
                    ReqCtaCte.nCtaCteEstado   = 1;
                    ReqCtaCte.dCtaCteFecVence = dCtaCteFecVence;
                    //ReqCtaCte.dCtaCteFecPago = dCtaCteFecPago; //Para actualizar campo cuando realiza el pago.
                    ReqCtaCte.dCtaCteFecEmis  = dCtaCteFecEmis;
                    ReqCtaCte.cCtaCteGlosa    = cGlosa;         //"Programación Pago Ficha Atención";
                    ReqCtaCte.nPrdCodigo      = nPrdCodigo;
                    ReqCtaCte.nMonCodigo      = nMonCodigo;     //Periodo actual
                    ReqCtaCte.fCtaCteIgv      = 0;              //fCtaCteIgv;
                    ReqCtaCte.dCtaCteFecProg  = dCtaCteFecEmis; //dCtaCteFecProg;
                    ReqCtaCte.cSerDescripcion = "";             //cSerDescripcion;
                    ReqCtaCte.fCtaCteSaldo    = 0;              //fCtaCteSaldo;

                    if (!ObjCtaCte.Ins_CuentaCorriente(ReqCtaCte))
                    {
                        throw new ApplicationException("Se encontraron errores en la transaccion: BL-Ins_CuentaCorriente.!");
                    }
                    else
                    {
                        exito = true;
                    }

                    //------------------------------------------------
                    //Insert Ins_CtaCteDetalle: recorre todo la "List"
                    //------------------------------------------------
                    DA_CtaCteDetalle daCCDet = new DA_CtaCteDetalle();
                    foreach (BE_ReqCtaCteDetalle Item in ReqCCDetalle)
                    {
                        Item.cCtaCteRecibo = cNroRecibo; //Id. Recibo
                        exito = daCCDet.Ins_CtaCteDetalle(Item);
                        if (!exito)
                        {
                            break;
                            throw new ApplicationException("Se encontraron errores en la transaccion: [Ins_CtaCteDetalle].!");
                        }
                    }

                    //-------------------------------------------------------------------------------------
                    //Insert CtaCteIntDetalle .- se aplica cambio para realizar pagos multiples en la Ficha
                    //Update 2016-04-06(eincio) - Ins_CtaCteIntDetalle <nIntCodigo>=1 pagos normales
                    //-------------------------------------------------------------------------------------
                    BLCtaCteIntDetalle Servicio = new BLCtaCteIntDetalle();

                    if (!Servicio.Ins_CtaCteIntDetalle(cNroRecibo, 1, nIntClase, "", nSolAdmNumero))
                    {
                        throw new ApplicationException("Se encontraron errores en la transaccion: BL-Ins_CtaCteIntDetalle.!");
                    }

                    //-------------------------------------------
                    //Actualizando AdmSolAtencion (cCtaCteRecibo)
                    //-------------------------------------------
                    BL_FichaAtencion.BL_FichaAtencion Obj_UpdFichaAtencion = new BL_FichaAtencion.BL_FichaAtencion();

                    if (!Obj_UpdFichaAtencion.Upd_AdmSolAtencion_for_cPerJuridica_nSolAdmNumero(cPerJurCodigo, nSolAdmNumero, cNroRecibo, nAdmSolEstado, cPerCodigoAut))
                    {
                        throw new ApplicationException("Se encontraron errores en la transaccion: BL-Upd_AdmSolAtencion_for_cPerJuridica_nSolAdmNumero.!");
                    }

                    tx.Complete();
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(exito);
        }
        //------------------------------------
        // Insert CtaCtePago / CtaCtePagDatos
        //------------------------------------
        public bool Ins_CtaCtePago_PagDatos(string cPerCodigo, string cPerJurCodigo, string cCtaCteRecibo, int nCaja, int nForPago, string cCtaCtePagNroOperacion, DateTime dCtaCtePagfecha, string CtaCtePagGlosa, double fCtaCtePagImporte, string cPerCodigoBanco, string cDescrBanco, string cNroTarjCta, string NroTrasacVoucher)
        {
            bool exito = false;

            try
            {
                using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required))
                {
                    int nCtaCtePagcodigo = 0;
                    int nPerCtaCodigo    = 0;
                    //int vnCtaCteTipo = 0;

                    //-------------
                    //Get PerCuenta
                    //-------------
                    BL_PerCuenta ObjPerCta = new BL_PerCuenta();
                    DataTable    dt        = new DataTable();
                    dt = ObjPerCta.Get_PerCuenta(cPerCodigo, cPerJurCodigo);

                    if (dt.Rows.Count > 0)
                    {
                        nPerCtaCodigo = Convert.ToInt32(dt.Rows[0]["nPerCtaCodigo"]);
                        //vnCtaCteTipo = Convert.ToInt32(dt.Rows[0]["nPerCtaTipo"]);
                    }
                    else
                    {
                        throw new ApplicationException("Persona <NO> tiene Numero Cuenta en. [PerCuenta].!");
                    }

                    //-------------------
                    //Insert: CtaCtePago
                    //-------------------
                    BL_CtaCtePago ObjPago = new BL_CtaCtePago();

                    //OUTPUT inserted.nCtaCtaPagCodigo (cm.ExecuteScalar())
                    nCtaCtePagcodigo = ObjPago.Ins_CtaCtePago(cCtaCteRecibo, cPerCodigo, nPerCtaCodigo, nCaja, nForPago, cCtaCtePagNroOperacion, dCtaCtePagfecha, CtaCtePagGlosa, fCtaCtePagImporte);

                    if (nCtaCtePagcodigo == 0)
                    {
                        throw new ApplicationException("Se encontraron errores en la transaccion: [Ins_CtaCtePago].!");
                    }

                    //----------------------------------------------------------
                    //Insert CtaCtePagDatos.- (Solo es diferente de 1-Efectivo)
                    //----------------------------------------------------------
                    if (nForPago != 1)
                    {
                        BL_CtaCtePagDatos ObjPagDatos = new BL_CtaCtePagDatos();
                        exito = ObjPagDatos.Ins_CtaCtePagDatos(nCtaCtePagcodigo, cPerCodigoBanco, cDescrBanco, cNroTarjCta, dCtaCtePagfecha, NroTrasacVoucher, fCtaCtePagImporte);
                        if (!exito)
                        {
                            throw new ApplicationException("Se encontraron errores en la transaccion: [Ins_CtaCtePagDatos].!");
                        }
                    }
                    tx.Complete();
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(exito);
        }