void printButton_Click(object sender, EventArgs e) { if (labelText.Text.Length <= 0) { return; } GenericLabel lbl = GenericLabel.GetGenericLabel(); lbl.SetLabelValues(labelText.Text); ZPLLabel zplLabel = ZPLLabel.GetLabelByName("CHARTER_UNIVERSAL"); zplLabel.SetLabelValues(lbl.LabelValues); //DellAslLpnLabel label = DellAslLpnLabel.GetDellAslLpnLabel(); //label.SetLabelValues("ASL5815204","D5551"); //ZPLLabel zplLabel = ZPLLabel.GetLabelByName("DELL_ASL_LPN"); //zplLabel.SetLabelValues(label.LabelValues); for (int i = 1; i <= labelCount.Value; i++) { zplLabel.Print(); } }
public void PrintIdLabel(Receipt receipt) { ZPLLabel label = ZPLLabel.GetLabelByName("ID_LABEL"); label.SetLabelValues(new object[] { receipt.UnitTrackingId }); label.Print(); }
private void btnPrint_Click(object sender, EventArgs e) { if (MessageBox.Show(string.Format("This will print {0} unit labels. Are you sure?", txtQty.Text), "SIMPLISTICA", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int _labelInit = 0; txtPrinter.Text = Values.LabelPrinterAddress.ToString(); using (var _conn = new cAccesoDatosNet(Values.gDatos.Server, "REPAIRS", Values.gDatos.User, Values.gDatos.Password)) using (var _sp = new SP(_conn, "pGetContador")) { _sp.AddParameterValue("@Contador", ""); _sp.AddParameterValue("@Serv", ""); _sp.AddParameterValue("@Codigo", cboService.Value + "_UNIT_ETIQ"); _sp.AddParameterValue("@Incremento", Convert.ToInt32(txtQty.Value)); _sp.Execute(); _labelInit = Convert.ToInt32(_sp.ReturnValues()["@Contador"]); } if (txtCharacter.Text == "") { throw (new Exception("Wrong character for labels.")); } string _printerAddress = ""; int _printerResolution = 0; using (var _RS = new DynamicRS(string.Format("select descripcion,cmp_varchar,cmp_integer from ETIQUETAS..datosEmpresa where codigo='{0}'", Values.LabelPrinterAddress), Values.gDatos)) { _RS.Open(); _printerAddress = _RS["cmp_varchar"].ToString(); _printerResolution = Convert.ToInt32(_RS["cmp_integer"]); //_printerType = _RS["descripcion"].ToString().Split('|')[0]; } var _label = new ZPLLabel(70, 32, 3, _printerResolution); var _unitLabel = new SingleBarcode(_label); //_label.addLine(35, 3, 0, "C", "", "[BC][UNITNUMBER]", 0, 2.5F, 1,true); //var _param = new Dictionary<string, string>(); using (var _printer = new cRawPrinterHelper(_printerAddress)) { var _delimiterLabel = new ZPLLabel(_unitLabel.Label.width, _unitLabel.Label.height, 3, _unitLabel.Label.dpi); delimiterLabel.delim(_delimiterLabel, "START UNIT LABELS", "-"); _printer.SendUTF8StringToPrinter(_delimiterLabel.ToString(), 1); //for (var i = _labelInit; i < _labelInit + Convert.ToInt32(txtQty.Value); i++) for (var i = _labelInit + Convert.ToInt32(txtQty.Value) - 1; i >= _labelInit; i--) { _unitLabel.Parameters["VALUE"] = txtCharacter.Text + i.ToString().PadLeft(8, '0'); for (var j = 0; j < Convert.ToInt32(txtQtyLabel.Text); j++) { _printer.SendUTF8StringToPrinter(_unitLabel.ToString(), 1); } } delimiterLabel.delim(_delimiterLabel, "END UNIT LABLES", "-"); _printer.SendUTF8StringToPrinter(_delimiterLabel.ToString(), 1); } } }
public static bool PrintDellLpnLabel(string lpn, string partNumber) { DellAslLpnLabel label = DellAslLpnLabel.GetDellAslLpnLabel(); label.SetLabelValues(lpn, partNumber); ZPLLabel zplLabel = ZPLLabel.GetLabelByName("DELL_ASL_LPN"); zplLabel.SetLabelValues(label.LabelValues); return(zplLabel.Print()); }
private void btnPrint_Click(object sender, EventArgs e) { if (MessageBox.Show(string.Format("This will print {0} unit labels. Are you sure?", txtLOCATION.Text), "SIMPLISTICA", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { string _printerAddress = ""; int _printerResolution = 0; using (var _RS = new DynamicRS(string.Format("select descripcion,cmp_varchar,cmp_integer from ETIQUETAS..datosEmpresa where codigo='{0}'", Values.LabelPrinterAddress), Values.gDatos)) { _RS.Open(); _printerAddress = _RS["cmp_varchar"].ToString(); _printerResolution = Convert.ToInt32(_RS["cmp_integer"]); } var _label = new ZPLLabel(75, 150, 3, _printerResolution); var _racklabel = new RackLabelWOL(_label); using (var _printer = new cRawPrinterHelper(_printerAddress)) if (txtAISLE.Text == "") { using (var _rs = new DynamicRS(string.Format("select cod3,location,alias from sistemas..whmapaliases where cod3='{0}' and location='{1}'", Convert.ToString(txtCOD3.Text), Convert.ToString(txtLOCATION.Text)), Values.gDatos)) { _rs.Open(); //iterate labels _rs.ToList().ForEach(row => { _racklabel.Parameters["VALUE"] = row["location"].ToString(); _racklabel.Parameters["HASHVAL"] = row["alias"].ToString(); if (!_printer.SendUTF8StringToPrinter(_racklabel.ToString(), 1)) { CTWin.MsgError(string.Format("Error printing label {}.", row["VALUE"])); } }); } } else { using (var _rs = new DynamicRS(string.Format("select cod3,location,alias from sistemas..whmapaliasess where cod3='{0}' and location like('{1}'+'%')", Convert.ToString(txtCOD3.Text), Convert.ToString(txtAISLE.Text)), Values.gDatos)) { _rs.Open(); //iterate labels _rs.ToList().ForEach(row => { _racklabel.Parameters["VALUE"] = row["location"].ToString(); _racklabel.Parameters["HASHVAL"] = row["alias"].ToString(); if (!_printer.SendUTF8StringToPrinter(_racklabel.ToString(), 1)) { CTWin.MsgError(string.Format("Error printing label {}.", row["VALUE"])); } }); } } } }
// TODO: delegate method to abstract label printing method. public void PrintReceiveLabel(Receipt receipt) { // Guard // Do not print labels for serialized units on carts // TODO: Write Specification(pattern) for this! if (receipt.ReceivingCart != null && receipt.Item.SerializedUnit != null) { return; } //ReceivingLabel label = ReceivingLabel.GetReceivingLabel(); ZPLLabel label = ZPLLabel.GetLabelByName("CHARTER_REC"); label.SetLabelValues( ReceivingLabelDetail.GetLabelDetailByLotId( receipt.UnitTrackingId).ToLabelArgs()); label.Print(); }
public bool PrintZplLabel(ZPLLabel label) { bool enabled = false; PrinterStream printerStream; StreamWriter writer; bool.TryParse(SCOUT.Core.Data.Helpers.Config["EnablePrinter"], out enabled); if (!enabled) { return(false); } printerStream = new PrinterStream(SCOUT.Core.Data.Helpers.Config["PrinterName"], "Generic Label"); writer = new StreamWriter(printerStream); try { writer.WriteLine(label.LabelData, label.LabelValues); return(true); } catch (Exception ex) { MessageBox.Show("Unable to print label." + Environment.NewLine + Environment.NewLine + ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } finally { writer.Flush(); writer.Close(); printerStream.Close(); } }
// Print all "unprinted" labels of the selected group private void btnPrint_Click(object sender, EventArgs e) { SetFormEnabled(false); if (cboPrinters.Value.ToString() == "") { SetFormEnabled(true); CTWin.MsgError("Select a printer first."); return; } string _printerType = ""; string _printerAddress = ""; int _printerResolution = 0; using (var _RS = new DynamicRS(string.Format("select descripcion,cmp_varchar,cmp_integer from datosEmpresa where codigo='{0}'", cboPrinters.Value), Values.gDatos)) { _RS.Open(); _printerAddress = _RS["cmp_varchar"].ToString(); _printerType = _RS["descripcion"].ToString().Split('|')[0]; _printerResolution = Convert.ToInt32(_RS["cmp_integer"]); } cLabel _delimiterLabel; cLabel _label; if (_printerType == "ZPL") { _delimiterLabel = new ZPLLabel(labelHeight, labelWidth, 3, _printerResolution); if (!NoDelim) { delimiterLabel.delim(_delimiterLabel, "START", SQLParameterString.Replace(" WHERE ", "")); } _label = new ZPLLabel(labelHeight, labelWidth, 3, _printerResolution); } else { SetFormEnabled(true); throw new NotImplementedException(); } using (var _printer = new cRawPrinterHelper(_printerAddress)) { //print delimiter start if (!NoDelim) { _printer.SendUTF8StringToPrinter(_delimiterLabel.ToString(), 1); } using (var _RS = new DynamicRS(string.Format("Select * from Campos_CS where codigo='{0}'", txtCode.Text), Values.gDatos)) { _RS.Open(); _RS.ToList().ForEach(z => { float _bh = z["barcodeHeight"] is DBNull ? 0 : Convert.ToSingle(z["barcodeHeight"]); float _bm = z["barcodeWidthmult"] is DBNull ? 0 : Convert.ToSingle(z["barcodeWidthmult"]); float _cs = z["charSize"] is DBNull ? 0 : Convert.ToSingle(z["charSize"]); _label.addLine(Convert.ToInt32(z["Col"]), Convert.ToInt32(z["Fila"]), Convert.ToSingle(CT.Qnuln(z["TamTexto"])), z["Orientacion"].ToString(), z["Estilo"].ToString(), z["Texto"].ToString(), _cs, _bh, _bm); }); } Dictionary <string, string> _parameters = new Dictionary <string, string>(); SQLSelect.Split('|').ToList().ForEach(x => _parameters.Add(x, "")); string _group = ""; vsLabels.ToList().Where(line => line.Cells["PRINTED"].Value.ToString() == "N").ToList().ForEach(line => { _parameters.ToList().ForEach(p => _parameters[p.Key] = line.Cells[p.Key].Value.ToString()); if (SQLGroup != "" && _group != line.Cells[SQLGroup].Value.ToString()) { _group = line.Cells[SQLGroup].Value.ToString(); if (!NoDelim) { delimiterLabel.delim(_delimiterLabel, "GROUP", SQLGroup + "|" + _group); _printer.SendUTF8StringToPrinter(_delimiterLabel.ToString(), 1); } } _printer.SendUTF8StringToPrinter(_label.ToString(_parameters, Convert.ToInt32(line.Cells["QTY"].Value)), 1); //cRawPrinterHelper.SendUTF8StringToPrinter(_printerAddress, _label.ToString(_parameters), Convert.ToInt32("2")); ChangeLineStatus(line); }); if (!NoDelim) { delimiterLabel.delim(_delimiterLabel, "END", "***"); _printer.SendUTF8StringToPrinter(_delimiterLabel.ToString(), 1); } SetFormEnabled(true); } }
private void btnLabelCMs_Click(object sender, EventArgs e) { if (MessageBox.Show("This will generate and print all CMs. Are you sure?", "SIMPLISTICA", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { //printer preparation string _printerAddress = ""; int _printerResolution = 0; if (Values.LabelPrinterAddress == "") { CTWin.MsgError("Select a label printer first in preferences."); return; } using (var _RS = new DynamicRS(string.Format("select descripcion,cmp_varchar,cmp_integer from ETIQUETAS..datosEmpresa where codigo='{0}'", Values.LabelPrinterAddress), Values.gDatos)) { _RS.Open(); _printerAddress = _RS["cmp_varchar"].ToString(); _printerResolution = Convert.ToInt32(_RS["cmp_integer"]); //_printerType = _RS["descripcion"].ToString().Split('|')[0]; } //label preparation var _label = new ZPLLabel(70, 31, 3, _printerResolution); var _CMLabel = new MicroCM(_label); //sp preparation using (var _printer = new cRawPrinterHelper(_printerAddress)) using (var _sp = new SP(Values.gDatos, "PGenerar_Paletags_linea")) { var _delimiterLabel = new ZPLLabel(_CMLabel.Label.width, _CMLabel.Label.height, 3, _CMLabel.Label.dpi); delimiterLabel.delim(_delimiterLabel, "START RECEIVAL", txtEntrada.Text); _printer.SendUTF8StringToPrinter(_delimiterLabel.ToString(), 1); //we will check line by line VS.ToList().Where(r => r.Cells[0].Value.ToString() != "").ToList().ForEach(r => { //first we generate the cms try { generateCM(Convert.ToInt32(txtEntrada.Value), Convert.ToInt32(r.Cells[1].Value)); } catch (Exception ex) { CTWin.MsgError(ex.Message); CTLM.StatusMsg(ex.Message); } //delimiter delimiterLabel.delim(_delimiterLabel, "LINE", r.Cells[1].Value.ToString()); _printer.SendUTF8StringToPrinter(_delimiterLabel.ToString(), 1); // then we print the labels using (var _rs = new DynamicRS(string.Format("Select cp.CM,cp.Entrada,cp.Linea,cp.Partnumber,cp.QTY,cp.xfec,c.Doc_Proveedor from CMS_PALETAGS cp inner join cab_Recepcion c on c.entrada=cp.entrada where cp.Entrada='{0}' and Linea='{1}'", Convert.ToInt32(txtEntrada.Value), Convert.ToInt32(r.Cells[1].Value)), Values.gDatos)) { _rs.Open(); _rs.ToList().ForEach(row => { _CMLabel.Parameters["CM"] = row["CM"].ToString(); _CMLabel.Parameters["RECEIVAL"] = row["Entrada"].ToString(); _CMLabel.Parameters["RECEIVAL_DATE"] = row["xfec"].ToString(); _CMLabel.Parameters["PARTNUMBER"] = row["Partnumber"].ToString(); _CMLabel.Parameters["QTY"] = row["QTY"].ToString(); if (!_printer.SendUTF8StringToPrinter(_CMLabel.ToString(), 1)) { CTWin.MsgError(string.Format("Error printing label {0}.", row["CM"])); } }); } delimiterLabel.delim(_delimiterLabel, "END RECEIVAL", txtEntrada.Text); _printer.SendUTF8StringToPrinter(_delimiterLabel.ToString(), 1); }); lstFlags["PALETAGS"] = true; CTLM.StatusMsg("CMs generated OK."); } } MessageBox.Show("Label printing task finished.", "SIMPLISTICA", MessageBoxButtons.OK, MessageBoxIcon.Information); }
public bool PrintZplLabel(ZPLLabel label) { return(true); }