コード例 #1
0
        private void btnIniciar_Click(object sender, RoutedEventArgs e)
        {
            Temporizador.Stop();
            frmConfiguracionTrabajo frm = new frmConfiguracionTrabajo();

            frm.ShowDialog();
            if (frm.DialogResult.HasValue && frm.DialogResult.Value == true)
            {
                TrabajoActivo = TrabajoGestor.ObtenerTrabajoActivo(Configuracion.NombreEquipo);
                CargaEtiquetas();
                btnIniciar.Content    = "INICIADO";
                btnIniciar.Background = Brushes.Salmon;
                CargaDatos();
            }
            Temporizador.Start();
        }
コード例 #2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ImprimeEtiquetaWorker.WorkerReportsProgress = true;
            ImprimeEtiquetaWorker.DoWork          += new DoWorkEventHandler(ImprimeEtiquetaWorker_DoWork);
            ImprimeEtiquetaWorker.ProgressChanged += new ProgressChangedEventHandler(ImprimeEtiquetaWorker_ProgressChanged);

            lvProdutos.ItemsSource    = oPesos;
            lvCajas.ItemsSource       = oPesosCajas;
            btnCierreManual.IsEnabled = false;
            gridProductos.IsEnabled   = false;
            gridCajas.IsEnabled       = false;
            btnIniciar.Tag            = null;

            // inicia el motor de Bartender
            try {
                BartenderEngine = new Bartender.Engine(true);
            } catch (Bartender.PrintEngineException ex) {
                Console.WriteLine(ex.Message);
                MessageBox.Show(this, ex.Message, "PesajeWPF");
            }

            try
            {
                PuertoCOM.Handshake              = Handshake.None;
                PuertoCOM.Parity                 = Parity.None;
                PuertoCOM.DataBits               = 8;
                PuertoCOM.StopBits               = StopBits.One;
                PuertoCOM.ReadTimeout            = 200;
                PuertoCOM.WriteTimeout           = 50;
                PuertoCOM.ReceivedBytesThreshold = 10;
                PuertoCOM.Open();
                PuertoCOM.DataReceived += PuertoCOM_DataReceived;

                if (PuertoCOM.IsOpen)
                {
                    lblCOM.Content       = Configuracion.PuertoCOM;
                    lblCOM.Foreground    = Brushes.Black;
                    COMBorder.Background = Brushes.Green;
                    TrabajoActivo        = TrabajoGestor.ObtenerTrabajoActivo(Configuracion.NombreEquipo);
                    CargaEtiquetas();
                }
                else
                {
                    //lblCOM.Content = $"Puerto {Configuracion.PuertoCOM} no encontrado";
                    COMBorder.Background   = Brushes.Red;
                    lblCOM.Foreground      = Brushes.Red;
                    btnIniciar.IsEnabled   = false;
                    btnFinalizar.IsEnabled = false;
                }

                if (TrabajoActivo != null)
                {
                    btnIniciar.Content    = "INICIADO";
                    btnIniciar.Background = Brushes.Salmon;
                    CargaEtiquetas();
                    CargaCajasActivas(TrabajoActivo.Id);
                    CargaProductosActivos(TrabajoActivo.Id);
                }
                else
                {
                    TrabajoActivo = new Trabajo();
                }
                CargaDatos();

                Temporizador.Tick += new EventHandler(Temporizador_Tick);
                //Temporizador.Interval = new TimeSpan(0, 0, 1);
                Temporizador.Interval = TimeSpan.FromMilliseconds(100);
                Temporizador.Start();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                lblCOM.Content = ex.Message;
            }
        }
