public static pdfDocument ImprimePlano(DataTable table, string NoObra) { String strFont = "Helvetica"; int leftMargin = 30; int pg = 1; int top = 40; //Tamanho da lin em pixel int nTamLinPixel = 19; // Variaveis de controle para quebra de linha de campos int QtdCaracterLinha = 100; int Tamanho; int QtdLin; int StrInicio; int StrFim; int cl; // Adiciona Página pdfDocument myDoc = new pdfDocument("Horizon", "Orion"); pdfPage myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); string DadosObra = NoObra; CabRelatorio(myDoc, myPage, top, DadosObra); top += 30; pdfTable myTable = SubCabRelatorio(myDoc, myPage, top); top += 10; string TipoAtividade = ""; string GrupoAtividade = ""; string Periodicidade = ""; // Imprimir linhas de detalhes pdfTableRow myRow = myTable.createRow(); try { foreach (DataRow row in table.Rows) { cl = 0; myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; if (TipoAtividade != row["cmpCoTipoAtividade"].ToString()) { row["cmpDcTipoAtividade"] = TiraCaractEspecial(row["cmpDcTipoAtividade"].ToString()); myRow[cl++].addText(row["cmpDcTipoAtividade"].ToString().TrimEnd()); TipoAtividade = row["cmpCoTipoAtividade"].ToString(); } else { myRow[cl++].addText(""); } if (GrupoAtividade != row["cmpCoGrupoAtividade"].ToString()) { row["cmpDcGrupoAtividade"] = TiraCaractEspecial(row["cmpDcGrupoAtividade"].ToString()); myRow[cl++].addText(row["cmpDcGrupoAtividade"].ToString().TrimEnd()); GrupoAtividade = row["cmpCoGrupoAtividade"].ToString(); } else { myRow[cl++].addText(""); } if (Periodicidade != row["cmpCoPeriodicidade"].ToString()) { myRow[cl++].addText(row["cmpDcPeriodicidade"].ToString()); Periodicidade = row["cmpCoPeriodicidade"].ToString(); } else { myRow[cl++].addText(""); } row["cmpDcItemAtividadePreventiva"] = TiraCaractEspecial(row["cmpDcItemAtividadePreventiva"].ToString()); Tamanho = row["cmpDcItemAtividadePreventiva"].ToString().Length; if (Tamanho > 0) { QtdLin = (Tamanho % QtdCaracterLinha == 0 ? Tamanho / QtdCaracterLinha : (Tamanho / QtdCaracterLinha) + 1); StrInicio = 0; for (int Linha = 1; Linha <= QtdLin; Linha++) { StrFim = Linha == QtdLin ? Tamanho - StrInicio : QtdCaracterLinha; if (Linha == 1) { myRow[cl++].addText(row["cmpDcItemAtividadePreventiva"].ToString().Substring(StrInicio, StrFim).Trim()); } else { cl = 0; myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; myRow[cl++].addText(""); myRow[cl++].addText(""); myRow[cl++].addText(""); myRow[cl++].addText(row["cmpDcItemAtividadePreventiva"].ToString().Substring(StrInicio, StrFim).Trim()); } myTable.addRow(myRow); StrInicio += QtdCaracterLinha; top += nTamLinPixel; } } //else //{ // myRow[cl++].addText(row["cmpDcDescricaoSolicitacao"].ToString().TrimEnd()); // myRow[cl++].addText(row["cmpDcLocal"].ToString()); // myRow[cl++].addText(row["cmpDtAbertura"].ToString().Substring(0, 10)); // myRow[cl++].addText(row["cmpDtConclusaoAtendimento"].ToString() == "" ? "" : row["cmpDtConclusaoAtendimento"].ToString().Substring(0, 10)); // myTable.addRow(myRow); // top += nTamLinPixel; //} if (top > 1250) { myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black); myPage.addTable(myTable); // Adiciona uma página myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); top = 30; CabRelatorio(myDoc, myPage, top, DadosObra); top += 30; myTable = SubCabRelatorio(myDoc, myPage, top); top = +10; } } if (top < 1250) { myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black); myPage.addTable(myTable); } } catch (Exception ex) { Global.ShowError(Global.Title, ex); } return(myDoc); }
public static pdfDocument ImprimeCapaRostoOS(DataTable table, string DataInicial, string DataFinal) { String strFont = "Helvetica"; int leftMargin = 30; int pg = 1; int top = 40; //Tamanho da lin em pixel int nTamLinPixel = 19; // Variaveis de controle para quebra de linha de campos int QtdCaracterLinha = 50; int Tamanho; int QtdLin; int StrInicio; int StrFim; int cl; DataTable DtTotMatOs; decimal TotMatOs = 0; TotMaterial totalMat = new TotMaterial(); totalMat.Adicionar(table); // Adiciona Página pdfDocument myDoc = new pdfDocument("Horizon", "Orion"); pdfPage myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); string DadosObra = (table.Rows[0]["cmpNoObra"].ToString().Trim() + (table.Rows[0]["cmpNuContrato"] != null ? " -> Contrato nº " + table.Rows[0]["cmpNuContrato"].ToString() : "")); CabRelatorio(myDoc, myPage, top, DadosObra, DataInicial, DataFinal); top += 30; //Imprime Total Geral de Material pdfTable myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2, new pdfTableStyle(myDoc.getFontReference(strFont), 9, pdfColor.Black, new pdfColor("FFFFFF")), new pdfTableStyle(myDoc.getFontReference(strFont), 8, pdfColor.Black, pdfColor.White)); myTable.coordX = leftMargin; myTable.coordY = getTop(myPage, top); cl = 0; myTable.tableHeader.rowHeight = 20; myTable.tableHeader.addColumn(550, predefinedAlignment.csRight); myTable.tableHeader[cl].addText("Total Geral de Material R$ " + totalMat.Valor.ToString("0,0.00")); myPage.addTable(myTable); top += 30; myTable = SubCabRelatorio(myDoc, myPage, top); top += 10; // Imprimir linhas de detalhes pdfTableRow myRow = myTable.createRow(); foreach (DataRow row in table.Rows) { DtTotMatOs = tblOSMaterial.RetornarTotalMatOS(Global.GetConnection(), row["cmpIdOs"].ToString()); TotMatOs = DtTotMatOs.Rows[0]["TotalMaterial"].ToString() != "" ? decimal.Parse(DtTotMatOs.Rows[0]["TotalMaterial"].ToString()) : 0; cl = 0; myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; myRow[cl++].addText(row["cmpNuOs"].ToString()); myRow[cl++].addText(row["cmpNoSolicitante"].ToString().TrimEnd()); row["cmpDcObservacoes"] = TiraCaractEspecial(row["cmpDcObservacoes"].ToString().ToUpper()); Tamanho = row["cmpDcObservacoes"].ToString().Length; if (Tamanho > 0) { QtdLin = (Tamanho % QtdCaracterLinha == 0 ? Tamanho / QtdCaracterLinha : (Tamanho / QtdCaracterLinha) + 1); StrInicio = 0; for (int Linha = 1; Linha <= QtdLin; Linha++) { StrFim = Linha == QtdLin ? Tamanho - StrInicio : QtdCaracterLinha; if (Linha == 1) { myRow[cl++].addText(row["cmpDcObservacoes"].ToString().Substring(StrInicio, StrFim).Trim()); myRow[cl++].addText(row["cmpDcLocal"].ToString()); myRow[cl++].addText(row["cmpDtAbertura"].ToString().Substring(0, 10)); myRow[cl++].addText(row["cmpDtConclusaoAtendimento"].ToString() == "" ? "" : row["cmpDtConclusaoAtendimento"].ToString().Substring(0, 10)); myRow[cl++].addText(TotMatOs.ToString("0,0.00")); } else { cl = 0; myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; myRow[cl++].addText(""); myRow[cl++].addText(""); myRow[cl++].addText(row["cmpDcObservacoes"].ToString().Substring(StrInicio, StrFim).Trim()); myRow[cl++].addText(""); myRow[cl++].addText(""); myRow[cl++].addText(""); myRow[cl++].addText(""); } myTable.addRow(myRow); StrInicio += QtdCaracterLinha; top += nTamLinPixel; } } else { myRow[cl++].addText(row["cmpDcDescricaoSolicitacao"].ToString().TrimEnd()); myRow[cl++].addText(row["cmpDcLocal"].ToString()); myRow[cl++].addText(row["cmpDtAbertura"].ToString().Substring(0, 10)); myRow[cl++].addText(row["cmpDtConclusaoAtendimento"].ToString() == "" ? "" : row["cmpDtConclusaoAtendimento"].ToString().Substring(0, 10)); myRow[cl++].addText(TotMatOs.ToString("0,0.00")); myTable.addRow(myRow); top += nTamLinPixel; } if (top > 1230) { myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black); myPage.addTable(myTable); // Adiciona uma página myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); top = 30; CabRelatorio(myDoc, myPage, top, DadosObra, DataInicial, DataFinal); top += 30; myTable = SubCabRelatorio(myDoc, myPage, top); top = +10; } } if (top < 1230) { //Imprime Total Geral de Material myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; cl = 0; myRow[cl++].addText(""); myRow[cl++].addText(""); myRow[cl++].addText(""); myRow[cl++].addText(""); myRow[cl++].addText(""); myRow[cl++].addText("Total ==>"); myRow[cl++].addText(totalMat.Valor.ToString("0,0.00")); myTable.addRow(myRow); myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black); myPage.addTable(myTable); } return(myDoc); }
public static pdfDocument ImprimeResumoOS(DataTable table, string DataInicial, string DataFinal) { String strFont = "Helvetica"; int leftMargin = 30; int pg = 1; int top = 40; TotalOS totalos = new TotalOS(); //Tamanho da lin em pixel int nTamLinPixel = 19; // Variaveis de controle para quebra de linha de campos int QtdCaracterLinha = 120; int Tamanho; int QtdLin; int StrInicio; int StrFim; int cl; // Adiciona Página pdfDocument myDoc = new pdfDocument("Horizon", "Orion"); pdfPage myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); string DadosObra = (table.Rows[0]["cmpNoObra"].ToString().Trim() + (table.Rows[0]["cmpNuContrato"] != null ? " -> Contrato nº " + table.Rows[0]["cmpNuContrato"].ToString() : "")); pdfTable myTable = CabRelatorio(myDoc, myPage, top, DadosObra, DataInicial, DataFinal); // Imprimir linhas de detalhes pdfTableRow myRow = myTable.createRow(); foreach (DataRow row in table.Rows) { totalos.Adicionar(row["cmpDcOrigemOS"].ToString()); cl = 0; row["cmpDcObservacoes"] = TiraCaractEspecial(row["cmpDcObservacoes"].ToString()); Tamanho = row["cmpDcObservacoes"].ToString().Length; if (Tamanho > 0) { QtdLin = (Tamanho % QtdCaracterLinha == 0 ? Tamanho / QtdCaracterLinha : (Tamanho / QtdCaracterLinha) + 1); StrInicio = 0; for (int Linha = 1; Linha <= QtdLin; Linha++) { StrFim = Linha == QtdLin ? Tamanho - StrInicio : QtdCaracterLinha; if (Linha == 1) { myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; myRow[cl++].addText(row["cmpDcObservacoes"].ToString().Substring(StrInicio, StrFim).Trim()); myRow[cl++].addText(row["cmpDtConclusaoAtendimento"].ToString()); } else { cl = 0; myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; myRow[cl++].addText(row["cmpDcObservacoes"].ToString().Substring(StrInicio, StrFim).Trim()); myRow[cl++].addText(""); } myTable.addRow(myRow); StrInicio += QtdCaracterLinha; top += nTamLinPixel; } } else { myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; myRow[cl++].addText(row["cmpDcDescricaoSolicitacao"].ToString().TrimEnd()); myRow[cl++].addText(row["cmpDtConclusaoAtendimento"].ToString()); myTable.addRow(myRow); top += nTamLinPixel; } if (top > 980) { myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black); myPage.addTable(myTable); // Adiciona uma página myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); top = 40; myTable = CabRelatorio(myDoc, myPage, top, DadosObra, DataInicial, DataFinal); top = +15; } } if (top < 980) { myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black); myPage.addTable(myTable); // Adiciona uma página myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat); top = 40; myTable = CabRelatorio(myDoc, myPage, top, DadosObra, DataInicial, DataFinal); top = +120; } // Imprimir Resumo dos atendimentos myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2, new pdfTableStyle(myDoc.getFontReference(strFont), 12, pdfColor.Black, new pdfColor("FFFFFF")), new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White)); myTable.coordX = leftMargin; myTable.coordY = getTop(myPage, top); cl = 0; myTable.tableHeader.rowHeight = 30; myTable.tableHeader.addColumn(300, predefinedAlignment.csCenter); myTable.tableHeader[cl++].addText("RESUMO DAS ATIVIDADES REALIZADAS"); myPage.addTable(myTable); top += 30; myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2, new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")), new pdfTableStyle(myDoc.getFontReference(strFont), 8, pdfColor.Black, pdfColor.White)); myTable.coordX = leftMargin; myTable.coordY = getTop(myPage, top); cl = 0; myTable.tableHeader.rowHeight = 12; myTable.tableHeader.addColumn(200, predefinedAlignment.csLeft); myTable.tableHeader[cl++].addText("Tipo de Atendimento"); myTable.tableHeader.addColumn(100, predefinedAlignment.csRight); myTable.tableHeader[cl++].addText("Quantidade"); cl = 0; myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; myRow[cl++].addText("Eventuais"); myRow[cl++].addText(totalos.Eventual.ToString()); myTable.addRow(myRow); cl = 0; myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; myRow[cl++].addText("Interno"); myRow[cl++].addText(totalos.Interno.ToString()); myTable.addRow(myRow); cl = 0; myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; myRow[cl++].addText("Preventiva"); myRow[cl++].addText(totalos.Preventiva.ToString()); myTable.addRow(myRow); cl = 0; myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; myRow[cl++].addText("Externo"); myRow[cl++].addText(totalos.Externa.ToString()); myTable.addRow(myRow); cl = 0; myRow = myTable.createRow(); myRow.rowStyle = myTable.rowStyle; myRow[cl++].addText("Fora de Escopo"); myRow[cl++].addText(totalos.ForaEscopo.ToString()); myTable.addRow(myRow); myPage.addTable(myTable); top += 150; // Imprimir indíce da eficiência da manutenção myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2, new pdfTableStyle(myDoc.getFontReference(strFont), 12, pdfColor.Black, new pdfColor("FFFFFF")), new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White)); myTable.coordX = leftMargin; myTable.coordY = getTop(myPage, top); cl = 0; myTable.tableHeader.rowHeight = 30; myTable.tableHeader.addColumn(200, predefinedAlignment.csCenter); myTable.tableHeader[cl++].addText("EFICIÊNCIA DA MANUTENÇÃO"); myPage.addTable(myTable); top += 30; myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2, new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")), new pdfTableStyle(myDoc.getFontReference(strFont), 8, pdfColor.Black, pdfColor.White)); myTable.coordX = leftMargin; myTable.coordY = getTop(myPage, top); float Soma1 = totalos.Preventiva + totalos.Interno; float Soma2 = totalos.Preventiva + totalos.Interno + totalos.Externa; float IEM = (Soma1 / Soma2) * 100; cl = 0; myTable.tableHeader.rowHeight = 12; myTable.tableHeader.addColumn(200, predefinedAlignment.csLeft); myTable.tableHeader[cl++].addText("Resultado ==> " + string.Format("{0:0.0000}%", IEM)); //string.Format("{0:N2}%", IEM.ToString())); myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black); myPage.addTable(myTable); return(myDoc); }
/// <summary> /// create page and add result to page for each result /// </summary> /// <param name="results"> the results to be added to the document</param> /// <param name="doc"> the document to be edited </param> private void addResults(List <Results> results, pdfDocument doc) { int fontsize = 12; pdfColor black = new pdfColor(predefinedColor.csBlack); pdfColor white = new pdfColor(predefinedColor.csWhite); pdfColor grey = new pdfColor(predefinedColor.csLightGray); foreach (Results result in results) { //create and add page to document pdfPage page = doc.addPage(); //height variable to keep track of where to place next element int height = page.height; //calc new height height -= fontsize + 20; //add result name with x:20 y: height page.addText(result.Name, 20, height, predefinedFont.csHelveticaBold, fontsize); height -= fontsize + 20; string s; if (result.StepsRequired.Count != 0) { s = result.AllRequiredSteps ? "ja" : "nee"; } else { s = "is geen bewijsstuk"; } //add if all requred stepps are taken page.addText("alle benodigede stappen uitgevoerd: " + s, 20, height, predefinedFont.csHelvetica, fontsize); //creating table of required and taken steps pdfTable table = new pdfTable(); //defineing table style table.borderSize = 1; table.borderColor = new pdfColor(predefinedColor.csBlack); table.tableHeaderStyle = new pdfTableRowStyle(predefinedFont.csHelveticaBold, fontsize, black, white); table.rowStyle = new pdfTableRowStyle(predefinedFont.csHelvetica, fontsize, black, white); table.alternateRowStyle = new pdfTableRowStyle(predefinedFont.csHelvetica, fontsize, black, grey); // tableColomns use whole page widht int tableColomnSize = (page.width - 40) / 2; //add colomns to table table.tableHeader.addColumn(new pdfTableColumn("required steps", predefinedAlignment.csCenter, tableColomnSize)); table.tableHeader.addColumn(new pdfTableColumn("steps taken", predefinedAlignment.csCenter, tableColomnSize)); //check which table is larger steps taken or steps required if (result.StepsRequired.Count >= result.StepsTaken.Count) { for (int i = 0; i < result.StepsRequired.Count; i++) { //create new row pdfTableRow row = table.createRow(); //add value to first cell of row row[0].columnValue = result.StepsRequired[i]; try { // try to add value to second cell row[1].columnValue = result.StepsTaken[i]; } catch (System.Exception) { // on a indexOutOfBounds add empty row[1].columnValue = ""; } //add row to table table.addRow(row); } } else { for (int i = 0; i < result.StepsTaken.Count; i++) { //create table row pdfTableRow row = table.createRow(); try { // try to add value to second cell row[0].columnValue = result.StepsRequired[i]; } catch (System.Exception) { // on a indexOutOfBounds add empty row[0].columnValue = ""; } row[1].columnValue = result.StepsTaken[i]; //add table row table.addRow(row); } } //calc new height height -= 20; //add table to page page.addTable(table, 20, height); } }