/*guardando conjunto de registro utilizando Listas List*/ public bool Insert_CtaCteDetalle(List <BE_ReqCtaCteDetalle> listCtaCteDetalle) { bool exito = true; DA_CtaCteDetalle ctaCteDetalleDAO = new DA_CtaCteDetalle(); foreach (BE_ReqCtaCteDetalle Item in listCtaCteDetalle) { exito = ctaCteDetalleDAO.Ins_CtaCteDetalle(Item); if (!exito) { break; throw new ApplicationException("Se encontraron errores en la transaccion: [Insert_CtaCteDetalle].!"); } } return(exito); }
public DataTable Get_CtaCteDetalle(BE_ReqCtaCteDetalle ctaCteDetalle) { DA_CtaCteDetalle Obj = new DA_CtaCteDetalle(); return(Obj.Get_CtaCteDetalle(ctaCteDetalle)); }
//---------------------------------------------------------------------------- // 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; }
//-------------- //Realizar Pago //--------------- public bool Ins_RealizarPago(string cPerJurCodigo, string cPerCodigo, long nPrdCodigo, string cTipCtaCodigo, string cCtaCteRecCargo, Dictionary <string, double> ListRecibo, string cPerUserCodigo, long nCajCodigo, long nCtaCteComCodigo, string cCtaCteComNumero, DateTime dFecRegistro, double ImporteTotal, double ImportePago, double ImporteAmortizado, string cCtaCteObserv, List <BE_ReqCtaCteDetalle> ReqCCDetalle) { bool exito = false; long nCtaCtaPagCodigo = 0; string cCtaCteRecAbono = ""; //double PagImporte=0; //DateTime sFecTrans = new DateTime() ; //CtaCtePago BL_CtaCtePago blCCPago = new BL_CtaCtePago(); //CtaCteComprobante BL_CtaCteComprobante BLComp = new BL_CtaCteComprobante(); //CtaCteDetalle DA_CtaCteDetalle daCCDet = new DA_CtaCteDetalle(); //CtaCteItem BL_CtaCteItem blCCItem = new BL_CtaCteItem(); //CtaCteIteLine BL_CtaCteIteLine blCCIteLine = new BL_CtaCteIteLine(); //CtaCteReferencia BL_CtaCteReferencia blCCRefe = new BL_CtaCteReferencia(); //Update CtaCteItem BL_CtaCteItem daCCItem = new BL_CtaCteItem(); //Update Correlativo BL_CtaCteNumeracion blCCNumeracion = new BL_CtaCteNumeracion(); try { using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required)) { //Genera nuevo recibo pero en Negativo(-) en la tabla [CtaCteItem] cCtaCteRecAbono = blCCItem.Ins_CtaCteItem(cPerJurCodigo, cPerCodigo, nPrdCodigo, cTipCtaCodigo, dFecRegistro.Year, -ImportePago, dFecRegistro, 1); if (cCtaCteRecAbono == null) { throw new ApplicationException("Se encontro Nro. Recibo que va a cancelar: [Get_CtaCteItem].!"); } //-----------------/ //CtaCteComprobante //-----------------/ if (ImporteAmortizado == 0) { if (nCtaCteComCodigo == 3005) //Recibo Ingreso { long nCtaCteComCodigoComp = 0; string cCtaCteComNumeroComp = ""; BL_CtaCteNumeracion BLCorrelativo = new BL_CtaCteNumeracion(); //Genera Recibo (99) en CtaCteComprobante nCtaCteComCodigoComp = 3006; //RECIBO (REC) cCtaCteComNumeroComp = BLCorrelativo.Get_CtaCteNumCorrelativo(cPerJurCodigo, 0, nCtaCteComCodigoComp); if (!BLComp.Ins_CtaCteComprobante(cPerJurCodigo, cPerCodigo, cCtaCteRecAbono, nCajCodigo, nCtaCteComCodigoComp, cCtaCteComNumeroComp, dFecRegistro, ImporteTotal, cPerUserCodigo)) { throw new ApplicationException("Se encontraron errores en la transaccion: [Ins_CtaCteComprobante].!"); } //Update Correlativo si pasa por este bucle Recibo 3006 BL_CtaCteNumeracion BLUpdCorrelativo = new BL_CtaCteNumeracion(); int valor = cCtaCteComNumeroComp.Length - 8; string resultCorre = cCtaCteComNumeroComp.Substring(valor, 8); long NumeroNew = 0; NumeroNew = Convert.ToInt32(resultCorre); if (!BLUpdCorrelativo.Upd_CtaCteNumeracion_nCtaCteNumero(cPerJurCodigo, 0, nCtaCteComCodigoComp, NumeroNew)) { throw new ApplicationException("Se encontraron errores en la transaccion a Update nCtaCteComCodigo-3006: [Upd_CtaCteNumeracion_nCtaCteNumero].!"); } } else { if (!BLComp.Ins_CtaCteComprobante(cPerJurCodigo, cPerCodigo, cCtaCteRecAbono, nCajCodigo, nCtaCteComCodigo, cCtaCteComNumero, dFecRegistro, ImporteTotal, cPerUserCodigo)) { throw new ApplicationException("Se encontraron errores en la transaccion: [Ins_CtaCteComprobante].!"); } } } //<- //-------------- //Ins_CtaCtePago //-------------- nCtaCtaPagCodigo = blCCPago.Ins_CtaCtePago(cPerJurCodigo, cPerCodigo, cCtaCteRecAbono, nCajCodigo, nCtaCteComCodigo, cCtaCteComNumero, cPerUserCodigo, cCtaCteObserv); //OUTPUT inserted.nCtaCtaPagCodigo (cm.ExecuteScalar()) //----------------- //Ins_CtaCteDetalle //----------------- foreach (BE_ReqCtaCteDetalle Item in ReqCCDetalle) { Item.nCtaCtePagCodigo = nCtaCtaPagCodigo; //paso el autogenerado de CtaCtePago(nCtaCtePagCodigo) exito = daCCDet.Ins_CtaCteDetalle(Item); //PagImporte = PagImporte + Item.nCtaCtePagImporte; //sFecTrans = Item.dCtaCteFecTransacion; if (!exito) { break; throw new ApplicationException("Se encontraron errores en la transaccion: [Ins_CtaCteDetalle].!"); } } //Nuevo Cambio if (ListRecibo.Count == 0) /*Pago Simple*/ { //---------------- //CtaCteReferencia //---------------- if (!blCCRefe.Ins_CtaCteReferencia(cPerJurCodigo, cPerCodigo, cCtaCteRecCargo, cCtaCteRecAbono, nCtaCtaPagCodigo, ImportePago, "", dFecRegistro)) //PagImporte { throw new ApplicationException("Se encontraron errores en la transaccion: [Ins_CtaCteReferencia].!"); } //------------------------------------ // Actualizar campo nCtaCteImpAplicado //------------------------------------ if (!daCCItem.Upd_CtaCteItem_nCtaCteImpAplicado(cPerJurCodigo, cCtaCteRecCargo, ImportePago, "CANCELA")) //PagImporte { throw new ApplicationException("Se encontraron errores en la transaccion: [Upd_CtaCteItem_nCtaCteImpAplicado].!"); } } else { //Aqui tengo que recorrer los recibos seleccionados *Pago Multiple* foreach (KeyValuePair <string, double> pair in ListRecibo) { //---------------- //CtaCteReferencia //---------------- if (!blCCRefe.Ins_CtaCteReferencia(cPerJurCodigo, cPerCodigo, pair.Key, cCtaCteRecAbono, nCtaCtaPagCodigo, pair.Value, "", dFecRegistro)) //PagImporte { throw new ApplicationException("Se encontraron errores en la transaccion: [Ins_CtaCteReferencia].!"); } //------------------------------------ // Actualizar campo nCtaCteImpAplicado //------------------------------------ //if (!daCCItem.Upd_CtaCteItem_nCtaCteImpAplicado(cPerJurCodigo, cCtaCteRecCargo, ImportePago, "CANCELA")) //PagImporte if (!daCCItem.Upd_CtaCteItem_nCtaCteImpAplicado(cPerJurCodigo, pair.Key, pair.Value, "CANCELA")) //PagImporte { throw new ApplicationException("Se encontraron errores en la transaccion: [Upd_CtaCteItem_nCtaCteImpAplicado].!"); } } ListRecibo.Clear(); } //------------------------------------------- // Actualizar CtaCteNumeracion(nCtaCteNumero) //------------------------------------------- int value = cCtaCteComNumero.Length - 8; string result = cCtaCteComNumero.Substring(value, 8); long Numeracion = 0; Numeracion = Convert.ToInt32(result); if (!blCCNumeracion.Upd_CtaCteNumeracion_nCtaCteNumero(cPerJurCodigo, nCajCodigo, nCtaCteComCodigo, Numeracion)) { throw new ApplicationException("Se encontraron errores en la transaccion: [Upd_CtaCteItem_nCtaCteImpAplicado].!"); } 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); }