private void button1_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(txtNumeroDeEmpleado.Text)) { MessageBox.Show("El número de empleado es requerido para este proceso.", "Mensaje del Sistema"); ActiveControl = txtNumeroDeEmpleado; return; } pictureBox1.Image = null; pictureBox2.Image = null; if (Printer == null) { MessageBox.Show("La impresora no est activa", "Mensaje del Sistema"); } else { ZebraCardPrint.DLL.DatosCarnet datosCarnet = new ZebraCardPrint.DLL.DatosCarnet(); if (datosCarnet.EmpleadoActivo(txtNumeroDeEmpleado.Text) > 0) { checkBox1.Checked = true; datosCarnet.DeleteDatosCarnet(); datosCarnet.SPDatosCarnet(txtNumeroDeEmpleado.Text); dataTable = datosCarnet.LoadCarnet(); //datosCarnet.SDInsertaImpresionCarnet(txtNumeroDeEmpleado.Text); Print(Printer); } else { MessageBox.Show("El número de empleado ingresado no pertenece a ningún colaborador activo.", "Mensaje del Sistema"); } } }
public void Print(string Printer) { Connection connection = null; ZebraCardPrinter zebraCardPrinter = null; ZebraCardPrint.DLL.DatosCarnet datosCarnet = new ZebraCardPrint.DLL.DatosCarnet(); try { //connection = new TcpConnection("1.2.3.4", 9100); connection = new UsbConnection(Printer); connection.Open(); zebraCardPrinter = ZebraCardPrinterFactory.GetInstance(connection); List <GraphicsInfo> graphicsData = DrawGraphics(zebraCardPrinter, dataTable); // Set the card source //Descomentar zebraCardPrinter.SetJobSetting(ZebraCardJobSettingNames.CARD_SOURCE, "Feeder"); // Feeder=default // Set the card destination - If the destination value is not specifically set, it will be auto set to the most appropriate value if (checkBox1.CheckState == CheckState.Unchecked) { // Set the card source zebraCardPrinter.SetJobSetting(ZebraCardJobSettingNames.CARD_SOURCE, "Feeder"); // Feeder=default // Set the card destination - If the destination value is not specifically set, it will be auto set to the most appropriate value if (zebraCardPrinter.HasLaminator()) { zebraCardPrinter.SetJobSetting(ZebraCardJobSettingNames.CARD_DESTINATION, "LaminatorAny"); } else { zebraCardPrinter.SetJobSetting(ZebraCardJobSettingNames.CARD_DESTINATION, "Eject"); } // Send job int jobId = zebraCardPrinter.Print(1, graphicsData); // Poll job status JobStatusInfo jobStatus = PollJobStatus(jobId, zebraCardPrinter); MessageBox.Show($"Impresion Id: {jobId} completada con estado: '{jobStatus.PrintStatus}'."); if (jobStatus.PrintStatus.ToString().ToUpper() == "DONE_OK") { datosCarnet.SDInsertaImpresionCarnet(txtNumeroDeEmpleado.Text); rdoAmbasCaras.Checked = true; } } } catch (Exception e) { MessageBox.Show($"Error printing image: {e.Message}"); } finally { CloseQuietly(connection, zebraCardPrinter); } }