Exemplo n.º 1
0
 public static void Consultar(out List<eFact_Entidades.Archivo> Archivos, eFact_Entidades.Archivo.TipoConsultaArchivos TipoConsultaArchivos, eFact_Entidades.Archivo.OtrosFiltros OtrosFiltros, DateTime FechaDsd, DateTime FechaHst, CedEntidades.Sesion Sesion)
 {
     List<eFact_Entidades.Archivo> archivos = new List<eFact_Entidades.Archivo>();
     eFact_DB.Archivo a = new eFact_DB.Archivo(Sesion);
     a.Consultar(archivos, TipoConsultaArchivos, OtrosFiltros, FechaDsd, FechaHst);
     Archivos = archivos;
 }
Exemplo n.º 2
0
 public static void Consultar(out List<eFact_Entidades.Lote> Lotes, eFact_Entidades.Lote.TipoConsulta TipoConsulta, DateTime FechaDsd, DateTime FechaHst, string CuitVendedor, string NumeroLote, string PuntoVenta, bool VerPendientes, CedEntidades.Sesion Sesion)
 {
     List<eFact_Entidades.Lote> lotes = new List<eFact_Entidades.Lote>();
     eFact_DB.Lote l = new eFact_DB.Lote(Sesion);
     l.Consultar(out lotes, TipoConsulta, FechaDsd, FechaHst, CuitVendedor, NumeroLote, PuntoVenta, VerPendientes);
     Lotes = lotes;
 }
Exemplo n.º 3
0
 public void Leer(eFact_Entidades.Vendedor Vendedor)
 {
     StringBuilder commandText = new StringBuilder();
     commandText.Append("Select * from Vendedores");
     commandText.Append(" where CuitVendedor='" + Vendedor.CuitVendedor + "'");
     DataTable dt = new DataTable();
     dt = (DataTable)Ejecutar(commandText.ToString(), TipoRetorno.TB, Transaccion.Acepta, sesion.CnnStr);
     if (dt.Rows.Count != 0)
     {
         Vendedor.CuitVendedor = dt.Rows[0]["CuitVendedor"].ToString();
         Vendedor.Nombre = dt.Rows[0]["Nombre"].ToString();
         Vendedor.NumeroSerieCertificado = dt.Rows[0]["NumeroSerieCertificado"].ToString();
         if (dt.Rows[0]["Logo"].GetType() != Type.GetType("System.DBNull"))
         {
             Vendedor.Logo = ((byte[])dt.Rows[0]["Logo"]);
         }
         Vendedor.Codigo = dt.Rows[0]["Codigo"].ToString();
         if (dt.Rows[0]["CondicionIVA"].GetType() != Type.GetType("System.DBNull"))
         {
             Vendedor.CondicionIVA = Convert.ToInt32(dt.Rows[0]["CondicionIVA"].ToString());
         }
         if (dt.Rows[0]["CondicionIB"].GetType() != Type.GetType("System.DBNull"))
         {
             Vendedor.CondicionIB = Convert.ToInt32(dt.Rows[0]["CondicionIB"].ToString());
         }
         Vendedor.NroIB = dt.Rows[0]["NroIB"].ToString();
         if (dt.Rows[0]["InicioActividades"].GetType() != Type.GetType("System.DBNull"))
         {
             Vendedor.InicioActividades = Convert.ToDateTime(dt.Rows[0]["InicioActividades"].ToString());
         }
         else
         {
             Vendedor.InicioActividades = FechaMax;
         }
         Vendedor.Contacto = dt.Rows[0]["Contacto"].ToString();
         Vendedor.DomicilioCalle = dt.Rows[0]["DomicilioCalle"].ToString();
         Vendedor.DomicilioNumero = dt.Rows[0]["DomicilioNumero"].ToString();
         Vendedor.DomicilioPiso = dt.Rows[0]["DomicilioPiso"].ToString();
         Vendedor.DomicilioDepto = dt.Rows[0]["DomicilioDepto"].ToString();
         Vendedor.DomicilioSector = dt.Rows[0]["DomicilioSector"].ToString();
         Vendedor.DomicilioTorre = dt.Rows[0]["DomicilioTorre"].ToString();
         Vendedor.DomicilioManzana = dt.Rows[0]["DomicilioManzana"].ToString();
         Vendedor.Localidad = dt.Rows[0]["Localidad"].ToString();
         Vendedor.Provincia = dt.Rows[0]["Provincia"].ToString();
         Vendedor.CP = dt.Rows[0]["CP"].ToString();
         Vendedor.EMail = dt.Rows[0]["EMail"].ToString();
         Vendedor.Telefono = dt.Rows[0]["Telefono"].ToString();
     }
     else
     {
         throw new Microsoft.ApplicationBlocks.ExceptionManagement.Vendedor.Inexistente("Cuit: " + Vendedor.CuitVendedor);
     }
 }
Exemplo n.º 4
0
 public static void ActualizarBandejaEntrada(eFact_Entidades.Archivo Archivo, FileInfo ArchFileInfo, CedEntidades.Sesion Sesion)
 {
     Archivo.Nombre = ArchFileInfo.Name;
     Archivo.Path = ArchFileInfo.DirectoryName;
     Archivo.Tipo = ArchFileInfo.Extension;
     Archivo.FechaCreacion = ArchFileInfo.CreationTime;
     Archivo.FechaModificacion = ArchFileInfo.LastWriteTime;
     Archivo.Tamaño = ArchFileInfo.Length;
     Archivo.TamañoUMedida = "KB";
     Archivo.IdUsuario = Sesion.Usuario.IdUsuario;
     //archivo.FechaProcesado
     //archivo.IdLote
     //archivo.Comentario
 }
Exemplo n.º 5
0
 private void Copiar(DataSet ds, int NroRowPpal, eFact_Entidades.Comprobante Hasta)
 {
     DataRow Desde;
     Desde = ds.Tables[0].Rows[NroRowPpal];
     Hasta.IdLote = Convert.ToInt32(Desde["IdLote"]);
     Hasta.PuntoVenta = Convert.ToString(Desde["PuntoVenta"]);
     Hasta.IdTipoComprobante = Convert.ToInt16(Desde["IdTipoComprobante"]);
     Hasta.NumeroComprobante = Convert.ToString(Desde["NumeroComprobante"]);
     Hasta.TipoDocComprador = Convert.ToInt16(Desde["TipoDocComprador"]);
     Hasta.NroDocComprador = Desde["NroDocComprador"].ToString();
     Hasta.NombreComprador = Desde["NombreComprador"].ToString();
     Hasta.Fecha = Convert.ToDateTime(Desde["Fecha"]);
     Hasta.IdMoneda = Convert.ToString(Desde["IdMoneda"]);
     Hasta.Importe = Convert.ToDecimal(Desde["Importe"]);
     Hasta.ImporteMonedaOrigen = Convert.ToDecimal(Desde["ImporteMonedaOrigen"]);
     Hasta.TipoCambio = Convert.ToDecimal(Desde["TipoCambio"]);
 }
Exemplo n.º 6
0
 public void Leer(eFact_Entidades.Comprobante Comprobante)
 {
     StringBuilder commandText = new StringBuilder();
     commandText.Append("Select * from Comprobantes");
     commandText.Append(" where IdLote=" + Comprobante.IdLote + " and IdTipoComprobante = '" + Comprobante.IdTipoComprobante + "' and NumeroComprobante='" + Comprobante.NumeroComprobante + "'");
     DataSet ds = new DataSet();
     ds = (DataSet)Ejecutar(commandText.ToString(), TipoRetorno.DS, Transaccion.Acepta, sesion.CnnStr);
     if (ds.Tables.Count == 0)
     {
         throw new Microsoft.ApplicationBlocks.ExceptionManagement.Validaciones.NoHayDatos();
     }
     else
     {
         if (ds.Tables[0].Rows.Count != 0)
         {
             Copiar(ds, 0, Comprobante);
         }
     }
 }
Exemplo n.º 7
0
 private void Copiar(DataRow Desde, eFact_Entidades.Archivo Hasta)
 {
     Hasta.IdArchivo = Convert.ToInt32(Desde["IdArchivo"]);
     Hasta.Nombre = Convert.ToString(Desde["Nombre"]);
     Hasta.Path = Convert.ToString(Desde["Path"]);
     Hasta.Tipo = Convert.ToString(Desde["Tipo"]);
     Hasta.FechaCreacion = Convert.ToDateTime(Desde["FechaCreacion"]);
     Hasta.FechaModificacion = Convert.ToDateTime(Desde["FechaModificacion"]);
     Hasta.Tamaño = Convert.ToInt32(Desde["Tamaño"]);
     Hasta.TamañoUMedida = Convert.ToString(Desde["TamañoUMedida"]);
     Hasta.Comentario = Convert.ToString(Desde["Comentario"]);
     Hasta.FechaProceso = Convert.ToDateTime(Desde["FechaProceso"]);                
     Hasta.NombreProcesado = Convert.ToString(Desde["NombreProcesado"]);
     Hasta.IdUsuario = Convert.ToString(Desde["IdUsuario"]);
     if (!Desde["IdLote"].Equals(System.DBNull.Value))
     {
         Hasta.IdLote = Convert.ToInt32(Desde["IdLote"]);
     }
 }
Exemplo n.º 8
0
        public static void ActualizarDatosCAE(eFact_Entidades.Lote Lote, FeaEntidades.InterFacturas.lote_comprobantes Lc)
        {
            MemoryStream ms;
            System.Xml.XmlTextWriter writer;
            System.Xml.Serialization.XmlSerializer x;
            String XmlizedString;
            
            //Actualizar lote
            ms = new MemoryStream();
            XmlizedString = null;
            writer = new XmlTextWriter(ms, System.Text.Encoding.GetEncoding("ISO-8859-1"));
            x = new System.Xml.Serialization.XmlSerializer(Lc.GetType());
            x.Serialize(writer, Lc);
            ms = (MemoryStream)writer.BaseStream;
            XmlizedString = eFact_RN.Tablero.ByteArrayToString(ms.ToArray());
            ms.Close();
            ms = null;
            Lote.LoteXmlIF = XmlizedString;

            eFact_Entidades.Comprobante comprobante =new eFact_Entidades.Comprobante();
            string sFecha = "";
            for (int i = 0; i < Lc.comprobante.Length; i++)
            {
                eFact_Entidades.Comprobante c = Lote.Comprobantes.Find((delegate(eFact_Entidades.Comprobante e1) { return e1.IdTipoComprobante == Convert.ToInt16(Lc.comprobante[i].cabecera.informacion_comprobante.tipo_de_comprobante.ToString()) && e1.NumeroComprobante == Lc.comprobante[i].cabecera.informacion_comprobante.numero_comprobante.ToString(); }));
                if (Lc.comprobante[i].cabecera.informacion_comprobante.cae != null)
                {
                    c.NumeroCAE = Lc.comprobante[i].cabecera.informacion_comprobante.cae.ToString();
                }
                if (Lc.comprobante[i].cabecera.informacion_comprobante.fecha_obtencion_cae != null)
                {
                    sFecha = Lc.comprobante[i].cabecera.informacion_comprobante.fecha_obtencion_cae.ToString();
                    c.FechaCAE = Convert.ToDateTime(sFecha.Substring(0, 4) + "/" + sFecha.Substring(4, 2) + "/" + sFecha.Substring(6, 2));
                }
                if (Lc.comprobante[i].cabecera.informacion_comprobante.fecha_vencimiento_cae != null)
                {
                    sFecha = Lc.comprobante[i].cabecera.informacion_comprobante.fecha_vencimiento_cae.ToString();
                    c.FechaVtoCAE = Convert.ToDateTime(sFecha.Substring(0, 4) + "/" + sFecha.Substring(4, 2) + "/" + sFecha.Substring(6, 2));
                }
                c.EstadoIFoAFIP = Lc.comprobante[i].cabecera.informacion_comprobante.resultado;
                c.ComentarioIFoAFIP = Lc.comprobante[i].cabecera.informacion_comprobante.motivo;
            }
        }
