I load the pdf in a GRID and print the documents that come out (If the query brings 2 = print those 2 PDFs) the problem is that it generates a lot of load in the server since it runs adobe to print each PDF and then I can not close the program I have to close by Task Manager. I use this DLL PdfPrintingNet.dll
public class imprimirmanifiesto
{
public void imprimir(string dobleslash)
{
Process p = new Process();
p.StartInfo = new ProcessStartInfo()
{
CreateNoWindow = true,
Verb = "print",
FileName = "C:\Users\bodega\Documents\Manifiestos\" + dobleslash + ".pdf"
};
p.Start();
}
}
FOR THE PRINT BUTTON
private void button2_Click_1(object sender, EventArgs e)
{
r = new imprimirmanifiesto();
int pos = 0;
bool a = true;
while (a == true)
{
try
{
if (string.IsNullOrEmpty(dataGridView1.Rows[pos].Cells[0].Value.ToString()))
{
a = false;
}
else
{
a = true;
}
r.imprimir(dataGridView1.Rows[pos].Cells[1].Value.ToString());
pos++;
}
catch (Exception q)
{
}
}
}
CONSULTATION
public bool consultar(DataGridView grillita, Decimal factura, String tipo)
{
bool resultado = true;
try
{
String consulta;
OracleConnection con = new OracleConnection();
OracleCommand comando;
OracleDataReader lector;
int cuenta = 1;
int fila = 0;
grillita.Rows.Clear();
//con.ConnectionString = "Data Source = Duna02; User Id = DUNA; Password = duna; Unicode = true;";
con.ConnectionString = "Data Source = QWERTY; User Id = DUNA; Password = QWERTY1; Unicode = true;";
con.Open();
consulta = "select DISTINCT ULTIMA_IMPORT, MI_ARTIC_FABRICA from CRM_MANIFIESTOS_02 join TIMOVIMIENTODETALLE on CRM_MANIFIESTOS_02.CODIGO = TIMOVIMIENTODETALLE.MV2_ARTIC where TIMOVIMIENTODETALLE.MV2_NUM ='" + factura + "' AND CRM_MANIFIESTOS_02.CODIGO = MV2_ARTIC AND MV2_TIPO ='" + tipo + "' order by CRM_MANIFIESTOS_02.ULTIMA_IMPORT asc";
comando = new OracleCommand(consulta, con);
lector = comando.ExecuteReader();
while (lector.Read())
{
grillita.Rows.Add();
grillita.Rows[fila].Cells[2].Value = lector.GetDecimal(0);
grillita.Rows[fila].Cells[1].Value = "Manifiesto " + lector.GetDecimal(0) + "-" + lector.GetString(1);
grillita.Rows[fila].Cells[0].Value = cuenta;
fila++;
cuenta++;
}
con.Close();
}
catch (Exception abc)
{
MessageBox.Show("Verifique número de importación y seleccione un tipo");
}
return resultado;
}