Ejemplo n.º 1
0
        private void InitPrintData()
        {
            for (int i = 1; i <= ucPagerEx1.PageCount; i++)
            {
                List <SendOrder> orders;
                if (i == 1)
                {
                    orders = SendOrderDataList;
                }
                else
                {
                    var orderdata = SearchSendOrderList(i);
                    orders = orderdata.Data;
                }

                foreach (var order in orders.Where(w => !Printed.Contains(w.ID.ToString())))
                {
                    var printdata = new PrintData {
                        FName = txtSendName.Text, SName = txtAccount.Text, LName = txtLinkMan.Text, Tel = txtTel.Text, Img = pbCode.ImageLocation, OrderData = OrderInfo(order.ID), IsCheck = true
                    };
                    print.Enqueue(printdata, rpt, pagesize, autoprint);
                }
            }

            this.Invoke(new Action(() => { btnAutoPrint.Text = "启动自动打印"; }));
        }
Ejemplo n.º 2
0
 public void Enqueue(PrintData aj, ReportClass rpt, string printType, string printModel)
 {
     isbusy          = true;
     this.rpt        = rpt;
     this.printType  = printType;
     this.printModel = printModel;
     printData.Enqueue(aj);
     isbusy = false;
 }
Ejemplo n.º 3
0
        public void PrintB(PrintData info)
        {
            StringBuilder sb        = new StringBuilder();
            var           maxLength = 16;

            var orderinfo = info.OrderData;

            sb.Clear();
            sb.AppendFormat("客户:{0}\n", orderinfo.user_name);
            sb.AppendFormat("日期:{0}\n", orderinfo.time);
            sb.Append("商品         重量         单价         金额\n");
            var mtotal = 0.00;
            var Data   = orderinfo.product_list.Where(w => (printModel == "A" && w.balance_color == 0) || (printModel == "B" && w.balance_color == 1));

            foreach (var good in Data)
            {
                if (good.name.Length > maxLength)
                {
                    sb.Append(good.name.Substring(0, maxLength) + "\n");
                    var stra = good.name.Substring(maxLength);
                    if (stra.Length > maxLength)
                    {
                        sb.Append(stra.Substring(0, maxLength) + "\n");
                        stra = stra.Substring(maxLength);
                        sb.Append(stra);
                    }
                    else
                    {
                        sb.Append(stra);
                    }
                }
                else
                {
                    sb.Append(good.name);
                }
                var weight        = good.real_num.ToString();
                var price_padLeft = 18;
                var price         = good.price.ToString();
                var total_padLeft = 15;
                var total         = good.total.ToString();
                mtotal += good.total;
                sb.AppendFormat("            {0}{1}{2}\n", weight, price.PadLeft(price_padLeft - weight.Length, ' '), total.PadLeft(total_padLeft - price.Length, ' '));
            }
            sb.AppendFormat("{0}\n", "合计:" + mtotal.ToString().PadLeft(42, ' '));
            sb.Append("\n");
            sb.AppendFormat("收款账号名称:{0}\n", info.SName);
            sb.AppendFormat("联系人:{0}\n", info.LName);
            sb.AppendFormat("联系电话:{0}\n", info.Tel);
            sb.Append("\n");
            sb.Append("收货人:\n");
            PrintB(sb.ToString());
        }
Ejemplo n.º 4
0
        private void btnAutoPrint_Click(object sender, EventArgs e)
        {
            OrderEdit();
            DataVerifier dv = new DataVerifier();

            dv.Check(string.IsNullOrWhiteSpace(deliveName), "没有送货单名称");
            dv.CheckIfBeforePass(string.IsNullOrWhiteSpace(sName), "没有收款账号");
            dv.CheckIfBeforePass(string.IsNullOrWhiteSpace(lName), "没有联系人");
            dv.CheckIfBeforePass(orderinfo.Data == null, "没有可打印的数据");
            if (dv.Pass)
            {
                using (Printer print = new Printer())
                {
                    PrintData info = new PrintData {
                        FName = deliveName, SName = sName, LName = lName, Tel = tel, Img = imgPath, OrderData = orderinfo.Data
                    };
                    print.Enqueue(info, rpt, printType, printModel);
                    print.OncePrint();
                }
            }
            dv.ShowMsgIfFailed();
        }
Ejemplo n.º 5
0
        public bool Print(PrintData info)
        {
            if (printdata == null)
            {
                printdata = new DataSet();
                DataTable mainTable = new DataTable();
                mainTable.TableName = "mainTable";
                mainTable.Columns.AddRange(new[] {
                    new DataColumn("FName", typeof(string)),    //送货单名称
                    new DataColumn("CName", typeof(string)),    //客户名称
                    new DataColumn("DateTime", typeof(string)), //日期
                    new DataColumn("PName", typeof(string)),    //支付宝账号
                    new DataColumn("LName", typeof(string)),    //联系人
                    new DataColumn("Img", typeof(string))
                });

                DataTable sunTable = new DataTable();
                sunTable.TableName = "sunTable";
                sunTable.Columns.AddRange(new[] {
                    new DataColumn("ID", typeof(int)),          //序号
                    new DataColumn("PName", typeof(string)),    //商品
                    new DataColumn("Num", typeof(float)),       //拍单数量
                    new DataColumn("Weight", typeof(float)),    //重量
                    new DataColumn("Unit", typeof(string)),     //单位
                    new DataColumn("Price", typeof(decimal)),   //单价
                    new DataColumn("Total", typeof(decimal)),   //金额
                });

                printdata.Tables.Add(mainTable);
                printdata.Tables.Add(sunTable);
            }
            else
            {
                printdata.Tables[0].Rows.Clear();
                printdata.Tables[1].Rows.Clear();
            }

            var rowA = printdata.Tables[0].NewRow();

            rowA["FName"]    = info.FName;
            rowA["CName"]    = info.OrderData.user_name;
            rowA["DateTime"] = info.OrderData.time;
            rowA["PName"]    = info.SName;
            rowA["LName"]    = info.LName;
            rowA["Img"]      = info.Img;
            printdata.Tables[0].Rows.Add(rowA);
            var Data = new List <OrderProduct>();

            if (info.IsCheck)
            {
                if (!info.OrderData.product_list.Any(w => Convert.ToDecimal(w.real_num) <= 0))
                {
                    if (printModel == "A" && !info.OrderData.product_list.Any(w => w.balance_color == 1))
                    {
                        Data = info.OrderData.product_list;
                    }
                    else if (printModel == "B" && info.OrderData.product_list.Any(w => w.balance_color == 1))
                    {
                        Data = info.OrderData.product_list;
                    }
                }
            }
            else
            {
                Data = info.OrderData.product_list;
            }

            if (Data.Count == 0)
            {
                return(false);
            }

            foreach (var item in Data)
            {
                var row = printdata.Tables[1].NewRow();
                row["ID"]     = item.index;
                row["PName"]  = item.name;
                row["Num"]    = item.num;
                row["Weight"] = string.IsNullOrWhiteSpace(item.real_num) ? "0": item.real_num;
                row["Unit"]   = item.unit;
                row["Price"]  = item.price;
                row["Total"]  = item.total;
                printdata.Tables[1].Rows.Add(row);
            }

            Write(info.OrderData.id.ToString());

            return(Print(printdata));
        }