コード例 #3
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            dtFechaEnvasado.SelectedDate = DateTime.Today;
            txtCopiasProducto.Text       = CopiasProducto.ToString();
            txtCopiasCaja.Text           = CopiasCaja.ToString();
            txtCopiasTotal.Text          = CopiasTotal.ToString();
            txtCierre.Text = ProductosParaCierre.ToString();

            PrinterSettings.StringCollection lstImpresoras = PrinterSettings.InstalledPrinters;
            cmbImpresoraProducto.ItemsSource = lstImpresoras;
            cmbImpresoraCaja.ItemsSource     = lstImpresoras;
            cmbImpresoraTotal.ItemsSource    = lstImpresoras;

            PrinterSettings ps = new PrinterSettings();

            cmbImpresoraProducto.SelectedItem = ps.PrinterName;
            cmbImpresoraCaja.SelectedItem     = ps.PrinterName;
            cmbImpresoraTotal.SelectedItem    = ps.PrinterName;

            TrabajoActivo = TrabajoGestor.ObtenerTrabajoActivo(Configuracion.NombreEquipo);
            if (TrabajoActivo != null)
            {
                txtLote.Text = TrabajoActivo.Lote;
                dtFechaEnvasado.SelectedDate = TrabajoActivo.Fecha;
                if (!string.IsNullOrEmpty(TrabajoActivo.EtiquetaProducto))
                {
                    RutaEtiquetas = System.IO.Path.GetDirectoryName(TrabajoActivo.EtiquetaProducto);
                }
                if (!string.IsNullOrEmpty(TrabajoActivo.EtiquetaCaja))
                {
                    RutaEtiquetas = System.IO.Path.GetDirectoryName(TrabajoActivo.EtiquetaCaja);
                }
                if (!string.IsNullOrEmpty(TrabajoActivo.EtiquetaTotal))
                {
                    RutaEtiquetas = System.IO.Path.GetDirectoryName(TrabajoActivo.EtiquetaTotal);
                }
                txtEtiquetaProducto.Text = System.IO.Path.GetFileName(TrabajoActivo.EtiquetaProducto);
                txtEtiquetaCaja.Text     = System.IO.Path.GetFileName(TrabajoActivo.EtiquetaCaja);
                txtEtiquetaTotal.Text    = System.IO.Path.GetFileName(TrabajoActivo.EtiquetaTotal);
                if (lstImpresoras.Cast <string>().ToList().Contains(TrabajoActivo.ImpresoraProducto))
                {
                    cmbImpresoraProducto.SelectedItem = TrabajoActivo.ImpresoraProducto;
                }
                if (lstImpresoras.Cast <string>().ToList().Contains(TrabajoActivo.ImpresoraCaja))
                {
                    cmbImpresoraCaja.SelectedItem = TrabajoActivo.ImpresoraCaja;
                }
                if (lstImpresoras.Cast <string>().ToList().Contains(TrabajoActivo.ImpresoraTotal))
                {
                    cmbImpresoraTotal.SelectedItem = TrabajoActivo.ImpresoraTotal;
                }
                txtCopiasProducto.Text = TrabajoActivo.CopiasProducto.ToString();
                CopiasProducto         = TrabajoActivo.CopiasProducto;
                CopiasCaja             = TrabajoActivo.CopiasCaja;
                CopiasTotal            = TrabajoActivo.CopiasTotal;
                ProductosParaCierre    = TrabajoActivo.NumeroProductosCierre;
                txtCopiasCaja.Text     = TrabajoActivo.CopiasCaja.ToString();
                txtCopiasTotal.Text    = TrabajoActivo.CopiasTotal.ToString();
                txtCierre.Text         = TrabajoActivo.NumeroProductosCierre.ToString();
                // Sólo dejar cambiar las impresoras, las copias y el número de productos para el cierre de caja automático.
                txtLote.IsReadOnly                 = true;
                btnLimpiaLote.IsEnabled            = false;
                btnLimpiaProducto.IsEnabled        = false;
                btnLimpiaCaja.IsEnabled            = false;
                btnLimpiaTotal.IsEnabled           = false;
                btnTecladoLote.IsEnabled           = false;
                btnBuscaEtiquetaProducto.IsEnabled = false;
                btnBuscaEtiquetaCaja.IsEnabled     = false;
                btnBuscaEtiquetaTotal.IsEnabled    = false;
                dtFechaEnvasado.IsEnabled          = false;
            }
            else
            {
                TrabajoActivo = new Trabajo();
            }
        }