Example #1
0
        public static void generateReport(SWInfo sw)
        {
            string[,] info = new string[, ] {
                { "Calculation Items", "Your Condition", "Your Points" },
                { "Some NOC codes could get bonus", sw.NOC, sw.NocBonusPoints.ToString() },
                { "Skill level and points", sw.SkillLevel.ToString(), sw.JobLevelPoints.ToString() },
                { "Is your job in Top 100", sw.Intop100?"Yes":"No", sw.Top100Bonus.ToString() },
                { "Current in BC working in same occupation", sw.CurrentWorkInBCPosition?"Yes":"No", sw.CurrentWorkPoints.ToString() },
                { "Annual job wage", sw.Wage.ToString(), sw.WagePoints.ToString() },
                { "Work region", sw.Region, sw.RegionPoints.ToString() },
                { "Direct related work experience", sw.DirectWorkExperience.ToString(), sw.DirectWorkExperiencePoints.ToString() },
                { "One year direct experience in Canada", sw.OneYearDirectExperienceInCanada?"Yes":"No", sw.OneYearDirectExperienceInCanadaPoints.ToString() },
                { "Education Level", sw.Education, sw.EducationPoints.ToString() },
                { "Education bonus", sw.EducationBonus, sw.EducationBonusPoints.ToString() },
                { "CLB Luange level", sw.CLB.ToString(), sw.CLBPoints.ToString() }
            };



            Document doc = new Document(PageSize.LETTER, 72, 72, 72, 72);

            string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            string fn   = path + @"\BCPNP-SW Points-" + sw.Client + DateTime.Now.ToString("yyMMdd") + "-" + String.Format("{0:hh}", DateTime.Now) + String.Format("{0:mm}", DateTime.Now) + String.Format("{0:ss}", DateTime.Now) + ".pdf";

            PdfWriter.GetInstance(doc, new FileStream(fn, FileMode.Create));

            doc.Open();

            // add a img to pdf

            iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(@"Resources\logo.png");

            img.SetAbsolutePosition(toUnit(5f), toUnit(9.75f));
            // set the size to be 2.5 inch x 1.5 inch
            img.ScaleToFit(toUnit(2.5f), toUnit(1.5f));
            doc.Add(img);

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

            PDFItems font = new PDFItems();

            Paragraph Title         = (new Paragraph(18.5f, " BCPNP Skill Worker Scoring Anlaysis", font.fontLevel3)
            {
                SpacingAfter = 15
            });
            Paragraph paraforClient = (new Paragraph(18.5f, "For: " + sw.Client + "   Date: " + DateTime.Today.ToString("MMM-dd,yyyy") + "     Total Points: " + sw.TotalPoints.ToString(), font.fontLevel6)
            {
                SpacingAfter = 10
            });

            Title.Alignment         = Element.ALIGN_CENTER;
            paraforClient.Alignment = Element.ALIGN_CENTER;
            ////para.IndentationRight = 10;
            doc.Add(Title);
            doc.Add(paraforClient);


            PdfPTable table = new PdfPTable(3);

            float[] sglTblHdWidths = new float[3];
            sglTblHdWidths[0] = 300f;
            sglTblHdWidths[1] = 200f;
            sglTblHdWidths[2] = 100f;
            // Set the column widths on table creation. Unlike HTML cells cannot be sized.
            table.SetWidths(sglTblHdWidths);

            table.HorizontalAlignment = Element.ALIGN_MIDDLE;
            // float[] width = new float[3] { toUnit(2.17f),toUnit(2.17f),toUnit(2.17f)};
            table.WidthPercentage = 100;
            table.GetFittingRows(18f, 0);
            PdfPCell cell = new PdfPCell(new Phrase((sw.Client + " Scores in detail\n"), font.fontLevel5));

            cell.Colspan = 3;

            cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
            table.AddCell(cell);


            for (int i = 0; i < info.Length / 3; i++)
            {
                table.AddCell(info[i, 0]);
                table.AddCell(info[i, 1]);
                table.AddCell(info[i, 2]);
            }

            doc.Add(table);


            Chunk thanks = new Chunk("\nThanks for your enquiry.\nIf you have further requirement for how to upgrade your scores, please make an appointment with our ICCRC licensed Immigration Consultant.\n\n");

            //  sign.Leading = 36;
            doc.Add(thanks);
            //RCICSigning(doc);
            //table.SpacingAfter = 0;
            //Chunk sign = new Chunk("Jacky Zhang\nRCIC: R511623\n");
            //doc.Add(sign);

            //float curY = writer.GetVerticalPosition(false);
            //float x = doc.Left + sign.GetWidthPoint();
            //MessageBox.Show(x.ToString());

            Chunk contact1 = new Chunk("\n\n\nContact Information\nGuangson Headquarter:\n#1017 4500 Kingsway, Burnaby V5H 2A9\nEmail:[email protected]\tTel:+ 1 604 - 282 - 1536");

            //contact1.Font = fontBody;
            doc.Add(contact1);



            Chunk contact2 = new Chunk("\nGuangson Immigration:\n#2319 4500 Kingsway, Burnaby V5H 2A9\nEmail:[email protected]\t+ 1 604-558-1536");

            //contact2.Font = cxfontLevel1;
            doc.Add(contact2);
            //BaseFont.AddToResourceSearch("iTextAsian.dll");
            BaseFont bfChinese = BaseFont.CreateFont(
                "MHei-Medium",
                "UniCNS-UCS2-H", // 橫式中文
                BaseFont.NOT_EMBEDDED
                );
            Font fontChinese = new Font(bfChinese, 8);

            doc.Add(new Paragraph(
                        @"聰明難,糊塗難,
                由聰明而轉入糊塗更難,
                放一著,退一步,當下心安,非圖後來福報也。",
                        fontChinese
                        ));
            doc.Add(new Paragraph(
                        @"1991年9月—1996年6月:
                哈尔滨市马家沟小学
                1996年9月—2000年6月:
                哈尔滨市萧红中学
                2000年9月—2003年6月:
                哈尔滨市第十三中学
                2003年9月—2005年5月:
                加拿大多伦多Seneca学院(ESL)
                2006年9月—2010年6月:
                哈尔滨师范大学运动训练专业",
                        fontChinese
                        ));


            doc.Close();

            // Open the new created pdf
            System.Diagnostics.Process.Start(fn);
        }
        private void btnReport_Click(object sender, EventArgs e)
        {
            SWInfo sw = new SWInfo();

            if (txtClient.Text != "")
            {
                sw.Client = txtClient.Text;
            }
            else
            {
                MessageBox.Show("Please enter your client's name");
                return;
            }
            sw.NOC = txtNocBonus.Text;
            if (lblTotalPoints.Text != "0")
            {
                sw.TotalPoints = int.Parse(lblTotalPoints.Text);
            }
            else
            {
                MessageBox.Show("You didn't even do anything. Why so hurry to generate report?!");
                return;
            }
            if (int.Parse(inTop100Score.Text) != 0)
            {
                sw.Intop100 = true;
            }
            else
            {
                sw.Intop100 = false;
            }

            sw.SkillLevel = char.Parse(lblJobLevel.Text);
            if (cbxCurrentWork.Checked)
            {
                sw.CurrentWorkInBCPosition = true;
            }
            else
            {
                sw.CurrentWorkInBCPosition = false;
            }

            if (txtWage.Text != "")
            {
                sw.Wage       = float.Parse(txtWage.Text);
                sw.WagePoints = int.Parse(lblWagePoints.Text);
            }
            else
            {
                MessageBox.Show("Pleae input annual wage");
                return;
            }

            if (cmbRegion.SelectedIndex > -1)
            {
                sw.Region = swp.region[cmbRegion.SelectedIndex, 0];
            }
            else
            {
                MessageBox.Show("Pleae select the work region");
                return;
            }

            if (txtDirectWorkExp.Text != "")
            {
                sw.DirectWorkExperience = float.Parse(txtDirectWorkExp.Text);
            }
            else
            {
                MessageBox.Show("Pleae input direct work experience");
                return;
            }

            if (cbxCanadianExp.Checked)
            {
                sw.OneYearDirectExperienceInCanada = true;
            }
            else
            {
                sw.OneYearDirectExperienceInCanada = false;
            }

            if (cmbEducaton.SelectedIndex > -1)
            {
                sw.Education = swp.education[cmbEducaton.SelectedIndex, 0];
            }
            else
            {
                MessageBox.Show("Pleae select education level");
                return;
            }

            if (cklEduBonus.SelectedIndex > -1)
            {
                foreach (object itemChecked in cklEduBonus.CheckedItems)
                {
                    DataRowView castedItem = itemChecked as DataRowView;
                    int         index      = cklEduBonus.Items.IndexOf(itemChecked);
                    sw.EducationBonus = sw.EducationBonus + swp.eduBonus[index, 0] + "\n";
                }
                sw.EducationBonusPoints = int.Parse(lblEduBonusPoints.Text);
            }
            else
            {
                MessageBox.Show("Pleae select education bonus");
                return;
            }
            if (txtCLBLevel.Text != "")
            {
                sw.CLB = int.Parse(txtCLBLevel.Text);
            }
            else
            {
                MessageBox.Show("Pleae input CLB level");
                return;
            }


            sw.NocBonusPoints                        = int.Parse(lblNOCBonusPoints.Text);
            sw.JobLevelPoints                        = int.Parse(lblJobLevelPoints.Text);
            sw.Top100Bonus                           = int.Parse(inTop100Score.Text);
            sw.CurrentWorkPoints                     = int.Parse(lblCurrentWorkPoints.Text);
            sw.WagePoints                            = int.Parse(lblWagePoints.Text);
            sw.RegionPoints                          = int.Parse(lblRegionalPoints.Text);
            sw.DirectWorkExperiencePoints            = int.Parse(lblDirectWorkExpPoints.Text);
            sw.OneYearDirectExperienceInCanadaPoints = int.Parse(lblCanadianExpPoints.Text);
            sw.EducationPoints                       = int.Parse(lblEducationPoints.Text);
            sw.EducationBonusPoints                  = int.Parse(lblEduBonusPoints.Text);
            sw.CLBPoints = int.Parse(lblCLBpoints.Text);

            //txtWHWeekly.Text;
            //txtHRate.Text;
            //txtMRate.Text;
            //txtYrate.Text;

            //cmbTestType.Text;
            //txtListening.Text;
            //txtReading.Text;
            //txtWriting.Text;
            //txtSpeaking.Text;


            Report.generateReport(sw);
        }