Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.84 KB | None | 0 0
  1. StringBuilder Query = new StringBuilder();
  2. Query.Append(" SELECT ");
  3. Query.Append(" CAST(0 AS bit) AS SELECIONAR ");
  4. Query.Append(" ,SC.C2_NUM AS GUIA ");
  5. Query.Append(" ,SB.B1_DESC AS PRODUTO ");
  6. Query.Append(" ,SC.C2_XNPAIS [PAÍS ORIGEM] ");
  7. Query.Append(" ,CONVERT(VARCHAR(10), CAST( SC.C2_XDTFAB AS DATE),103) AS [DT. FABRICAÇÃO] ");
  8. Query.Append(" ,CONVERT(VARCHAR(10), CAST( SC.C2_XDTVALI AS DATE),103) AS [DT. VALIDADE] ");
  9. Query.Append(" ,SC.C2_XLOTEF AS [LT. FABRICANTE] ");
  10. Query.Append(" ,SC.C2_XLOTE AS [LT. INTERNO] ");
  11. Query.Append(" ,SB.B1_XDCB AS DCB ");
  12. Query.Append(" ,SB.B1_XCAS AS CAS ");
  13. Query.Append(" ,CONVERT(VARCHAR(10),CAST(SB.B1_PESO AS NUMERIC(15, 3))) + SB.B1_XSEGUM AS PESO ");
  14. Query.Append(" ,SC.C2_XNOMFA AS FABRICANTE ");
  15. Query.Append(" ,CB.CB0_CODETI AS [COD. BARRAS] ");
  16. Query.Append(" FROM SC2020 AS SC ");
  17. Query.Append(" INNER JOIN SB1020 AS SB WITH (NOLOCK) ON SB.B1_COD = SC.C2_PRODUTO ");
  18. Query.Append(" INNER JOIN CB0020 AS CB WITH (NOLOCK) ON CB.CB0_LOTE = SC.C2_XLOTE ");
  19. Query.Append(" WHERE C2_NUM = @C2_NUM ");
  20.  
  21. comando = conex.CreateCommand();
  22. comando.CommandText = Query.ToString();
  23.  
  24. comando.Parameters.Add("@C2_NUM", SqlDbType.VarChar).Value = txtGuiaFrac.Text.Trim();
  25.  
  26. try
  27. {
  28. SqlDataAdapter dados = new SqlDataAdapter(comando);
  29. DataTable dtLista = new DataTable();
  30. dados.Fill(dtLista);
  31.  
  32. DGW_EtqFracionamento.DataSource = dtLista;
  33.  
  34. DGW_EtqFracionamento.Columns["GUIA"].ReadOnly = true;
  35. DGW_EtqFracionamento.Columns["PRODUTO"].ReadOnly = true;
  36. DGW_EtqFracionamento.Columns["PAÍS ORIGEM"].ReadOnly = true;
  37. DGW_EtqFracionamento.Columns["DT. FABRICAÇÃO"].ReadOnly = true;
  38. DGW_EtqFracionamento.Columns["DT. VALIDADE"].ReadOnly = true;
  39. DGW_EtqFracionamento.Columns["LT. FABRICANTE"].ReadOnly = true;
  40. DGW_EtqFracionamento.Columns["LT. INTERNO"].ReadOnly = true;
  41. DGW_EtqFracionamento.Columns["DCB"].ReadOnly = true;
  42. DGW_EtqFracionamento.Columns["CAS"].ReadOnly = true;
  43. DGW_EtqFracionamento.Columns["PESO"].ReadOnly = true;
  44. DGW_EtqFracionamento.Columns["FABRICANTE"].ReadOnly = true;
  45. DGW_EtqFracionamento.Columns["COD. BARRAS"].ReadOnly = true;
  46. }
  47. catch
  48. {
  49. MessageBox.Show("Não existem dados a serem encontrados");
  50. }
  51. }
  52.  
  53. var filter = from DataRow row in tableGrid.Rows
  54. where Convert.ToBoolean(row["SELECIONAR"])
  55. select row;
  56. if (filter.Count() > 0)
  57. {
  58. tableRelatorio = filter.CopyToDataTable();
  59. if (caixa_selecao.ShowDialog() == DialogResult.Cancel)
  60. return;
  61. else
  62. EtqFraciona.PrinterSettings = caixa_selecao.PrinterSettings;
  63. EtqFraciona.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("Etiqueta", 420, 200);
  64. etqfrac();
  65. }
  66. else
  67. {
  68. MessageBox.Show("Selecione pelo menos um registro para impressão!", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  69. return;
  70. }
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement