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"])); } }); } } } }
// Add the results of a query to the current area public bool AddQuery(string pSQL, cAccesoDatosNet pConn, EspackFont pFont = null, bool pHideTitles = false) { using (var _rs = new DynamicRS(pSQL, pConn)) { _rs.Open(); if (_rs.RecordCount == 0) { MessageBox.Show("The query returned no data.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } else { Dictionary <string, List <string> > _matrix = new Dictionary <string, List <string> >(); foreach (var _item in _rs.Fields) { _matrix[_item.ToString()] = new List <string>(); } int _col; _rs.ToList().ForEach(_row => { _col = 0; _row.ItemArray.ToList().ForEach(_column => { _matrix[_matrix.Keys.ToList()[_col]].Add(_column.ToString()); _col++; }); }); foreach (var _key in _matrix.Keys) { Areas.Add(CurrentArea = new EspackPrintingArea(EnumDocumentZones.BODY, pFont, pDocking: EnumZoneDocking.RIGHTWARDS)); // Add current column title if (!pHideTitles) { AddText(true, _key.ToString(), true); CurrentArea.PermanentRows++; } // Add data for current column foreach (var _item in _matrix[_key]) { AddText(_item.ToString(), true); CurrentArea.DataRows++; } } } } return(true); }
public ListRepairs2LoadAdapter(Context context) { this.context = context; using (var recordset = new DynamicRS(query, Values.gDatos)) { recordset.Open(); ListElements = recordset.ToList().Select(r => new Repair() { UnitNumber = r["UnitNumber"].ToString().Trim(), RepairCode = r["RepairCode"].ToString().Trim(), Flags = r["Flags"].ToString().Trim() }).ToList(); //(from r in _RS.ToList() select r["RepairCode"] + "|" + r["UnitNumber"]).ToList<string>(); recordset.Close(); } }
public override void NotifyDataSetChanged() { base.NotifyDataSetChanged(); LoadLabel.Text = Loads.Label; using (var recordset = new DynamicRS(query, Values.gDatos)) { recordset.Open(); ListElements = recordset.ToList().Select(r => new Repair() { UnitNumber = r["UnitNumber"].ToString().Trim(), RepairCode = r["RepairCode"].ToString().Trim(), Flags = r["Flags"].ToString().Trim() }).ToList(); //(from r in _RS.ToList() select r["RepairCode"] + "|" + r["UnitNumber"]).ToList<string>(); recordset.Close(); } }
private void ShowDetails() { vsLabels.ClearEspackControl(); vsLabels.ColumnCount = 0; vsLabels.Conn = Values.gDatos; string _group = ""; if (vsGroups.CurrentCell != null) { _group = (vsGroups.CurrentCell.Value.ToString() != "" ? " and grupo='" + vsGroups.CurrentCell.Value + "'" : ""); } List <string> _SelectFields = new List <string>(); _SelectFields.Add("IDREG"); _SelectFields.AddRange(SQLSelect.Split('|')); _SelectFields.Add("QTY"); _SelectFields.Add("PRINTED"); for (int i = 0; i < _SelectFields.Count; i++) { vsLabels.AddColumn(_SelectFields[i].ToUpper()); } SQLPrintable.Split('|').ToList().ForEach(x => ((CtlVSColumn)vsLabels.Columns[x.ToString()]).Print = true); ((CtlVSColumn)vsLabels.Columns[0]).Aggregate = AggregateOperations.COUNT; ((CtlVSColumn)vsLabels.Columns["QTY"]).Aggregate = AggregateOperations.SUM; var _Sql = string.Format("SELECT IDREG,DATA=datos,QTY,PRINTED=impreso FROM etiquetas_detalle WHERE codigo='{0}' and parametros='{1}'{2} order by datos,idreg", txtCode.Text, SQLParameterString.Replace("'", "#"), _group); using (var _RS = new DynamicRS(_Sql, Values.gDatos)) { _RS.Open(); _RS.ToList().ForEach(x => { List <string> row = new List <string>(); row.Add(x["IDREG"].ToString()); row.AddRange(x["DATA"].ToString().Split('|')); row.Add(x["QTY"].ToString()); row.Add(x["PRINTED"].ToString()); vsLabels.Rows.Add(row.ToArray()); //Application.DoEvents(); //vsLabels.Rows.Add(x["IDREG"].ToString(), x["DATA"].ToString(), x["QTY"].ToString(), x["PRINTED"]); }); }; //vsLabels.UpdateEspackControl(); }
private void FillApps() { using (var _RS = new DynamicRS("select Code=ServiceCode,Description,DB,ExeName=s.app,Zone=s.location,s.ServiceCode,s.version from general..Permiso_Servicios p inner join services s on s.ServiceCode=p.codigo where p.LoginSql= '" + Values.User + "' and general.dbo.checkFlag(flags,'OBS')=0", Values.gDatos)) { _RS.Open(); _RS.ToList() //.Where(a => a["Code"].ToString()=="LOGISTICA").ToList() .ForEach(x => { var _app = new cAppBot(x["Code"].ToString(), x["Description"].ToString(), x["DB"].ToString(), x["ExeName"].ToString(), x["Zone"].ToString(), Values.DBServerList[x["Zone"].ToString()], Values.ShareServerList[Values.COD3], x["ServiceCode"].ToString(), pVersion: x["version"].ToString()); _app.AfterLaunch += _app_AfterLaunch;; Values.AppList.Add(_app); }); } Values.AppList.Add(new cAppBot("Tools", "TOOLS", "", "", "", null, Values.ShareServerList[Values.COD3], "", true)); //Values.AppList.Add(new cAppBot("lib", "lib", "", "", "", null, Values.ShareServerList[Values.COD3], true)); }
public Form1() { InitializeComponent(); CTLM.Conn = new cAccesoDatosNet("DB01", "SISTEMAS", "sa", "5380"); txtUserCode.AutoCompleteMode = AutoCompleteMode.Suggest; txtUserCode.AutoCompleteSource = AutoCompleteSource.CustomSource; //txtUserCode.TextBox.Multiline = false; var autoCompleteCustomSource = new AutoCompleteStringCollection(); txtText.AutoCompleteMode = AutoCompleteMode.SuggestAppend; txtText.AutoCompleteSource = AutoCompleteSource.CustomSource; using (DynamicRS rs = new DynamicRS("Select UserCode from Users", CTLM.Conn)) { rs.Open(); rs.ToList().ForEach(r => autoCompleteCustomSource.Add(r[0].ToString())); } txtUserCode.AutoCompleteCustomSource = autoCompleteCustomSource; txtText.AutoCompleteCustomSource = autoCompleteCustomSource; CTLM.DBTable = "vUsers"; CTLM.AddItem(txtUserCode, "UserCode", CTLMControlTypes.Search); CTLM.AddItem(txtUserNumber, "UserNumber", CTLMControlTypes.Search); CTLM.AddItem(txtPwdExp, "PasswordEXP", CTLMControlTypes.NoSearch); CTLM.AddItem(cboMainCOD3, "MainCOD3", CTLMControlTypes.Search); CTLM.AddItem(lstCOD3, "COD3", CTLMControlTypes.Search); CTLM.AddItem(txtDesCod3, "desCOD3", CTLMControlTypes.NoSearch); lstCOD3.Source("select n.COD3,Descripcion=n.cod3 from NetworkSedes n inner join general..sedes g on g.cod3=n.COD3 order by n.Cod3"); cboMainCOD3.Source("select n.COD3,g.Descripcion from NetworkSedes n inner join general..sedes g on g.cod3=n.COD3 order by n.Cod3", txtDesCod3); CTLM.Start(); VS.Conn = CTLM.Conn; VS.SQL = "Select UserCode, Area, COD3 from Users where usercode!='' order by UserCode"; VS.Start(); VS.UpdateEspackControl(); //VS.FilterRowEnabled = true; }
// 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); } }
// Get/Generate the labels private void btnObtain_Click(object sender, EventArgs e) { SetFormEnabled(false); clearing = true; vsGroups.ClearEspackControl(); vsParameters.ToList().ForEach(z => { Parameters[z.Cells[0].Value.ToString()] = z.Cells[1].Value.ToString(); }); // var s = Parameters.Where(x => x.Value == "").ToDictionary(a => a.Key, a => a.Value); //Dictionary<string, string>) if (s.Count != 0) { MessageBox.Show("Parameter " + s.First().Key + " must be entered.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); SetFormEnabled(true); clearing = false; return; } ; var _Sql = "SELECT " + SQLSelect.Replace("|", ",") + " FROM " + SQLView; SQLParameterString = ""; Parameters.ToList().ForEach(x => { Parameters[x.Key] = x.Value; SQLParameterString += x.Key + (x.Value != "NOTHING" ? "='" + x.Value + "'" : "") + " and "; }); if (SQLParameterString != "") { SQLParameterString = " WHERE " + SQLParameterString.Substring(0, SQLParameterString.Length - 5); } _Sql += SQLParameterString; if (SQLOrder != "") { _Sql += " ORDER BY " + SQLOrder.Replace("|", ","); } using (var _RS = new DynamicRS(_Sql, Values.gDatos)) { _RS.Open(); if (_RS.EOF) { SetFormEnabled(true); MessageBox.Show("No rows returned.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } ShowDetails(); GenerateGroups(_RS.ToList()); if (_RS.RecordCount != vsLabels.RowCount) { GenerateNewLabels(_RS.ToList()); ShowDetails(); } } SetFormEnabled(true); clearing = false; }
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); }