Exemple #1
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            string templatePath = TEMPLATE_DIRECTORY;

            // None decoration frame
            if (cmbTemplate.SelectedIndex == 0)
            {
                templatePath += TEMPLATE_SIMPLE;
            }
            // Decoration frame
            else
            {
                templatePath += TEMPLATE_FRAME;
            }

            bpac.DocumentClass doc = new DocumentClass();
            if (doc.Open(templatePath) != false)
            {
                doc.GetObject("objCompany").Text = txtCompany.Text;
                doc.GetObject("objName").Text    = txtName.Text;

                // doc.SetMediaById(doc.Printer.GetMediaId(), true);
                doc.StartPrint("", PrintOptionConstants.bpoDefault);
                doc.PrintOut(1, PrintOptionConstants.bpoDefault);
                doc.EndPrint();
                doc.Close();
            }
            else
            {
                MessageBox.Show("Open() Error: " + doc.ErrorCode);
            }
        }
Exemple #2
0
        public void Print(BarcodeVolksschiessen barcodeInfo)
        {
            DocumentClass doc      = new DocumentClass();
            const string  path     = @".\Templates\Volksschiessen_2015.lbx";
            string        fullPath = Path.GetFullPath(path);

            if (doc.Open(fullPath))
            {
                IObject barcode = doc.GetObject("barcode");
                barcode.Text = Convert.ToString(barcodeInfo.Barcode);

                IObject shooterName = doc.GetObject("shooterName");
                shooterName.Text = Convert.ToString(barcodeInfo.FirstName + " " + barcodeInfo.LastName);

                IObject dateOfBirth = doc.GetObject("dateOfBirth");
                dateOfBirth.Text = Convert.ToString(barcodeInfo.DateOfBirth != null ? ((DateTime)barcodeInfo.DateOfBirth).ToString("dd.MM.yyyy") : string.Empty);

                IObject groupName = doc.GetObject("GroupName");
                groupName.Text = Convert.ToString(barcodeInfo.Gruppenstich ?? string.Empty);

                IObject isGroup = doc.GetObject("isGruppen");
                isGroup.Text = Convert.ToString(barcodeInfo.Gruppenstich == null ? string.Empty : "x");

                doc.StartPrint("", PrintOptionConstants.bpoDefault);
                doc.PrintOut(1, PrintOptionConstants.bpoDefault);
                doc.EndPrint();
                doc.Close();
            }
            else
            {
                throw new InvalidOperationException(string.Format("Can not open template file '{0}'", fullPath));
            }
        }
    public void Print(BarcodeVolksschiessen barcodeInfo)
    {
      DocumentClass doc = new DocumentClass();
      const string path = @".\Templates\Volksschiessen_2015.lbx";
      string fullPath = Path.GetFullPath(path);
      if (doc.Open(fullPath))
      {
        IObject barcode = doc.GetObject("barcode");
        barcode.Text = Convert.ToString(barcodeInfo.Barcode);

        IObject shooterName = doc.GetObject("shooterName");
        shooterName.Text = Convert.ToString(barcodeInfo.FirstName + " " + barcodeInfo.LastName);

        IObject dateOfBirth = doc.GetObject("dateOfBirth");
        dateOfBirth.Text = Convert.ToString(barcodeInfo.DateOfBirth != null ? ((DateTime)barcodeInfo.DateOfBirth).ToString("dd.MM.yyyy") : string.Empty);

        IObject groupName = doc.GetObject("GroupName");
        groupName.Text = Convert.ToString(barcodeInfo.Gruppenstich ?? string.Empty);

        IObject isGroup = doc.GetObject("isGruppen");
        isGroup.Text = Convert.ToString(barcodeInfo.Gruppenstich == null ? string.Empty : "x");

        doc.StartPrint("", PrintOptionConstants.bpoDefault);
        doc.PrintOut(1, PrintOptionConstants.bpoDefault);
        doc.EndPrint();
        doc.Close();
      }
      else
      {
        throw new InvalidOperationException(string.Format("Can not open template file '{0}'", fullPath));
      }
    }
