Example #1
0
        /// <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);
            }
        }
Example #2
0
        /// <summary>
        /// 列印
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btn_Print_Click(object sender, EventArgs e)
        {
            try
            {
                List <string> shelfBarcode           = new List <string>();
                List <POS_Library.DB.Storage> BCList = new List <POS_Library.DB.Storage>();

                foreach (GridViewRow row in gv_List.Rows)
                {
                    CheckBox cbTest = row.Cells[0].FindControl("CB_Select") as CheckBox;

                    if (cbTest.Checked)
                    {
                        var shelfid = CF.TransLabelToShelfId(row.Cells[1].Text);
                        POS_Library.DB.Storage item = new POS_Library.DB.Storage();
                        item.ShelfId       = shelfid;
                        item.Area          = shelfid.Substring(0, 1);
                        item.Row           = int.Parse(shelfid.Substring(1, 2));
                        item.Base          = int.Parse(shelfid.Substring(3, 2));
                        item.Layer         = int.Parse(shelfid.Substring(5, 2));
                        item.Grid          = int.Parse(shelfid.Substring(7, 2));
                        item.StorageTypeId = int.Parse(row.Cells[5].Text);
                        BCList.Add(item);
                    }
                }
                bool result      = false;
                var  p           = new POS_Library.Public.BarcodePrint();
                var  radio       = int.Parse(radioStore.SelectedValue);
                var  destination = dropMachine.SelectedValue;

                //解析DropDownList文字,取得machineId
                var machineId = POS_Library.Public.Utility.GetMachineId(destination);
                if (radio == store)
                {
                    PosPrint posPrint = new PosPrint();
                    result = p.PrintShelfBarcode(posPrint, BCList, machineId, false, _areaId);
                }
                else
                {
                    Printer printer = new Printer();
                    result = p.PrintShelfBarcode(printer, BCList, machineId, false, _areaId);
                }

                if (result)
                {
                    Response.Write("列印成功!");
                }
                else
                {
                    Response.Write("列印失敗!");
                }
            }
            catch (Exception ex)
            {
                Response.Write("系統發生錯誤 " + ex.Message);
            }
        }
Example #3
0
        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;
            }
        }
Example #4
0
        /// <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);
        }