public cp_orden_giro_Info Get_Info_orden_giro(int IdEmpresa ,int IdTipoCbte_Ogiro,decimal IdCbteCble_Ogiro) { try { return data.Get_Info_orden_giro(IdEmpresa, IdTipoCbte_Ogiro, IdCbteCble_Ogiro); } catch (Exception ex) { Core.Erp.Info.Log_Exception.LoggingManager.Logger.Log(Core.Erp.Info.Log_Exception.LoggingCategory.Error, ex.Message); throw new Core.Erp.Info.Log_Exception.DalException(string.Format("", "Get_Info_orden_giro", ex.Message), ex) { EntityType = typeof(cp_orden_giro_Bus) }; } }
public bool ModificarDB(cp_orden_giro_Info InfoOrdenGiro_I, ref string msg) { Boolean res = true; try { cp_orden_giro_Info info = new cp_orden_giro_Info(); info.IdEmpresa = InfoOrdenGiro_I.IdEmpresa; info.IdTipoCbte_Ogiro = InfoOrdenGiro_I.IdTipoCbte_Ogiro; info.IdCbteCble_Ogiro = InfoOrdenGiro_I.IdCbteCble_Ogiro; cp_orden_giro_Data odata = new cp_orden_giro_Data(); info = odata.Get_Info_orden_giro(info); if (info.co_serie == InfoOrdenGiro_I.co_serie && info.co_factura == InfoOrdenGiro_I.co_factura) { // no valido } else { //valido if (data.ExisteFacturaPorProveedor(InfoOrdenGiro_I.IdEmpresa, InfoOrdenGiro_I.IdProveedor, InfoOrdenGiro_I.co_serie, InfoOrdenGiro_I.co_factura)) { msg = "La Factura#: " + InfoOrdenGiro_I.co_serie + "-" + InfoOrdenGiro_I.co_factura + ". Ya se encuentra ingresada"; res = false; return(false); } } //diario contable x OG if (CbteCble_B.ModificarDB(InfoOrdenGiro_I.Info_CbteCble_x_OG, ref msg)) { //OG cp_orden_giro_Data OdataOG = new cp_orden_giro_Data(); if (OdataOG.ModificarDB(InfoOrdenGiro_I, ref msg)) { #region reembolso formaspago y retenciones InfoOrdenGiro_I.lst_formasPagoSRI.ForEach(p => { p.IdCbteCble_Ogiro = InfoOrdenGiro_I.IdCbteCble_Ogiro; p.IdTipoCbte_Ogiro = InfoOrdenGiro_I.IdTipoCbte_Ogiro; }); if (!pagoSRI_B.ModificarDB(InfoOrdenGiro_I.lst_formasPagoSRI, InfoOrdenGiro_I.IdEmpresa, InfoOrdenGiro_I.IdCbteCble_Ogiro, InfoOrdenGiro_I.IdTipoCbte_Ogiro, ref msg)) { msg = "No se pudo Modificar la(s) forma(s) de pago \n Comuníquese con sistemas por favor"; res = false; } if (InfoOrdenGiro_I.Info_Retencion != null && InfoOrdenGiro_I.Info_Retencion.Info_CbteCble_x_RT != null) { if (InfoOrdenGiro_I.Info_Retencion.IdEmpresa != 0) { // Verificar Retencion cp_retencion_Bus bus_Reten = new cp_retencion_Bus(); if (bus_Reten.Existe_Retencion(InfoOrdenGiro_I.Info_Retencion.IdEmpresa, InfoOrdenGiro_I.Info_Retencion.IdRetencion)) { //Modifica if (!Bus_Retencion.ModificarDB(InfoOrdenGiro_I.Info_Retencion, InfoOrdenGiro_I.Info_Retencion.Info_CbteCble_x_RT, ref msg)) { msg = "No se pudo Actualizar las retenciones"; res = false; } } else { InfoOrdenGiro_I.Info_Retencion.IdCbteCble_Ogiro = InfoOrdenGiro_I.IdCbteCble_Ogiro; if (Bus_Retencion.Graba_CbteCble_Ret_FactProveedor(InfoOrdenGiro_I.Info_Retencion, InfoOrdenGiro_I.Info_Retencion.Info_CbteCble_x_RT, ref mensaje)) { //actualizando el suencial de la retencion serie y #retencion Bus_Retencion.Modificar_Num_Retencion(InfoOrdenGiro_I.Info_Retencion, ref mensaje); } else { mensaje = "Hubo un inconveniente al ingresar la retención comuniquese con sistemas.." + mensaje; res = false; } } } } #endregion if (InfoOrdenGiro_I.Info_cuotas_x_doc.lst_cuotas_det.Count != 0) { InfoOrdenGiro_I.Info_cuotas_x_doc.IdEmpresa_ct = InfoOrdenGiro_I.IdEmpresa; InfoOrdenGiro_I.Info_cuotas_x_doc.IdTipoCbte = InfoOrdenGiro_I.IdTipoCbte_Ogiro; InfoOrdenGiro_I.Info_cuotas_x_doc.IdCbteCble = InfoOrdenGiro_I.IdCbteCble_Ogiro; bus_cuotas_x_doc.GuardarDB(InfoOrdenGiro_I.Info_cuotas_x_doc); } msg = "La Fact. Proveedor # " + InfoOrdenGiro_I.IdCbteCble_Ogiro + " se modificó Exitósamente"; } } } catch (Exception ex) { Core.Erp.Info.Log_Exception.LoggingManager.Logger.Log(Core.Erp.Info.Log_Exception.LoggingCategory.Error, ex.Message); throw new Core.Erp.Info.Log_Exception.DalException(string.Format("", "ModificarFacturaProveedor", ex.Message), ex) { EntityType = typeof(cp_orden_giro_Bus) }; } return(res); }
public bool ModificarDB(cp_orden_giro_Info InfoOrdenGiro_I, ref string msg) { Boolean res = true; try { cp_orden_giro_Info info = new cp_orden_giro_Info(); info.IdEmpresa = InfoOrdenGiro_I.IdEmpresa; info.IdTipoCbte_Ogiro = InfoOrdenGiro_I.IdTipoCbte_Ogiro; info.IdCbteCble_Ogiro = InfoOrdenGiro_I.IdCbteCble_Ogiro; cp_orden_giro_Data odata = new cp_orden_giro_Data(); info = odata.Get_Info_orden_giro(info); if (info.co_serie == InfoOrdenGiro_I.co_serie && info.co_factura == InfoOrdenGiro_I.co_factura) { // no valido } else { //valido if (data.ExisteFacturaPorProveedor(InfoOrdenGiro_I.IdEmpresa, InfoOrdenGiro_I.IdProveedor, InfoOrdenGiro_I.co_serie, InfoOrdenGiro_I.co_factura)) { msg = "La Factura#: " + InfoOrdenGiro_I.co_serie + "-" + InfoOrdenGiro_I.co_factura + ". Ya se encuentra ingresada"; res = false; return(false); } } //diario contable x OG if (CbteCble_B.ModificarDB(InfoOrdenGiro_I.Info_CbteCble_x_OG, ref msg)) { //OG cp_orden_giro_Data OdataOG = new cp_orden_giro_Data(); if (OdataOG.ModificarDB(InfoOrdenGiro_I, ref msg)) { #region reembolso formaspago y retenciones InfoOrdenGiro_I.lst_reembolso.ForEach(p => { p.IdCbteCble_Ogiro = InfoOrdenGiro_I.IdCbteCble_Ogiro; p.IdTipoCbte_Ogiro = InfoOrdenGiro_I.IdTipoCbte_Ogiro; }); if (!Reem_B.ModificarLst(InfoOrdenGiro_I.lst_reembolso, InfoOrdenGiro_I.IdEmpresa, InfoOrdenGiro_I.IdCbteCble_Ogiro, InfoOrdenGiro_I.IdTipoCbte_Ogiro)) { msg = "No se pudo Modificar lo(s) reembolso(s) \n Comuníquese con sistemas por favor"; res = false; } InfoOrdenGiro_I.lst_formasPagoSRI.ForEach(p => { p.IdCbteCble_Ogiro = InfoOrdenGiro_I.IdCbteCble_Ogiro; p.IdTipoCbte_Ogiro = InfoOrdenGiro_I.IdTipoCbte_Ogiro; }); if (!pagoSRI_B.ModificarDB(InfoOrdenGiro_I.lst_formasPagoSRI, InfoOrdenGiro_I.IdEmpresa, InfoOrdenGiro_I.IdCbteCble_Ogiro, InfoOrdenGiro_I.IdTipoCbte_Ogiro, ref msg)) { msg = "No se pudo Modificar la(s) forma(s) de pago \n Comuníquese con sistemas por favor"; res = false; } if (InfoOrdenGiro_I.Info_Retencion != null && InfoOrdenGiro_I.Info_Retencion.Info_CbteCble_x_RT != null) { if (InfoOrdenGiro_I.Info_Retencion.IdEmpresa != 0) { // Verificar Retencion cp_retencion_Bus bus_Reten = new cp_retencion_Bus(); if (bus_Reten.Existe_Retencion(InfoOrdenGiro_I.Info_Retencion.IdEmpresa, InfoOrdenGiro_I.Info_Retencion.IdRetencion)) { //Modifica if (!Bus_Retencion.ModificarDB(InfoOrdenGiro_I.Info_Retencion, InfoOrdenGiro_I.Info_Retencion.Info_CbteCble_x_RT, ref msg)) { msg = "No se pudo Actualizar las retenciones"; res = false; } } else { InfoOrdenGiro_I.Info_Retencion.IdCbteCble_Ogiro = InfoOrdenGiro_I.IdCbteCble_Ogiro; if (Bus_Retencion.Graba_CbteCble_Ret_FactProveedor(InfoOrdenGiro_I.Info_Retencion, InfoOrdenGiro_I.Info_Retencion.Info_CbteCble_x_RT, ref mensaje)) { //actualizando el suencial de la retencion serie y #retencion Bus_Retencion.Modificar_Num_Retencion(InfoOrdenGiro_I.Info_Retencion, ref mensaje); } else { mensaje = "Hubo un inconveniente al ingresar la retención comuniquese con sistemas.." + mensaje; res = false; } } } } #endregion if (InfoOrdenGiro_I.Info_cuotas_x_doc.lst_cuotas_det.Count != 0) { InfoOrdenGiro_I.Info_cuotas_x_doc.IdEmpresa_ct = InfoOrdenGiro_I.IdEmpresa; InfoOrdenGiro_I.Info_cuotas_x_doc.IdTipoCbte = InfoOrdenGiro_I.IdTipoCbte_Ogiro; InfoOrdenGiro_I.Info_cuotas_x_doc.IdCbteCble = InfoOrdenGiro_I.IdCbteCble_Ogiro; bus_cuotas_x_doc.GuardarDB(InfoOrdenGiro_I.Info_cuotas_x_doc); } List <imp_ordencompra_ext_x_ct_cbtecble_Info> Tab_Int = ocXcbt_B.Get_List_ordencompra_ext_x_ct_cbtecble(InfoOrdenGiro_I.IdEmpresa, InfoOrdenGiro_I.IdTipoCbte_Ogiro, InfoOrdenGiro_I.IdCbteCble_Ogiro, ref msg); if (Tab_Int == null || Tab_Int.Count < 1) { #region if (InfoOrdenGiro_I.LstImportacionGrid.Count() > 0) { InfoOrdenGiro_I.LstImportacionGrid.ForEach(p => p.IdCbteCble = InfoOrdenGiro_I.IdCbteCble_Ogiro); if (ocXgastosxImp_B.GuardarDB(InfoOrdenGiro_I.LstImportacionGrid, ref mensaje)) { InfoOrdenGiro_I.LstocXcbt_I.ForEach(p => p.ct_IdCbteCble = InfoOrdenGiro_I.IdCbteCble_Ogiro); if (ocXcbt_B.GuardarDB(InfoOrdenGiro_I.LstocXcbt_I, ref mensaje)) { InfoOrdenGiro_I.LisImportacion.ForEach(p => p.og_IdCbteCble = InfoOrdenGiro_I.IdCbteCble_Ogiro); if (Importacion_B.GrabarDB(InfoOrdenGiro_I.LisImportacion, ref mensaje)) { InfoOrdenGiro_I.LstImportacionOC.ForEach(p => p.og_IdCbteCble = InfoOrdenGiro_I.IdCbteCble_Ogiro); if (!OC_B.GrabarDB(InfoOrdenGiro_I.LstImportacionOC, ref mensaje)) { mensaje = "Hubo un inconveniente al ingresar la importación comuniquese con sistemas.." + mensaje; res = false; } } else { mensaje = "Hubo un inconveniente al ingresar la importación comuniquese con sistemas.." + mensaje; res = false; } } else { mensaje = "Hubo un inconveniente al ingresar la importación comuniquese con sistemas.." + mensaje; res = false; } } else { mensaje = "Hubo un inconveniente al ingresar la importación comuniquese con sistemas.." + mensaje; res = false; } } #endregion } else { List <imp_ordencompra_ext_x_imp_gastosxImport_Info> a = ocXgastosxImp_B.Get_List_ordencompra_ext_x_imp_gastosxImport(Tab_Int[0].imp_IdEmpresa, Tab_Int[0].imp_IdSucusal, Tab_Int[0].imp_IdOrdenCompraExt); List <imp_ordencompra_ext_x_imp_gastosxImport_Info> b = new List <imp_ordencompra_ext_x_imp_gastosxImport_Info>(); if (a != null) { b = a.FindAll(q => Convert.ToInt32(q.IdTipoCbte) == InfoOrdenGiro_I.IdTipoCbte_Ogiro && Convert.ToDecimal(q.IdCbteCble) == InfoOrdenGiro_I.IdCbteCble_Ogiro); } //eliminar tabla intermedia ocXcbt_B.EliminarDB(Tab_Int[0].ct_IdEmpresa, Tab_Int[0].ct_IdCbteCble, Tab_Int[0].ct_IdTipoCbte); imp_ordencompra_ext_x_imp_gastosxImport_Det_Bus detBus = new imp_ordencompra_ext_x_imp_gastosxImport_Det_Bus(); foreach (imp_ordencompra_ext_x_imp_gastosxImport_Info item in b) { if (!detBus.EliminarDB(item, ref msg)) { return(false); } if (!ocXgastosxImp_B.EliminarDB(item.IdEmpresa, item.IdSucusal, item.IdOrdenCompraExt, item.IdRegistroGasto, ref msg)) { return(false); } } if (InfoOrdenGiro_I.LstImportacionGrid.Count() > 0) { InfoOrdenGiro_I.LstImportacionGrid.ForEach(p => p.IdCbteCble = InfoOrdenGiro_I.IdCbteCble_Ogiro); if (!ocXgastosxImp_B.GuardarDB(InfoOrdenGiro_I.LstImportacionGrid, ref mensaje)) { return(false); } InfoOrdenGiro_I.LstocXcbt_I.ForEach(p => p.ct_IdCbteCble = InfoOrdenGiro_I.IdCbteCble_Ogiro); if (!ocXcbt_B.GuardarDB(InfoOrdenGiro_I.LstocXcbt_I, ref mensaje)) { return(false); } var d = Importacion_B.Get_List_orden_giro_x_imp_ordencompra_ext(Tab_Int[0].ct_IdEmpresa, Tab_Int[0].ct_IdCbteCble, Tab_Int[0].ct_IdTipoCbte); if (d != null) { Importacion_B.EliminarDB(d); InfoOrdenGiro_I.LisImportacion.ForEach(p => p.og_IdCbteCble = InfoOrdenGiro_I.IdCbteCble_Ogiro); if (!Importacion_B.GrabarDB(InfoOrdenGiro_I.LisImportacion, ref mensaje)) { return(false); } var e = OC_B.Get_List_orden_giro_x_com_ordencompra_local(Tab_Int[0].ct_IdEmpresa, Tab_Int[0].ct_IdCbteCble, Tab_Int[0].ct_IdTipoCbte); if (e != null) { OC_B.EliminarLista(e); InfoOrdenGiro_I.LstImportacionOC.ForEach(p => p.og_IdCbteCble = InfoOrdenGiro_I.IdCbteCble_Ogiro); if (!OC_B.GrabarDB(InfoOrdenGiro_I.LstImportacionOC, ref mensaje)) { mensaje = "Hubo un inconveniente al ingresar la importación comuniquese con sistemas.." + mensaje; res = false; } } } //} } } msg = "La Fact. Proveedor # " + InfoOrdenGiro_I.IdCbteCble_Ogiro + " se modificó Exitósamente"; } } } catch (Exception ex) { Core.Erp.Info.Log_Exception.LoggingManager.Logger.Log(Core.Erp.Info.Log_Exception.LoggingCategory.Error, ex.Message); throw new Core.Erp.Info.Log_Exception.DalException(string.Format("", "ModificarFacturaProveedor", ex.Message), ex) { EntityType = typeof(cp_orden_giro_Bus) }; } return(res); }
public List <cp_nota_DebCre_Info> Get_List_nota_DebCre(int IdEmpresa, int anio, int mes) { try { List <cp_nota_DebCre_Info> lM = new List <cp_nota_DebCre_Info>(); EntitiesCuentasxPagar Base = new EntitiesCuentasxPagar(); string msg = ""; var select_ = from T in Base.vwcp_nota_DebCre_ATS where T.IdEmpresa == IdEmpresa && T.cn_fecha.Year == anio && T.cn_fecha.Month == mes && T.Estado == "A" select T; foreach (var item in select_) { cp_nota_DebCre_Info dat = new cp_nota_DebCre_Info(); dat.IdEmpresa = item.IdEmpresa; dat.IdCbteCble_Nota = item.IdCbteCble_Nota; dat.IdTipoCbte_Nota = item.IdTipoCbte_Nota; dat.IdProveedor = item.IdProveedor; dat.cn_fecha = item.cn_fecha; dat.cn_serie1 = item.cn_serie1; dat.cn_serie2 = item.cn_serie2; dat.cn_Nota = item.cn_Nota; dat.cn_observacion = item.cn_observacion; dat.cn_subtotal_iva = item.cn_subtotal_iva; dat.cn_subtotal_siniva = item.cn_subtotal_siniva; dat.cn_baseImponible = item.cn_baseImponible; dat.cn_Por_iva = item.cn_Por_iva; dat.cn_valoriva = item.cn_valoriva; dat.IdCod_ICE = item.IdCod_ICE; dat.cn_Ice_base = item.cn_Ice_base; dat.cn_Ice_por = item.cn_Ice_por; dat.cn_Ice_valor = item.cn_Ice_valor; dat.cn_Serv_por = item.cn_Serv_por; dat.cn_Serv_valor = item.cn_Serv_valor; dat.cn_BaseSeguro = item.cn_BaseSeguro; dat.cn_total = item.cn_total; dat.cn_vaCoa = item.cn_vaCoa; dat.cn_Autorizacion = item.cn_Autorizacion; dat.IdTipoServicio = item.IdTipoServicio; dat.IdCtaCble_Acre = item.IdCtaCble_Acre; dat.IdCtaCble_IVA = item.IdCtaCble_IVA; dat.IdUsuario = item.IdUsuario; dat.Fecha_Transac = item.Fecha_Transac; dat.Estado = item.Estado; dat.IdUsuarioUltMod = item.IdUsuarioUltMod; dat.Fecha_UltMod = item.Fecha_UltMod; dat.IdUsuarioUltAnu = item.IdUsuarioUltAnu; dat.MotivoAnu = item.MotivoAnu; dat.nom_pc = item.nom_pc; dat.ip = item.ip; dat.Fecha_UltAnu = item.Fecha_UltAnu; dat.IdCbteCble_Anulacion = item.IdCbteCble_Anulacion; dat.IdTipoCbte_Anulacion = item.IdTipoCbte_Anulacion; dat.cn_tipoLocacion = item.cn_tipoLocacion; dat.IdCentroCosto = item.IdCentroCosto; dat.IdSucursal = item.IdSucursal; dat.IdTipoFlujo = item.IdTipoFlujo; dat.DebCre = (item.DebCre == "C") ? "Credito" : "Debito"; dat.IdIden_credito = item.IdIden_credito; dat.IdTipoNota = item.IdTipoNota; dat.cn_Autorizacion_Imprenta = null; dat.PagoLocExt = item.PagoLocExt; dat.PaisPago = item.PaisPago; dat.ConvenioTributacion = item.ConvenioTributacion; dat.PagoSujetoRetencion = item.PagoSujetoRetencion; dat.fecha_autorizacion = Convert.ToDateTime(item.fecha_autorizacion); dat.Num_Nota = "NT" + item.DebCre + "#:" + item.cn_serie1 + "-" + item.cn_serie2 + "-" + item.cn_Nota; dat.cn_Fecha_vcto = item.cn_Fecha_vcto; dat.InfoProveedor.IdProveedor = item.IdProveedor; dat.InfoProveedor.Persona_Info.IdTipoDocumento = item.IdTipoDocumento; dat.InfoProveedor.Persona_Info.pe_cedulaRuc = item.pe_cedulaRuc; dat.InfoProveedor.Persona_Info.pe_Naturaleza = item.pe_Naturaleza; dat.InfoProveedor.Persona_Info.pe_razonSocial = item.pe_razonSocial; cp_orden_pago_cancelaciones_Data Odata_can = new cp_orden_pago_cancelaciones_Data(); cp_orden_pago_cancelaciones_Info Info_cance = new cp_orden_pago_cancelaciones_Info(); Info_cance = Odata_can.Get_list_Cancelacion_x_Pagos(dat.IdEmpresa, dat.IdTipoCbte_Nota, dat.IdCbteCble_Nota, ref msg).FirstOrDefault(); if (Info_cance != null) { cp_orden_giro_Data OG_data = new cp_orden_giro_Data(); cp_orden_giro_Info Info_Og = new cp_orden_giro_Info(); Info_Og = OG_data.Get_Info_orden_giro(Convert.ToInt32(Info_cance.IdEmpresa_cxp), Convert.ToInt32(Info_cance.IdTipoCbte_cxp), Convert.ToDecimal(Info_cance.IdCbteCble_cxp)); if (Info_Og.IdEmpresa != 0) { dat.docModificado = Info_Og.IdOrden_giro_Tipo; dat.estabModificado = Info_Og.co_serie.Substring(0, 3); dat.ptoEmiModificado = Info_Og.co_serie.Substring(4, 3); dat.secModificado = Info_Og.co_factura; dat.autModificado = Info_Og.Num_Autorizacion; dat.cn_num_doc_modificado = Info_Og.co_factura; } lM.Add(dat); } } return(lM); } catch (Exception ex) { string arreglo = ToString(); tb_sis_Log_Error_Vzen_Data oDataLog = new tb_sis_Log_Error_Vzen_Data(); tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); mensaje = ex.ToString() + " " + ex.Message; throw new Exception(ex.ToString()); } }