コード例 #1
0
ファイル: PrintBarCode.aspx.cs プロジェクト: lk3679/ObShop
        /// <summary>
        /// 列印
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnPrintProduct_Click(object sender, EventArgs e)
        {
            try
            {
                var destination = DDL_destination_ticket.SelectedValue;
                //解析DropDownList文字,取得machineId
                var machineId = Utility.GetMachineId(destination);
                var bars      = new List <BarcodePrint.BarcodeLabl>();
                if (lsbList.Items.Count > 0)
                {
                    for (int i = 0; i < lsbList.Items.Count; i++)
                    {
                        var bar = new BarcodePrint.BarcodeLabl();
                        bar.ProductId = lsbList.Items[i].Text;
                        bar.Barcode   = lsbList.Items[i].Value.Split('|')[0];
                        bar.Price     = lsbList.Items[i].Value.Split('|')[1];
                        bars.Add(bar);
                    }
                    var barcodeLabels = bars.GroupBy(x => new { x.ProductId, x.Barcode, x.Price }).Select(x => new BarcodePrint.BarcodeLabl
                    {
                        ProductId = x.Key.ProductId,
                        Barcode   = x.Key.Barcode,
                        Quantity  = x.Count().ToString(),
                        Price     = machineId == "P_SaleProduct"?x.Key.Price:""
                    }).ToList();
                    if (!barcodeLabels.Any())
                    {
                        lbl_Message.Text = "系統無此條碼!";
                        return;
                    }

                    var    printer     = new PosPrint();
                    var    p           = new BarcodePrint();
                    var    result      = p.PrintBarcode(printer, machineId, barcodeLabels);
                    string showMessage = string.Empty;
                    if (result)
                    {
                        showMessage = "<script>alert('列印成功!');</script>";
                    }
                    else
                    {
                        showMessage = "<script>alert('列印失敗!');</script>";
                    }
                    txt_productId.Text = "";
                    lsbList.Items.Clear();
                    Page.RegisterClientScriptBlock("checkinput", @showMessage);
                }
                else
                {
                    lbl_Message.Text = "沒有輸入任何要印的產品!";
                }
            }
            catch (Exception ex)
            {
                Response.Write("系統發生錯誤 " + ex.Message);
            }
        }
コード例 #2
0
ファイル: ProductChange.aspx.cs プロジェクト: lk3679/ObShop
        protected void btnPrintShelf_Click(object sender, EventArgs e)
        {
            try
            {
                var destination = DDL_destination_ticket.SelectedValue;
                //解析DropDownList文字,取得machineId
                var machineId = Utility.GetMachineId(destination);

                var pDa           = new POS_Library.ShopPos.ProductChangeDA();
                var result        = pDa.GetPriceProductChange();
                var printProduct  = result.Where(x => x.Print).ToList();
                var barcodeLabels = new List <BarcodePrint.BarcodeLabl>();
                var ckPrint       = true;
                if (printProduct.Any())
                {
                    foreach (var item in printProduct)
                    {
                        var barcodeLabel = new BarcodePrint.BarcodeLabl();
                        barcodeLabel.ProductId = item.ProductId;
                        barcodeLabel.Barcode   = item.Barcode;
                        barcodeLabel.Quantity  = item.Quantity.ToString();
                        barcodeLabel.Price     = item.NewPrice.ToString();
                        barcodeLabels.Add(barcodeLabel);

                        var printer     = new PosPrint();
                        var p           = new BarcodePrint();
                        var resultPrint = p.PrintBarcode(printer, machineId, barcodeLabels);
                        if (resultPrint)
                        {
                            pDa.SetPriceProductChange(item);
                        }
                        else
                        {
                            ckPrint = false;
                        }
                    }
                    if (!ckPrint)
                    {
                        lbl_Message.Text = "有部分條碼列印失敗!請繼續列印!";
                    }
                    else
                    {
                        lbl_Message.Text = "列印完成!";
                    }
                }
                else
                {
                    lbl_Message.Text = "沒有需要列印之產品!";
                }
                Default();
            }
            catch (Exception ex)
            {
                lbl_Message.Text = "列印失敗!請繼續列印!" + ex.Message;
            }
        }
コード例 #3
0
ファイル: PrintBarCode.aspx.cs プロジェクト: lk3679/ObShop
        /// <summary>
        /// 列印
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnPrintShelf_Click(object sender, EventArgs e)
        {
            var destination = DDL_destination_ticket.SelectedValue;
            //取得machineId
            var machineId     = Utility.GetMachineId(destination);
            var barcodeLabels = new List <BarcodePrint.BarcodeLabl>();

            //取checkbox有勾的
            foreach (GridViewRow row in gv_product_id.Rows)
            {
                var BL = new BarcodePrint.BarcodeLabl();
                BL.Id        = row.Cells[0].Text;
                BL.ProductId = row.Cells[1].Text;
                BL.Barcode   = row.Cells[2].Text;
                DropDownList ddl = row.Cells[3].FindControl("DDL_Quantity") as DropDownList;
                BL.Quantity = ddl.SelectedValue;
                BL.Price    = machineId == "P_SaleProduct" ? row.Cells[4].Text : "";
                //放入List
                barcodeLabels.Add(BL);
            }

            string showMessage = string.Empty;

            if (barcodeLabels.Count > 0)
            {
                var printer = new PosPrint();
                var p       = new BarcodePrint();
                var result  = p.PrintBarcode(printer, machineId, barcodeLabels);
                if (result)
                {
                    showMessage = "<script>alert('列印成功!');</script>";
                }
                else
                {
                    showMessage = "<script>alert('列印失敗!');</script>";
                }
            }
            else
            {
                showMessage = "<script>alert('沒有選擇資料!');</script>";
            }

            Page.RegisterClientScriptBlock("checkinput", @showMessage);
        }