Exemplo n.º 9
0
 public void Consultar(List<eFact_Entidades.Archivo> Archivos, eFact_Entidades.Archivo.TipoConsultaArchivos TipoConsultaArchivos, eFact_Entidades.Archivo.OtrosFiltros OtrosFiltros, DateTime FechaDsd, DateTime FechaHst)
 {
     StringBuilder commandText = new StringBuilder();
     //Query Lotes
     commandText.Append("select * from Archivos ");
     if (TipoConsultaArchivos == eFact_Entidades.Archivo.TipoConsultaArchivos.FechaCreacion)
     {
         commandText.Append("where FechaCreacion >= '" + FechaDsd.ToString("yyyyMMdd") + "' and FechaCreacion <= Dateadd(Day, 1, '" + FechaHst.ToString("yyyyMMdd") + "') ");
     }
     else
     {
         commandText.Append("where FechaProceso >= '" + FechaDsd.ToString("yyyyMMdd") + "' and FechaProceso <= Dateadd(Day, 1, '" + FechaHst.ToString("yyyyMMdd") + "') ");
     }
     if (OtrosFiltros != eFact_Entidades.Archivo.OtrosFiltros.SinAplicar)
     {
         if (OtrosFiltros == eFact_Entidades.Archivo.OtrosFiltros.OK)
         {
             commandText.Append(" and IdLote is not null");
         }
         else
         {
             commandText.Append(" and IdLote is null");
         }
     }
     commandText.Append(" order by IdArchivo Desc");
     DataTable dt = new DataTable();
     dt = (DataTable)Ejecutar(commandText.ToString(), TipoRetorno.TB, Transaccion.Usa, sesion.CnnStr);
     if (dt.Rows.Count == 0)
     {
         throw new Microsoft.ApplicationBlocks.ExceptionManagement.Validaciones.NoHayDatos();
     }
     else
     {
         for (int i = 0; i < dt.Rows.Count; i++)
         {
             eFact_Entidades.Archivo archivo = new eFact_Entidades.Archivo();
             Copiar(dt.Rows[i], archivo);
             Archivos.Add(archivo);
         }
     }
 }
Exemplo n.º 10
0
 public void Leer(eFact_Entidades.Archivo Archivo)
 {
     StringBuilder commandText = new StringBuilder();
     //Query Lotes
     commandText.Append("select * from Archivos ");
     if (Archivo.IdArchivo != 0)
     {
         commandText.Append("where IdArchivo=" + Archivo.IdArchivo + " ");
     }
     else
     {
         throw new Microsoft.ApplicationBlocks.ExceptionManagement.Validaciones.ValorNoInfo("IdArchivo");
     }
     DataTable dt = new DataTable();
     dt = (DataTable)Ejecutar(commandText.ToString(), TipoRetorno.TB, Transaccion.Usa, sesion.CnnStr);
     if (dt.Rows.Count == 0)
     {
         throw new Microsoft.ApplicationBlocks.ExceptionManagement.Validaciones.NoHayDatos();
     }
     else
     {
         Copiar(dt.Rows[0], Archivo);
     }
 }
Exemplo n.º 11
0
 private static int Comparer(eFact_Entidades.Lote x, eFact_Entidades.Lote y)
 {
     return x.NumeroLote.CompareTo(y.NumeroLote);
 }
Exemplo n.º 12
0
        private static int ordenarPorNroComprobante(eFact_Entidades.Comprobante A1, eFact_Entidades.Comprobante A2)
        {

            return Convert.ToInt32(A1.IdTipoComprobante.ToString().Trim() + A1.NumeroComprobante.PadLeft(8, Convert.ToChar("0"))).CompareTo(Convert.ToInt32(A2.IdTipoComprobante + A2.NumeroComprobante.PadLeft(8, Convert.ToChar("0"))));
        }
