1
I have a tag and on that tag I have a field that is very large.
I need to break the line, to go to the bottom line when I reach a certain number of characters.
etqfracpic1.Add("Cas: " + reader[10].ToString());
// como estou passando o comando
How can I do that?
Excuse me follow the full code.
List<string> etqfracpic = new List<string>();
List<string> etqfracpic1 = new List<string>();
public frmEtqFracPic(string guiapic)
{
InitializeComponent();
txt_guia.Text = guiapic;
}
private void etqfrac()
{
conex.Open();
SqlCommand comando;
StringBuilder Query = new StringBuilder();
Query.Append(" SELECT ");
Query.Append(" CAST(0 AS bit) AS SELECIONAR ");
Query.Append(" ,SC.C2_NUM ");
Query.Append(" ,SB.B1_DESC ");
Query.Append(" ,SC.C2_XNOMFA ");
Query.Append(" ,SC.C2_XNPAIS ");
Query.Append(" ,SC.C2_XLOTEF ");
Query.Append(" ,CONVERT(VARCHAR(10),CAST(SB.B1_PESO AS NUMERIC(15, 3))) + ' ' + SB.B1_XSEGUM AS PESO ");
Query.Append(" ,CONVERT(VARCHAR(10),CAST(SB.B1_PESBRU AS NUMERIC(15, 3))) + ' ' + SB.B1_XSEGUM AS PESBRU ");
Query.Append(" ,CONVERT(VARCHAR(10), CAST( SC.C2_XDTFAB AS DATE),103) AS DATAF ");
Query.Append(" ,CONVERT(VARCHAR(10), CAST( SC.C2_XDTVALI AS DATE),103) AS DATAV ");
Query.Append(" ,SB.B1_XCAS ");
Query.Append(" ,CB.CB0_CODETI AS [COD. BARRAS] ");
Query.Append(" FROM SC2020 AS SC ");
Query.Append(" INNER JOIN SB1020 AS SB WITH (NOLOCK) ON SB.B1_COD = SC.C2_PRODUTO ");
Query.Append(" INNER JOIN CB0020 AS CB WITH (NOLOCK) ON CB.CB0_LOTE = SC.C2_XLOTE ");
Query.Append(" WHERE C2_NUM = @C2_NUM ");
comando = conex.CreateCommand();
comando.CommandText = Query.ToString();
comando.Parameters.Add("@C2_NUM", SqlDbType.VarChar).Value = txt_guia.Text.Trim();
DataTable tableGrid = (DataTable)DGW_EtqPic.DataSource;
DataTable tableRelatorio = null;
var filter = from DataRow row in tableGrid.Rows
where Convert.ToBoolean(row["SELECIONAR"])
select row;
if (filter.Count() > 0)
{
tableRelatorio = filter.CopyToDataTable();
SqlDataReader reader = comando.ExecuteReader();
{
while (reader.Read())
{
txt_codbarraspic.Text = reader[11].ToString();
txt_cas.Text = reader[10].ToString();
etqfracpic.Add("PRODUTO: " + " " + reader[2].ToString());
etqfracpic.Add("FABRICANTE: " + " " + reader[3].ToString());
etqfracpic.Add("ORIGEM: " + " " + reader[4].ToString());
etqfracpic.Add("LOTE" + " " + reader[5].ToString());
etqfracpic.Add("P. BRUTO: " + reader[7].ToString() + " " + "P. LIQUIDO: " + " " + reader[6].ToString());
etqfracpic.Add("FABRICAÇÃO: " + " " + reader[9].ToString() + " " + "VALIDADE: " + " " + reader[9].ToString());
etqfracpic1.Add("CAS: " + txt_cas.Text.Replace("-", "").Replace(" ", ""));
etqfracpic.Add("Guia: " + reader[1].ToString());
BarcodeLib.Barcode codbarraspic = new BarcodeLib.Barcode();
codbarraspic.IncludeLabel = true;
PB_codbarraspic.BackgroundImage = codbarraspic.Encode(BarcodeLib.TYPE.CODE128, txt_codbarraspic.Text.Replace(" ", ""), Color.Black, Color.White, 300, 60);
Etqpic.Print();
etqfracpic.Clear();
etqfracpic1.Clear();
break;
}
}
conex.Close();
}
There’s no way I can help you seeing just one line of code.
– Jéf Bueno
I’m sorry I put the full code up.
– Junior Guerreiro
Got it. You can get a Substring() which returns a string of the desired size. Substring
– Gilberto B. Terra Jr.
Example, if it is up to 80 characters the maximum size, you can use Reader[10]. Tostring(). Substring(0,80);
– Gilberto B. Terra Jr.
Gilberto good afternoon. So the suggestion that you passed it to me in 80 character , but my problem is that it has 120 character, and the rest he did not print, for in 80, I need that when you get to 80 he go to the bottom line and continue the characters.
– Junior Guerreiro
@Juniorguerreiro I put in . Netfiddle: https://dotnetfiddle.net/rXtiXi If you release here, I put as answer
– Rovann Linhalis
Rovann thank you so much for your help gave right here...
– Junior Guerreiro