示例#1
0
        public static AppointmentType GetAppointmentType(int id)
        {
            AppointmentType appointmentType = new AppointmentType();

            var elements = ConsularAppointmentTypes.List;
            var list     = from ele in elements
                           where ele.Code == id
                           select ele;

            if (list.Count() > 0)
            {
                appointmentType = list.First();
            }

            return(appointmentType);
        }
示例#2
0
        private static void FillFormFields(PdfStamper pdfStamper, ConsularApptVM consularAppt)
        {
            AcroFields pdfFormFields = pdfStamper.AcroFields;

            pdfFormFields.SetField("Name", consularAppt.Name);
            pdfFormFields.SetField("PassportNumber", consularAppt.PassportNumber);
            pdfFormFields.SetField("AppointmentDate", String.Format("{0:dd MMM, yyyy [dddd]}", consularAppt.AppointmentDate));
            pdfFormFields.SetField("QueueNumber", consularAppt.QueueNumber.ToString());
            AppointmentType appointmentType = ConsularAppointmentTypes.GetAppointmentType(consularAppt.AppointmentType);

            pdfFormFields.SetField("ServiceType", appointmentType.Description);
            pdfFormFields.SetField("Name2", consularAppt.Name);
            pdfFormFields.SetField("PassportNumber2", consularAppt.PassportNumber);
            pdfFormFields.SetField("PhoneNumber", consularAppt.ContactPhone);
            pdfFormFields.SetField("Email", consularAppt.ContactEmail);
            iTextSharp.text.Image txtImage = null;
            using (var memStream = Graphics.GenerateQrCodeStream(GetQrCodeString(consularAppt)))
            {
                memStream.Position = 0;
                txtImage           = iTextSharp.text.Image.GetInstance(memStream);
            }

            var   fp     = pdfFormFields.GetFieldPositions("QRCode");
            float right  = fp[0].position.Right;
            float left   = fp[0].position.Left;
            float top    = fp[0].position.Top;
            float bottom = fp[0].position.Bottom;

            txtImage.ScaleToFit(115, 115);
            txtImage.SetAbsolutePosition(left, bottom);

            int            pageNum     = 1;
            PdfContentByte contentByte = pdfStamper.GetOverContent(pageNum);

            contentByte.AddImage(txtImage);

            pdfStamper.FormFlattening = false;
        }