예제 #1
0
 protected void CuentaSoporte()
 {
     using (CobranzasDataContext db = new CobranzasDataContext())
     {
         Entidades.Cuentas Cuenta = db.Cuentas.Single(x => x.idCuenta == Convert.ToInt32(Id));
         if (Convert.ToInt32(Val) != Cuenta.idPersona)
         {
             Response.Write("No está autorizado para ver este Soporte");
             return;
         }
         if (Cuenta.Ruta == null)
         {
             Response.Write("El archivo que ha seleccionado no está disponible en este momento, favor intente más tarde.");
             return;
         }
         if (Cuenta.Personas.idPais == "USA" && Cuenta.Soportes.Any(x => x.Codigo == "") && Request["Original"] == null)
         {
             Response.Write("<html><head></head><body><table style='width:100%; height:100%;'><tr>" +
                            "<td style='width:50%'><iframe height='100%' width='100%' seamless src='" + Request.Url + "&Original=1'>Outstanding Debt Notice</iframe></td>" +
                            "<td style='width:50%'><iframe height='100%' width='100%' seamless src='" + Request.Url + "&Original=2'>Invoice</iframe></td>" +
                            "</tr></table></body></html>");
             return;
         }
         String Ruta = "";
         if (Request["Original"] == "2")
         {
             Ruta = Cuenta.Soportes.First(x => x.Codigo == "").Ubicacion;
         }
         else
         {
             Ruta = Cuenta.Ruta;
         }
         try //trata de guardar la gestión
         {
             Entidades.Gestiones Gestion = new Entidades.Gestiones();
             Gestion.idOperador  = 1;
             Gestion.Fecha       = DateTime.Now;
             Gestion.Descripcion = "La persona ha visto el soporte de la factura";
             Gestion.idPersona   = Cuenta.idPersona;
             Gestion.idStatus    = 29;
             Gestion.Cuentas_Gestiones.Add(new Entidades.Cuentas_Gestiones {
                 idCuenta = Cuenta.idCuenta
             });
             db.Gestiones.InsertOnSubmit(Gestion);
             db.SubmitChanges();
         }
         catch { }
         BajarArchivo(Ruta, Response);
         return;
     }
 }
