Sei sulla pagina 1di 14

private void printPdf_IOPM(string directory, string lokacija)

{
string proizvodi = String.Empty;
string vrsta = String.Empty;
string ciljne_grupe = String.Empty;

List<Proizvod> lp = null;
lp = new List<Proizvod>();
lp =
Proizvod_Materijal_Service.getListaProizvodaByMaterialID(materijalForma.C_id);
if (lp != null)
{
foreach (var p in lp)
{
if (!proizvodi.Contains(p.C_zasticeno_ime))
proizvodi += p.C_zasticeno_ime + "; ";
}
}

vrsta =
Proizvod_Materijal_Service.getVrstaProizvodaByMaterijalID(materijalForma.C_id);

List<Inicijalizacija_CiljnaGrupa> lista_I_CG = new


List<Inicijalizacija_CiljnaGrupa>();
lista_I_CG =
Inicijalizacija_CiljnaGrupa_Service.Get_Lista_Inicijalizacija_CiljnaGrupa_By_Inicij
alizacija_ID(materijalForma.C_inicijalizacija_ID.Value);

foreach (Inicijalizacija_CiljnaGrupa icg in lista_I_CG)


{
ciljne_grupe +=
CiljnaGrupa_Service.getCiljnjaGrupaByID(icg.C_ciljna_grupa_ID.Value).C_naziv + ";
";
}

//This is the absolute path to the PDF that we will create


// string outputFile =
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
"Sample.pdf");

//Create a standard .Net FileStream for the file, setting various flags
FileStream fs = new FileStream(lokacija, FileMode.Create,
FileAccess.Write, FileShare.None);

//Create a new PDF document setting the size to A4


Document doc = new Document(PageSize.A4);
doc.AddAuthor(Session.logiraniKorisnik.C_ime + " " +
Session.logiraniKorisnik.C_prezime + ", "
+ Session.logiraniKorisnik.C_zvanje + ", " +
Session.logiraniKorisnik.C_pozicija);
doc.AddCreator("Elvis Kadi�");
doc.AddKeywords("IOPM-System Bosnalijek Nalog");
doc.AddSubject("IOPM-System Bosnalijek Nalog PDF document");
doc.AddTitle(materijalForma.Inicijalizacija.C_pm_code.ToString() + "
IOPM-System Bosnalijek");

//Bind the PDF document to the FileStream using an iTextSharp PdfWriter


PdfWriter w = PdfWriter.GetInstance(doc, fs);
doc.AddHeader("Approval", "Promotional Material Approval Form");

//SET
FONTS/////////////////////////////////////////////////////////////////

BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1250,


BaseFont.NOT_EMBEDDED);
iTextSharp.text.Font f1 = new iTextSharp.text.Font(bf, 14,
iTextSharp.text.Font.NORMAL);
iTextSharp.text.Font f2 = new iTextSharp.text.Font(bf, 10,
iTextSharp.text.Font.NORMAL);

//Open the document for writing


doc.Open();

doc.Add(new Paragraph("IOPM Form - Promotional Material Approval",


f1));

doc.Add(new Paragraph("\n", f2));

//string locimage ="ProjectNamespace.Properties.Resources.Logo.png";


//iTextSharp.text.Image Logo =
iTextSharp.text.Image.GetInstance(locimage);
//Logo.ScalePercent(24f);
//doc.Add(Logo);

//Create a table with two columns


PdfPTable t = new PdfPTable(2);
//actual width of table in points
t.TotalWidth = 512f;
//fix the absolute width of the tableEkremt
t.LockedWidth = true;

//relative col widths in proportions - 1/3 and 2/3


float[] widths = new float[] { 0.8f, 2f };
t.SetWidths(widths);
t.HorizontalAlignment = 0;
//leave a gap before and after the table
t.SpacingBefore = 20f;
t.SpacingAfter = 30f;

//Borders are drawn by the individual cells, not the table itself.
//Tell the default cell that we do not want a border drawn
t.DefaultCell.Border = 0;

