Beispiel #1
0
        //private static String PrepareBarcode(long num)
        //{
        //    var curTicketNum = num.ToString(CultureInfo.InvariantCulture);
        //    var curTicketLength = curTicketNum.Length;
        //    return curTicketLength > 13
        //                       ? curTicketNum.Remove(13, curTicketLength)
        //                       : curTicketNum.Insert(curTicketLength - 1, "0000000000000".Remove(0, 13 - curTicketLength));
        //}

        private PrintResult SendToPrint(String printerName, ICashVoucherItem item, String barcode)
        {
            IsShowErrorMessage = false;
            try
            {
                #if !DEBUG || PRINT_DEBUG
                if (!PrinterDeviceHelper.IsPlug(printerName))
                {
                    throw new Exception("Принтер {0} не подключен!".F(printerName));
                }
                var pathToTemplate = SettingsStore.Load().PathToTemplate;
                RawPrinterHelper.SendStringToPrinter(printerName, ZebraHelper.LoadAndFillTemplate(pathToTemplate, CurrentDateTime.ToString("dd.MM.yyyy HH:mm:ss"), item.Price.ToString(CultureInfo.InvariantCulture), item.PrintTitle, "", barcode));
                #endif
            }
            catch (Exception e)
            {
                PrintTroubleToLog(e);
                IsShowErrorMessage = true;
                RightErrorMessage  = e.Message;
                return(PrintResult.Failure);
            }
            finally
            {
                CurrentTicketNumber++;
                TicketsLeft--;
            }

            if (TicketsLeft <= 25)
            {
                RightErrorMessage  = "Заканчиваются билеты! Осталось: {0}".F(TicketsLeft);
                IsShowErrorMessage = true;
            }

            return(TicketsLeft > 0 ? PrintResult.Success : PrintResult.SuccessAndNeedNewTicketRoll);
        }
