Exemple #1
0
        public static string NombreCompletoRecibo(Lfx.Data.IConnection dataBase, int iId)
        {
            // Toma el Id del recibo y devuelve el tipo y número (por ejemplo: "Recibo #003" o "Comprobante de Pago #256")
            Lfx.Data.Row TmpRecibo = dataBase.Row("recibos", "id_recibo", iId);

            if (TmpRecibo == null)
            {
                return("");
            }
            else if (System.Convert.ToInt32(TmpRecibo["numero"]) > 0)
            {
                return("Recibo Nº " + System.Convert.ToInt32(TmpRecibo["numero"]).ToString("00000000"));
            }
            else
            {
                return("Recibo S/N");
            }
        }
Exemple #2
0
        public static System.Drawing.Image ProductImage(Lfx.Data.IConnection dataBase, int productId, DownloadImage downloadImage)
        {
            string CachePath     = Lfx.Environment.Folders.CacheFolder;
            string ImageFileName = "product_" + productId.ToString() + ".jpg";
            bool   ImageInCache  = System.IO.File.Exists(CachePath + ImageFileName);

            if (downloadImage == DownloadImage.Always ||
                (downloadImage == DownloadImage.OnlyIfNotInCache && ImageInCache == false) ||
                ((downloadImage == DownloadImage.PreferCacheOnSlowLinks && ImageInCache == false) || Lfx.Workspace.Master.SlowLink == false))
            {
                //Download image and save to cache
                Lfx.Data.Row ImagenDB = dataBase.Row("articulos_imagenes", "imagen", "id_articulo", productId);

                if (ImagenDB != null && ImagenDB.Fields["imagen"].Value != null && ((byte[])(ImagenDB.Fields["imagen"].Value)).Length > 5)
                {
                    //Guardar imagen en cache
                    System.IO.BinaryWriter wr = new System.IO.BinaryWriter(System.IO.File.OpenWrite(CachePath + ImageFileName), System.Text.Encoding.Default);
                    wr.Write(((byte[])(ImagenDB.Fields["imagen"].Value)));
                    wr.Close();

                    byte[] ByteArr = ((byte[])(ImagenDB.Fields["imagen"].Value));
                    System.Drawing.Image Img;

                    using (System.IO.MemoryStream loStream = new System.IO.MemoryStream(ByteArr)) {
                        Img = System.Drawing.Image.FromStream(loStream);
                    }
                    return(Img);
                }
                else
                {
                    //Devuelve la imagen de la categoría, en lugar de la del artículo
                    int CategoriaArticulo = dataBase.FieldInt("SELECT id_categoria FROM articulos WHERE id_articulo=" + productId.ToString());
                    return(CategoryImage(dataBase, CategoriaArticulo, downloadImage));
                }
            }

            //Serve only from cache
            if (ImageInCache)
            {
                return(System.Drawing.Image.FromFile(CachePath + ImageFileName));
            }

            return(null);
        }
Exemple #3
0
        /// <summary>
        /// Devuelve el número de un comprobante (por ejemplo: 0001-00000135).
        /// </summary>
        public static string NumeroCompleto(Lfx.Data.IConnection connection, int itemId)
        {
            Lfx.Data.Row Comp;
            if (connection.InTransaction)
            {
                Comp = connection.Row("comprob", "id_comprob", itemId);
            }
            else
            {
                Comp = Lfx.Workspace.Master.Tables["comprob"].FastRows[itemId];
            }

            if (Comp == null)
            {
                return("");
            }
            else
            {
                return(System.Convert.ToInt32(Comp["pv"]).ToString("0000") + "-" + System.Convert.ToInt32(Comp["numero"]).ToString("00000000"));
            }
        }
Exemple #4
0
        public static System.Drawing.Image CategoryImage(Lfx.Data.IConnection dataBase, int categoryId, DownloadImage downloadImage)
        {
            string CachePath     = Lfx.Environment.Folders.CacheFolder;
            string ImageFileName = "product_category_" + categoryId.ToString() + ".jpg";
            bool   ImageInCache  = System.IO.File.Exists(CachePath + ImageFileName);

            if (downloadImage == DownloadImage.Always ||
                (downloadImage == DownloadImage.OnlyIfNotInCache && ImageInCache == false) ||
                ((downloadImage == DownloadImage.PreferCacheOnSlowLinks && ImageInCache == false) || Lfx.Workspace.Master.SlowLink == false))
            {
                //Download image and save to cache
                Lfx.Data.Row ImagenDB = dataBase.Row("articulos_categorias", "imagen", "id_categoria", categoryId);

                if (ImagenDB != null && ImagenDB["imagen"] != null && ((byte[])(ImagenDB["imagen"])).Length > 5)
                {
                    //Guardar imagen en cache
                    System.IO.BinaryWriter wr = new System.IO.BinaryWriter(System.IO.File.OpenWrite(CachePath + ImageFileName), System.Text.Encoding.Default);
                    wr.Write(((byte[])(ImagenDB["imagen"])));
                    wr.Close();

                    byte[] ByteArr = ((byte[])(ImagenDB["imagen"]));
                    System.IO.MemoryStream loStream = new System.IO.MemoryStream(ByteArr);
                    return(System.Drawing.Image.FromStream(loStream));
                }
                else
                {
                    return(null);
                }
            }

            //Serve only from cache
            if (ImageInCache)
            {
                return(System.Drawing.Image.FromFile(CachePath + ImageFileName));
            }

            return(null);
        }