public List <vwImp_OrdenCompraExt_X_CbteCble_Info> Get_List_OrdenCompraExt_X_CbteCble_x_DiariosXgastos(int IdEmpresa, int IdSucursal, decimal IdOrdenCompra, decimal IdRegistrosGasto) { List <vwImp_OrdenCompraExt_X_CbteCble_Info> lst = new List <vwImp_OrdenCompraExt_X_CbteCble_Info>(); try { using (EntitiesImportacion oContext = new EntitiesImportacion()) { string Query = "select a.*,a.cb_Fecha as Fecha ,b.tc_TipoCbte as tipoCTCB from ct_cbtecble a inner join ct_cbtecble_tipo b on a.IdTipoCbte= b.IdTipoCbte" + " where IdCbteCble = (select IdCbteCble from dbo.imp_ordencompra_ext_x_imp_gastosxImport where IdRegistroGasto=" + IdRegistrosGasto + " and IdEmpresa =" + IdEmpresa + " and IdSucusal =" + IdSucursal + " and IdOrdenCompraExt=" + IdOrdenCompra + ") and IdEmpresa =" + IdEmpresa + " and a.IdTipoCbte = (select IdTipoCbte from dbo.imp_ordencompra_ext_x_imp_gastosxImport where IdRegistroGasto=" + IdRegistrosGasto + " and IdEmpresa=" + IdEmpresa + " and IdSucusal =" + IdSucursal + " and IdOrdenCompraExt=" + IdOrdenCompra + ") " + " union" + " select a.* ,a.cb_Fecha as Fecha ,b.tc_TipoCbte as tipoCTCB from ct_cbtecble a inner join ct_cbtecble_tipo b on a.IdTipoCbte= b.IdTipoCbte " + " where IdCbteCble = (select IdCbteCble_Anu from dbo.imp_ordencompra_ext_x_imp_gastosxImport where IdRegistroGasto=" + IdRegistrosGasto + " and IdEmpresa =" + IdEmpresa + " and IdSucusal =" + IdSucursal + " and IdOrdenCompraExt=" + IdOrdenCompra + ") and IdEmpresa =" + IdEmpresa + " and a.IdTipoCbte = (select IdTipoCbte_Anu from dbo.imp_ordencompra_ext_x_imp_gastosxImport where IdRegistroGasto=" + IdRegistrosGasto + " and IdEmpresa =" + IdEmpresa + " and IdSucusal =" + IdSucursal + " and IdOrdenCompraExt=" + IdOrdenCompra + ") "; var Consulta = oContext.Database.SqlQuery <ct_Cbtecble_Info>(Query); List <ct_Cbtecble_Info> lstCt = new List <ct_Cbtecble_Info>(); lstCt = Consulta.ToList(); foreach (var item in lstCt) { vwImp_OrdenCompraExt_X_CbteCble_Info Info = new vwImp_OrdenCompraExt_X_CbteCble_Info(); Info.IdCbte = item.IdCbteCble; Info.CodCbte = item.CodCbteCble; Info.Estado = item.Estado; Info.Fecha = item.cb_Fecha; Info.Valor = item.cb_Valor; Info.Observacion = item.cb_Observacion; Info.TipoComprobanteContable = item.tipoCTCB; Info.IdEmpresa = IdEmpresa; Info.IdSucursal = IdSucursal; Info.IdOrdenCompraExt = IdOrdenCompra; Info.ct_IdTipoCbte = item.IdTipoCbte; lst.Add(Info); } } return(lst); } 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()); } }
public List <vwImp_OrdenCompraExt_X_CbteCble_Info> Get_List_DiariosxImportacion(int idempresa, int IdSucursal, Decimal IdOrdenCompra) { List <vwImp_OrdenCompraExt_X_CbteCble_Info> lst = new List <vwImp_OrdenCompraExt_X_CbteCble_Info>(); try { EntitiesImportacion Imp = new EntitiesImportacion(); var Consulta = from q in Imp.vwImp_OrdenCompraExt_X_CbteCble where q.imp_IdEmpresa == idempresa && q.imp_IdSucusal == IdSucursal && q.imp_IdOrdenCompraExt == IdOrdenCompra select q; foreach (var item in Consulta) { vwImp_OrdenCompraExt_X_CbteCble_Info obj = new vwImp_OrdenCompraExt_X_CbteCble_Info(); obj.IdCbte = item.IdCbteCble; obj.IdEmpresa = item.imp_IdEmpresa; obj.IdSucursal = item.imp_IdSucusal; obj.Observacion = item.cb_Observacion; obj.TipoComprobanteContable = item.tc_TipoCbte; obj.Valor = item.cb_Valor; obj.CodCbte = item.CodCbteCble; obj.IdOrdenCompraExt = item.imp_IdOrdenCompraExt; obj.Fecha = item.cb_Fecha; obj.Estado = item.cb_Estado; obj.TipoReg = item.TipoReg; obj.ct_IdTipoCbte = item.ct_IdTipoCbte; lst.Add(obj); } return(lst); } 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()); } }