Beispiel #2
0
        private void Bgw_DoWork(object sender, DoWorkEventArgs e)
        {
            StringBuilder sbMessaggio = new StringBuilder();
            DataSet       ds          = e.Argument as DataSet;

            CDCBLL bll = new CDCBLL();
            int    numeroTotaleEtichette = 0;

            foreach (DataRow riga in ds.Tables[tableName].Rows)
            {
                string numeroEtichette = string.Empty;
                if (riga[12] != System.DBNull.Value)
                {
                    numeroEtichette = (string)riga[12];
                }


                string prefisso    = (string)riga[3];
                string parte       = (string)riga[4];
                string colore      = (string)riga[5];
                string linea       = (string)riga[9];
                string descrizione = (string)riga[10];

                string messaggioVerifica;
                List <Tuple <int, int> > SC_QTA;

                if (bll.verificaNumeroEtichette(numeroEtichette, out messaggioVerifica, out SC_QTA))
                {
                    foreach (Tuple <int, int> tupla in SC_QTA)
                    {
                        string etichetta = string.Format("{0} {1} {2} {3}   da {4} pezzi IN CORSO", prefisso, parte, colore, linea, tupla.Item2);

                        for (int i = 0; i < tupla.Item1; i++)
                        {
                            numeroTotaleEtichette++;
                            ZebraHelper.EseguiStampaEtichetta(printer, riga, tupla.Item2.ToString());
                            Thread.Sleep(150);
                            string messaggio = string.Format(@"{0}{1}", sbMessaggio.ToString(), etichetta);
                            bgw.ReportProgress(numeroTotaleEtichette, messaggio);

                            if (bgw.CancellationPending)
                            {
                                e.Cancel = true;
                                return;
                            }
                        }
                    }
                    sbMessaggio.AppendLine(string.Format("{0} {1} {2} {3}   numero etichette: {4} STAMPATE", prefisso, parte, colore, linea, numeroEtichette));
                }
                ZebraHelper.EseguiStampaEtichettaSeparatore(printer);
            }
            bgw.ReportProgress(numeroTotaleEtichette, sbMessaggio.ToString());
        }
        private void dgvUbicazioni_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex < 4 || e.ColumnIndex > 5)
            {
                return;
            }
            if (e.RowIndex < 0)
            {
                return;
            }
            try
            {
                if (e.ColumnIndex == 4)
                {
                    decimal    idUbicazione = (decimal)dgvUbicazioni.Rows[e.RowIndex].Cells[0].Value;
                    Spedizioni spedizioni   = new Spedizioni();
                    spedizioni.CancellaUbicazione(idUbicazione, _utenteConnesso);
                }

                if (e.ColumnIndex == 5)
                {
                    if (ddlStampanti.SelectedIndex == -1)
                    {
                        MessageBox.Show("Selezionare una stampante", "ATTENZIONE", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    string PrinterName = ddlStampanti.SelectedItem.ToString();
                    string codice      = (string)dgvUbicazioni.Rows[e.RowIndex].Cells[1].Value;
                    string descrizione = (string)dgvUbicazioni.Rows[e.RowIndex].Cells[2].Value;
                    string barcode     = (string)dgvUbicazioni.Rows[e.RowIndex].Cells[3].Value;

                    ZebraHelper.StampaEtichettaUbicazione(PrinterName, codice, descrizione, barcode);
                }
            }
            catch (Exception ex)
            {
                MostraEccezione("Impossibile eseguire l'operazione", ex);
            }
        }
Beispiel #4
0
        private void btnVerificaEtichette_Click(object sender, EventArgs e)
        {
            btnStampaEtichette.Enabled = false;;
            StringBuilder messaggioErrore = new StringBuilder();

            StringBuilder messaggioBuono        = new StringBuilder();
            bool          mostraMessaggioErrore = false;

            if (ddlStampanti.SelectedIndex == -1)
            {
                mostraMessaggioErrore = true;
                messaggioErrore.AppendLine(string.Format("Selezionare una stampamnte"));
            }

            CDCBLL bll = new CDCBLL();

            try
            {
                lblMessaggio.Text = string.Empty;
                if (_dsServizio.Tables[tableName].Rows.Count == 0)
                {
                    lblMessaggio.Text = "NESSUNA ETICHETTA DA STAMPARE";
                    return;
                }
                int indiceRiga = 1;
                foreach (DataRow riga in _dsServizio.Tables[tableName].Rows)
                {
                    string linea = string.Empty;
                    if (riga[9] != System.DBNull.Value)
                    {
                        linea = (string)riga[9];
                    }
                    string descrizione = string.Empty;
                    if (riga[10] != System.DBNull.Value)
                    {
                        descrizione = (string)riga[10];
                    }
                    string destinazione = string.Empty;
                    if (riga[11] != System.DBNull.Value)
                    {
                        destinazione = (string)riga[11];
                    }
                    string numeroEtichette = string.Empty;
                    if (riga[12] != System.DBNull.Value)
                    {
                        numeroEtichette = (string)riga[12];
                    }

                    descrizione     = descrizione.Trim();
                    destinazione    = destinazione.Trim();
                    numeroEtichette = numeroEtichette.Replace(" ", string.Empty).ToUpper();

                    string finitura = (string)riga[5];
                    finitura = finitura.ToUpper().Trim();
                    if ((!string.IsNullOrEmpty(finitura) || !(finitura == "NULL")) && string.IsNullOrEmpty(linea))
                    {
                        mostraMessaggioErrore = true;
                        messaggioErrore.AppendLine(string.Format("Riga {0}: Inserire la linea", indiceRiga));
                    }
                    if (string.IsNullOrEmpty(descrizione))
                    {
                        mostraMessaggioErrore = true;
                        messaggioErrore.AppendLine(string.Format("Riga {0}: Inserire la descrizione", indiceRiga));
                    }
                    if (string.IsNullOrEmpty(destinazione))
                    {
                        mostraMessaggioErrore = true;
                        messaggioErrore.AppendLine(string.Format("Riga {0}: Inserire la destinazione", indiceRiga));
                    }

                    if (string.IsNullOrEmpty(numeroEtichette))
                    {
                        mostraMessaggioErrore = true;
                        messaggioErrore.AppendLine(string.Format("Riga {0}: Inserire il numero di etichette", indiceRiga));
                    }
                    indiceRiga++;

                    string messaggio;
                    List <Tuple <int, int> > SC_QTA;
                    if (!bll.verificaNumeroEtichette(numeroEtichette, out messaggio, out SC_QTA))
                    {
                        mostraMessaggioErrore = true;
                        messaggioErrore.AppendLine(string.Format("Riga {0}: numero etichette errato", indiceRiga));
                    }
                    else
                    {
                        string prefisso = (string)riga[3];
                        string parte    = (string)riga[4];
                        string colore   = (string)riga[5];
                        string commessa = (string)riga[6];
                        messaggioBuono.AppendLine(string.Format("{0}-{1}-{2}  {3}", prefisso, parte, colore, commessa));
                        messaggioBuono.AppendLine(messaggio);
                    }
                }

                if (mostraMessaggioErrore)
                {
                    MessageBox.Show(messaggioErrore.ToString(), "ATTENZIONE", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                string zebraPrinter = ddlStampanti.SelectedItem.ToString();

                foreach (DataRow riga in _dsServizio.Tables[tableName].Rows)
                {
                    ZebraHelper.EseguiStampaEtichetta(zebraPrinter, riga, "1");
                }

                MessageBox.Show(messaggioBuono.ToString(), "ATTENZIONE", MessageBoxButtons.OK, MessageBoxIcon.Information);

                btnStampaEtichette.Enabled = true;
            }

            catch (Exception ex)
            {
                btnStampaEtichette.Enabled = false;
                MostraEccezione(ex, "Errore nella verifica etichette");
            }
        }