Exemplo n.º 13
0
        public static void Procesar(out eFact_Entidades.Lote Lote, eFact_Entidades.Archivo Archivo, eFact_Entidades.Aplicacion Aplicacion, CedEntidades.Sesion Sesion)
        {
            //Antes de procesar el archivo grabamos los datos básicos del mismo.
            if (Archivo.Tipo.ToUpper() != ".TXT" && Archivo.Tipo.ToUpper() != ".XML" && Archivo.Tipo.ToUpper() != ".REC")
            {
                throw new Microsoft.ApplicationBlocks.ExceptionManagement.Archivo.TipoDeArchivoIncorrecto("Solo se aceptan archivo TXT o XML.");
            }
            FeaEntidades.InterFacturas.lote_comprobantes Lc = new FeaEntidades.InterFacturas.lote_comprobantes();
            System.IO.MemoryStream ms;
            System.Xml.Serialization.XmlSerializer x;
            switch (Aplicacion.CodigoAplic.ToString())
            {
                case "eFactInterface":
                    {
                        if (Archivo.Tipo.ToUpper() == ".XML")
                        {
                            //StreamReader objReader = new StreamReader(Archivo.Path + "\\" + Archivo.Nombre, Encoding.GetEncoding("iso-8859-1"));
                            StreamReader objReader = new StreamReader(Archivo.Path + "\\" + Archivo.Nombre, Encoding.GetEncoding("utf-8"));
                            string cadena;
                            cadena = objReader.ReadToEnd();
                            objReader.Close();
                            byte[] a = new byte[cadena.Length];// esta es la declaracion de tu arreglo
                            System.Text.Encoding codificador;
                            //codificador = System.Text.Encoding.GetEncoding("iso-8859-1");
                            codificador = System.Text.Encoding.GetEncoding("utf-8");
                            cadena = cadena.Replace("&", "&amp;");
                            a = codificador.GetBytes(cadena);
                            ms = new System.IO.MemoryStream(a);
                            ms.Seek(0, System.IO.SeekOrigin.Begin);
                            Lc = new FeaEntidades.InterFacturas.lote_comprobantes();
                            x = new System.Xml.Serialization.XmlSerializer(Lc.GetType());
                            Lc = (FeaEntidades.InterFacturas.lote_comprobantes)x.Deserialize(ms);
                        }
                        else if (Archivo.Tipo.ToUpper() == ".TXT")
                        {
                            eFact_RN.Engine Engine = new eFact_RN.Engine();
                            Lc = new FeaEntidades.InterFacturas.lote_comprobantes();
                            Engine.LeerMultiRegistro(out Lc, Archivo.Path + "\\" + Archivo.Nombre, Sesion);
                        }
                        else if (Archivo.Tipo.ToUpper() == ".REC")
                        {
                            eFact_RN.Engine Engine = new eFact_RN.Engine();
                            Lc = new FeaEntidades.InterFacturas.lote_comprobantes();
                            Engine.LeerRegistroRECE(out Lc, Archivo.Path + "\\" + Archivo.Nombre, Sesion);
                        }
                        break;
                    }
                default:
                    {
                        break;
                    }
            }
            if (Lc.cabecera_lote.cuit_vendedor.ToString().Trim() != Aplicacion.OtrosFiltrosCuit.Trim() && Aplicacion.OtrosFiltrosCuit.Trim() != "")
            {
                throw new Microsoft.ApplicationBlocks.ExceptionManagement.Archivo.CUITNoHabilitadoParaElUsuario(Lc.cabecera_lote.cuit_vendedor.ToString());
            }
            eFact_Entidades.Lote lote = new eFact_Entidades.Lote();
            lote.CuitVendedor = Lc.cabecera_lote.cuit_vendedor.ToString();
            lote.PuntoVenta = Lc.cabecera_lote.punto_de_venta.ToString();
            lote.NumeroLote = Lc.cabecera_lote.id_lote.ToString();
            lote.CantidadRegistros = Convert.ToInt32(Lc.cabecera_lote.cantidad_reg.ToString());
            //Verificar bandeja de salida.-----------
            int numeroEnvioDisponible = 0;
            eFact_RN.Lote.ObtenerNumeroEnvioDisponible(out numeroEnvioDisponible, lote.CuitVendedor, lote.NumeroLote, lote.PuntoVenta, Sesion);
            lote.NumeroEnvio = numeroEnvioDisponible;
            //---------------------------------------
            lote.NombreArch = Archivo.Nombre;
            if (Lc.cabecera_lote.IdNaturalezaLoteFieldSpecified)
            {
                lote.IdNaturalezaLote = Lc.cabecera_lote.IdNaturalezaLoteField;
            }
            else
            {
                lote.IdNaturalezaLote = "";
            }
            int cantComprobantes = 0;
            for (int i = 0; i < Lc.comprobante.Length; i++)
            {
                if (Lc.comprobante[i] != null)
                {
                    cantComprobantes += 1;
                }
                else
                {
                    break;
                }
            }
            if (Lc.comprobanteDespacho != null)
            {
                for (int i = 0; i < Lc.comprobanteDespacho.Length; i++)
                {
                    if (Lc.comprobanteDespacho[i] != null)
                    {
                        cantComprobantes += 1;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            if (Lc.cabecera_lote.cantidad_reg != cantComprobantes)
            {
                throw new Microsoft.ApplicationBlocks.ExceptionManagement.Archivo.ProcesarArchivo("Problemas con la cantidad de registros declarada.");
            }
            List<eFact_Entidades.ComprobanteC> cCListVigentes = new List<eFact_Entidades.ComprobanteC>();
            List<eFact_Entidades.ComprobanteD> cDListVigentes = new List<eFact_Entidades.ComprobanteD>();
            if (Lc.cabecera_lote.IdNaturalezaLoteField != null && Lc.cabecera_lote.IdNaturalezaLoteField == "Compra")
            {
                //----- Consultar comprobantes de compras 'Vigentes' -----.
                if (Lc.comprobante[0] != null)
                {
                    cCListVigentes = eFact_RN.Comprobante.ConsultarComprobantesCVigentes(Lc.cabecera_lote.cuit_vendedor.ToString(), Sesion);
                }    
                //----- Consultar despachos 'Vigentes' -----.
                if (Lc.comprobanteDespacho[0] != null)
                {
                    cDListVigentes = eFact_RN.Comprobante.ConsultarComprobantesDVigentes(Lc.cabecera_lote.cuit_vendedor.ToString(), Sesion);
                }
            }
            List<eFact_Entidades.Comprobante> cVListVigentes = new List<eFact_Entidades.Comprobante>();
            if (Lc.cabecera_lote.IdNaturalezaLoteField != null && Lc.cabecera_lote.IdNaturalezaLoteField == "Venta")
            {
                //----- Consultar comprobantes de ventas 'Vigentes' -----.
                cVListVigentes = eFact_RN.Comprobante.ConsultarComprobantesVigentes(Lc.cabecera_lote.cuit_vendedor.ToString(), Sesion);
            }
            for (int i = 0; i < Lc.comprobante.Length; i++)
            {
                if (Lc.comprobante[i] != null)
                {
                    if (lote.IdNaturalezaLote != "Compra")
                    {
                        //Ventas
                        eFact_Entidades.Comprobante c = new eFact_Entidades.Comprobante();
                        c.IdTipoComprobante = Convert.ToInt16(Lc.comprobante[i].cabecera.informacion_comprobante.tipo_de_comprobante.ToString());
                        c.NumeroComprobante = Lc.comprobante[i].cabecera.informacion_comprobante.numero_comprobante.ToString();
                        c.TipoDocComprador = Convert.ToInt16(Lc.comprobante[i].cabecera.informacion_comprador.codigo_doc_identificatorio.ToString());
                        c.NroDocComprador = Lc.comprobante[i].cabecera.informacion_comprador.nro_doc_identificatorio.ToString();
                        c.NombreComprador = Lc.comprobante[i].cabecera.informacion_comprador.denominacion;
                        c.Fecha = ConvertirStringToDateTime(Lc.comprobante[i].cabecera.informacion_comprobante.fecha_emision.ToString());
                        c.NumeroCAE = Convert.ToString(Lc.comprobante[i].cabecera.informacion_comprobante.cae);
                        if (Lc.comprobante[i].cabecera.informacion_comprobante.fecha_obtencion_cae != null && Lc.comprobante[i].cabecera.informacion_comprobante.fecha_obtencion_cae.ToString() != "")
                        {
                            c.FechaCAE = ConvertirStringToDateTime(Lc.comprobante[i].cabecera.informacion_comprobante.fecha_obtencion_cae.ToString());
                        }
                        if (Lc.comprobante[i].cabecera.informacion_comprobante.fecha_vencimiento_cae != null && Lc.comprobante[i].cabecera.informacion_comprobante.fecha_vencimiento_cae.ToString() != "")
                        {
                            c.FechaVtoCAE = ConvertirStringToDateTime(Lc.comprobante[i].cabecera.informacion_comprobante.fecha_vencimiento_cae.ToString());
                        }
                        c.IdMoneda = Convert.ToString(Lc.comprobante[i].resumen.codigo_moneda);
                        c.Importe = Convert.ToDecimal(Lc.comprobante[i].resumen.importe_total_factura);
                        if (Lc.comprobante[i].resumen.importes_moneda_origen != null)
                        {
                            c.ImporteMonedaOrigen = Convert.ToDecimal(Lc.comprobante[i].resumen.importes_moneda_origen.importe_total_factura);
                        }
                        c.TipoCambio = Convert.ToDecimal(Lc.comprobante[i].resumen.tipo_de_cambio);
                        if (Lc.comprobante[i].extensiones != null)
                        {
                            if (Lc.comprobante[i].extensiones.extensiones_camara_facturas != null)
                            {
                                if (Lc.comprobante[i].extensiones.extensiones_camara_facturas.clave_de_vinculacion != null)
                                {
                                    Lc.comprobante[i].extensiones.extensiones_camara_facturas.clave_de_vinculacion = Lc.comprobante[i].extensiones.extensiones_camara_facturas.clave_de_vinculacion.Trim();
                                    if (Lc.comprobante[i].extensiones.extensiones_camara_facturas.clave_de_vinculacion.Length != 0 && Lc.comprobante[i].extensiones.extensiones_camara_facturas.clave_de_vinculacion.Length != 32)
                                    {
                                        Lc.comprobante[i].extensiones.extensiones_camara_facturas.clave_de_vinculacion = Cedeira.SV.Fun.CreateMD5Hash(Lc.comprobante[i].extensiones.extensiones_camara_facturas.clave_de_vinculacion);
                                    }
                                }
                            }
                        }
                        lote.Comprobantes.Add(c);
                        if (lote.IdNaturalezaLote == "Venta")
                        {
                            List<eFact_Entidades.Comprobante> listAux = cVListVigentes.FindAll((delegate(eFact_Entidades.Comprobante e1) { return e1.NroDocComprador == c.NroDocComprador && e1.PuntoVenta.ToString() == c.PuntoVenta && e1.IdTipoComprobante == c.IdTipoComprobante && e1.NumeroComprobante == c.NumeroComprobante; }));
                            if (listAux.Count != 0)
                            {
                                throw new Microsoft.ApplicationBlocks.ExceptionManagement.Archivo.ProcesarArchivo("Comprobante existente. Cuit Comprador: " + c.NroDocComprador + " Punto Venta: " + c.PuntoVenta + " Tipo: " + c.IdTipoComprobante.ToString() + " Nro: " + c.NumeroComprobante);
                            }
                        }
                    }
                    else
                    {
                        //Compras
                        eFact_Entidades.ComprobanteC cC = new eFact_Entidades.ComprobanteC();
                        cC.PuntoVenta = Lc.comprobante[i].cabecera.informacion_comprobante.punto_de_venta.ToString();
                        cC.IdTipoComprobante = Convert.ToInt16(Lc.comprobante[i].cabecera.informacion_comprobante.tipo_de_comprobante.ToString());
                        cC.NumeroComprobante = Lc.comprobante[i].cabecera.informacion_comprobante.numero_comprobante.ToString();
                        cC.TipoDocVendedor = Convert.ToInt16("80");
                        cC.NroDocVendedor = Lc.comprobante[i].cabecera.informacion_vendedor.cuit.ToString();
                        cC.NombreVendedor = Lc.comprobante[i].cabecera.informacion_vendedor.razon_social;
                        cC.Fecha = ConvertirStringToDateTime(Lc.comprobante[i].cabecera.informacion_comprobante.fecha_emision.ToString());
                        cC.IdMoneda = Convert.ToString(Lc.comprobante[i].resumen.codigo_moneda);
                        cC.Importe = Convert.ToDecimal(Lc.comprobante[i].resumen.importe_total_factura);
                        if (Lc.comprobante[i].resumen.importes_moneda_origen != null)
                        {
                            cC.ImporteMonedaOrigen = Convert.ToDecimal(Lc.comprobante[i].resumen.importes_moneda_origen.importe_total_factura);
                        }
                        cC.TipoCambio = Convert.ToDecimal(Lc.comprobante[i].resumen.tipo_de_cambio);
                        lote.ComprobantesC.Add(cC);

                        List<eFact_Entidades.ComprobanteC> listAux = cCListVigentes.FindAll((delegate(eFact_Entidades.ComprobanteC e1) { return e1.NroDocVendedor == cC.NroDocVendedor && e1.PuntoVenta.ToString() == cC.PuntoVenta && e1.IdTipoComprobante == cC.IdTipoComprobante && e1.NumeroComprobante == cC.NumeroComprobante; }));
                        if (listAux.Count != 0)
                        {
                            throw new Microsoft.ApplicationBlocks.ExceptionManagement.Archivo.ProcesarArchivo("Comprobante existente. Cuit Vendedor: " + cC.NroDocVendedor + " Punto Venta: " + cC.PuntoVenta + " Tipo: " + cC.IdTipoComprobante.ToString() + " Nro: " + cC.NumeroComprobante);
                        }
                    }
                }
                else
                {
                    break;
                }
            }
            if (Lc.comprobanteDespacho != null)
            {
                for (int i = 0; i < Lc.comprobanteDespacho.Length; i++)
                {
                    if (Lc.comprobanteDespacho[i] != null)
                    {
                        eFact_Entidades.ComprobanteD cD = new eFact_Entidades.ComprobanteD();
                        cD.IdTipoComprobante = Convert.ToInt16(Lc.comprobanteDespacho[i].DespachoCabecera.TipoComprobante.ToString());
                        cD.NumeroDespacho = Lc.comprobanteDespacho[i].DespachoCabecera.NumeroDespacho.ToString();
                        cD.TipoDocVendedor = Convert.ToInt16(Lc.comprobanteDespacho[i].DespachoCabecera.TipoDocVendedor);
                        cD.NroDocVendedor = Lc.comprobanteDespacho[i].DespachoCabecera.NroDocVendedor.ToString();
                        cD.NombreVendedor = Lc.comprobanteDespacho[i].DespachoCabecera.NombreVendedor;
                        cD.Fecha = ConvertirStringToDateTime(Lc.comprobanteDespacho[i].DespachoCabecera.Fecha.ToString());
                        cD.IdMoneda = Convert.ToString(Lc.comprobanteDespacho[i].DespachoResumen.Moneda);
                        cD.Importe = Convert.ToDecimal(Lc.comprobanteDespacho[i].DespachoResumen.ImporteTotal);
                        //cD.ImporteMonedaOrigen = Convert.ToDecimal(Lc.comprobante[i].resumen.importes_moneda_origen.importe_total_factura);
                        cD.TipoCambio = Convert.ToDecimal(Lc.comprobanteDespacho[i].DespachoResumen.TipoCambio);
                        lote.ComprobantesD.Add(cD);

                        List<eFact_Entidades.ComprobanteD> listAux = cDListVigentes.FindAll((delegate(eFact_Entidades.ComprobanteD e1) { return e1.NroDocVendedor == cD.NroDocVendedor && e1.IdTipoComprobante == cD.IdTipoComprobante && e1.NumeroDespacho == cD.NumeroDespacho; }));
                        if (listAux.Count != 0)
                        {
                            throw new Microsoft.ApplicationBlocks.ExceptionManagement.Archivo.ProcesarArchivo("Comprobante de Despacho existente. Cuit Vendedor: " + cD.NroDocVendedor + " Tipo: " + cD.IdTipoComprobante.ToString() + " Nro: " + cD.NumeroDespacho);
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            string loteXml = "";
            eFact_RN.Lote.SerializarLc(out loteXml, Lc);
            lote.LoteXml = loteXml;
            Lote = lote;
        }
Exemplo n.º 14
0
 public static void Leer(eFact_Entidades.Archivo Archivo, CedEntidades.Sesion Sesion)
 {
     eFact_DB.Archivo db = new eFact_DB.Archivo(Sesion);
     db.Leer(Archivo);
 }
Exemplo n.º 15
0
 public ConsultaLote(eFact_Entidades.ComprobanteP ComprobanteP, Modo modo)
 {
     InitializeComponent();
     comprobanteP = ComprobanteP;
     modoActual = modo;
 }
Exemplo n.º 16
0
 public void ActualizarFechaEnvio(eFact_Entidades.Lote Lote, string HandlerEvento)
 {
     StringBuilder commandText = new StringBuilder();
     commandText.Append(HandlerEvento);
     commandText.Append(" Update Lotes set FechaEnvio = GetDate()");
     commandText.Append(" where IdLote = " + Lote.IdLote);
     commandText.Append(" declare @IdLote int select @IdLote=@@Identity");
     commandText.Append(" end");
     DataTable dt = new DataTable();
     dt = (DataTable)Ejecutar(commandText.ToString(), TipoRetorno.TB, Transaccion.Usa, sesion.CnnStr);
 }
Exemplo n.º 17
0
 public DataTable Insertar(eFact_Entidades.Lote Lote, string HandlerEvento, string HandlerArchivo)
 {
     StringBuilder commandText = new StringBuilder();
     string loteXml = "";
     string loteXmlIF = "";
     if (Lote.LoteXml != null && Lote.LoteXml != "")
     {
         loteXml = Lote.LoteXml.Replace("'", "''");
     }
     if (Lote.LoteXmlIF != null && Lote.LoteXmlIF != "")
     {
         loteXmlIF = Lote.LoteXmlIF.Replace("'", "''");
     }
     commandText.Append(HandlerEvento);
     commandText.Append(" insert Lotes values ('");
     commandText.Append(Lote.CuitVendedor + "', '");
     commandText.Append(Lote.NumeroLote + "', '");
     commandText.Append(Lote.PuntoVenta + "', ");
     commandText.Append(Lote.NumeroEnvio + ", ");
     commandText.Append("@IdOp, ");
     commandText.Append("GetDate(), ");
     commandText.Append("null, ");
     commandText.Append(Lote.CantidadRegistros + ", '");
     commandText.Append(Lote.NombreArch + "', '");
     commandText.Append(loteXml + "', '");
     commandText.Append(loteXmlIF + "', '");
     commandText.Append(Lote.IdNaturalezaLote + "') ");
     commandText.Append("declare @IdLote int select @IdLote=@@Identity");
     string nombreComprador = "";
     string nombreVendedor = "";
     for (int i = 0; i < Lote.Comprobantes.Count; i++)
     {
         nombreComprador = "";
         if (Lote.Comprobantes[i].NombreComprador != null && Lote.Comprobantes[i].NombreComprador != "")
         {
             nombreComprador = Lote.Comprobantes[i].NombreComprador.Replace("'", "''");
         }
         commandText.Append(" insert Comprobantes values (@IdLote, '");
         commandText.Append(Lote.Comprobantes[i].IdTipoComprobante + "', '");
         commandText.Append(Lote.Comprobantes[i].NumeroComprobante + "', '");
         commandText.Append(Lote.Comprobantes[i].TipoDocComprador + "', '");
         commandText.Append(Lote.Comprobantes[i].NroDocComprador + "', '");
         commandText.Append(nombreComprador + "', '");
         commandText.Append(Lote.Comprobantes[i].Fecha.ToString("yyyyMMdd") + "', '");
         commandText.Append(Lote.Comprobantes[i].IdMoneda + "', ");
         commandText.Append(Lote.Comprobantes[i].Importe + ", ");
         if (Lote.Comprobantes[i].NumeroCAE == null)
         {
             commandText.Append("null, ");
         }
         else
         {
             commandText.Append("'" + Lote.Comprobantes[i].NumeroCAE + "', ");
         }
         if (Lote.Comprobantes[i].FechaCAE == null || Convert.ToInt32(Lote.Comprobantes[i].FechaCAE.ToString("yyyyMMdd")) <= 20010101)
         {
             commandText.Append("null, ");
         }
         else
         {
             commandText.Append("'" + Lote.Comprobantes[i].FechaCAE.ToString("yyyyMMdd") + "', ");
         }
         if (Lote.Comprobantes[i].FechaVtoCAE == null || Convert.ToInt32(Lote.Comprobantes[i].FechaVtoCAE.ToString("yyyyMMdd")) <= 20010101)
         {
             commandText.Append("null, ");
         }
         else
         {
             commandText.Append("'" + Lote.Comprobantes[i].FechaVtoCAE.ToString("yyyyMMdd") + "', ");
         }
         commandText.Append(Lote.Comprobantes[i].ImporteMonedaOrigen + ", ");
         commandText.Append(Lote.Comprobantes[i].TipoCambio + ", ");
         if (Lote.Comprobantes[i].EstadoIFoAFIP == null)
         {
             commandText.Append("null, ");
         }
         else
         {
             commandText.Append("'" + Lote.Comprobantes[i].EstadoIFoAFIP + "', ");
         }
         if (Lote.Comprobantes[i].ComentarioIFoAFIP == null)
         {
             commandText.Append("null) ");
         }
         else
         {
             commandText.Append("'" + Lote.Comprobantes[i].ComentarioIFoAFIP + "') ");
         }
     }
     for (int i = 0; i < Lote.ComprobantesC.Count; i++)
     {
         nombreVendedor = "";
         if (Lote.ComprobantesC[i].NombreVendedor != null && Lote.ComprobantesC[i].NombreVendedor != "")
         {
             nombreVendedor = Lote.ComprobantesC[i].NombreVendedor.Replace("'", "''");
         }
         commandText.Append(" insert ComprobantesC values (@IdLote, '");
         commandText.Append(Lote.ComprobantesC[i].PuntoVenta + "', '");
         commandText.Append(Lote.ComprobantesC[i].IdTipoComprobante + "', '");
         commandText.Append(Lote.ComprobantesC[i].NumeroComprobante + "', '");
         commandText.Append(Lote.ComprobantesC[i].TipoDocVendedor + "', '");
         commandText.Append(Lote.ComprobantesC[i].NroDocVendedor + "', '");
         commandText.Append(nombreVendedor + "', '");
         commandText.Append(Lote.ComprobantesC[i].Fecha.ToString("yyyyMMdd") + "', '");
         commandText.Append(Lote.ComprobantesC[i].IdMoneda + "', ");
         commandText.Append(Lote.ComprobantesC[i].Importe + ", ");
         commandText.Append(Lote.ComprobantesC[i].ImporteMonedaOrigen + ", ");
         commandText.Append(Lote.ComprobantesC[i].TipoCambio + ") ");
     }
     for (int i = 0; i < Lote.ComprobantesD.Count; i++)
     {
         nombreVendedor = "";
         if (Lote.ComprobantesD[i].NombreVendedor != null && Lote.ComprobantesD[i].NombreVendedor != "")
         {
             nombreVendedor = Lote.ComprobantesD[i].NombreVendedor.Replace("'", "''");
         }
         commandText.Append(" insert ComprobantesD values (@IdLote, '");
         commandText.Append(Lote.ComprobantesD[i].IdTipoComprobante + "', '");
         commandText.Append(Lote.ComprobantesD[i].NumeroDespacho + "', '");
         commandText.Append(Lote.ComprobantesD[i].TipoDocVendedor + "', '");
         commandText.Append(Lote.ComprobantesD[i].NroDocVendedor + "', '");
         commandText.Append(nombreVendedor + "', '");
         commandText.Append(Lote.ComprobantesD[i].Fecha.ToString("yyyyMMdd") + "', '");
         commandText.Append(Lote.ComprobantesD[i].IdMoneda + "', ");
         commandText.Append(Lote.ComprobantesD[i].Importe + ") ");
     }
     commandText.Append(HandlerArchivo);
     commandText.Append(" Select @IdLote ");
     DataTable dt = new DataTable();
     dt = (DataTable)Ejecutar(commandText.ToString(), TipoRetorno.TB, Transaccion.Usa, sesion.CnnStr);
     return dt;
 }
Exemplo n.º 18
0
 public void Leer(eFact_Entidades.Lote Lote)
 {
     StringBuilder commandText = new StringBuilder();
     //Query Lotes
     commandText.Append("select ");
     commandText.Append("Lotes.*, WF_Op.IdFlow ,WF_Op.IdCircuito, WF_Op.IdNivSeg, WF_Op.IdEstado, WF_Op.DescrOp, WF_Op.UltActualiz, WF_Flow.DescrFlow, WF_Circuito.DescrCircuito , WF_NivSeg.DescrNivSeg, WF_Estado.DescrEstado ");
     commandText.Append("INTO #Lotes ");
     commandText.Append("from Lotes ");
     commandText.Append("inner join WF_Op on Lotes.IdOp = WF_Op.IdOp ");
     commandText.Append("inner join WF_Flow on WF_Op.IdFlow=WF_Flow.IdFlow ");
     commandText.Append("inner join WF_Circuito on WF_Op.IdCircuito=WF_Circuito.IdCircuito ");
     commandText.Append("inner join WF_NivSeg on WF_Op.IdNivSeg=WF_NivSeg.IdNivSeg ");
     commandText.Append("inner join WF_Estado on WF_Op.IdEstado=WF_Estado.IdEstado ");
     if (Lote.IdLote != 0)
     {
         commandText.Append("where IdLote=" + Lote.IdLote + " ");
     }
     else if(Lote.CuitVendedor != "" && Lote.PuntoVenta != "" && Lote.NumeroLote != "" && Lote.NumeroEnvio != 0)
     {
         commandText.Append("where CuitVendedor = '" + Lote.CuitVendedor + "' ");
         commandText.Append("and PuntoVenta = '" + Lote.PuntoVenta + "' ");
         commandText.Append("and NumeroLote = '" + Lote.NumeroLote + "' ");
         commandText.Append("and NumeroEnvio = " + Lote.NumeroEnvio + " ");
     }
     else
     {
         throw new Microsoft.ApplicationBlocks.ExceptionManagement.Validaciones.ValorNoInfo("IdLote");
     }
     commandText.Append("select * from #Lotes ");
     //Select Comprobantes
     commandText.Append("select Comprobantes.* from #Lotes ");
     commandText.Append("inner join Comprobantes on Comprobantes.IdLote = #Lotes.IdLote ");
     //Select ComprobantesC (Compras)
     commandText.Append("select ComprobantesC.* from #Lotes ");
     commandText.Append("inner join ComprobantesC on ComprobantesC.IdLote = #Lotes.IdLote ");
     //Select ComprobantesD (Compras - Despachos de Importación)
     commandText.Append("select ComprobantesD.* from #Lotes ");
     commandText.Append("inner join ComprobantesD on ComprobantesD.IdLote = #Lotes.IdLote ");
     //Select WF_LOG
     commandText.Append("Select #Lotes.IdLote, ");
     commandText.Append("WF_Log.Fecha, WF_Evento.DescrEvento as Evento, WF_Estado.DescrEstado as Estado, WCUsuarios.Nombre+' ('+WF_Log.IdUsuario+')' as Responsable, WCUsuarios.Nombre as Nombre, ");
     commandText.Append("WF_Log.Comentario, WF_Log.IdLog, WF_Log.IdFlow, WF_Log.IdCircuito, WF_Log.IdNivSeg, WF_Log.IdGrupo, WF_Log.Supervisor, WF_Log.IdUsuario, ");
     commandText.Append("WF_Log.SupervisorNivel, WF_Log.IdEvento, WF_Log.IdEstado, WF_Flow.DescrFlow, WF_Circuito.DescrCircuito, WCTbGrupos.Descr as DescrGrupo ");
     commandText.Append("from #Lotes, WF_Log, WCUsuarios, WF_Evento, WF_Estado, WF_Flow, WF_Circuito, WCTbGrupos ");
     commandText.Append("where WF_Log.IdOp = #Lotes.idOp "); 
     commandText.Append("and WF_Log.IdUsuario=WCUsuarios.IdUsuario ");
     commandText.Append("and WF_Log.IdFlow=WF_Evento.IdFlow ");
     commandText.Append("and WF_Log.IdFlow=WF_Flow.IdFlow ");
     commandText.Append("and WF_Log.IdCircuito=WF_Circuito.IdCircuito ");
     commandText.Append("and WF_Log.IdGrupo=WCTbGrupos.IdGrupo ");
     commandText.Append("and WF_Log.IdEvento=WF_Evento.IdEvento ");
     commandText.Append("and WF_Log.IdEstado=WF_Estado.IdEstado ");
     //Select Eventos Posibles del WF    
     commandText.Append("Select #Lotes.IdLote, ");
     commandText.Append("WF_Evento.IdFlow, IdEvento, DescrEvento, TextoAccion, IdEstadoDsd, IdEstadoHst, Automatico, CXO, XLote, WF_Flow.DescrFlow, EstadoDsd.DescrEstado as DescrEstadoDsd, EstadoHst.DescrEstado as DescrEstadoHst ");
     commandText.Append("from #Lotes ");
     commandText.Append("inner join WF_Evento on WF_Evento.IdFlow = #Lotes.IdFlow ");
     commandText.Append("inner join WF_Flow on WF_Flow.IdFlow = #Lotes.IdFlow ");
     commandText.Append("inner join WF_Estado EstadoDsd on EstadoDsd.IdEstado=WF_Evento.IdEstadoDsd ");
     commandText.Append("inner join WF_Estado EstadoHst on EstadoHst.IdEstado=WF_Evento.IdEstadoHst ");
     commandText.Append("where WF_Evento.IdEvento in (select IdEvento from WF_EsquemaSeg where IdCircuito = #Lotes.IdCircuito and IdFlow = #Lotes.IdFlow ) ");
     commandText.Append("and WF_Evento.IdEstadoDsd = #Lotes.IdEstado or WF_Evento.IdEstadoDsd = '<EstadoNoFinal>' ");
     //Select Eventos Posibles por lote
     commandText.Append("Select #Lotes.IdLote, ");
     commandText.Append("WF_Evento.IdFlow, IdEvento, DescrEvento, TextoAccion, IdEstadoDsd, IdEstadoHst, Automatico, CXO, XLote, WF_Flow.DescrFlow, EstadoDsd.DescrEstado as DescrEstadoDsd, EstadoHst.DescrEstado as DescrEstadoHst ");
     commandText.Append("from #Lotes ");
     commandText.Append("inner join WF_Evento on WF_Evento.IdFlow = #Lotes.IdFlow and WF_Evento.XLote=1 ");
     commandText.Append("inner join WF_Flow on WF_Flow.IdFlow = #Lotes.IdFlow ");
     commandText.Append("inner join WF_Estado EstadoDsd on EstadoDsd.IdEstado=WF_Evento.IdEstadoDsd ");
     commandText.Append("inner join WF_Estado EstadoHst on EstadoHst.IdEstado=WF_Evento.IdEstadoHst ");
     commandText.Append("where WF_Evento.IdEvento in (select IdEvento from WF_EsquemaSeg where IdCircuito = #Lotes.IdCircuito and IdFlow = #Lotes.IdFlow ) ");
     commandText.Append("and WF_Evento.IdEstadoDsd = #Lotes.IdEstado or WF_Evento.IdEstadoDsd = '<EstadoNoFinal>' ");
     //commandText.Append("drop table #Lotes ");
     DataSet ds = new DataSet();
     ds = (DataSet)Ejecutar(commandText.ToString(), TipoRetorno.DS, Transaccion.Usa, sesion.CnnStr);
     if (ds.Tables.Count == 0)
     {
         throw new Microsoft.ApplicationBlocks.ExceptionManagement.Validaciones.NoHayDatos();
     }
     else
     {
         Copiar(ds, 0, Lote);
         Lote.WF.EsquemaSegEventosPosibles = WF_EsquemaSegEventosPosibles_qry(Lote.WF);
     }
 }
Exemplo n.º 19
0
 public static void ActualizarBandejaSalida(out List<eFact_Entidades.Lote> Lotes, eFact_Entidades.Lote.TipoConsulta TipoConsulta, DateTime FechaDsd, DateTime FechaHst, String CuitVendedor, String NumeroLote, String PuntoVenta, bool VerPendientes, CedEntidades.Sesion Sesion)
 {
     List<eFact_Entidades.Lote> lotes = new List<eFact_Entidades.Lote>();
     eFact_RN.Lote.Consultar(out lotes, TipoConsulta, FechaDsd, FechaHst, CuitVendedor, NumeroLote, PuntoVenta, VerPendientes, Sesion);
     Lotes = lotes;
 }
Exemplo n.º 20
0
 private void CopiarConLoteXML(DataSet ds, int NroRowPpal, eFact_Entidades.ComprobanteD Hasta)
 {
     DataRow Desde;
     Desde = ds.Tables[0].Rows[NroRowPpal];
     Hasta.IdLote = Convert.ToInt32(Desde["IdLote"]);
     Hasta.LoteXml = Convert.ToString(Desde["LoteXml"].ToString());
     Hasta.IdTipoComprobante = Convert.ToInt16(Desde["IdTipoComprobante"]);
     Hasta.NumeroDespacho = Convert.ToString(Desde["NumeroDespacho"]);
     Hasta.TipoDocVendedor = Convert.ToInt16(Desde["TipoDocVendedor"]);
     Hasta.NroDocVendedor = Desde["NroDocVendedor"].ToString();
     Hasta.NombreVendedor = Desde["NombreVendedor"].ToString();
     Hasta.Fecha = Convert.ToDateTime(Desde["Fecha"]);
     Hasta.IdMoneda = Convert.ToString(Desde["IdMoneda"]);
     Hasta.Importe = Convert.ToDecimal(Desde["Importe"]);
     //Hasta.ImporteMonedaOrigen = Convert.ToDecimal(Desde["ImporteMonedaOrigen"]);
     //Hasta.TipoCambio = Convert.ToDecimal(Desde["TipoCambio"]);
 }
Exemplo n.º 21
0
 public string Insertar(eFact_Entidades.Archivo Archivo, bool Handler)
 {
     StringBuilder commandText = new StringBuilder();
     commandText.Append(" insert Archivos values ('");
     commandText.Append(Archivo.Nombre + "', '");
     commandText.Append(Archivo.Tipo + "', '");
     commandText.Append(Archivo.Path + "', '");
     commandText.Append(Archivo.FechaCreacion.ToString("yyyyMMdd HH:mm:ss") + "', '");
     commandText.Append(Archivo.FechaModificacion.ToString("yyyyMMdd HH:mm:ss") + "', ");
     commandText.Append(Archivo.Tamaño + ", '");
     commandText.Append(Archivo.TamañoUMedida + "', ");
     if (Archivo.Comentario != null)
     {
         commandText.Append("'" + Archivo.Comentario.Replace(Convert.ToChar("'"), Convert.ToChar(" ")) + "', ");
     }
     else 
     {
         commandText.Append("null, ");
     }
     commandText.Append("'" + Archivo.FechaProceso.ToString("yyyyMMdd HH:mm:ss") + "', ");
     if (Archivo.NombreProcesado != null)
     {
         commandText.Append("'" + Archivo.NombreProcesado + "', ");
     }
     else
     {
         commandText.Append("null, ");
     }
     commandText.Append("'" + Archivo.IdUsuario + "', ");
     if (Handler)
     {
         commandText.Append("@IdLote) ");
         return commandText.ToString();
     }
     else
     {
         commandText.Append("null) ");
         Ejecutar(commandText.ToString(), TipoRetorno.None, Transaccion.Usa, sesion.CnnStr);
         return "";
     }
 }
Exemplo n.º 22
0
 private void EjecutarEventoBandejaS(string IdEvento, string Comentario, eFact_Entidades.Lote lote)
 {
     //CedEntidades.Evento evento = new CedEntidades.Evento();
     //evento.Id = IdEvento;
     //evento.Flow.IdFlow = "eFact";
     //evento.Flow.DescrFlow = "Facturación Electrónica";
     //evento.Comentario = Comentario;
     //Cedeira.SV.WF.LeerEvento(evento, Aplicacion.Sesion);
     //eFact_RN.Lote.VerificarEnviosPosteriores(false, lote.CuitVendedor, lote.NumeroLote, lote.PuntoVenta, lote.NumeroEnvio, eFact_R.Aplicacion.Sesion);
     //eFact_RN.Lote.Ejecutar(lote, evento, "", Aplicacion.Aplic, Aplicacion.Sesion);
     //RefreshBandejaSalida();
 }
Exemplo n.º 23
0
 public void Consultar(out List<eFact_Entidades.Lote> Lotes, eFact_Entidades.Lote.TipoConsulta TipoConsulta, DateTime FechaDsd, DateTime FechaHst, string CuitVendedor, string NumeroLote, string PuntoVenta, bool VerPendientes)
 {
     StringBuilder commandText = new StringBuilder();
     //Query PF
     commandText.Append("select ");
     commandText.Append("Lotes.*, WF_Op.IdFlow ,WF_Op.IdCircuito, WF_Op.IdNivSeg, WF_Op.IdEstado, WF_Op.DescrOp, WF_Op.UltActualiz, WF_Flow.DescrFlow, WF_Circuito.DescrCircuito , WF_NivSeg.DescrNivSeg, WF_Estado.DescrEstado ");
     commandText.Append("INTO #Lotes ");
     commandText.Append("from Lotes ");
     commandText.Append("inner join WF_Op on Lotes.IdOp = WF_Op.IdOp ");
     commandText.Append("inner join WF_Flow on WF_Op.IdFlow=WF_Flow.IdFlow ");
     commandText.Append("inner join WF_Circuito on WF_Op.IdCircuito=WF_Circuito.IdCircuito ");
     commandText.Append("inner join WF_NivSeg on WF_Op.IdNivSeg=WF_NivSeg.IdNivSeg ");
     commandText.Append("inner join WF_Estado on WF_Op.IdEstado=WF_Estado.IdEstado ");
     if (TipoConsulta == eFact_Entidades.Lote.TipoConsulta.FechaAlta)
     {
         commandText.Append("where (Lotes.FechaAlta >= '" + FechaDsd.ToString("yyyyMMdd") + "' and Lotes.FechaAlta < Dateadd ( Day, 1, '" + FechaHst.ToString("yyyyMMdd") + "') ");
     }
     else if (TipoConsulta == eFact_Entidades.Lote.TipoConsulta.FechaEnvio)
     {
         commandText.Append("where (Lotes.FechaEnvio >= '" + FechaDsd.ToString("yyyyMMdd") + "' and Lotes.FechaEnvio <= Dateadd ( Day, 1, '" + FechaHst.ToString("yyyyMMdd") + "') ");
     }
     else
     {
         commandText.Append("where (1=1 ");
     }
     //Otros Filtros
     string queryOtrosFiltros = ""; 
     if (CuitVendedor != "")
     {
         queryOtrosFiltros += "and Lotes.CuitVendedor = '" + CuitVendedor + "' ";
         commandText.Append(queryOtrosFiltros);
     }
     if (NumeroLote != "")
     {
         queryOtrosFiltros += "and Lotes.NumeroLote = '" + NumeroLote + "' ";
         commandText.Append(queryOtrosFiltros);
     }
     if (PuntoVenta != "")
     {
         queryOtrosFiltros += "and Lotes.PuntoVenta = '" + PuntoVenta + "' ";
         commandText.Append(queryOtrosFiltros);
     }
     commandText.Append(") ");
     if (VerPendientes)
     {
         commandText.Append(" or (WF_Op.IdEstado in ('PteEnvio', 'PteRespIF', 'PteRespAFIP') " + queryOtrosFiltros + ") ");
     }
     commandText.Append("select * from #Lotes order by IdLote Desc ");
     commandText.Append("IF @@ROWCOUNT > 0 ");
     commandText.Append("BEGIN ");
     //Select Comprobantes
     commandText.Append("select Comprobantes.* from #Lotes ");
     commandText.Append("inner join Comprobantes on Comprobantes.IdLote = #Lotes.IdLote ");
     //Select ComprobantesC (Compras)
     commandText.Append("select ComprobantesC.* from #Lotes ");
     commandText.Append("inner join ComprobantesC on ComprobantesC.IdLote = #Lotes.IdLote ");
     //Select ComprobantesD (Compras - Despachos de Importación)
     commandText.Append("select ComprobantesD.* from #Lotes ");
     commandText.Append("inner join ComprobantesD on ComprobantesD.IdLote = #Lotes.IdLote ");
     //Select WF_LOG
     commandText.Append("Select #Lotes.IdLote, ");
     commandText.Append("WF_Log.Fecha, WF_Evento.DescrEvento as Evento, WF_Estado.DescrEstado as Estado, WCUsuarios.Nombre+' ('+WF_Log.IdUsuario+')' as Responsable, WCUsuarios.Nombre as Nombre, ");
     commandText.Append("WF_Log.Comentario, WF_Log.IdLog, WF_Log.IdFlow, WF_Log.IdCircuito, WF_Log.IdNivSeg, WF_Log.IdGrupo, WF_Log.Supervisor, WF_Log.IdUsuario, ");
     commandText.Append("WF_Log.SupervisorNivel, WF_Log.IdEvento, WF_Log.IdEstado, WF_Flow.DescrFlow, WF_Circuito.DescrCircuito, WCTbGrupos.Descr as DescrGrupo ");
     commandText.Append("from #Lotes, WF_Log, WCUsuarios, WF_Evento, WF_Estado, WF_Flow, WF_Circuito, WCTbGrupos ");
     commandText.Append("where WF_Log.IdOp = #Lotes.IdOp ");
     commandText.Append("and WF_Log.IdUsuario=WCUsuarios.IdUsuario ");
     commandText.Append("and WF_Log.IdFlow=WF_Evento.IdFlow ");
     commandText.Append("and WF_Log.IdFlow=WF_Flow.IdFlow ");
     commandText.Append("and WF_Log.IdCircuito=WF_Circuito.IdCircuito ");
     commandText.Append("and WF_Log.IdGrupo=WCTbGrupos.IdGrupo ");
     commandText.Append("and WF_Log.IdEvento=WF_Evento.IdEvento ");
     commandText.Append("and WF_Log.IdEstado=WF_Estado.IdEstado ");
     //Select Eventos Posibles del WF    
     commandText.Append("Select #Lotes.IdLote, ");
     commandText.Append("WF_Evento.IdFlow, IdEvento, DescrEvento, TextoAccion, IdEstadoDsd, IdEstadoHst, Automatico, CXO, XLote, WF_Flow.DescrFlow, EstadoDsd.DescrEstado as DescrEstadoDsd, EstadoHst.DescrEstado as DescrEstadoHst ");
     commandText.Append("from #Lotes ");
     commandText.Append("inner join WF_Evento on WF_Evento.IdFlow = #Lotes.IdFlow ");
     commandText.Append("inner join WF_Flow on WF_Flow.IdFlow = #Lotes.IdFlow ");
     commandText.Append("inner join WF_Estado EstadoDsd on EstadoDsd.IdEstado=WF_Evento.IdEstadoDsd ");
     commandText.Append("inner join WF_Estado EstadoHst on EstadoHst.IdEstado=WF_Evento.IdEstadoHst ");
     commandText.Append("where WF_Evento.IdEvento in (select IdEvento from WF_EsquemaSeg where IdCircuito = #Lotes.IdCircuito and IdFlow = #Lotes.IdFlow ) ");
     commandText.Append("and WF_Evento.IdEstadoDsd = #Lotes.IdEstado or WF_Evento.IdEstadoDsd = '<EstadoNoFinal>' ");
     //Select Eventos Posibles por lote
     commandText.Append("Select #Lotes.IdLote, ");
     commandText.Append("WF_Evento.IdFlow, IdEvento, DescrEvento, TextoAccion, IdEstadoDsd, IdEstadoHst, Automatico, CXO, XLote, WF_Flow.DescrFlow, EstadoDsd.DescrEstado as DescrEstadoDsd, EstadoHst.DescrEstado as DescrEstadoHst ");
     commandText.Append("from #Lotes ");
     commandText.Append("inner join WF_Evento on WF_Evento.IdFlow = #Lotes.IdFlow and WF_Evento.XLote=1 ");
     commandText.Append("inner join WF_Flow on WF_Flow.IdFlow = #Lotes.IdFlow ");
     commandText.Append("inner join WF_Estado EstadoDsd on EstadoDsd.IdEstado=WF_Evento.IdEstadoDsd ");
     commandText.Append("inner join WF_Estado EstadoHst on EstadoHst.IdEstado=WF_Evento.IdEstadoHst ");
     commandText.Append("where WF_Evento.IdEvento in (select IdEvento from WF_EsquemaSeg where IdCircuito = #Lotes.IdCircuito and IdFlow = #Lotes.IdFlow ) ");
     commandText.Append("and WF_Evento.IdEstadoDsd = #Lotes.IdEstado or WF_Evento.IdEstadoDsd = '<EstadoNoFinal>' ");
     commandText.Append("END ");
     commandText.Append("DROP TABLE #Lotes ");
     DataSet ds = new DataSet();
     ds = (DataSet)Ejecutar(commandText.ToString(), TipoRetorno.DS, Transaccion.Usa, sesion.CnnStr);
     List<eFact_Entidades.Lote> lotes = new List<eFact_Entidades.Lote>();
     if (ds.Tables.Count == 0)
     {
         throw new Microsoft.ApplicationBlocks.ExceptionManagement.Validaciones.NoHayDatos();
     }
     else
     {
         for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
         {
             eFact_Entidades.Lote Lote = new eFact_Entidades.Lote();
             Copiar(ds, i, Lote);
             Lote.WF.EsquemaSegEventosPosibles = WF_EsquemaSegEventosPosibles_qry(Lote.WF);
             lotes.Add(Lote);
         }
     }
     Lotes = lotes;
 }
Exemplo n.º 24
0
        public void Modificar(eFact_Entidades.Vendedor Vendedor)
        {
            //Declaramos y abrimos la conexión con la base de datos donde la variable de conexión especifica el path de nuestro archivo sdf
            System.Data.SqlClient.SqlConnection conexion = new System.Data.SqlClient.SqlConnection(sesion.CnnStr);
            conexion.Open();

            //Creamos el comando SQL para insertar, atentos al parámetro @Imagen
            string comandoSQL = "UPDATE Vendedores set Nombre = '" + Vendedor.Nombre + "', NumeroSerieCertificado = '" + Vendedor.NumeroSerieCertificado + "' "; 
            //Asignamos el array de bytes al parametro @Imagen
            if (Vendedor.Logo != null)
            {
                comandoSQL += ", Logo = @Imagen ";
            }
            else
            {
                comandoSQL += ", Logo = null ";
            }
            comandoSQL += ", Codigo = '" + Vendedor.Codigo + "' ";
            comandoSQL += ", CondicionIVA = " + Vendedor.CondicionIVA + " ";
            comandoSQL += ", CondicionIB = " + Vendedor.CondicionIB + " ";
            comandoSQL += ", NroIB = '" + Vendedor.NroIB + "' ";
            if (Vendedor.InicioActividades.GetType() != Type.GetType("System.DBNull"))
            {
                comandoSQL += ", InicioActividades = '" + Vendedor.InicioActividades.ToString("yyyyMMdd") + "' ";
            }
            comandoSQL += ", Contacto = '" + Vendedor.Contacto + "' ";
            comandoSQL += ", DomicilioCalle = '" + Vendedor.DomicilioCalle + "' ";
            comandoSQL += ", DomicilioNumero = '" + Vendedor.DomicilioNumero + "' ";
            comandoSQL += ", DomicilioPiso = '" + Vendedor.DomicilioPiso + "' ";
            comandoSQL += ", DomicilioDepto = '" + Vendedor.DomicilioDepto + "' ";
            comandoSQL += ", DomicilioSector = '" + Vendedor.DomicilioSector + "' ";
            comandoSQL += ", DomicilioTorre = '" + Vendedor.DomicilioTorre + "' ";
            comandoSQL += ", DomicilioManzana = '" + Vendedor.DomicilioManzana + "' ";
            comandoSQL += ", Localidad = '" + Vendedor.Localidad + "' ";
            comandoSQL += ", Provincia = '" + Vendedor.Provincia + "' ";
            comandoSQL += ", CP = '" + Vendedor.CP + "' ";
            comandoSQL += ", EMail = '" + Vendedor.EMail + "' ";
            comandoSQL += ", Telefono = '" + Vendedor.Telefono + "' ";
            comandoSQL += "where CuitVendedor = '" + Vendedor.CuitVendedor + "'";
            System.Data.SqlClient.SqlCommand comando = new System.Data.SqlClient.SqlCommand(comandoSQL, conexion);
            if (Vendedor.Logo != null)
            {
                comando.Parameters.AddWithValue("@Imagen", Vendedor.Logo);
            }
            //Ejecutamos y grabamos
            comando.ExecuteNonQuery();
            conexion.Close();
        }
Exemplo n.º 25
0
 public void ActualizarDatosError(eFact_Entidades.Lote Lote, string HandlerEvento)
 {
     StringBuilder commandText = new StringBuilder();
     string loteXmlIF = "";
     if (Lote.LoteXmlIF != null && Lote.LoteXmlIF != "")
     {
         loteXmlIF = Lote.LoteXmlIF.Replace("'", "''");
     }
     commandText.Append(HandlerEvento);
     commandText.Append(" Update Lotes set LoteXMLIF = '");
     commandText.Append(loteXmlIF + "'");
     commandText.Append(" where IdLote = " + Lote.IdLote);
     commandText.Append(" declare @IdLote int select @IdLote=@@Identity");
     for (int i = 0; i < Lote.Comprobantes.Count; i++)
     {
         string estado = "";
         if (Lote.Comprobantes[i].EstadoIFoAFIP != null)
         {
             estado = Lote.Comprobantes[i].EstadoIFoAFIP;
         }
         string comentario = "";
         if (Lote.Comprobantes[i].ComentarioIFoAFIP != null)
         {
             comentario = Lote.Comprobantes[i].ComentarioIFoAFIP;
         }
         commandText.Append(" Update Comprobantes set EstadoIFoAFIP = '" + estado + "', ");
         commandText.Append("ComentarioIFoAFIP = '" + comentario + "' ");
         commandText.Append("where IdLote = " + Lote.IdLote + " and IdTipoComprobante = '" + Lote.Comprobantes[i].IdTipoComprobante + "' ");
         commandText.Append("and NumeroComprobante = '" + Lote.Comprobantes[i].NumeroComprobante + "' ");
     }
     if (HandlerEvento != "")
     {
         commandText.Append(" end");
     }
     DataTable dt = new DataTable();
     dt = (DataTable)Ejecutar(commandText.ToString(), TipoRetorno.TB, Transaccion.Usa, sesion.CnnStr);
 }
Exemplo n.º 26
0
 private void CopiarSimple(DataSet ds, int NroRowPpal, eFact_Entidades.Lote Hasta)
 {
     DataRow Desde;
     Desde = ds.Tables[0].Rows[NroRowPpal];
     Hasta.IdLote = Convert.ToInt32(Desde["IdLote"]);
     Hasta.CuitVendedor = Convert.ToString(Desde["CuitVendedor"]);
     Hasta.PuntoVenta = Convert.ToString(Desde["PuntoVenta"]);
     Hasta.NumeroLote = Convert.ToString(Desde["NumeroLote"]);
     Hasta.NumeroEnvio = Convert.ToInt32(Desde["NumeroEnvio"]);
     Hasta.IdOp = Convert.ToInt32(Desde["IdOp"]);
     Hasta.FechaAlta = Convert.ToDateTime(Desde["FechaAlta"]);
     if (Desde["FechaEnvio"].ToString() == "")
     {
         Desde["FechaEnvio"] = "31/12/9998";
     }
     Hasta.FechaEnvio = Convert.ToDateTime(Desde["FechaEnvio"]);
     Hasta.NombreArch = Convert.ToString(Desde["NombreArch"]);
     Hasta.CantidadRegistros = Convert.ToInt32(Desde["CantidadRegistros"]);
     Hasta.LoteXml = Convert.ToString(Desde["LoteXml"]);
     Hasta.LoteXmlIF = Convert.ToString(Desde["LoteXmlIF"]);
     Hasta.IdNaturalezaLote = Convert.ToString(Desde["IdNaturalezaLote"]);
 }
Exemplo n.º 27
0
 public void GuardarNovedades(eFact_Entidades.Novedades novedad)
 {
     StringBuilder commandText = new StringBuilder();
     commandText.Append("insert Novedades values ('");
     commandText.Append(novedad.CuitVendedor + "', " + novedad.IdLote + ", " + novedad.NumeroEnvio + ", " + novedad.PuntoVenta + ", " + novedad.IdLog + ", " + novedad.IdOp + ", '" + novedad.NumeroLote + "', '" + novedad.IdEstado + "', '" + novedad.Comentario.Replace("'", " ") + "', '" + novedad.FechaAlta.ToString("yyyyMMdd HH:mm:ss") + "', " + novedad.CantidadRegistros + ")");
     Ejecutar(commandText.ToString(), TipoRetorno.TB, Transaccion.Usa, sesion.CnnStr);
 }
Exemplo n.º 28
0
 public static string Insertar(eFact_Entidades.Archivo Archivo, bool Handler, CedEntidades.Sesion Sesion)
 {
     eFact_DB.Archivo db = new eFact_DB.Archivo(Sesion);
     return db.Insertar(Archivo, Handler);
 }
Exemplo n.º 29
0
 private void Copiar(DataSet ds, int NroRowPpal, eFact_Entidades.Lote Hasta)
 {
     DataRow Desde;
     Desde = ds.Tables[0].Rows[NroRowPpal];
     Hasta.IdLote = Convert.ToInt32(Desde["IdLote"]);
     Hasta.CuitVendedor = Convert.ToString(Desde["CuitVendedor"]);
     Hasta.PuntoVenta = Convert.ToString(Desde["PuntoVenta"]);
     Hasta.NumeroLote = Convert.ToString(Desde["NumeroLote"]);
     Hasta.NumeroEnvio = Convert.ToInt32(Desde["NumeroEnvio"]);
     Hasta.IdOp = Convert.ToInt32(Desde["IdOp"]);
     Hasta.FechaAlta = Convert.ToDateTime(Desde["FechaAlta"]);
     if (Desde["FechaEnvio"].ToString() == "")
     {
         Desde["FechaEnvio"] = "31/12/9998";
     }
     Hasta.FechaEnvio = Convert.ToDateTime(Desde["FechaEnvio"]);
     Hasta.NombreArch = Convert.ToString(Desde["NombreArch"]);
     Hasta.CantidadRegistros = Convert.ToInt32(Desde["CantidadRegistros"]);
     Hasta.LoteXml = Convert.ToString(Desde["LoteXml"]);
     Hasta.LoteXmlIF = Convert.ToString(Desde["LoteXmlIF"]);
     Hasta.IdNaturalezaLote = Convert.ToString(Desde["IdNaturalezaLote"]);
     Hasta.WF = new CedEntidades.WF();
     Hasta.WF.IdOp = Convert.ToInt32(Desde["IdOp"]);
     Hasta.WF.IdFlow = Convert.ToString(Desde["IdFlow"]);
     Hasta.WF.DescrFlow = Convert.ToString(Desde["DescrFlow"]);
     Hasta.WF.IdCircuito = Convert.ToString(Desde["IdCircuito"]);
     Hasta.WF.IdCircuitoOrig = Hasta.WF.IdCircuito;
     Hasta.WF.DescrCircuito = Convert.ToString(Desde["DescrCircuito"]);
     Hasta.WF.IdNivSeg = Convert.ToInt32(Desde["IdNivSeg"]);
     Hasta.WF.DescrNivSeg = Convert.ToString(Desde["DescrNivSeg"]);
     Hasta.WF.DescrOp = Convert.ToString(Desde["DescrOp"]);
     Hasta.WF.IdEstado = Convert.ToString(Desde["IdEstado"]);
     Hasta.WF.UltActualiz = Cedeira.SV.db.ByteArray2TimeStamp((byte[])Desde["UltActualiz"]);
     Hasta.WF.DescrEstado = Convert.ToString(Desde["DescrEstado"]);
     Hasta.WF.Sesion = sesion;
     //Comprobantes
     DataRow[] dr = ds.Tables[1].Select("IdLote = " + Convert.ToInt32(Hasta.IdLote));
     Hasta.Comprobantes = new List<eFact_Entidades.Comprobante>();
     for (int i = 0; i < dr.Length; i++)
     {
         eFact_Entidades.Comprobante c = new eFact_Entidades.Comprobante();
         c.IdLote = Convert.ToInt32(dr[i]["IdLote"]);
         c.IdTipoComprobante = Convert.ToInt16(dr[i]["IdTipoComprobante"]);
         c.NumeroComprobante = Convert.ToString(dr[i]["NumeroComprobante"]);
         c.IdMoneda = Convert.ToString(dr[i]["IdMoneda"]);
         c.Importe = Convert.ToDecimal(dr[i]["Importe"]);
         c.NroDocComprador = Convert.ToString(dr[i]["NroDocComprador"]);
         c.TipoDocComprador = Convert.ToInt16(dr[i]["TipoDocComprador"]);
         c.NombreComprador = Convert.ToString(dr[i]["NombreComprador"]);
         c.Fecha= Convert.ToDateTime(dr[i]["Fecha"]);
         c.NumeroCAE = Convert.ToString(dr[i]["NumeroCAE"]);
         if (dr[i]["FechaCAE"].ToString() == "")
         {
             dr[i]["FechaCAE"] = "31/12/9998";
         }
         c.FechaCAE = Convert.ToDateTime(dr[i]["FechaCAE"]);
         if (dr[i]["FechaVtoCAE"].ToString() == "")
         {
             dr[i]["FechaVtoCAE"] = "31/12/9998";
         }
         c.FechaVtoCAE = Convert.ToDateTime(dr[i]["FechaVtoCAE"]);
         if (dr[i]["ImporteMonedaOrigen"].ToString() != "")
         {
             c.ImporteMonedaOrigen = Convert.ToDecimal(dr[i]["ImporteMonedaOrigen"]);
         }
         if (dr[i]["ImporteMonedaOrigen"].ToString() != "")
         {
             c.TipoCambio = Convert.ToDecimal(dr[i]["TipoCambio"]);
         }
         if (dr[i]["EstadoIFoAFIP"].ToString() != "")
         {
             c.EstadoIFoAFIP = Convert.ToString(dr[i]["EstadoIFoAFIP"]);
         }
         if (dr[i]["ComentarioIFoAFIP"].ToString() != "")
         {
             c.ComentarioIFoAFIP = Convert.ToString(dr[i]["ComentarioIFoAFIP"]);
         }
         Hasta.Comprobantes.Add(c);
     }
     //ComprobantesC (Compras)
     dr = ds.Tables[2].Select("IdLote = " + Convert.ToInt32(Hasta.IdLote));
     Hasta.ComprobantesC = new List<eFact_Entidades.ComprobanteC>();
     for (int i = 0; i < dr.Length; i++)
     {
         eFact_Entidades.ComprobanteC cC = new eFact_Entidades.ComprobanteC();
         cC.IdLote = Convert.ToInt32(dr[i]["IdLote"]);
         cC.PuntoVenta = Convert.ToString(dr[i]["PuntoVenta"]);
         cC.IdTipoComprobante = Convert.ToInt16(dr[i]["IdTipoComprobante"]);
         cC.NumeroComprobante = Convert.ToString(dr[i]["NumeroComprobante"]);
         cC.IdMoneda = Convert.ToString(dr[i]["IdMoneda"]);
         cC.Importe = Convert.ToDecimal(dr[i]["Importe"]);
         cC.NroDocVendedor = Convert.ToString(dr[i]["NroDocVendedor"]);
         cC.TipoDocVendedor = Convert.ToInt16(dr[i]["TipoDocVendedor"]);
         cC.NombreVendedor = Convert.ToString(dr[i]["NombreVendedor"]);
         cC.Fecha = Convert.ToDateTime(dr[i]["Fecha"]);
         if (dr[i]["ImporteMonedaOrigen"].ToString() != "")
         {
             cC.ImporteMonedaOrigen = Convert.ToDecimal(dr[i]["ImporteMonedaOrigen"]);
         }
         if (dr[i]["ImporteMonedaOrigen"].ToString() != "")
         {
             cC.TipoCambio = Convert.ToDecimal(dr[i]["TipoCambio"]);
         }
         Hasta.ComprobantesC.Add(cC);
     }
     //ComprobantesC (Compras - Despachos de Impotación)
     dr = ds.Tables[3].Select("IdLote = " + Convert.ToInt32(Hasta.IdLote));
     Hasta.ComprobantesD = new List<eFact_Entidades.ComprobanteD>();
     for (int i = 0; i < dr.Length; i++)
     {
         eFact_Entidades.ComprobanteD cD = new eFact_Entidades.ComprobanteD();
         cD.IdLote = Convert.ToInt32(dr[i]["IdLote"]);
         cD.IdTipoComprobante = Convert.ToInt16(dr[i]["IdTipoComprobante"]);
         cD.NumeroDespacho = Convert.ToString(dr[i]["NumeroDespacho"]);
         cD.NroDocVendedor = Convert.ToString(dr[i]["NroDocVendedor"]);
         cD.TipoDocVendedor = Convert.ToInt16(dr[i]["TipoDocVendedor"]);
         cD.NombreVendedor = Convert.ToString(dr[i]["NombreVendedor"]);
         cD.Fecha = Convert.ToDateTime(dr[i]["Fecha"]);
         cD.IdMoneda = Convert.ToString(dr[i]["IdMoneda"]);
         cD.Importe = Convert.ToDecimal(dr[i]["Importe"]);
         //if (dr[i]["ImporteMonedaOrigen"].ToString() != "")
         //{
         //    cD.ImporteMonedaOrigen = Convert.ToDecimal(dr[i]["ImporteMonedaOrigen"]);
         //}
         //if (dr[i]["ImporteMonedaOrigen"].ToString() != "")
         //{
         //    cD.TipoCambio = Convert.ToDecimal(dr[i]["TipoCambio"]);
         //}
         Hasta.ComprobantesD.Add(cD);
     }
     //WF
     dr = ds.Tables[4].Select("IdLote = " + Convert.ToInt32(Hasta.IdLote));
     Hasta.WF.Log = new List<CedEntidades.Log>();
     for (int i = 0; i < dr.Length; i++)
     {
         CedEntidades.Log l = new CedEntidades.Log();
         l.Circuito.IdCircuito = Convert.ToString(dr[i]["IdCircuito"]);
         l.Comentario = Convert.ToString(dr[i]["Comentario"]);
         l.Estado = Convert.ToString(dr[i]["Estado"]);
         l.Evento.Id = Convert.ToString(dr[i]["IdEvento"]);
         l.Evento.Descr = Convert.ToString(dr[i]["Evento"]);
         l.Fecha = Convert.ToDateTime(dr[i]["Fecha"]);
         l.Flow.IdFlow = Convert.ToString(dr[i]["IdFlow"]);
         l.Grupo.Id = Convert.ToString(dr[i]["IdGrupo"]);
         l.Grupo.Descr = Convert.ToString(dr[i]["DescrGrupo"]);
         l.IdLog = Convert.ToInt32(dr[i]["IdLog"]);
         l.IdNivSeg = Convert.ToInt32(dr[i]["IdNivSeg"]);
         l.Responsable = Convert.ToString(dr[i]["Responsable"]);
         l.Supervisor = Convert.ToBoolean(dr[i]["Supervisor"]);
         l.SupervisorNivel = Convert.ToByte(dr[i]["SupervisorNivel"]);
         l.Usuario.IdUsuario = Convert.ToString(dr[i]["IdUsuario"]);
         l.Usuario.Nombre = Convert.ToString(dr[i]["Nombre"]);
         Hasta.WF.Log.Add(l);
     }
     dr = ds.Tables[5].Select("IdLote = " + Convert.ToInt32(Hasta.IdLote));
     Hasta.WF.EventosPosibles = new List<CedEntidades.Evento>();
     for (int i = 0; i < dr.Length; i++)
     {
         CedEntidades.Evento evento = new CedEntidades.Evento();
         evento.Flow.IdFlow = Convert.ToString(dr[i]["IdFlow"]);
         evento.Id = Convert.ToString(dr[i]["IdEvento"]);
         evento.Descr = Convert.ToString(dr[i]["DescrEvento"]);
         evento.TextoAccion = Convert.ToString(dr[i]["TextoAccion"]);
         evento.IdEstadoDsd.IdEstado = Convert.ToString(dr[i]["IdEstadoDsd"]);
         evento.IdEstadoHst.IdEstado = Convert.ToString(dr[i]["IdEstadoHst"]);
         evento.Automatico = Convert.ToBoolean(dr[i]["Automatico"]);
         evento.CXO = Convert.ToBoolean(dr[i]["CXO"]);
         evento.XLote = Convert.ToBoolean(dr[i]["XLote"]);
         evento.Flow.DescrFlow = Convert.ToString(dr[i]["DescrFlow"]);
         evento.IdEstadoDsd.DescrEstado = Convert.ToString(dr[i]["DescrEstadoDsd"]);
         evento.IdEstadoHst.DescrEstado = Convert.ToString(dr[i]["DescrEstadoHst"]);
         Hasta.WF.EventosPosibles.Add(evento);
     }
     dr = ds.Tables[6].Select("IdLote = " + Convert.ToInt32(Hasta.IdLote));
     Hasta.WF.EventosXLotePosibles = new List<CedEntidades.Evento>();
     for (int i = 0; i < dr.Length; i++)
     {
         CedEntidades.Evento evento = new CedEntidades.Evento();
         evento.Flow.IdFlow = Convert.ToString(dr[i]["IdFlow"]);
         evento.Id = Convert.ToString(dr[i]["IdEvento"]);
         evento.Descr = Convert.ToString(dr[i]["DescrEvento"]);
         evento.TextoAccion = Convert.ToString(dr[i]["TextoAccion"]);
         evento.IdEstadoDsd.IdEstado = Convert.ToString(dr[i]["IdEstadoDsd"]);
         evento.IdEstadoHst.IdEstado = Convert.ToString(dr[i]["IdEstadoHst"]);
         evento.Automatico = Convert.ToBoolean(dr[i]["Automatico"]);
         evento.CXO = Convert.ToBoolean(dr[i]["CXO"]);
         evento.XLote = Convert.ToBoolean(dr[i]["XLote"]);
         evento.Flow.DescrFlow = Convert.ToString(dr[i]["DescrFlow"]);
         evento.IdEstadoDsd.DescrEstado = Convert.ToString(dr[i]["DescrEstadoDsd"]);
         evento.IdEstadoHst.DescrEstado = Convert.ToString(dr[i]["DescrEstadoHst"]);
         Hasta.WF.EventosXLotePosibles.Add(evento);
     }
 }
Exemplo n.º 30
0
        private void ProcesarComprobante(out CrystalDecisions.CrystalReports.Engine.ReportDocument ReporteDocumento, eFact_Entidades.Lote Lote, int Renglon)
        {
            try
            {
                //Cursor = System.Windows.Forms.Cursors.WaitCursor;
                facturaRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                //facturaRpt.Load("Facturacion\\Electronica\\Reportes\\Factura.rpt");

                ////Crear un lote de un solo comprobante, para la impresion o exportacion del pdf.
                //eFact_Entidades.Lote LoteConUnSoloComprobante = new eFact_Entidades.Lote();
                //LoteConUnSoloComprobante.CuitVendedor = Lote.CuitVendedor;
                //LoteConUnSoloComprobante.FechaAlta = Lote.FechaAlta;
                //LoteConUnSoloComprobante.FechaEnvio = Lote.FechaEnvio;
                //LoteConUnSoloComprobante.IdLote = Lote.IdLote;
                //LoteConUnSoloComprobante.IdOp = Lote.IdOp;
                //LoteConUnSoloComprobante.LoteXml = Lote.LoteXml;
                //LoteConUnSoloComprobante.LoteXmlIF = Lote.LoteXmlIF;
                //LoteConUnSoloComprobante.NumeroEnvio = Lote.NumeroEnvio;
                //LoteConUnSoloComprobante.NumeroLote = Lote.NumeroLote;
                //LoteConUnSoloComprobante.PuntoVenta = Lote.PuntoVenta;
                //LoteConUnSoloComprobante.CantidadRegistros = 1;
                //LoteConUnSoloComprobante.Comprobantes.Add(Lote.Comprobantes[Renglon]);
                //LoteConUnSoloComprobante.WF = Lote.WF;
                //FeaEntidades.InterFacturas.lote_comprobantes lc = new FeaEntidades.InterFacturas.lote_comprobantes();
                //eFact_RN.Lote.DeserializarLc(out lc, LoteConUnSoloComprobante, true);
                ////Entidad para reporte crystal. Al desserializar se pierden los descuentos de la entidad original.
                //FeaEntidades.Reporte.lote_comprobantes lcReporte = new FeaEntidades.Reporte.lote_comprobantes();
                //eFact_RN.Lote.DeserializarLc(out lcReporte, LoteConUnSoloComprobante);
                //for (int i = 0; i < lc.comprobante.Length; i++)
                //{
                //    if (i == 0)
                //    {
                //        lc.comprobante[i] = lc.comprobante[Renglon];
                //        lcReporte.comprobante[i] = lcReporte.comprobante[Renglon];
                //        for (int l = 0; l < lc.comprobante[i].detalle.linea.Length; l++)
                //        {
                //            if (lc.comprobante[i].detalle.linea[l].lineaDescuentos != null)
                //            {
                //                lcReporte.comprobante[i].detalle.linea[l].lineaDescuentos = new FeaEntidades.Reporte.lineaDescuentos[lc.comprobante[i].detalle.linea[l].lineaDescuentos.Length];
                //                for (int d = 0; d < lcReporte.comprobante[i].detalle.linea[l].lineaDescuentos.Length; d++)
                //                {
                //                    lcReporte.comprobante[i].detalle.linea[l].lineaDescuentos[d] = new FeaEntidades.Reporte.lineaDescuentos();
                //                    lcReporte.comprobante[i].detalle.linea[l].lineaDescuentos[d].descripcion_descuento = lc.comprobante[i].detalle.linea[l].lineaDescuentos[d].descripcion_descuento;
                //                    lcReporte.comprobante[i].detalle.linea[l].lineaDescuentos[d].importe_descuento = lc.comprobante[i].detalle.linea[l].lineaDescuentos[d].importe_descuento;
                //                    lcReporte.comprobante[i].detalle.linea[l].lineaDescuentos[d].importe_descuento_moneda_origen = lc.comprobante[i].detalle.linea[l].lineaDescuentos[d].importe_descuento_moneda_origen;
                //                    lcReporte.comprobante[i].detalle.linea[l].lineaDescuentos[d].importe_descuento_moneda_origenSpecified = lc.comprobante[i].detalle.linea[l].lineaDescuentos[d].importe_descuento_moneda_origenSpecified;
                //                    lcReporte.comprobante[i].detalle.linea[l].lineaDescuentos[d].importe_descuento_moneda_origenSpecified = true;
                //                    lcReporte.comprobante[i].detalle.linea[l].lineaDescuentos[d].porcentaje_descuento = lc.comprobante[i].detalle.linea[l].lineaDescuentos[d].porcentaje_descuento;
                //                    lcReporte.comprobante[i].detalle.linea[l].lineaDescuentos[d].porcentaje_descuentoSpecified = lc.comprobante[i].detalle.linea[l].lineaDescuentos[d].porcentaje_descuentoSpecified;
                //                    lcReporte.comprobante[i].detalle.linea[l].lineaDescuentos[d].porcentaje_descuentoSpecified = true;
                //                }
                //            }
                //            else
                //            {
                //                lcReporte.comprobante[0].detalle.linea[l].lineaDescuentos = new FeaEntidades.Reporte.lineaDescuentos[1];
                //                lcReporte.comprobante[0].detalle.linea[l].lineaDescuentos[0] = new FeaEntidades.Reporte.lineaDescuentos();
                //                lcReporte.comprobante[0].detalle.linea[l].lineaDescuentos[0].descripcion_descuento = "";
                //                lcReporte.comprobante[0].detalle.linea[l].lineaDescuentos[0].importe_descuento = 0;
                //                lcReporte.comprobante[0].detalle.linea[l].lineaDescuentos[0].porcentaje_descuento = 0;
                //                lcReporte.comprobante[0].detalle.linea[l].lineaDescuentos[0].porcentaje_descuentoSpecified = true;
                //                lcReporte.comprobante[0].detalle.linea[l].lineaDescuentos[0].importe_descuento_moneda_origen = 0;
                //                lcReporte.comprobante[0].detalle.linea[l].lineaDescuentos[0].importe_descuento_moneda_origenSpecified = true;
                //            }
                //        }
                //    }
                //    else
                //    {
                //        lc.comprobante[i] = null;
                //        lcReporte.comprobante[i] = null;
                //    }
                //}
                
                //AsignarCamposOpcionales(lcReporte);
                //ReemplarResumenImportesMonedaExtranjera(lcReporte);
                //DataSet ds = new DataSet();
                //XmlSerializer objXS = new XmlSerializer(lcReporte.GetType());
                //StringWriter objSW = new StringWriter();
                //objXS.Serialize(objSW, lcReporte);
                //StringReader objSR = new StringReader(objSW.ToString());
                //ds.ReadXml(objSR);
                
                //string pxsd = string.Format("{0}\\Facturacion\\Electronica\\Reportes\\lote_comprobantes.xsd",System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location));
                //System.IO.File.Copy(pxsd, @System.IO.Path.GetTempPath() + "lote_comprobantes.xsd", true);
                
                //string imagen = string.Format("{0}\\Facturacion\\Electronica\\Reportes\\Imagen.xsd",System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location));
                //System.IO.File.Copy(imagen, @System.IO.Path.GetTempPath() + "Imagen.xsd", true);

                //facturaRpt.SetDataSource(ds);

                //facturaRpt.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperLetter;
                //facturaRpt.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait;

                //IncrustarLogo();
                //GenerarCodigoBarras(lcReporte.cabecera_lote.cuit_vendedor + lcReporte.comprobante[0].cabecera.informacion_comprobante.tipo_de_comprobante.ToString("00") + lcReporte.comprobante[0].cabecera.informacion_comprobante.punto_de_venta.ToString("0000") + lcReporte.comprobante[0].cabecera.informacion_comprobante.cae + lcReporte.comprobante[0].cabecera.informacion_comprobante.fecha_vencimiento_cae);
                //AsignarParametros(lcReporte.comprobante[0].resumen.importe_total_factura);

                ReporteDocumento = facturaRpt;
            }
            catch (Exception ex)
            {
                ReporteDocumento = null;
                //MessageBox.Show(ex.Message, "Problemas al procesar el comprobante", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                throw new Microsoft.ApplicationBlocks.ExceptionManagement.Reporte.ProblemasProcesando(ex);
            }
            finally
            {
                Cursor = System.Windows.Forms.Cursors.Default;
            }
        }