Пример #1
0
        /// <summary>
        /// 获取充值小票模版
        /// </summary>
        /// <param name="ticketModel"></param>
        /// <param name="titleStr"></param>
        /// <returns></returns>
        public string GetPrintStrByRecharge(TicketModel ticketModel, out string titleStr)
        {
            TicketSet ticketSet = new TicketSet();

            ticketSet.TicketWidth = ticketModel.TicketWidth - 5;
            ticketSet.SignWeight  = '-';
            ticketSet.SignLight   = '-';
            ticketSet.Colper1     = 0.33M;
            //ticketSet.Colper2 = 0.16M;
            ticketSet.Colper3            = 0.33M;
            ticketSet.Colper4            = 0.33M;
            ticketSet.KeyColper          = 0.22M;
            ticketSet.ValueColper        = 0.22M;
            ticketSet.KeyTopColper       = 0.19M;
            ticketSet.ValueTopColper     = 0.15M;
            ticketSet.MidCol1KeyColper   = 0.16M;
            ticketSet.MidCol1ValueColper = 0.26M;

            ticketSet.TicketSignature = "";
            ticketSet.TicketTitle     = ticketModel.StoreName;
            ticketSet.AddKeyAndValueTop("机号:", ticketModel.DeviceNumber);
            ticketSet.AddKeyAndValueTop("收银员:", ticketModel.Cashier);
            ticketSet.AddKeyAndValueTop("充值卡号:", ticketModel.SN);
            ticketSet.AddKeyAndValueTop("充值时间:", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            ticketSet.AddKeyAndValueTop("打印时间:", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

            DataTable productListDT = new DataTable();

            productListDT.Columns.Add("", typeof(string));
            productListDT.Columns.Add("充前金额", typeof(string));
            productListDT.Columns.Add("充值金额", typeof(string));
            //productListDT.Columns.Add("售价", typeof(string));
            productListDT.Columns.Add("可用金额", typeof(string));

            //int productNo = 1;
            string productNoStr = string.Empty;
            //foreach (var productModel in ticketModel.ProductList)
            //{
            //if (productNo < 10) productNoStr = "0" + productNo + ".";
            //if (productNo >= 10) productNoStr = productNo + ".";

            DataRow newRow1 = productListDT.NewRow();

            //newRow1["条码/品名0"] = "   " + productModel.Code;
            //string productNumStr = productModel.Num.ToString("0.###");

            newRow1["充前金额"] = ticketModel.rechargeModel.BeforeAmount.ToString("f2");

            newRow1["充值金额"] = " " + ticketModel.rechargeModel.RechargeAmount.ToString("f2") + " ";
            //newRow1["售价"] = productModel.Price.ToString("f2");
            newRow1["可用金额"] = ticketModel.rechargeModel.CurrentBalance.ToString("f2");
            productListDT.Rows.Add(newRow1);

            //productNo++;
            //}

            ticketSet.DtGoodsList = productListDT;

            ticketSet.AddKeyAndValueMid("充值方式:", ticketModel.PayType);
            ticketSet.AddKeyAndValueMid("实收:", "¥" + ticketModel.Receivable);

            if (ticketModel.FootItemList != null)
            {
                foreach (var footItem in ticketModel.FootItemList)
                {
                    ticketSet.AddKeyAndValueFoot(footItem, "");
                }
            }

            ticketSet.TicketFooter = "";

            var ticketStr   = ticketSet.Ticket(true);
            var ticketTitle = ticketSet.GetTicketTitle();

            titleStr = ticketTitle;
            return(ticketStr);
        }
Пример #2
0
        public string GetPrintStr(TicketModel ticketModel, out string titleStr)
        {
            TicketSet ticketSet = new TicketSet();

            ticketSet.TicketWidth = ticketModel.TicketWidth - 5;
            ticketSet.SignWeight  = '-';
            ticketSet.SignLight   = '-';
            ticketSet.Colper1     = 0.50M;
            //ticketSet.Colper2 = 0.16M;
            ticketSet.Colper3            = 0.23M;
            ticketSet.Colper4            = 0.26M;
            ticketSet.KeyColper          = 0.22M;
            ticketSet.ValueColper        = 0.22M;
            ticketSet.KeyTopColper       = 0.19M;
            ticketSet.ValueTopColper     = 0.15M;
            ticketSet.MidCol1KeyColper   = 0.16M;
            ticketSet.MidCol1ValueColper = 0.26M;

            ticketSet.TicketSignature = "";
            ticketSet.TicketTitle     = ticketModel.StoreName;
            ticketSet.AddKeyAndValueTop("机号:", ticketModel.DeviceNumber);
            ticketSet.AddKeyAndValueTop("收银员:", ticketModel.Cashier);
            ticketSet.AddKeyAndValueTop("流水号:", ticketModel.SN);
            string timeStr = "";

            switch (ticketModel.OrderType)
            {
            case 1:
            case 2:
                timeStr = "退换时间:";
                break;

            case 3:
                timeStr = "退单时间:";
                break;

            default:
                timeStr = "销售时间:";
                break;
            }
            ticketSet.AddKeyAndValueTop(timeStr, ticketModel.CreateDT.ToString("yyyy-MM-dd HH:mm:ss"));
            ticketSet.AddKeyAndValueTop("打印时间:", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));


            DataTable productListDT = new DataTable();

            productListDT.Columns.Add("条码/品名0", typeof(string));
            productListDT.Columns.Add("条码/品名", typeof(string));
            productListDT.Columns.Add("数量", typeof(string));
            //productListDT.Columns.Add("售价", typeof(string));
            productListDT.Columns.Add("小计", typeof(string));

            int    productNo    = 1;
            string productNoStr = string.Empty;

            foreach (var productModel in ticketModel.ProductList)
            {
                if (productNo < 10)
                {
                    productNoStr = "0" + productNo + ".";
                }
                if (productNo >= 10)
                {
                    productNoStr = productNo + ".";
                }

                DataRow newRow1 = productListDT.NewRow();
                newRow1["条码/品名0"] = "   " + productModel.Code;
                string productNumStr = productModel.Num.ToString("0.###");
                if (productModel.IsPromotion)
                {
                    newRow1["条码/品名"] = productNoStr + productModel.Name + "(促销)";
                }
                else
                {
                    newRow1["条码/品名"] = productNoStr + productModel.Name;
                }
                newRow1["数量"] = " " + productNumStr + " ";
                //newRow1["售价"] = productModel.Price.ToString("f2");
                newRow1["小计"] = productModel.SubTotal.ToString("f2");
                productListDT.Rows.Add(newRow1);

                productNo++;
            }

            ticketSet.DtGoodsList = productListDT;

            ticketSet.AddKeyAndValueMid("件数:", ticketModel.CountNum.ToString("f0"));
            if (Convert.ToDecimal(ticketModel.TotalPrice) >= 0)
            {
                ticketSet.AddKeyAndValueMid("应收:", "¥" + ticketModel.TotalPrice);
            }
            else
            {
                ticketSet.AddKeyAndValueMid("应收:", ticketModel.TotalPrice);
            }
            if (ticketModel.PayType != null)
            {
                ticketSet.AddKeyAndValueMid("结算:", ticketModel.PayType);
            }
            if (ticketModel.OrderType == 1 && Convert.ToDecimal(ticketModel.Receivable) > 0)
            {
                ticketSet.AddKeyAndValueMid("实收:", "¥" + ticketModel.Receivable);
            }
            else if (Convert.ToDecimal(ticketModel.Receivable) < 0)
            {
                ticketSet.AddKeyAndValueMid("退款:", ticketModel.Receivable);
            }
            else
            {
                ticketSet.AddKeyAndValueMid("实收:", "¥" + ticketModel.Receivable);
            }

            // ticketSet.AddKeyAndValueMid("称重:", Conver.FormatterZeroWeigh(ticketModel.Weigh));
            if (ticketModel.Change != 0)//3=退单
            {
                ticketSet.AddKeyAndValueMid("找零:", "¥" + ticketModel.Change.ToString("f2"));
            }
            //if (ticketModel.OrderType != 2)
            //{
            if (ticketModel.Preferential > 0 && ticketModel.OrderType != 3)
            {
                ticketSet.AddKeyAndValueMid("已优惠:", "¥" + ticketModel.Preferential.ToString("0.##"));
            }
            //退整单时显示原优惠
            if (ticketModel.Preferential > 0 && ticketModel.OrderType == 3)
            {
                ticketSet.AddKeyAndValueMid("原优惠:", "¥" + ticketModel.Preferential.ToString("0.##"));
            }
            //}
            //有导购员就显示导购员
            if (!string.IsNullOrEmpty(ticketModel.SaleMan))
            {
                if (ticketModel.SaleMan.Contains("["))
                {
                    var s = ticketModel.SaleMan.IndexOf('[');
                    var e = ticketModel.SaleMan.IndexOf(']');
                    ticketSet.AddKeyAndValueMid("导购员:", ticketModel.SaleMan.Substring(s + 1, e - s - 1));
                }
                else
                {
                    ticketSet.AddKeyAndValueMid("导购员:", ticketModel.SaleMan);
                }
            }
            //会员卡支付时显示余额
            if (ticketModel.CardAndBalances != null && ticketModel.CardAndBalances.Count > 0)
            {
                foreach (var item in ticketModel.CardAndBalances)
                {
                    ticketSet.AddKeyAndValueListForCard("卡号:" + item.FirstOrDefault().Key.ToString(), "\r\n余额:" + Convert.ToDecimal(item.FirstOrDefault().Value).ToString("f2"));
                }
            }

            if (ticketModel.FootItemList != null)
            {
                foreach (var footItem in ticketModel.FootItemList)
                {
                    ticketSet.AddKeyAndValueFoot(footItem, "");
                }
            }

            ticketSet.TicketFooter = "";

            var ticketStr   = ticketSet.Ticket();
            var ticketTitle = ticketSet.GetTicketTitle();

            titleStr = ticketTitle;
            return(ticketStr);
        }