Exemple #4
0
 public void Close()
 {
     if (!_doc.Close())
     {
         throw new BpacException("Unable to close document");
     }
 }
        public void Print(Bitmap QRCode)
        {
            var _toprint = PrinterErrorCheck(QRLocation);

            if (_toprint == ToPrint.Yes)
            {
                DocumentClass document = new DocumentClass();
                document.Printed += new IPrintEvents_PrintedEventHandler(HandlePrinted);
                document.Open(QRLocation);

                #region Document Object Text
                using (MemoryStream ms = new MemoryStream())
                {
                    QRCode.Save(ms, ImageFormat.Bmp);
                    document.GetObject("QRImage").SetData(0, ms, 4);
                }
                #endregion

                document.StartPrint((QRCode.GetHashCode().ToString() + " Print Job"), PrintOptionConstants.bpoDefault);
                document.PrintOut(1, PrintOptionConstants.bpoDefault);
                int ErrorCode = document.ErrorCode;

                Console.WriteLine("Error Code > " + ErrorCode);

                document.EndPrint();
                document.Close();
            }
            else if (_toprint == ToPrint.Retry)
            {
                restartPrint(QRCode);
            }
        }
Exemple #6
0
        public static void print(PrintModel print)
        {
            try
            {
                string directory = Directory.GetCurrentDirectory();
                string pfad      = directory + @"\ivy_label.LBX";

                bpac.DocumentClass doc = new DocumentClass();
                doc.Open(pfad);

                doc.GetObject("ArticleID").Text              = print.ArticleID.ToString();
                doc.GetObject("ArticleBCode").Text           = print.ArticleID.ToString();
                doc.GetObject("Manufacturer").Text           = print.Manufacturer.ToString();
                doc.GetObject("ManufacturerPartNumber").Text = print.ManufacturerPartNumber.ToString();
                doc.GetObject("ArticleQR").Text              = print.ArticleID.ToString();
                doc.GetObject("Description").Text            = print.Description.ToString();
                doc.SetPrinter("Brother QL-500", true);
                doc.StartPrint("", PrintOptionConstants.bpoDefault);
                doc.PrintOut(1, PrintOptionConstants.bpoDefault);
                doc.EndPrint();
                doc.Close();
            }catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
        private void toolStripButton7_Click(object sender, EventArgs e)
        {
            var re = MessageBox.Show("需要打印列表中的货位条码码?", "提示", MessageBoxButtons.OKCancel);

            if (re == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }

            if (!System.IO.File.Exists("resources\\名称.lbx"))
            {
                MessageBox.Show("条码打印模板文件不存在,请增加一个!");
                return;
            }

            bpac.DocumentClass doc = new DocumentClass();

            doc.Open("resources\\名称.lbx");

            foreach (DataGridViewRow i in this.dataGridView1.Rows)
            {
                Business.Models.WareHouseZonePositionModel m = i.DataBoundItem as Business.Models.WareHouseZonePositionModel;
                doc.GetObject("Title").Text = m.WareHouseZoneName + "  " + m.Name;

                doc.SetBarcodeData(0, m.BarCode);
                doc.StartPrint("", PrintOptionConstants.bpoHalfCut);
                doc.PrintOut(1, PrintOptionConstants.bpoHalfCut | PrintOptionConstants.bpoChainPrint);
            }

            doc.EndPrint();
            doc.Close();
        }
        public void Print(BitmapImage QRCode)
        {
            try
            {
                var _toprint = PrinterErrorCheck(QRLocation);
                if (_toprint == ToPrint.Yes)
                {
                    DocumentClass document = new DocumentClass();
                    document.Printed += new IPrintEvents_PrintedEventHandler(HandlePrinted);
                    document.Open(QRLocation);

                    #region Document Setting
                    using (MemoryStream ms = new MemoryStream())
                    {
                        BitmapEncoder enc = new BmpBitmapEncoder();
                        enc.Frames.Add(BitmapFrame.Create(QRCode));
                        enc.Save(ms);
                        Bitmap bitmap = new Bitmap(ms);
                        App.LocalFilesManagement.Save(bitmap, null, SaveConfig.QRCode, true);
                        IObjects data = document.Objects;
                        foreach (IObject obj in data)
                        {
                            Console.WriteLine(obj.Name);
                        }
                        Console.WriteLine(data);
                        document.GetObject("QRImage").SetData(0, App.LocalFilesManagement.TempBmpFile, 4);
                        App.LocalFilesManagement.ClearTmp(true);
                    }
                    #endregion

                    document.StartPrint((QRCode.GetHashCode().ToString() + " Print Job"), PrintOptionConstants.bpoDefault);
                    document.PrintOut(1, PrintOptionConstants.bpoDefault);
                    int ErrorCode = document.ErrorCode;

                    Console.WriteLine("Error Code > " + ErrorCode);

                    document.EndPrint();
                    document.Close();
                }
                else if (_toprint == ToPrint.Retry)
                {
                    restartPrint(QRCode);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemple #9
0
        private void SendToPrint()
        {
            try
            {
                var docClass = new DocumentClass();

                //if (!docClass.Printer.IsPrinterOnline("Engenharia_Etiquetas"))
                //{
                //    MessageBox.Show("A impressora não está Online, verifique se ela está ligada!", "Impressora OFF-LINE");
                //    return;
                //}

                if (docClass.Open(TagInstance.GetFileService().TemplatePath()))
                {
                    foreach (var productTag in TagInstance.GetProductServiceTag().GetTags())
                    {
                        if (productTag.Print != true)
                        {
                            continue;
                        }

                        docClass.GetObject(TagTemplateFieldNames.TagPosicao).Text     = productTag.Position ?? string.Empty;
                        docClass.GetObject(TagTemplateFieldNames.TagItem).Text        = productTag.Item ?? string.Empty;
                        docClass.GetObject(TagTemplateFieldNames.TagDescription).Text = productTag.Description ?? string.Empty;
                        docClass.GetObject(TagTemplateFieldNames.TagOf).Text          = productTag.Of ?? string.Empty;
                        docClass.GetObject(TagTemplateFieldNames.TagOrcamento).Text   = productTag.OrderNumber ?? string.Empty;
                        docClass.GetObject(TagTemplateFieldNames.TagNumDesenho).Text  = productTag.DrawingCodeName ?? string.Empty;
                        docClass.GetObject(TagTemplateFieldNames.TagData).Text        = DateTime.Now.ToString("MM/dd/yyyy") ?? string.Empty;

                        docClass.StartPrint(string.Empty, PrintOptionConstants.bpoDefault);
                        docClass.PrintOut(productTag.Quantity, PrintOptionConstants.bpoHalfCut);
                        productTag.Printed = docClass.EndPrint();
                    }
                    docClass.Close();
                }
                else
                {
                    MessageBox.Show($"Erro ao Abrir.\n{docClass.ErrorCode}");
                }
            }
            catch (Exception e)
            {
                throw new Exception("Erro ao imprimir.", e);
            }
        }
Exemple #10
0
        public void Print(BarcodeHerbstschiessen barcodeInfo)
        {
            DocumentClass doc      = new DocumentClass();
            const string  path     = @".\Templates\Herbstschiessen.lbx";
            string        fullPath = Path.GetFullPath(path);

            if (doc.Open(fullPath))
            {
                IObject barcode = doc.GetObject("barcode");
                barcode.Text = Convert.ToString(barcodeInfo.Barcode);

                IObject shooterName = doc.GetObject("shooterName");
                shooterName.Text = Convert.ToString(barcodeInfo.FirstName + " " + barcodeInfo.LastName);

                IObject dateOfBirth = doc.GetObject("dateOfBirth");
                dateOfBirth.Text = Convert.ToString(barcodeInfo.DateOfBirth != null ? ((DateTime)barcodeInfo.DateOfBirth).ToString("dd.MM.yyyy") : string.Empty);

                IObject groupName = doc.GetObject("GroupName");
                groupName.Text = Convert.ToString(barcodeInfo.Gruppenstich);

                IObject sieUndErName = doc.GetObject("SieUndErName");
                sieUndErName.Text = Convert.ToString(barcodeInfo.SieUndEr);

                IObject isGruppenstich = doc.GetObject("pass_103");
                isGruppenstich.Text = Convert.ToString(barcodeInfo.IsGruppenstich ? "x" : string.Empty);

                IObject isNachwuchsstich = doc.GetObject("pass_104");
                isNachwuchsstich.Text = Convert.ToString(barcodeInfo.IsNachwuchsstich ? "x" : string.Empty);

                IObject isWorschtUndBrot = doc.GetObject("pass_101");
                isWorschtUndBrot.Text = Convert.ToString(barcodeInfo.IsWorschtUndBrot ? "x" : string.Empty);

                IObject isSieUndEr = doc.GetObject("pass_102");
                isSieUndEr.Text = Convert.ToString(barcodeInfo.IsSieUndEr ? "x" : string.Empty);

                doc.StartPrint("", PrintOptionConstants.bpoDefault);
                doc.PrintOut(1, PrintOptionConstants.bpoDefault);
                doc.EndPrint();
                doc.Close();
            }
            else
            {
                throw new InvalidOperationException(string.Format("Can not open template file '{0}'", fullPath));
            }
        }
    public void Print(BarcodeHerbstschiessen barcodeInfo)
    {
      DocumentClass doc = new DocumentClass();
      const string path = @".\Templates\Herbstschiessen.lbx";
      string fullPath = Path.GetFullPath(path);
      if (doc.Open(fullPath))
      {
        IObject barcode = doc.GetObject("barcode");
        barcode.Text = Convert.ToString(barcodeInfo.Barcode);

        IObject shooterName = doc.GetObject("shooterName");
        shooterName.Text = Convert.ToString(barcodeInfo.FirstName + " " + barcodeInfo.LastName);

        IObject dateOfBirth = doc.GetObject("dateOfBirth");
        dateOfBirth.Text = Convert.ToString(barcodeInfo.DateOfBirth != null ? ((DateTime)barcodeInfo.DateOfBirth).ToString("dd.MM.yyyy") : string.Empty);

        IObject groupName = doc.GetObject("GroupName");
        groupName.Text = Convert.ToString(barcodeInfo.Gruppenstich);

        IObject sieUndErName = doc.GetObject("SieUndErName");
        sieUndErName.Text = Convert.ToString(barcodeInfo.SieUndEr);

        IObject isGruppenstich = doc.GetObject("pass_103");
        isGruppenstich.Text = Convert.ToString(barcodeInfo.IsGruppenstich ? "x" : string.Empty);

        IObject isNachwuchsstich = doc.GetObject("pass_104");
        isNachwuchsstich.Text = Convert.ToString(barcodeInfo.IsNachwuchsstich ? "x" : string.Empty);

        IObject isWorschtUndBrot = doc.GetObject("pass_101");
        isWorschtUndBrot.Text = Convert.ToString(barcodeInfo.IsWorschtUndBrot ? "x" : string.Empty);

        IObject isSieUndEr = doc.GetObject("pass_102");
        isSieUndEr.Text = Convert.ToString(barcodeInfo.IsSieUndEr ? "x" : string.Empty);

        doc.StartPrint("", PrintOptionConstants.bpoDefault);
        doc.PrintOut(1, PrintOptionConstants.bpoDefault);
        doc.EndPrint();
        doc.Close();
      }
      else
      {
        throw new InvalidOperationException(string.Format("Can not open template file '{0}'", fullPath));
      }
    }
        /// <summary>
        /// Controla el evento del botón para la impresión de viñetas en el impresor Brother QL 700
        /// </summary>
        /// <param name="sender">Objeto que llama a la acción</param>
        /// <param name="e">Evento Ejecutado</param>
        protected void btnExecutePrint_Click(object sender, EventArgs e)
        {
            string templatePath = TEMPLATE_DIRECTORY;
            templatePath += TEMPLATE_SIMPLE;

            bpac.DocumentClass doc = new DocumentClass();
            if (doc.Open(templatePath) != false)
            {
                string connStr = ConfigurationManager.ConnectionStrings[mainConnectionString].ConnectionString;
                using (var conn = new SqlConnection(connStr))
                using (var cmd = conn.CreateCommand())
                {
                    conn.Open();
                    cmd.CommandText = "SELECT reg_id, reg_type, type_name, reg_quantity, reg_serial, reg_desc FROM tbl_reg_equipment, tbl_type_equipment where type_id = reg_type and reg_visitor = @reg_visitor";
                    cmd.Parameters.AddWithValue("reg_visitor", visitorID);
                    SqlDataReader dreader = cmd.ExecuteReader();
                    while (dreader.Read())
                    {
                        String name = dreader["type_name"].ToString().Trim();
                        doc.GetObject("objName").Text = name;
                        doc.GetObject("objSerial").Text = dreader["reg_serial"].ToString().Trim();
                        doc.GetObject("objBarcode").Text = dreader["reg_id"].ToString().Trim();
                        doc.GetObject("objDesc").Text = dreader["reg_desc"].ToString().Trim();
                        doc.GetObject("objOwner").Text = lblTitle.Text.Trim();

                        // doc.SetMediaById(doc.Printer.GetMediaId(), true);
                        doc.StartPrint("", PrintOptionConstants.bpoDefault);
                        doc.PrintOut(1, PrintOptionConstants.bpoDefault);
                        doc.EndPrint();
                    }
                    doc.Close();
                    dreader.Close();
                    conn.Close();
                }
                
                        
            }
            else
            {
                //MessageBox.Show("Open() Error: " + doc.ErrorCode);
            }
        }
        public void Print(TLabel tLabel)
        {
            var _toprint = PrinterErrorCheck(LabelLocation);

            if (_toprint == ToPrint.Yes)
            {
                DocumentClass document = new DocumentClass();
                document.Printed += new IPrintEvents_PrintedEventHandler(HandlePrinted);
                document.Open(LabelLocation);
                var barcodeIndex = document.GetBarcodeIndex("Barcode");

                #region Document Object Text
                document.GetObject("Name").Text    = tLabel.Name;
                document.GetObject("Address").Text = tLabel.Address;
                document.SetBarcodeData(barcodeIndex, tLabel.Barcode);
                document.GetObject("DeliveryDate").Text      = tLabel.DeliveryDate;
                document.GetObject("ConsignmentNumber").Text = tLabel.ConsignmentNumber;
                document.GetObject("PostCode").Text          = tLabel.PostCode;
                document.GetObject("Telephone").Text         = tLabel.Telephone;
                document.GetObject("Location").Text          = tLabel.Location;
                document.GetObject("Weight").Text            = tLabel.Weight;
                document.GetObject("LocationNumber").Text    = tLabel.LocationNumber;
                document.GetObject("ParcelNumber").Text      = tLabel.ParcelNumber;
                #endregion

                document.StartPrint((tLabel.Name + " Print Job"), PrintOptionConstants.bpoDefault);
                document.PrintOut(1, PrintOptionConstants.bpoDefault);
                int ErrorCode = document.ErrorCode;

                Console.WriteLine("Error Code > " + ErrorCode);

                document.EndPrint();
                document.Close();
            }
            else if (_toprint == ToPrint.Retry)
            {
                restartPrint(tLabel);
            }
        }
Exemple #14
0
        public void Print(string labelName, Dictionary <String, String> substitutions)
        {
            var doc = new DocumentClass();

            if (doc.Open("labels/" + labelName + ".lbx"))
            {
                foreach (var s in substitutions)
                {
                    doc.GetObject(s.Key).Text = s.Value;
                }
                doc.SetPrinter(printerName, false);
                doc.SetMediaById(doc.Printer.GetMediaId(), true);
                doc.StartPrint("", PrintOptionConstants.bpoDefault);
                doc.PrintOut(1, PrintOptionConstants.bpoDefault);
                doc.EndPrint();
                doc.Close();
                Console.WriteLine("Label printed");
            }
            else
            {
                Console.WriteLine("Can't open label file!");
            }
        }
Exemple #15
0
        public void Print(IRegisterDetail item)
        {
            string template = string.Concat(AppDomain.CurrentDomain.BaseDirectory, @"drivers\Simple.lbx");

            string barcode = Coder.Calculate(Convert.ToUInt32(item.Id));
            string name = item.DetailType.Id > 0 ? item.DetailType.Name : item.Name;

            bpac.DocumentClass doc = new DocumentClass();
            if (doc.Open(template))
            {
                doc.GetObject("Code").Text = barcode;
                doc.GetObject("InvNum").Text = item.Register.InvNumber;
                doc.GetObject("Name").Text = string.Format("{0}. {1}", item.Npp, name);

                doc.StartPrint("",  PrintOptionConstants.bpoChainPrint | PrintOptionConstants.bpoAutoCut);
                doc.PrintOut(1, PrintOptionConstants.bpoChainPrint | PrintOptionConstants.bpoAutoCut);
                doc.EndPrint();
                doc.Close();
            }
            else
            {
                throw new Exception("Невозможно открыть шаблон");
            }
        }
Exemple #16
0
        public void Print(GenericBarcode_20150909 barcodeInfo)
        {
            DocumentClass doc      = new DocumentClass();
            const string  path     = @".\Templates\Generic_20150909.lbx";
            string        fullPath = Path.GetFullPath(path);

            if (doc.Open(fullPath))
            {
                IObject barcode = doc.GetObject("barcode");
                barcode.Text = Convert.ToString(barcodeInfo.Barcode);

                IObject shooterName = doc.GetObject("shooterName");
                shooterName.Text = Convert.ToString(barcodeInfo.FirstName + " " + barcodeInfo.LastName);

                IObject dateOfBirth = doc.GetObject("dateOfBirth");
                dateOfBirth.Text = Convert.ToString(barcodeInfo.DateOfBirth != null ? ((DateTime)barcodeInfo.DateOfBirth).ToString("dd.MM.yyyy") : string.Empty);

                AddCollectionLabel(barcodeInfo, doc, 0);
                AddCollectionLabel(barcodeInfo, doc, 1);

                AddStichLabel(barcodeInfo, doc, 1);
                AddStichLabel(barcodeInfo, doc, 2);
                AddStichLabel(barcodeInfo, doc, 3);
                AddStichLabel(barcodeInfo, doc, 4);
                AddStichLabel(barcodeInfo, doc, 5);

                doc.StartPrint("", PrintOptionConstants.bpoDefault);
                doc.PrintOut(1, PrintOptionConstants.bpoDefault);
                doc.EndPrint();
                doc.Close();
            }
            else
            {
                throw new InvalidOperationException(string.Format("Can not open template file '{0}'", fullPath));
            }
        }
        private ToPrint PrinterErrorCheck(string Location)
        {
            var           error    = -1;
            DocumentClass document = new DocumentClass();

            try
            {
                document.Open(Location);

                object[] printers = (object[])document.Printer.GetInstalledPrinters();
                Console.WriteLine("Printers Found");
                foreach (var printer in printers)
                {
                    Console.WriteLine(printer);
                }
                Console.WriteLine("End Printers Found");
                string TemplateMedia = document.GetMediaName();
                string PrinterMedia  = document.Printer.GetMediaName();
                Console.WriteLine("Template Media: " + TemplateMedia + ", Printer Media: " + PrinterMedia);

                if (printers.Length == 0)
                {
                    error = 4258;
                    document.Close();
                    var result = (DialogResult)PMessageBox.Show("Error: e" + error + "No printer aviliable" + ": refer wiki > e" + error,
                                                                "fault in Printers", MessageBoxButtons.RetryCancel);
                    if (result == DialogResult.Retry)
                    {
                        return(ToPrint.Retry);
                    }
                    return(ToPrint.No);
                }
                else if (printers.Length > 0)
                {
                    if (!document.Printer.IsPrinterOnline(printers[0].ToString()))
                    {
                        error = 4261;
                        document.Close();
                        var result = (DialogResult)PMessageBox.Show("Error: e" + error + "\nTheres printer connected" +
                                                                    "\nRefer wiki > e" + error, "No printer connection", MessageBoxButtons.RetryCancel);
                        if (result == DialogResult.Retry)
                        {
                            return(ToPrint.Retry);
                        }
                        return(ToPrint.No);
                    }
                    else if (TemplateMedia != PrinterMedia)
                    {
                        if (PrinterMedia == "")
                        {
                            error = 3465;
                            document.Close();
                            var result = (DialogResult)PMessageBox.Show("Error: e" + error + "No media installed in connected printer" + ": refer wiki > e" + error,
                                                                        "Check Printers", MessageBoxButtons.RetryCancel);
                            if (result == DialogResult.Retry)
                            {
                                return(ToPrint.Retry);
                            }
                            return(ToPrint.No);
                        }
                        else
                        {
                            error = 3461;
                            document.Close();
                            var result = (DialogResult)PMessageBox.Show("Error: e" + error + "\nMedia installed in printer: " + PrinterMedia +
                                                                        "\nIs not equal to document media: " + TemplateMedia + "\nMake sure media in printer is: " + TemplateMedia + "\nRefer wiki > e" + error,
                                                                        "Check Media", MessageBoxButtons.RetryCancel);
                            if (result == DialogResult.Retry)
                            {
                                return(ToPrint.Retry);
                            }
                            return(ToPrint.No);
                        }
                    }
                    error = -1;
                    document.Close();
                    return(ToPrint.Yes);
                }
                return(ToPrint.No);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                error = 4261;
                document.Close();
                var result = (DialogResult)PMessageBox.Show("Error: e" + error + "No Brother printer connected found" + ": refer wiki > e" + error,
                                                            "Check Printers", MessageBoxButtons.RetryCancel);
                if (result == DialogResult.Retry)
                {
                    return(ToPrint.Retry);
                }
                return(ToPrint.No);
            }
        }
      public void Print(GenericBarcode_20150909 barcodeInfo)
      {
          DocumentClass doc = new DocumentClass();
          const string path = @".\Templates\Generic_20150909.lbx";
          string fullPath = Path.GetFullPath(path);
          if (doc.Open(fullPath))
          {
              IObject barcode = doc.GetObject("barcode");
              barcode.Text = Convert.ToString(barcodeInfo.Barcode);

              IObject shooterName = doc.GetObject("shooterName");
              shooterName.Text = Convert.ToString(barcodeInfo.FirstName + " " + barcodeInfo.LastName);

              IObject dateOfBirth = doc.GetObject("dateOfBirth");
              dateOfBirth.Text = Convert.ToString(barcodeInfo.DateOfBirth != null ? ((DateTime)barcodeInfo.DateOfBirth).ToString("dd.MM.yyyy") : string.Empty);

              AddCollectionLabel(barcodeInfo, doc, 0);
              AddCollectionLabel(barcodeInfo, doc, 1);

              AddStichLabel(barcodeInfo, doc, 1);
              AddStichLabel(barcodeInfo, doc, 2);
              AddStichLabel(barcodeInfo, doc, 3);
              AddStichLabel(barcodeInfo, doc, 4);
              AddStichLabel(barcodeInfo, doc, 5);

              doc.StartPrint("", PrintOptionConstants.bpoDefault);
              doc.PrintOut(1, PrintOptionConstants.bpoDefault);
              doc.EndPrint();
              doc.Close();
          }
          else
          {
              throw new InvalidOperationException(string.Format("Can not open template file '{0}'", fullPath));
          }
      }
Exemple #19
0
 public static void Close()
 {
     doc.Close();
 }
        public FormWareHouseZonePosition()
        {
            InitializeComponent();

            #region 右键打印单条货位条码
            RightMenu = new Pharmacy.UI.Common.BaseRightMenu(this.dataGridView1);
            RightMenu.InsertMenuItem("打印该货位的条码", delegate()
            {
                var re = MessageBox.Show("需要打印该行货位条码码?", "提示", MessageBoxButtons.OKCancel);
                if (re == System.Windows.Forms.DialogResult.Cancel)
                {
                    return;
                }

                if (!System.IO.File.Exists("resources\\名称.lbx"))
                {
                    MessageBox.Show("条码打印模板文件不存在,请增加一个!");
                    return;
                }

                bpac.DocumentClass doc = new DocumentClass();

                doc.Open("resources\\名称.lbx");

                Business.Models.WareHouseZonePositionModel m = this.dataGridView1.CurrentRow.DataBoundItem as Business.Models.WareHouseZonePositionModel;
                doc.GetObject("Title").Text = m.WareHouseZoneName + "  " + m.Name;
                doc.SetBarcodeData(0, m.BarCode);
                doc.StartPrint("", PrintOptionConstants.bpoDefault);
                doc.PrintOut(1, PrintOptionConstants.bpoDefault);

                doc.EndPrint();
                doc.Close();
            });
            #endregion

            this.EleModel = SearialiserHelper <Ele_Lab> .DeSerializeFileToObj("EleSetup.bin");

            if (this.EleModel.IsEnabled)
            {
                if (elelab.unart_manage.com_manage.FirstOrDefault() == null)
                {
                    int[] ss = new int[] { int.Parse(this.EleModel.PortName.Substring(3)) };
                    elelab.unart_manage.init_com_sys(ss);
                }
            }
            this.button2.Visible = this.EleModel.IsEnabled;

            this.dataGridView1.RowPostPaint       += delegate(object o, DataGridViewRowPostPaintEventArgs ex) { DataGridViewOperator.SetRowNumber((DataGridView)o, ex); };
            this.dataGridView1.ReadOnly            = true;
            this.dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;

            #region 插入仓库数据到combo和事件
            this.comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
            this.comboBox2.DropDownStyle = ComboBoxStyle.DropDownList;

            var w = this.PharmacyDatabaseService.AllWarehouses(out msg).Where(r => r.Deleted == false).OrderBy(r => r.Name).ToList();
            w.Insert(0, new Models.Warehouse
            {
                Name = "全部",
                Id   = Guid.Empty,
            });
            this.comboBox1.ValueMember   = "Id";
            this.comboBox1.DisplayMember = "Name";
            this.comboBox1.DataSource    = w;
            this.comboBox1.SelectedIndex = 0;

            var wz  = this.PharmacyDatabaseService.AllWarehouseZones(out msg).Where(r => r.Deleted == false).OrderBy(r => r.Name).ToList();
            var wzt = new List <Models.WarehouseZone>();
            wzt.Add(
                new Models.WarehouseZone
            {
                Name = "全部",
                Id   = Guid.Empty,
            });

            this.comboBox2.ValueMember   = "Id";
            this.comboBox2.DisplayMember = "Name";
            this.comboBox2.DataSource    = wzt;
            this.comboBox2.SelectedIndex = 0;

            this.comboBox1.SelectedIndexChanged += (sender, e) =>
            {
                var wzs = wz.Where(r => r.WarehouseId == (Guid)this.comboBox1.SelectedValue).OrderBy(r => r.Name).ToList();

                wzs.Insert(0, new Models.WarehouseZone
                {
                    Name = "全部",
                    Id   = Guid.Empty,
                });
                this.comboBox2.ValueMember   = "Id";
                this.comboBox2.DisplayMember = "Name";
                this.comboBox2.DataSource    = wzs;
                this.comboBox2.SelectedIndex = 0;
            };
            #endregion


            //批量创建
            this.toolStripButton2.Click += (sender, e) =>
            {
                FormWareHouseZonePosition_Editor frm = new FormWareHouseZonePosition_Editor(w, wz);
                frm.Show(this);
            };

            #region 修改ACTION
            Action <object, EventArgs> EditPostionAction = (sender, e) =>
            {
                if (this.dataGridView1.CurrentRow == null)
                {
                    return;
                }
                var c = this.dataGridView1.CurrentRow.DataBoundItem as Business.Models.WareHouseZonePositionModel;
                using (FormWareHouseZonePositionEdit frm = new FormWareHouseZonePositionEdit(w, wz, c))
                {
                    var re = frm.ShowDialog();
                    if (re == System.Windows.Forms.DialogResult.OK)
                    {
                        this.toolStripButton1_Click(null, null);
                    }
                }
            };
            #endregion

            //修改
            this.toolStripButton3.Click += (sender, e) => EditPostionAction(sender, e);
            //Datagridview双击修该货位
            this.dataGridView1.CellDoubleClick += (sender, e) =>
            {
                if (e.RowIndex < 0 || e.ColumnIndex < 0)
                {
                    return;
                }
                EditPostionAction(null, null);
            };
        }