示例#1
0
        private void OnImprimirEtiqueta_Individual(object sender, EventArgs e)
        {
            Boolean       validacion          = false;
            List <String> codAuxiliares       = new List <String>();
            String        serial              = View.GetMacImpre_Individual.Text;
            String        mac                 = View.GetSerialImpre_Individual.Text;
            Int32         cantidadImpresiones = 1;

            if (serial != "" || mac != "")
            {
                if (View.Get_StackCodigosAdicionales.Children.Count > 0) //Si el stackpanel tiene controles adicionales para codigos aparte de serial y mac

                // Se recorre todo el stackpanel en busca de Textbox, especificamente del valor que tengan estos
                {
                    foreach (var child in View.Get_StackCodigosAdicionales.Children)
                    {
                        var textBox = child as TextBox;
                        if (textBox == null)
                        {
                            continue;
                        }

                        if (textBox.Text == "")
                        {
                            textBox.BorderBrush = Brushes.Red;
                            textBox.KeyUp      += new KeyEventHandler(KeyUp_CodigoAdicional);
                            validacion          = true;
                        }
                        else
                        {
                            textBox.BorderBrush = Brushes.AliceBlue;
                            codAuxiliares.Add(textBox.Text);
                        }
                    }
                }

                if (validacion)
                {
                    Util.ShowError("Todos los campo deben estar completos.");
                    return;
                }
                else
                {
                    System.Windows.Forms.PrintDialog pd = new System.Windows.Forms.PrintDialog();
                    pd.PrinterSettings = new PrinterSettings();
                    Int32.TryParse(View.GetCantidad_Impresiones.Text, out cantidadImpresiones);

                    //try {
                    if (System.Windows.Forms.DialogResult.OK == pd.ShowDialog())
                    {
                        PrinterControl.EtiquetadoEquipoIndividual(serial, mac, this.rutaEtiqueta, this.ipservidor, codAuxiliares, cantidadImpresiones, pd.PrinterSettings.PrinterName);
                    }
                    //}
                    // catch(Exception ex){
                    //     Util.ShowError("Error en la impresión, por favor verifique la conexión a la impresora Zebra "+ex.Message);
                    // }
                }
            }
            else
            {
                Util.ShowError("Todos los campo deben estar completos.");
            }
        }