private void btnListado_Click(object sender, RoutedEventArgs e) { Temporizador.Stop(); // TODO: Mostrar listado de los últimos trabajos por si deseamos reimprimir la etiqueta de todal de un trabajo anterior frmTrabajos frm = new frmTrabajos(); frm.ShowDialog(); if (frm.DialogResult.HasValue && frm.DialogResult.Value == true) { if (frm.TrabajoSeleccionado != null) { if (System.IO.File.Exists(frm.TrabajoSeleccionado.EtiquetaTotal)) { Bartender.LabelFormatDocument ReimprimirEtiquetaTotal = BartenderEngine.Documents.Open(frm.TrabajoSeleccionado.EtiquetaTotal); ReimprimirEtiquetaTotal.PrintSetup.PrinterName = frm.TrabajoSeleccionado.ImpresoraTotal; if (ReimprimirEtiquetaTotal.PrintSetup.SupportsIdenticalCopies) { ReimprimirEtiquetaTotal.PrintSetup.IdenticalCopiesOfLabel = frm.TrabajoSeleccionado.CopiasTotal; } ImprimeEtiquetaWorker.RunWorkerAsync(ReimprimirEtiquetaTotal); ReimprimirEtiquetaTotal.Close(Bartender.SaveOptions.DoNotSaveChanges); } } } Temporizador.Start(); }
private void CargaEtiquetas() { if (TrabajoActivo != null && TrabajoActivo.Id > 0) { /* Etiqueta de Producto */ // Comprobar si existe el archivo lblMensajes.Text = string.Empty; if (!string.IsNullOrEmpty(TrabajoActivo.EtiquetaProducto) && System.IO.File.Exists(TrabajoActivo.EtiquetaProducto)) { // Cargar la etiqueta sólo si no hay ninguna cargada o el archivo es distinto al cargado if (EtiquetaProducto == null || (EtiquetaProducto != null && EtiquetaProducto.FileName != TrabajoActivo.EtiquetaProducto)) { // Cerrar la etiqueta si hay alguna if (EtiquetaProducto != null) { EtiquetaProducto.Close(Bartender.SaveOptions.DoNotSaveChanges); } EtiquetaProducto = BartenderEngine.Documents.Open(TrabajoActivo.EtiquetaProducto); } EtiquetaProducto.PrintSetup.PrinterName = TrabajoActivo.ImpresoraProducto; if (EtiquetaProducto.PrintSetup.SupportsIdenticalCopies) { EtiquetaProducto.PrintSetup.IdenticalCopiesOfLabel = TrabajoActivo.CopiasProducto; } // foreach (var x in EtiquetaProducto.SubStrings) { switch (x.Name.ToLower()) { case "pesaje_peso": x.Value = "0"; break; case "pesaje_lote": x.Value = string.Empty; break; case "pesaje_fecha": x.Value = DateTime.Today.ToShortDateString(); break; case "pesaje_numero": x.Value = "0"; break; default: break; } } } else { EtiquetaProducto = null; lblMensajes.Text += Environment.NewLine + "Etiqueta de producto no existe"; } /* Etiqueta de Caja */ if (!string.IsNullOrEmpty(TrabajoActivo.EtiquetaCaja) && System.IO.File.Exists(TrabajoActivo.EtiquetaCaja)) { if (EtiquetaCaja == null || (EtiquetaCaja != null && EtiquetaCaja.FileName != TrabajoActivo.EtiquetaCaja)) { if (EtiquetaCaja != null) { EtiquetaCaja.Close(Bartender.SaveOptions.DoNotSaveChanges); } EtiquetaCaja = BartenderEngine.Documents.Open(TrabajoActivo.EtiquetaCaja); } EtiquetaCaja.PrintSetup.PrinterName = TrabajoActivo.ImpresoraCaja; if (EtiquetaCaja.PrintSetup.SupportsIdenticalCopies) { EtiquetaCaja.PrintSetup.IdenticalCopiesOfLabel = TrabajoActivo.CopiasCaja; } // foreach (var x in EtiquetaCaja.SubStrings) { switch (x.Name.ToLower()) { case "pesaje_peso": x.Value = "0"; break; case "pesaje_lote": x.Value = string.Empty; break; case "pesaje_fecha": x.Value = DateTime.Today.ToShortDateString(); break; case "pesaje_numero": x.Value = "0"; break; case "pesaje_numeroproductos": x.Value = "0"; break; default: break; } } } else { EtiquetaCaja = null; lblMensajes.Text += Environment.NewLine + "Etiqueta de caja no existe"; } /* Etiqueta de Total */ if (!string.IsNullOrEmpty(TrabajoActivo.EtiquetaTotal) && System.IO.File.Exists(TrabajoActivo.EtiquetaTotal)) { if (EtiquetaTotal == null || (EtiquetaTotal != null && EtiquetaTotal.FileName != TrabajoActivo.EtiquetaTotal)) { if (EtiquetaTotal != null) { EtiquetaTotal.Close(Bartender.SaveOptions.DoNotSaveChanges); } EtiquetaTotal = BartenderEngine.Documents.Open(TrabajoActivo.EtiquetaTotal); } EtiquetaTotal.PrintSetup.PrinterName = TrabajoActivo.ImpresoraTotal; if (EtiquetaTotal.PrintSetup.SupportsIdenticalCopies) { EtiquetaTotal.PrintSetup.IdenticalCopiesOfLabel = TrabajoActivo.CopiasTotal; } // foreach (var x in EtiquetaTotal.SubStrings) { switch (x.Name.ToLower()) { case "pesaje_peso": x.Value = "0"; break; case "pesaje_lote": x.Value = string.Empty; break; case "pesaje_fecha": x.Value = DateTime.Today.ToShortDateString(); break; case "pesaje_numero": x.Value = "0"; break; case "pesaje_numerocajas": x.Value = "0"; break; default: break; } } } else { EtiquetaTotal = null; lblMensajes.Text += Environment.NewLine + "Etiqueta de total no existe"; } if (!string.IsNullOrEmpty(lblMensajes.Text.ToString())) { lblMensajes.Text = "ETIQUETAS:" + lblMensajes.Text; } } else { EtiquetaCaja = null; EtiquetaProducto = null; EtiquetaTotal = null; } }