예제 #2
0
        public static otCuenta FromCuenta(Entidades.Cuentas c)
        {
            otCuenta Nuevo = new otCuenta();

            Nuevo.idPersona      = c.idPersona;
            Nuevo.idCuenta       = c.idCuenta;
            Nuevo.Documento      = c.Codigo;
            Nuevo.Persona        = c.Personas.Nombre;
            Nuevo.CodigoPersona  = c.Personas.Codigo;
            Nuevo.Fecha          = c.FechaInicio;
            Nuevo.FechaEntrega   = c.FechaEntrega;
            Nuevo.Total          = c.Monto;
            Nuevo.TotalDolar     = c.Monto / c.CambioDolar;
            Nuevo.TotalLocal     = c.Monto * c.CambioLocal;
            Nuevo.MontoBase      = c.MontoBase.Value;
            Nuevo.MontoBaseDolar = c.MontoBase.Value / c.CambioDolar;
            Nuevo.MontoBaseLocal = c.MontoBase.Value * c.CambioLocal;
            Nuevo.MontoIva       = c.MontoIva.Value;
            Nuevo.MontoIvaDolar  = c.MontoIva.Value / c.CambioDolar;
            Nuevo.MontoIvaLocal  = c.MontoIva.Value * c.CambioLocal;
            Nuevo.Cliente        = c.Clientes.Nombre;
            Nuevo.CodigoCliente  = c.Clientes.Codigo;
            Nuevo.Producto       = c.Productos.Nombre;
            Nuevo.Moneda         = c.idMoneda;
            Nuevo.Antiguedad     = (DateTime.Now - (c.FechaInicio ?? DateTime.Now)).Days;
            Nuevo.CambioDolar    = c.CambioDolar;
            Nuevo.MonedaLocal    = c.Personas.Paises.idMoneda;
            Nuevo.CambioLocal    = c.CambioLocal;
            Nuevo.Deuda          = c.MontoRestante;// Monto + ((Decimal?)c.Movimientos.Sum(x => x.Monto) ?? 0);
            Nuevo.DeudaDolar     = Nuevo.Deuda / c.CambioDolar;
            Nuevo.DeudaLocal     = Nuevo.Deuda * c.CambioLocal;
            Nuevo.EnReclamo      = c.EnReclamo;                               //c.Cuentas_Reclamos.Any(x => x.StatusReclamo.Abierto);
            Nuevo.Status         = c.EnReclamo ? "En Reclamo" : "En Gestión"; // c.Flujos_Pasos == null ? "Ninguno" : c.Flujos_Pasos.Pasos.Nombre;
            Nuevo.EsMeta         = "";                                        // c.Metas_Operadores_Cuentas.Any(x => x.Finalizado == null && x.Activa).ToString();
            Nuevo.CampoExtra     = (from d in c.Datos.Elements("Dato") where (string)d.Attribute("Clave") == "Bl" select d.Value).FirstOrDefault();
            //c.Datos.XPathEvaluate("/Datos/Dato[@Clave='Bl']").ToString();
            return(Nuevo);
        }
        public void BajarArchivo()
        {
            try
            {
                using (CobranzasDataContext db = new CobranzasDataContext())
                {
                    //String RutaTemporales = db.Parametros.Single(x => x.Clave == "RutaTemporales").Valor;
                    String Archivo = "";
                    //String NombreArchivo = "";
                    if (Request["idSoporte"] != null)
                    {
                        Entidades.Soportes Soporte   = db.Soportes.Single(x => x.idSoporte == Convert.ToInt32(Request["idSoporte"]));
                        String             Ubicacion = Soporte.Ubicacion;
                        Archivo = Ubicacion + Request["Archivo"] ?? "";
                    }
                    if (Request["idCuenta"] != null)
                    {
                        Entidades.Cuentas Cuenta = db.Cuentas.Single(x => x.idCuenta == Convert.ToInt32(Request["idCuenta"]));
                        Archivo = Cuenta.Ruta;
                    }
                    if (Request["idGestion"] != null)
                    {
                        Response.Write("<!DOCTYPE html><html><head><link href='/Estilos/Estilos.css?ver=9' rel='stylesheet' type='text/css' /></head><body><h1>Soportes para la Gestión:</h1>");
                        foreach (Entidades.Soportes Soporte in db.Soportes.Where(x => x.idTabla == Convert.ToInt32(Request["idGestion"]) && x.Tabla == "Gestiones"))
                        {
                            Response.Write("<a class='Telefono' href='/Emergentes/ctrlSoportes.aspx?idSoporte=" + Soporte.idSoporte + "'>" + Soporte.Nombre + "</a><br>");
                        }

                        Response.Write("</body></html>");
                        Response.Flush();
                        Response.End();
                        return;
                    }

                    //try
                    //{
                    Negocios.BajarArchivo(Archivo, Response);
                    //}
                    //catch { }
                    //if (Archivo.IndexOf("\\") == -1)// URL
                    //{
                    //    NombreArchivo = Archivo.Substring(Archivo.LastIndexOf("//") + 1);
                    //    String Ruta2 = RutaTemporales + DateTime.Now.ToString("yyyyMMddHHmmss") + NombreArchivo;

                    //    Response.Redirect(Archivo, true);
                    //    return;
                    //}
                    //else { //UNC
                    //    NombreArchivo = Archivo.Substring(Archivo.LastIndexOf("\\") + 1);
                    //}
                    //if (Archivo.ToLower().EndsWith(".pdf")) Response.ContentType = "application/pdf";
                    //if (Archivo.ToLower().EndsWith(".jpg")) Response.ContentType = "image/jpeg";
                    //if (Archivo.ToLower().EndsWith(".gif")) Response.ContentType = "image/gif";
                    //Response.AddHeader("content-disposition", "inline;filename='" + NombreArchivo + "'");
                    ////application/octet-stream
                    //Response.WriteFile(Archivo, true);

                    //Response.End();
                }
            }
            catch (Exception Ex)
            {
                //Ex.Registrar();
            }
        }