//Add four cells. Cells are added starting at the top left of the table
working left to right first, then down
t.AddCell(new Phrase("Promotional Code: ", f2));
t.AddCell(new
Phrase(materijalForma.Inicijalizacija.C_pm_code.ToUpper(), f2));
t.AddCell(new Phrase("Product(s): ", f2));
t.AddCell(new Phrase(proizvodi, f2));
t.AddCell(new Phrase("Type of PM:", f2));
t.AddCell(new Phrase(vrsta, f2));
t.AddCell(new Phrase("Target Group(s)", f2));
t.AddCell(new Phrase(ciljne_grupe, f2));

t.AddCell(new Phrase("Source of PM: ", f2));


switch (materijalForma.Inicijalizacija.C_izvor.Value)
{
case 1: t.AddCell(new Phrase("Developed Locally", f2)); break;
case 2: t.AddCell(new Phrase("Corporate Material", f2)); break;
case 3: t.AddCell(new Phrase("Corporate Material Adoption", f2));
break;
default: t.AddCell(new Phrase("Developed Locally", f2)); break;
}
t.AddCell(new Phrase("Leave piece: ", f2));
if (materijalForma.Inicijalizacija.C_distribuira_se.Value)
t.AddCell(new Phrase("Yes", f2));
else t.AddCell(new Phrase("No", f2));
t.AddCell(new Phrase("Quantity(Peaces): ", f2));
t.AddCell(new
Phrase(materijalForma.Inicijalizacija.C_kolicina.Value.ToString(), f2));
t.AddCell(new Phrase("Date of first use: ", f2));
t.AddCell(new
Phrase(materijalForma.Inicijalizacija.C_datum_prve_upotrebe.Value.ToString(), f2));
t.AddCell(new Phrase("Date of last use: ", f2));
t.AddCell(new
Phrase(materijalForma.Inicijalizacija.C_datum_zadnje_upotrebe.Value.ToString(),
f2));

