Ejemplo n.º 1
0
 public ProductBase(ProductBase product)
 {
     //Basic
     this.Id                = product.Id;
     this.Code              = product.Code;
     this.AlternativeCode   = product.AlternativeCode;
     this.Description       = product.Description;
     this.Brand             = product.Brand;
     this.Category          = product.Category;
     this.Provider          = product.Provider;
     this.ProviderProductId = product.ProviderProductId;
     this.ImageName         = product.ImageName;
     this.Image             = product.Image;
     //Amounts
     this.AmountSold    = product.AmountSold;
     this.Cost          = product.Cost;
     this.CostCurrency  = product.CostCurrency;
     this.Price         = product.Price;
     this.PriceCurrency = product.PriceCurrency;
     //Quantities
     this.LastQuantitySold       = product.LastQuantitySold;
     this.TotalQuantityAvailable = product.TotalQuantityAvailable;
     this.LocalQuantityAvailable = product.LocalQuantityAvailable;
     this.MinimumStockQuantity   = product.MinimumStockQuantity;
     this.InternalQuantity       = product.InternalQuantity;
     this.QuantitySold           = product.QuantitySold;
     //dates
     this.LastPurchaseDate = product.LastPurchaseDate;
     this.LastSaleDate     = product.LastSaleDate;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Add new product to data table
        /// </summary>
        /// <param name="product"></param>
        /// <returns></returns>
        public bool AddNewProductToTable(ProductBase product)
        {
            _dictofdata.Rows.Add();
            var row = _dictofdata.Rows[_dictofdata.Rows.Count - 1];

            row["NumeroProducto"]      = product.Id.ToString();
            row["Codigo"]              = product.Code;
            row["CodigoAlterno"]       = product.AlternativeCode;
            row["ProveedorProductoId"] = product.ProviderProductId;
            row["Descripcion"]         = product.Description;
            row["Proveedor"]           = product.Provider;
            row["Categoria"]           = product.Category;
            row["Costo"]                    = product.Cost.ToString(CultureInfo.InvariantCulture);
            row["CostoMoneda"]              = product.CostCurrency;
            row["Precio"]                   = product.Price.ToString();
            row["PrecioMoneda"]             = product.PriceCurrency;
            row["CantidadInternoHistorial"] = product.InternalQuantity.ToString();
            row["CantidadVendidoHistorial"] = product.QuantitySold.ToString();
            row["CantidadLocal"]            = product.LocalQuantityAvailable.ToString();
            row["CantidadDisponibleTotal"]  = product.TotalQuantityAvailable.ToString();
            row["VendidoHistorial"]         = product.AmountSold.ToString();
            row["CantidadMinima"]           = product.MinimumStockQuantity.ToString();
            row["UltimoPedidoFecha"]        = product.LastPurchaseDate.ToString();
            row["UltimaTransaccionFecha"]   = product.LastSaleDate.ToString();
            row["Imagen"]                   = product.ImageName;

            return(true);
        }
Ejemplo n.º 3
0
        internal void Execute_ClickEnterCommand(object parameter)
        {
            if (Category != null && Price != null && Price != "0")
            {
                if (ManualProduct == null)
                {
                    if (UsdEnabled == true)
                    {
                        ManualProduct = ProductBase.Add(Description, Category, Math.Round(decimal.Parse(Price) * MainWindowViewModel.GetInstance().ExchangeRate, 2), Quantity);
                    }
                    else
                    {
                        ManualProduct = ProductBase.Add(Description, Category, decimal.Parse(Price), Quantity);
                    }
                }
                else
                {
                    //Check price currency and current currency state
                    if (ManualProduct.PriceCurrency == CurrencyTypeEnum.USD)
                    {
                        UsdEnabled          = true;
                        ManualProduct.Price = Math.Round(decimal.Parse(Price) * MainWindowViewModel.GetInstance().ExchangeRate, 2);
                    }
                    else
                    {
                        UsdEnabled          = false;
                        ManualProduct.Price = decimal.Parse(Price);
                    }

                    ManualProduct.Description      = Description;
                    ManualProduct.Category         = Category;
                    ManualProduct.LastQuantitySold = Quantity;
                }
            }
            //MainWindowViewModel.AddManualProductToCart(ManualProduct); Changed from static
            var main = MainWindowViewModel.GetInstance();

            main.AddManualProductToCart(ManualProduct);
            Clear         = true;
            Price         = "0";
            Description   = "";
            Quantity      = 1;
            ManualProduct = null;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Update the sold product
        /// </summary>
        /// <param name="product"></param>
        /// <returns></returns>
        public bool UpdateSoldProductToTable(ProductBase product)
        {
            for (int index = 0; index < _dictofdata.Rows.Count; index++)
            {
                var row = _dictofdata.Rows[index];
                if (row["Codigo"].ToString() == product.Code)
                {
                    row["CantidadDisponibleTotal"] = product.TotalQuantityAvailable.ToString();
                    row["Precio"] = product.Price.ToString();
                    row["CantidadVendidoHistorial"] = product.QuantitySold.ToString();
                    row["VendidoHistorial"]         = product.AmountSold.ToString();
                    row["CantidadInternoHistorial"] = product.InternalQuantity.ToString();
                    row["CantidadLocal"]            = product.LocalQuantityAvailable.ToString();
                    row["UltimaTransaccionFecha"]   = product.LastSaleDate.ToString();
                }
            }

            return(true);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Search and returns a list of products
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public List <ProductBase> Search(string input)
        {
            var products = new List <ProductBase>();

            //Return empty list if invalid inputs are entered for the search
            if (string.IsNullOrWhiteSpace(input) || input == "x")
            {
                return(products);
            }

            if (input == "*")
            {
                var allProducts = _dictofdata.AsEnumerable();
                foreach (var row in allProducts)
                {
                    var product = new ProductBase()
                    {
                        Id                     = Int32.Parse(row["NumeroProducto"].ToString()),
                        Code                   = row["Codigo"].ToString(),
                        AlternativeCode        = row["CodigoAlterno"].ToString(),
                        ProviderProductId      = row["ProveedorProductoId"].ToString(),
                        Description            = row["Descripcion"].ToString(),
                        Provider               = row["Proveedor"].ToString(),
                        Category               = row["Categoria"].ToString(),
                        LastPurchaseDate       = Convert.ToDateTime(row["UltimoPedidoFecha"].ToString()),
                        Cost                   = Decimal.Parse(row["Costo"].ToString()),
                        Price                  = decimal.Parse(row["Precio"].ToString()),
                        InternalQuantity       = Int32.Parse(row["CantidadInternoHistorial"].ToString()),
                        QuantitySold           = Int32.Parse(row["CantidadVendidoHistorial"].ToString()),
                        AmountSold             = decimal.Parse(row["VendidoHistorial"].ToString()),
                        LocalQuantityAvailable = Int32.Parse(row["CantidadLocal"].ToString()),
                        TotalQuantityAvailable = Int32.Parse(row["CantidadDisponibleTotal"].ToString()),
                        MinimumStockQuantity   = Int32.Parse(row["CantidadMinima"].ToString()),
                        LastSaleDate           = Convert.ToDateTime(row["UltimaTransaccionFecha"].ToString()),
                        ImageName              = row["Imagen"].ToString()
                    };

                    product.CostCurrency  = row["CostoMoneda"].ToString().ToUpper() == "USD" ? CurrencyTypeEnum.USD : CurrencyTypeEnum.MXN;
                    product.PriceCurrency = row["PrecioMoneda"].ToString().ToUpper() == "USD" ? CurrencyTypeEnum.USD : CurrencyTypeEnum.MXN;

                    products.Add(product);
                }

                return(products);
            }

            var descriptionFilter = _dictofdata.AsEnumerable().Where(r => r.Field <string>("Descripcion").ToLower().Contains(input));
            var codeFilter        = _dictofdata.AsEnumerable().Where(r => r.Field <string>("Codigo").ToLower().Contains(input));

            foreach (var row in codeFilter)
            {
                var product = new ProductBase()
                {
                    Id                     = Int32.Parse(row["NumeroProducto"].ToString()),
                    Code                   = row["Codigo"].ToString(),
                    AlternativeCode        = row["CodigoAlterno"].ToString(),
                    ProviderProductId      = row["ProveedorProductoId"].ToString(),
                    Description            = row["Descripcion"].ToString(),
                    Provider               = row["Proveedor"].ToString(),
                    Category               = row["Categoria"].ToString(),
                    LastPurchaseDate       = Convert.ToDateTime(row["UltimoPedidoFecha"].ToString()),
                    Cost                   = Decimal.Parse(row["Costo"].ToString()),
                    Price                  = decimal.Parse(row["Precio"].ToString()),
                    InternalQuantity       = Int32.Parse(row["CantidadInternoHistorial"].ToString()),
                    QuantitySold           = Int32.Parse(row["CantidadVendidoHistorial"].ToString()),
                    AmountSold             = decimal.Parse(row["VendidoHistorial"].ToString()),
                    LocalQuantityAvailable = Int32.Parse(row["CantidadLocal"].ToString()),
                    TotalQuantityAvailable = Int32.Parse(row["CantidadDisponibleTotal"].ToString()),
                    MinimumStockQuantity   = Int32.Parse(row["CantidadMinima"].ToString()),
                    LastSaleDate           = Convert.ToDateTime(row["UltimaTransaccionFecha"].ToString()),
                    ImageName              = row["Imagen"].ToString()
                };

                product.CostCurrency  = row["CostoMoneda"].ToString().ToUpper() == "USD" ? CurrencyTypeEnum.USD : CurrencyTypeEnum.MXN;
                product.PriceCurrency = row["PrecioMoneda"].ToString().ToUpper() == "USD" ? CurrencyTypeEnum.USD : CurrencyTypeEnum.MXN;

                products.Add(product);
            }

            foreach (var row in descriptionFilter)
            {
                var product = new ProductBase()
                {
                    Id                     = Int32.Parse(row["NumeroProducto"].ToString()),
                    Code                   = row["Codigo"].ToString(),
                    AlternativeCode        = row["CodigoAlterno"].ToString(),
                    ProviderProductId      = row["ProveedorProductoId"].ToString(),
                    Description            = row["Descripcion"].ToString(),
                    Provider               = row["Proveedor"].ToString(),
                    Category               = row["Categoria"].ToString(),
                    LastPurchaseDate       = Convert.ToDateTime(row["UltimoPedidoFecha"].ToString()),
                    Cost                   = Decimal.Parse(row["Costo"].ToString()),
                    Price                  = decimal.Parse(row["Precio"].ToString()),
                    InternalQuantity       = Int32.Parse(row["CantidadInternoHistorial"].ToString()),
                    QuantitySold           = Int32.Parse(row["CantidadVendidoHistorial"].ToString()),
                    AmountSold             = decimal.Parse(row["VendidoHistorial"].ToString()),
                    LocalQuantityAvailable = Int32.Parse(row["CantidadLocal"].ToString()),
                    TotalQuantityAvailable = Int32.Parse(row["CantidadDisponibleTotal"].ToString()),
                    MinimumStockQuantity   = Int32.Parse(row["CantidadMinima"].ToString()),
                    LastSaleDate           = Convert.ToDateTime(row["UltimaTransaccionFecha"].ToString()),
                    ImageName              = row["Imagen"].ToString()
                };

                product.CostCurrency  = row["CostoMoneda"].ToString().ToUpper() == "USD" ? CurrencyTypeEnum.USD : CurrencyTypeEnum.MXN;
                product.PriceCurrency = row["PrecioMoneda"].ToString().ToUpper() == "USD" ? CurrencyTypeEnum.USD : CurrencyTypeEnum.MXN;

                //Add if it does not exist already
                if (!products.Exists(x => x.Code == product.Code))
                {
                    products.Add(product);
                }
            }

            return(products);
        }
Ejemplo n.º 6
0
        public static IEnumerable <ProductBase> AddListItem(IEnumerable <ProductBase> item, ProductBase newItem, int selectedItemIndex)
        {
            var updatedList = item.ToList();

            if (updatedList.Count < 20)
            {
                updatedList.Insert(selectedItemIndex + 1, newItem);
            }
            var tempItem = updatedList[selectedItemIndex];

            updatedList.RemoveAt(selectedItemIndex);
            return(updatedList);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Prints end of sales X receipt
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void PrintEndOfDaySalesFullReceipt(object sender, PrintPageEventArgs e)
        {
            Graphics graphic = e.Graphics;

            Font font          = new Font("Courier New", 9, System.Drawing.FontStyle.Bold);
            Font storeNameFont = new Font("Courier New", 14, System.Drawing.FontStyle.Bold);
            Font storeInfoFont = new Font("Courier New", 8, System.Drawing.FontStyle.Bold);

            var   buf                 = string.Empty;
            float fontHeight          = 9.0f + 4.5f;
            float storeNameFontHeight = storeNameFont.GetHeight();
            float storeInfoFontHeight = 8 + 6f;

            //Parse Description
            var commentsLines = new List <string>();

            if (EndOfDayAmountData.Comments == null)
            {
                commentsLines.Add(" ");
            }
            else
            {
                commentsLines = Formatter.BreakDownString(EndOfDayAmountData.Comments, 35);
            }

            int startX = 5;
            int startY = 1;
            int offset = 10;

            int itemsNumber = 0;

            //Header business info
            buf = "  " + Pos.BusinessName;
            graphic.DrawString(buf, storeNameFont, new SolidBrush(Color.Black), startX,
                               startY + offset);
            offset = offset + (int)storeNameFontHeight;
            buf    = "     " + Pos.FiscalName;
            graphic.DrawString(buf, storeInfoFont, new SolidBrush(Color.Black), startX,
                               startY + offset);
            offset = offset + (int)storeInfoFontHeight;
            buf    = "          " + Pos.FiscalType + "  " + Pos.FiscalNumber;
            graphic.DrawString(buf, storeInfoFont, new SolidBrush(Color.Black), startX,
                               startY + offset);
            offset = offset + (int)storeInfoFontHeight;
            buf    = "  " + Pos.FiscalStreetAddress;
            graphic.DrawString(buf, storeInfoFont, new SolidBrush(Color.Black),
                               startX, startY + offset);
            offset = offset + (int)storeInfoFontHeight;
            buf    = "   " + Pos.FiscalCityAndZipCode + "  " + Pos.FiscalPhoneNumber;
            graphic.DrawString(buf, storeInfoFont, new SolidBrush(Color.Black), startX,
                               startY + offset);
            offset = offset + (int)storeInfoFontHeight;

            buf = "        " + Pos.FiscalEmail;
            graphic.DrawString(buf, storeInfoFont, new SolidBrush(Color.Black), startX,
                               startY + offset);
            offset = offset + (int)storeInfoFontHeight + 10;

            //Ticket numbers and range
            graphic.DrawString("Corte X    " + "Folio " + EndOfDayReceiptData.FirstReceiptNumber.ToString() + " al " +
                               EndOfDayReceiptData.LastReceiptNumber, storeInfoFont, new SolidBrush(Color.Black), startX,
                               startY + offset);
            offset = offset + (int)storeInfoFontHeight + 10;

            Thread.CurrentThread.CurrentCulture = new CultureInfo("es-MX");
            var date = DateTime.Now.ToString("g");

            var ticketNumber = "No. " + Pos.LastCorteZNumber.ToString();

            graphic.DrawString(ticketNumber.PadRight(18) + date, storeInfoFont, new SolidBrush(Color.Black), startX,
                               startY + offset);
            offset = offset + (int)storeInfoFontHeight + 10;

            //Sales per category loop
            foreach (var catInfo in EndOfDayReceiptData.SalesInfoPerCategory)
            {
                //mimic a product just to use the ToString overwrite
                var cat = new ProductBase()
                {
                    Category         = catInfo.Item1,
                    LastQuantitySold = catInfo.Item2,
                    Price            = catInfo.Item3
                };
                if (cat.LastAmountSold != 0 || cat.Price != 0)
                {
                    graphic.DrawString(cat.ToString(ReceiptType.DailyRegular), font, new SolidBrush(Color.Black), startX, startY + offset);
                    offset = offset + (int)fontHeight;
                }
            }

            offset = offset + 10;

            //TOTAL LE CABEN 35 letras
            //graphic.DrawString("***********************************", font,
            //    new SolidBrush(Color.Black), startX, startY + offset);

            //offset = offset + (int)fontHeight + 1;

            graphic.DrawString("********** Total Ventas ***********", font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Puntos Usados: ".PadLeft(20) + string.Format("{0}", EndOfDayReceiptData.PointsTotal), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Total Articulos: ".PadLeft(20) + string.Format("{0}", EndOfDayReceiptData.TotalItemsSold), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Efectivo MXN: ".PadLeft(20) + string.Format("{0:c}", EndOfDayReceiptData.CashTotal), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Tarjeta MXN: ".PadLeft(20) + string.Format("{0:c}", EndOfDayReceiptData.CardTotal), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Otro Metodo MXN: ".PadLeft(20) + string.Format("{0:c}", EndOfDayReceiptData.OtherTotal +
                                                                               EndOfDayReceiptData.BankTotal + EndOfDayReceiptData.CheckTotal), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Total MXN: ".PadLeft(20) + string.Format("{0:c}", EndOfDayReceiptData.TotalAmountSold), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("********** Devoluciones ***********", font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Total Articulos: ".PadLeft(20) + string.Format("{0}", EndOfDayReceiptData.TotalReturnItems), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Efectivo MXN: ".PadLeft(20) + string.Format("{0:c}", EndOfDayReceiptData.ReturnsCash), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Tarjeta MXN: ".PadLeft(20) + string.Format("{0:c}", EndOfDayReceiptData.ReturnsCard), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Total MXN: ".PadLeft(20) + string.Format("{0:c}", EndOfDayReceiptData.ReturnsCard + EndOfDayReceiptData.ReturnsCash),
                               font, new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("*********** Total Caja ************", font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Monedas Pesos: ".PadLeft(20) + string.Format("{0:c}", EndOfDayAmountData.MxnCoins), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Pesos 20: ".PadLeft(20) + string.Format("{0}", EndOfDayAmountData.Mxn20), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Pesos 50: ".PadLeft(20) + string.Format("{0}", EndOfDayAmountData.Mxn50), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Pesos 100: ".PadLeft(20) + string.Format("{0}", EndOfDayAmountData.Mxn100), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Pesos 200: ".PadLeft(20) + string.Format("{0}", EndOfDayAmountData.Mxn200), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Pesos 500: ".PadLeft(20) + string.Format("{0}", EndOfDayAmountData.Mxn500), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Pesos 1000: ".PadLeft(20) + string.Format("{0}", EndOfDayAmountData.Mxn1000), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Total Efectivo MXN: ".PadLeft(20) + string.Format("{0:c}", EndOfDayAmountData.MxnTotalCash), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Monedas Dolar: ".PadLeft(20) + string.Format("{0:c}", EndOfDayAmountData.UsdCoins), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Dolar 1: ".PadLeft(20) + string.Format("{0}", EndOfDayAmountData.Usd1), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Dolar 5: ".PadLeft(20) + string.Format("{0}", EndOfDayAmountData.Usd5), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Dolar 10: ".PadLeft(20) + string.Format("{0}", EndOfDayAmountData.Usd10), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Dolar 20: ".PadLeft(20) + string.Format("{0}", EndOfDayAmountData.Usd20), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Dolar 50: ".PadLeft(20) + string.Format("{0}", EndOfDayAmountData.Usd50), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Dolar 100: ".PadLeft(20) + string.Format("{0}", EndOfDayAmountData.Usd100), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Total Efectivo USD: ".PadLeft(20) + string.Format("{0:c}", EndOfDayAmountData.UsdTotalCash), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("********** Total Gastos ***********", font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Efectivo MXN: ".PadLeft(20) + string.Format("{0:c}", EndOfDayAmountData.ExpensesCash), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Totales MXN: ".PadLeft(20) + string.Format("{0:c}", EndOfDayAmountData.ExpensesTotal), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("************* Resumen *************", font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Usuario: ".PadLeft(20) + string.Format("{0}", EndOfDayAmountData.User), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Tipo de Corte: ".PadLeft(20) + string.Format("{0}", EndOfDayAmountData.EndOfSalesReceiptType), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Tipo de Cambio: ".PadLeft(20) + string.Format("{0:c}", EndOfDayAmountData.ExchangeRate), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Caja Inicio MXN: ".PadLeft(20) + string.Format("{0:c}", EndOfDayAmountData.InitialCash), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Caja Nueva MXN: ".PadLeft(20) + string.Format("{0:c}", EndOfDayAmountData.NewInitialCash), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Diferencia MXN: ".PadLeft(20) + string.Format("{0:c}", EndOfDayAmountData.Delta), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;
            offset = offset + (int)fontHeight + 1;

            graphic.DrawString("Comentarios: ", font, new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 1;

            foreach (var commentLine in commentsLines)
            {
                graphic.DrawString(string.Format("{0}", commentLine), font, new SolidBrush(Color.Black), startX, startY + offset);

                offset = offset + (int)fontHeight + 1;
            }

            graphic.DrawString(string.Format("  Final Corte {0} {1}", EndOfDayAmountData.EndOfSalesReceiptType, date), storeInfoFont, new SolidBrush(Color.Black),
                               startX, startY + offset);
            offset = offset + (int)storeInfoFontHeight;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Prints end of day Z receipt
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void PrintEndOfDaySalesReceipt(object sender, PrintPageEventArgs e)
        {
            Graphics graphic = e.Graphics;

            Font font          = new Font("Courier New", 9, System.Drawing.FontStyle.Bold);
            Font storeNameFont = new Font("Courier New", 14, System.Drawing.FontStyle.Bold);
            Font storeInfoFont = new Font("Courier New", 8, System.Drawing.FontStyle.Bold);

            var   buf                 = string.Empty;
            float fontHeight          = font.GetHeight();
            float storeNameFontHeight = storeNameFont.GetHeight();
            float storeInfoFontHeight = storeInfoFont.GetHeight();

            int startX = 5;
            int startY = 2;
            int offset = 10;

            int itemsNumber = 0;

            //Header business information
            buf = "  " + Pos.BusinessName;
            graphic.DrawString(buf, storeNameFont, new SolidBrush(Color.Black), startX,
                               startY + offset);
            offset = offset + (int)storeNameFontHeight;
            buf    = "     " + Pos.FiscalName;
            graphic.DrawString(buf, storeInfoFont, new SolidBrush(Color.Black), startX,
                               startY + offset);
            offset = offset + (int)storeInfoFontHeight;
            buf    = "          " + Pos.FiscalType + "  " + Pos.FiscalNumber;
            graphic.DrawString(buf, storeInfoFont, new SolidBrush(Color.Black), startX,
                               startY + offset);
            offset = offset + (int)storeInfoFontHeight;
            buf    = "  " + Pos.FiscalStreetAddress;
            graphic.DrawString(buf, storeInfoFont, new SolidBrush(Color.Black),
                               startX, startY + offset);
            offset = offset + (int)storeInfoFontHeight;
            buf    = "   " + Pos.FiscalCityAndZipCode + "  " + Pos.FiscalPhoneNumber;
            graphic.DrawString(buf, storeInfoFont, new SolidBrush(Color.Black), startX,
                               startY + offset);
            offset = offset + (int)storeInfoFontHeight;

            buf = "        " + Pos.FiscalEmail;
            graphic.DrawString(buf, storeInfoFont, new SolidBrush(Color.Black), startX,
                               startY + offset);
            offset = offset + (int)storeInfoFontHeight + 10;

            //Receipt number and tickets number range
            graphic.DrawString("Corte Z    " + "Folio " + EndOfDayReceiptData.FirstReceiptNumber.ToString() + " al " +
                               EndOfDayReceiptData.LastReceiptNumber, storeInfoFont, new SolidBrush(Color.Black), startX,
                               startY + offset);
            offset = offset + (int)storeInfoFontHeight + 10;

            Thread.CurrentThread.CurrentCulture = new CultureInfo("es-MX");
            var date = DateTime.Now.ToString("g");

            var ticketNumber = "No. " + Pos.LastCorteZNumber.ToString();

            graphic.DrawString(ticketNumber.PadRight(18) + date, storeInfoFont, new SolidBrush(Color.Black), startX,
                               startY + offset);
            offset = offset + (int)storeInfoFontHeight + 10;

            //Gets each category information
            foreach (var catInfo in EndOfDayReceiptData.SalesInfoPerCategory)
            {
                //mimic a product just to use the ToString overwrite
                var cat = new ProductBase()
                {
                    Category         = catInfo.Item1,
                    LastQuantitySold = catInfo.Item2,
                    Price            = catInfo.Item3
                };
                //product line
                if (cat.LastQuantitySold != 0 || cat.Price != 0)
                {
                    graphic.DrawString(cat.ToString(ReceiptType.DailyRegular), font, new SolidBrush(Color.Black), startX, startY + offset);
                    offset = offset + (int)fontHeight;
                }
            }

            offset = offset + 10;

            graphic.DrawString("Articulos: ".PadLeft(20) + string.Format("{0}", EndOfDayReceiptData.TotalItemsSold), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 5;

            graphic.DrawString("Efectivo: ".PadLeft(20) + string.Format("{0:c}", EndOfDayReceiptData.CashTotal), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 5;

            graphic.DrawString("Tarjeta: ".PadLeft(20) + string.Format("{0:c}", EndOfDayReceiptData.CardTotal), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 5;

            graphic.DrawString("Otro Metodo: ".PadLeft(20) + string.Format("{0:c}", EndOfDayReceiptData.OtherTotal +
                                                                           EndOfDayReceiptData.BankTotal + EndOfDayReceiptData.BankTotal), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 5;

            graphic.DrawString("Total: ".PadLeft(20) + string.Format("{0:c}", EndOfDayReceiptData.TotalAmountSold), font,
                               new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)fontHeight + 5;

            graphic.DrawString(string.Format("  Final Corte {0} {1}", EndOfDayAmountData.EndOfSalesReceiptType, date), storeInfoFont, new SolidBrush(Color.Black),
                               startX, startY + offset);
            offset = offset + (int)storeInfoFontHeight;
        }