private void Connection() { if (db.OpenConnection()) { label1.ForeColor = Color.Green; label1.Text = "Stato database: CONNESSO"; } else { label1.ForeColor = Color.Red; label1.Text = "Stato database: NON CONNESSO"; } }
private void Connection() { if (db.OpenConnection()) { lblConn.ForeColor = Color.Green; lblConn.Text = "Stato database " + db.Database + ": CONNESSO"; } else { lblConn.ForeColor = Color.Red; lblConn.Text = "Stato database: NON CONNESSO"; } }
public bool CreaTab() { const short col = 31; int qty = Convert.ToInt32(Qty); int pr_matri = Convert.ToInt32(Pr_matri) + 1; int se_matri = pr_matri + qty - 1; DBconnect db = new DBconnect(); string path_w2 = Creadir(PATH_W, Assem) + "\\" + Cod + "_" + Qty + "_Pz.pdf"; try { FileStream fileStream = new FileStream(path_w2, FileMode.Create, FileAccess.Write); PdfWriter writer = PdfWriter.GetInstance(doc1, fileStream); PdfPTable table = new PdfPTable(col); table.TotalWidth = 775; table.LockedWidth = true; float[] widths = new float[] { 20f, 95f, 100f, 15f, 15f, 15f, 16f, 16f, 16f, 16f, 16f, 16f, 15f, 15f, 15f, 15f, 15f, 15f, 15f, 15f, 15f, 15f, 15f, 15f, 15f, 15f, 15f, 15f, 15f, 15f, 122f }; List <Layout> layouts = new List <Layout>(); table.SetWidths(widths); PdfPCell cell; Font font = FontFactory.GetFont(FontFactory.TIMES_ROMAN); layouts = GeneraLayout(Cod, Descr, Assem); foreach (Layout items in layouts) { Font font2 = FontFactory.GetFont(FontFactory.TIMES_ROMAN); font2.Size = items.fontSize; cell = new PdfPCell(new Paragraph(items.message, font2)); cell.Colspan = items.colSpan; cell.Rowspan = items.rowSpan; cell.Rotation = items.rotation; cell.HorizontalAlignment = items.horAlignment; cell.VerticalAlignment = items.verAlignment; table.AddCell(cell); } font.Size = 10; ushort k = 0; for (int i = pr_matri; i <= se_matri; i++) { k++; cell = new PdfPCell(new Paragraph(k.ToString(), font)); //cell.Colspan = 31; cell.Rowspan = 2; table.AddCell(cell); cell = new PdfPCell(new Paragraph("", font)); cell.Rowspan = 2; table.AddCell(cell); cell = new PdfPCell(new Paragraph(Logotipo() + " " + i.ToString("d" + Cifre), font)); cell.Rowspan = 2; table.AddCell(cell); for (ushort j = 1; j <= 9; j++) { cell = new PdfPCell(new Paragraph("G", font)); table.AddCell(cell); cell = new PdfPCell(new Paragraph("L", font)); table.AddCell(cell); cell = new PdfPCell(new Paragraph("C", font)); table.AddCell(cell); } cell = new PdfPCell(new Paragraph("", font)); cell.Rowspan = 2; table.AddCell(cell); for (ushort j = 1; j <= 9; j++) { cell = new PdfPCell(new Paragraph(" ", font)); cell.Colspan = 3; table.AddCell(cell); } } table.HeaderRows = 2; doc1.Open(); writer.PageEvent = new HeadFoot(); doc1.Add(table); doc1.Close(); if (db.OpenConnection()) { db.InsertScheda(Id, pr_matri.ToString(), se_matri.ToString(), DateTime.Now.ToString("yyyy-MM-dd"), Assem); db.Close(); return(true); } else { MessageBox.Show("Attenzione database non aggiornato"); return(false); } } catch (DirectoryNotFoundException e) { MessageBox.Show("Errore di percorso {0}", e.Message); return(false); } }