try
{
if (materijalForma.Inicijalizacija.C_izvor.Value != 2 &&
string.Compare(vrsta,"Presentation")!=0)
{
//LOCAL ////////////////////////////////////////////

PdfPTable tod1 = new PdfPTable(4);


tod1.TotalWidth = 512f;
//fix the absolute width of the table
tod1.LockedWidth = true;

//relative col widths in proportions - 1/3 and 2/3


float[] widthstod1 = new float[] { 0.8f, 1.2f, 0.4f, 0.4f };
tod1.SetWidths(widthstod1);
tod1.HorizontalAlignment = 0;
//leave a gap before and after the table
tod1.SpacingBefore = 20f;
tod1.SpacingAfter = 20f;

tod1.AddCell(new Phrase("LOCAL", f2));


tod1.AddCell(new Phrase("Name: ", f2));
tod1.AddCell(new Phrase("Date", f2));
tod1.AddCell(new Phrase("Digital Signature", f2));

Korisnik k =
Korisnik_Service.getKorisnikById(inicijalizacijaForma.C_inicirao_ID.Value);
tod1.AddCell(new Phrase("Initiator:", f2));
tod1.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod1.AddCell(new
Phrase(inicijalizacijaForma.C_datum_inicijalizacije.Value.ToString(), f2));
tod1.AddCell(new Phrase("-", f2));

k =
Korisnik_Service.getKorisnikById(inicijalizacijaForma.C_odobrio_ID.Value);
tod1.AddCell(new Phrase("Initialization Approved By:", f2));
tod1.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod1.AddCell(new
Phrase(inicijalizacijaForma.C_datum_odobravanja.Value.ToString(), f2));
tod1.AddCell(new Phrase("-", f2));

k =
Korisnik_Service.getKorisnikById(tekstForma.C_tekst_kreirao_ID.Value);
tod1.AddCell(new Phrase("Text Created By:", f2));
tod1.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod1.AddCell(new
Phrase(tekstForma.C_tekst_datum_kreiranja.Value.ToString(), f2));
tod1.AddCell(new Phrase("-", f2));

k =
Korisnik_Service.getKorisnikById(tekstForma.C_tekst_odobrio_ID.Value);
tod1.AddCell(new Phrase("Text Approved By:", f2));
tod1.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod1.AddCell(new
Phrase(tekstForma.C_tekst_datum_odobravanja.Value.ToString(), f2));
tod1.AddCell(new Phrase("-", f2));

k =
Korisnik_Service.getKorisnikById(pripremaForma.C_priprema_kreirao_ID.Value);
tod1.AddCell(new Phrase("Graphic Created By:", f2));
tod1.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod1.AddCell(new
Phrase(pripremaForma.C_priprema_datum_kreiranja.Value.ToString(), f2));
tod1.AddCell(new Phrase("-", f2));

k =
Korisnik_Service.getKorisnikById(pripremaForma.C_priprema_odobrio_ID.Value);
tod1.AddCell(new Phrase("Graphic Approved By:", f2));
tod1.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod1.AddCell(new
Phrase(pripremaForma.C_priprema_datum_odobravanja.Value.ToString(), f2));
tod1.AddCell(new Phrase("-", f2));

k =
Korisnik_Service.getKorisnikById(inicijalizacijaForma.C_odobrio_loklano_ID.Value);
tod1.AddCell(new Phrase("Material Local Approved By:", f2));
tod1.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod1.AddCell(new
Phrase(inicijalizacijaForma.C_datum_odobravanja_lokalno.Value.ToString(), f2));
tod1.AddCell(new Phrase("-", f2));
//CORPORATE ////////////////////////////////////////////

PdfPTable tod2 = new PdfPTable(4);


tod2.TotalWidth = 512f;
//fix the absolute width of the table
tod2.LockedWidth = true;

//relative col widths in proportions - 1/3 and 2/3


float[] widthstod2 = new float[] { 0.8f, 1.2f, 0.4f, 0.4f };
tod2.SetWidths(widthstod2);
tod2.HorizontalAlignment = 0;
//leave a gap before and after the table
tod2.SpacingBefore = 20f;
tod2.SpacingAfter = 20f;

tod2.AddCell(new Phrase("CORPORATE APPROVAL", f2));


tod2.AddCell(new Phrase("Name: ", f2));
tod2.AddCell(new Phrase("Date", f2));
tod2.AddCell(new Phrase("Digital Signature", f2));

k =
Korisnik_Service.getKorisnikById(materijalForma.C_odobrio1_ID.Value);
tod2.AddCell(new Phrase("Corporate Medical Advisor:", f2));
tod2.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod2.AddCell(new
Phrase(materijalForma.C_datum_odobravanja1.Value.ToString(), f2));
tod2.AddCell(new Phrase("-", f2));

k =
Korisnik_Service.getKorisnikById(materijalForma.C_odobrio2_ID.Value);
tod2.AddCell(new Phrase("Corporate Designer:", f2));
tod2.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod2.AddCell(new
Phrase(materijalForma.C_datum_odobravanja2.Value.ToString(), f2));
tod2.AddCell(new Phrase("-", f2));

k =
Korisnik_Service.getKorisnikById(materijalForma.C_odobrio3_ID.Value);
tod2.AddCell(new Phrase("Corporate Product Manager:", f2));
tod2.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod2.AddCell(new
Phrase(materijalForma.C_datum_odobravanja3.Value.ToString(), f2));
tod2.AddCell(new Phrase("-", f2));

//FINAL ////////////////////////////////////////////

PdfPTable tod3 = new PdfPTable(4);


tod3.TotalWidth = 512f;
//fix the absolute width of the table
tod3.LockedWidth = true;

//relative col widths in proportions - 1/3 and 2/3


float[] widthstod3 = new float[] { 0.8f, 1.2f, 0.4f, 0.4f };
tod3.SetWidths(widthstod3);
tod3.HorizontalAlignment = 0;
//leave a gap before and after the table
tod3.SpacingBefore = 20f;
tod3.SpacingAfter = 20f;

tod3.AddCell(new Phrase("FINAL APPROVAL", f2));


tod3.AddCell(new Phrase("Name: ", f2));
tod3.AddCell(new Phrase("Date", f2));
tod3.AddCell(new Phrase("Digital Signature", f2));

k =
Korisnik_Service.getKorisnikById(materijalForma.C_odobrio4_ID.Value);
tod3.AddCell(new Phrase("Corporate Marketing Manager:", f2));
tod3.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod3.AddCell(new
Phrase(materijalForma.C_datum_odobravanja4.Value.ToString(), f2));
tod3.AddCell(new Phrase("-", f2));

k =
Korisnik_Service.getKorisnikById(materijalForma.C_odobrio5_ID.Value);
tod3.AddCell(new Phrase("Corporate Marketing Director:", f2));
tod3.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod3.AddCell(new
Phrase(materijalForma.C_datum_odobravanja5.Value.ToString(), f2));
tod3.AddCell(new Phrase("-", f2));

k =
Korisnik_Service.getKorisnikById(materijalForma.C_odobrio6_ID.Value);
tod3.AddCell(new Phrase("Corporate Sales Director:", f2));
tod3.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod3.AddCell(new
Phrase(materijalForma.C_datum_odobravanja6.Value.ToString(), f2));
tod3.AddCell(new Phrase("-", f2));

//Add the table to our document


doc.Add(t);
doc.Add(tod1);
doc.Add(tod2);
doc.Add(tod3);
//Close our document
doc.Close();

if (File.Exists(lokacija))
System.Diagnostics.Process.Start(@"AcroRd32.exe",
lokacija);
else
MetroMessageBox.Show(this,"Error! Document does not
exsist.", "IOPM.System",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
else if (materijalForma.Inicijalizacija.C_izvor.Value == 2 &&
string.Compare(vrsta, "Presentation") != 0)
{
PdfPTable tod1 = new PdfPTable(4);
tod1.TotalWidth = 512f;
//fix the absolute width of the table
tod1.LockedWidth = true;
//relative col widths in proportions - 1/3 and 2/3
float[] widthstod1 = new float[] { 0.8f, 1.2f, 0.4f, 0.4f };
tod1.SetWidths(widthstod1);
tod1.HorizontalAlignment = 0;
//leave a gap before and after the table
tod1.SpacingBefore = 20f;
tod1.SpacingAfter = 20f;

tod1.AddCell(new Phrase("CORPORATE", f2));


tod1.AddCell(new Phrase("Name: ", f2));
tod1.AddCell(new Phrase("Date", f2));
tod1.AddCell(new Phrase("Digital Signature", f2));

Korisnik k =
Korisnik_Service.getKorisnikById(inicijalizacijaForma.C_inicirao_ID.Value);
tod1.AddCell(new Phrase("Initiator:", f2));
tod1.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod1.AddCell(new
Phrase(inicijalizacijaForma.C_datum_inicijalizacije.Value.ToString(), f2));
tod1.AddCell(new Phrase("-", f2));

k =
Korisnik_Service.getKorisnikById(inicijalizacijaForma.C_odobrio_ID.Value);
tod1.AddCell(new Phrase("Initialization Approved By:", f2));
tod1.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod1.AddCell(new
Phrase(inicijalizacijaForma.C_datum_odobravanja.Value.ToString(), f2));
tod1.AddCell(new Phrase("-", f2));

k =
Korisnik_Service.getKorisnikById(tekstForma.C_tekst_kreirao_ID.Value);
tod1.AddCell(new Phrase("Text Created By:", f2));
tod1.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod1.AddCell(new
Phrase(tekstForma.C_tekst_datum_kreiranja.Value.ToString(), f2));
tod1.AddCell(new Phrase("-", f2));

k =
Korisnik_Service.getKorisnikById(tekstForma.C_tekst_odobrio_ID.Value);
tod1.AddCell(new Phrase("Text Approved By:", f2));
tod1.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod1.AddCell(new
Phrase(tekstForma.C_tekst_datum_odobravanja.Value.ToString(), f2));
tod1.AddCell(new Phrase("-", f2));

k =
Korisnik_Service.getKorisnikById(pripremaForma.C_priprema_kreirao_ID.Value);
tod1.AddCell(new Phrase("Graphic Created By:", f2));
tod1.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod1.AddCell(new
Phrase(pripremaForma.C_priprema_datum_kreiranja.Value.ToString(), f2));
tod1.AddCell(new Phrase("-", f2));

k =
Korisnik_Service.getKorisnikById(pripremaForma.C_priprema_odobrio_ID.Value);
tod1.AddCell(new Phrase("Graphic Approved By:", f2));
tod1.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod1.AddCell(new
Phrase(pripremaForma.C_priprema_datum_odobravanja.Value.ToString(), f2));
tod1.AddCell(new Phrase("-", f2));

//CORPORATE ////////////////////////////////////////////

//FINAL ////////////////////////////////////////////

PdfPTable tod3 = new PdfPTable(4);


tod3.TotalWidth = 512f;
//fix the absolute width of the table
tod3.LockedWidth = true;

//relative col widths in proportions - 1/3 and 2/3


float[] widthstod3 = new float[] { 0.8f, 1.2f, 0.4f, 0.4f };
tod3.SetWidths(widthstod3);
tod3.HorizontalAlignment = 0;
//leave a gap before and after the table
tod3.SpacingBefore = 20f;
tod3.SpacingAfter = 20f;

tod3.AddCell(new Phrase("FINAL APPROVAL", f2));


tod3.AddCell(new Phrase("Name: ", f2));
tod3.AddCell(new Phrase("Date", f2));
tod3.AddCell(new Phrase("Digital Signature", f2));

k =
Korisnik_Service.getKorisnikById(materijalForma.C_odobrio4_ID.Value);
tod3.AddCell(new Phrase("Corporate Marketing Manager:", f2));
tod3.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod3.AddCell(new
Phrase(materijalForma.C_datum_odobravanja4.Value.ToString(), f2));
tod3.AddCell(new Phrase("-", f2));

k =
Korisnik_Service.getKorisnikById(materijalForma.C_odobrio5_ID.Value);
tod3.AddCell(new Phrase("Corporate Marketing Director:", f2));
tod3.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod3.AddCell(new
Phrase(materijalForma.C_datum_odobravanja5.Value.ToString(), f2));
tod3.AddCell(new Phrase("-", f2));

k =
Korisnik_Service.getKorisnikById(materijalForma.C_odobrio6_ID.Value);
tod3.AddCell(new Phrase("Corporate Sales Director:", f2));
tod3.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod3.AddCell(new
Phrase(materijalForma.C_datum_odobravanja6.Value.ToString(), f2));
tod3.AddCell(new Phrase("-", f2));

//Add the table to our document


doc.Add(t);
doc.Add(tod1);
//doc.Add(tod2);
doc.Add(tod3);
//Close our document
doc.Close();

if (File.Exists(lokacija))
System.Diagnostics.Process.Start(@"AcroRd32.exe",
lokacija);
else
MetroMessageBox.Show(this, "Error! Document does not
exsist.", "IOPM.System", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if (materijalForma.Inicijalizacija.C_izvor.Value != 2 &&
string.Compare(vrsta, "Presentation") == 0)
{
//LOCAL ////////////////////////////////////////////

PdfPTable tod1 = new PdfPTable(4);


tod1.TotalWidth = 512f;
//fix the absolute width of the table
tod1.LockedWidth = true;

//relative col widths in proportions - 1/3 and 2/3


float[] widthstod1 = new float[] { 0.8f, 1.2f, 0.4f, 0.4f };
tod1.SetWidths(widthstod1);
tod1.HorizontalAlignment = 0;
//leave a gap before and after the table
tod1.SpacingBefore = 20f;
tod1.SpacingAfter = 20f;

tod1.AddCell(new Phrase("LOCAL", f2));


tod1.AddCell(new Phrase("Name: ", f2));
tod1.AddCell(new Phrase("Date", f2));
tod1.AddCell(new Phrase("Digital Signature", f2));

Korisnik k =
Korisnik_Service.getKorisnikById(inicijalizacijaForma.C_inicirao_ID.Value);
tod1.AddCell(new Phrase("Initiator:", f2));
tod1.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod1.AddCell(new
Phrase(inicijalizacijaForma.C_datum_inicijalizacije.Value.ToString(), f2));
tod1.AddCell(new Phrase("-", f2));

k =
Korisnik_Service.getKorisnikById(inicijalizacijaForma.C_odobrio_ID.Value);
tod1.AddCell(new Phrase("Initialization Approved By:", f2));
tod1.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod1.AddCell(new
Phrase(inicijalizacijaForma.C_datum_odobravanja.Value.ToString(), f2));
tod1.AddCell(new Phrase("-", f2));

k =
Korisnik_Service.getKorisnikById(tekstForma.C_tekst_kreirao_ID.Value);
tod1.AddCell(new Phrase("Text Created By:", f2));
tod1.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod1.AddCell(new
Phrase(tekstForma.C_tekst_datum_kreiranja.Value.ToString(), f2));
tod1.AddCell(new Phrase("-", f2));

k =
Korisnik_Service.getKorisnikById(tekstForma.C_tekst_odobrio_ID.Value);
tod1.AddCell(new Phrase("Text Approved By:", f2));
tod1.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod1.AddCell(new
Phrase(tekstForma.C_tekst_datum_odobravanja.Value.ToString(), f2));
tod1.AddCell(new Phrase("-", f2));

k =
Korisnik_Service.getKorisnikById(inicijalizacijaForma.C_odobrio_loklano_ID.Value);
tod1.AddCell(new Phrase("Material Local Approved By:", f2));
tod1.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod1.AddCell(new
Phrase(inicijalizacijaForma.C_datum_odobravanja_lokalno.Value.ToString(), f2));
tod1.AddCell(new Phrase("-", f2));

//CORPORATE ////////////////////////////////////////////

PdfPTable tod2 = new PdfPTable(4);


tod2.TotalWidth = 512f;
//fix the absolute width of the table
tod2.LockedWidth = true;

//relative col widths in proportions - 1/3 and 2/3


float[] widthstod2 = new float[] { 0.8f, 1.2f, 0.4f, 0.4f };
tod2.SetWidths(widthstod2);
tod2.HorizontalAlignment = 0;
//leave a gap before and after the table
tod2.SpacingBefore = 20f;
tod2.SpacingAfter = 20f;

tod2.AddCell(new Phrase("CORPORATE APPROVAL", f2));


tod2.AddCell(new Phrase("Name: ", f2));
tod2.AddCell(new Phrase("Date", f2));
tod2.AddCell(new Phrase("Digital Signature", f2));

k =
Korisnik_Service.getKorisnikById(materijalForma.C_odobrio1_ID.Value);
tod2.AddCell(new Phrase("Corporate Medical Advisor:", f2));
tod2.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod2.AddCell(new
Phrase(materijalForma.C_datum_odobravanja1.Value.ToString(), f2));
tod2.AddCell(new Phrase("-", f2));

k =
Korisnik_Service.getKorisnikById(materijalForma.C_odobrio2_ID.Value);
tod2.AddCell(new Phrase("Corporate Designer:", f2));
tod2.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod2.AddCell(new
Phrase(materijalForma.C_datum_odobravanja2.Value.ToString(), f2));
tod2.AddCell(new Phrase("-", f2));

k =
Korisnik_Service.getKorisnikById(materijalForma.C_odobrio3_ID.Value);
tod2.AddCell(new Phrase("Corporate Product Manager:", f2));
tod2.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod2.AddCell(new
Phrase(materijalForma.C_datum_odobravanja3.Value.ToString(), f2));
tod2.AddCell(new Phrase("-", f2));

//FINAL ////////////////////////////////////////////

PdfPTable tod3 = new PdfPTable(4);


tod3.TotalWidth = 512f;
//fix the absolute width of the table
tod3.LockedWidth = true;

//relative col widths in proportions - 1/3 and 2/3


float[] widthstod3 = new float[] { 0.8f, 1.2f, 0.4f, 0.4f };
tod3.SetWidths(widthstod3);
tod3.HorizontalAlignment = 0;
//leave a gap before and after the table
tod3.SpacingBefore = 20f;
tod3.SpacingAfter = 20f;

tod3.AddCell(new Phrase("FINAL APPROVAL", f2));


tod3.AddCell(new Phrase("Name: ", f2));
tod3.AddCell(new Phrase("Date", f2));
tod3.AddCell(new Phrase("Digital Signature", f2));

k =
Korisnik_Service.getKorisnikById(materijalForma.C_odobrio4_ID.Value);
tod3.AddCell(new Phrase("Corporate Marketing Manager:", f2));
tod3.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod3.AddCell(new
Phrase(materijalForma.C_datum_odobravanja4.Value.ToString(), f2));
tod3.AddCell(new Phrase("-", f2));

k =
Korisnik_Service.getKorisnikById(materijalForma.C_odobrio5_ID.Value);
tod3.AddCell(new Phrase("Corporate Marketing Director:", f2));
tod3.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod3.AddCell(new
Phrase(materijalForma.C_datum_odobravanja5.Value.ToString(), f2));
tod3.AddCell(new Phrase("-", f2));

k =
Korisnik_Service.getKorisnikById(materijalForma.C_odobrio6_ID.Value);
tod3.AddCell(new Phrase("Corporate Sales Director:", f2));
tod3.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod3.AddCell(new
Phrase(materijalForma.C_datum_odobravanja6.Value.ToString(), f2));
tod3.AddCell(new Phrase("-", f2));
//Add the table to our document
doc.Add(t);
doc.Add(tod1);
doc.Add(tod2);
doc.Add(tod3);
//Close our document
doc.Close();

if (File.Exists(lokacija))
System.Diagnostics.Process.Start(@"AcroRd32.exe",
lokacija);
else
MetroMessageBox.Show(this, "Error! Document does not
exsist.", "IOPM.System", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if (materijalForma.Inicijalizacija.C_izvor.Value == 2 &&
string.Compare(vrsta, "Presentation") == 0)
{
PdfPTable tod1 = new PdfPTable(4);
tod1.TotalWidth = 512f;
//fix the absolute width of the table
tod1.LockedWidth = true;

//relative col widths in proportions - 1/3 and 2/3


float[] widthstod1 = new float[] { 0.8f, 1.2f, 0.4f, 0.4f };
tod1.SetWidths(widthstod1);
tod1.HorizontalAlignment = 0;
//leave a gap before and after the table
tod1.SpacingBefore = 20f;
tod1.SpacingAfter = 20f;

tod1.AddCell(new Phrase("CORPORATE", f2));


tod1.AddCell(new Phrase("Name: ", f2));
tod1.AddCell(new Phrase("Date", f2));
tod1.AddCell(new Phrase("Digital Signature", f2));

Korisnik k =
Korisnik_Service.getKorisnikById(inicijalizacijaForma.C_inicirao_ID.Value);
tod1.AddCell(new Phrase("Initiator:", f2));
tod1.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod1.AddCell(new
Phrase(inicijalizacijaForma.C_datum_inicijalizacije.Value.ToString(), f2));
tod1.AddCell(new Phrase("-", f2));

k =
Korisnik_Service.getKorisnikById(inicijalizacijaForma.C_odobrio_ID.Value);
tod1.AddCell(new Phrase("Initialization Approved By:", f2));
tod1.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod1.AddCell(new
Phrase(inicijalizacijaForma.C_datum_odobravanja.Value.ToString(), f2));
tod1.AddCell(new Phrase("-", f2));

k =
Korisnik_Service.getKorisnikById(tekstForma.C_tekst_kreirao_ID.Value);
tod1.AddCell(new Phrase("Text Created By:", f2));
tod1.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod1.AddCell(new
Phrase(tekstForma.C_tekst_datum_kreiranja.Value.ToString(), f2));
tod1.AddCell(new Phrase("-", f2));

k =
Korisnik_Service.getKorisnikById(tekstForma.C_tekst_odobrio_ID.Value);
tod1.AddCell(new Phrase("Text Approved By:", f2));
tod1.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod1.AddCell(new
Phrase(tekstForma.C_tekst_datum_odobravanja.Value.ToString(), f2));
tod1.AddCell(new Phrase("-", f2));

//CORPORATE ////////////////////////////////////////////

//FINAL ////////////////////////////////////////////

PdfPTable tod3 = new PdfPTable(4);


tod3.TotalWidth = 512f;
//fix the absolute width of the table
tod3.LockedWidth = true;

//relative col widths in proportions - 1/3 and 2/3


float[] widthstod3 = new float[] { 0.8f, 1.2f, 0.4f, 0.4f };
tod3.SetWidths(widthstod3);
tod3.HorizontalAlignment = 0;
//leave a gap before and after the table
tod3.SpacingBefore = 20f;
tod3.SpacingAfter = 20f;

tod3.AddCell(new Phrase("FINAL APPROVAL", f2));


tod3.AddCell(new Phrase("Name: ", f2));
tod3.AddCell(new Phrase("Date", f2));
tod3.AddCell(new Phrase("Digital Signature", f2));

k =
Korisnik_Service.getKorisnikById(materijalForma.C_odobrio4_ID.Value);
tod3.AddCell(new Phrase("Corporate Marketing Manager:", f2));
tod3.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod3.AddCell(new
Phrase(materijalForma.C_datum_odobravanja4.Value.ToString(), f2));
tod3.AddCell(new Phrase("-", f2));

k =
Korisnik_Service.getKorisnikById(materijalForma.C_odobrio5_ID.Value);
tod3.AddCell(new Phrase("Corporate Marketing Director:", f2));
tod3.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod3.AddCell(new
Phrase(materijalForma.C_datum_odobravanja5.Value.ToString(), f2));
tod3.AddCell(new Phrase("-", f2));

k =
Korisnik_Service.getKorisnikById(materijalForma.C_odobrio6_ID.Value);
tod3.AddCell(new Phrase("Corporate Sales Director:", f2));
tod3.AddCell(new Phrase(k.C_ime + " " + k.C_prezime + ",\n" +
k.C_zvanje + ", " + k.C_pozicija, f2));
tod3.AddCell(new
Phrase(materijalForma.C_datum_odobravanja6.Value.ToString(), f2));
tod3.AddCell(new Phrase("-", f2));

//Add the table to our document


doc.Add(t);
doc.Add(tod1);
//doc.Add(tod2);
doc.Add(tod3);
//Close our document
doc.Close();

if (File.Exists(lokacija))
System.Diagnostics.Process.Start(@"AcroRd32.exe",
lokacija);
else
MetroMessageBox.Show(this, "Error! Document does not
exsist.", "IOPM.System", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
MetroMessageBox.Show(this, "Error! Document does not exsist.",
"IOPM.System", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

catch (Exception e)
{
MetroMessageBox.Show(this, e.ToString());
}
}

Potrebbero piacerti anche