Пример #1
0
        /// <summary>
        /// Returns true if IdentityCard instances are equal
        /// </summary>
        /// <param name="other">Instance of IdentityCard to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(IdentityCard other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     TypeIdentityDocument == other.TypeIdentityDocument ||
                     TypeIdentityDocument != null &&
                     TypeIdentityDocument.Equals(other.TypeIdentityDocument)
                     ) &&
                 (
                     DateOfIssue == other.DateOfIssue ||
                     DateOfIssue != null &&
                     DateOfIssue.Equals(other.DateOfIssue)
                 ) &&
                 (
                     SerialIdentityCard == other.SerialIdentityCard ||
                     SerialIdentityCard != null &&
                     SerialIdentityCard.Equals(other.SerialIdentityCard)
                 ) &&
                 (
                     NumberIedentityCard == other.NumberIedentityCard ||
                     NumberIedentityCard != null &&
                     NumberIedentityCard.Equals(other.NumberIedentityCard)
                 ));
        }
Пример #2
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (TypeIdentityDocument != null)
         {
             hashCode = hashCode * 59 + TypeIdentityDocument.GetHashCode();
         }
         if (DateOfIssue != null)
         {
             hashCode = hashCode * 59 + DateOfIssue.GetHashCode();
         }
         if (SerialIdentityCard != null)
         {
             hashCode = hashCode * 59 + SerialIdentityCard.GetHashCode();
         }
         if (NumberIedentityCard != null)
         {
             hashCode = hashCode * 59 + NumberIedentityCard.GetHashCode();
         }
         return(hashCode);
     }
 }
        public override int GetHashCode()
        {
            int hash = 17;

            hash ^= 31 + SerialNumber.ToInt();
            hash ^= 31 + DateOfIssue.ToShortDateString().ToInt();
            return(hash ^ 31 + ExpiryDate.ToShortDateString().ToInt());
        }
 public void PrintIdentificationInfo()
 {
     Console.WriteLine("Passport series and number: " + PassportSeries + PassportNumber);
     Console.WriteLine("Identification number: " + IdentificatioNumber);
     Console.WriteLine("Date of issue: " + DateOfIssue.ToString("d"));
     Console.WriteLine("Date of expiration: " + DateOfExpiration.ToString("d"));
     Console.WriteLine("Place of birth: " + PlaceOfBirth);
     Console.WriteLine("Issuing by: " + IssuingBy);
     PrintMainPersonalData();
 }
Пример #5
0
 public void IdentifyDriverLicense()
 {
     Console.WriteLine("Full name: " + FullName);
     Console.WriteLine("Date of birth: " + DateOfBirth.ToString("d"));
     Console.WriteLine("Place of birth: " + PlaceOfBirth);
     Console.WriteLine("Date of issue: " + DateOfIssue.ToString("d"));
     Console.WriteLine("Date of expiration: " + DateOfExpiration.ToString("d"));
     Console.WriteLine("Issuing by: " + IssuingBy);
     Console.WriteLine("Serial number: " + SerialNumber);
     Console.WriteLine("Category: " + Category);
 }
Пример #6
0
 DateTime getPaymentDueTerm()
 {
     try
     {
         return(DateOfIssue.AddDays(PaymentMethod.DueTerm));
     }
     catch (Exception)
     {
         return(DateOfIssue);
     }
 }
Пример #7
0
        public override List <string> Validate()
        {
            var errors = new List <string>();

            if (string.IsNullOrEmpty(Authority))
            {
                errors.Add($"Passport authority must be specified");
            }
            if (DateOfIssue.AddYears(10) < DateTime.Now)
            {
                errors.Add($"Passport with date of issue {DateOfIssue.Date} has expired already");
            }

            if (string.IsNullOrEmpty(Series))
            {
                errors.Add($"Passport series must be specified");
            }
            else if (!Regex.IsMatch(Series, RegexConstants.PassportSeries))
            {
                errors.Add($"Passport series {Series} is invalid");
            }

            if (string.IsNullOrEmpty(Number))
            {
                errors.Add($"Passport number must be specified");
            }
            else if (!Regex.IsMatch(Number, RegexConstants.PassportNumber))
            {
                errors.Add($"Passport number {Number} is invalid");
            }

            if (string.IsNullOrEmpty(IdentificationNumber))
            {
                errors.Add($"Passport identificetion number must be specified");
            }
            else if (!Regex.IsMatch(IdentificationNumber, RegexConstants.PassportIdentificationNumber))
            {
                errors.Add($"Passport identificetion number {IdentificationNumber} is invalid");
            }

            return(errors);
        }
Пример #8
0
        void FillFrontSideTextByDrawText(Graphics gr)
        {
            var textMargin = GraphicsHelper.DefaultMainTextMargin + 26;

            GraphicsHelper.DrawMainText(gr, "1.", 146);
            GraphicsHelper.DrawText(gr, RegNumber.ToUpper(), textMargin, 146);
            GraphicsHelper.DrawMainText(gr, "2.", 183);
            GraphicsHelper.DrawText(gr, Model.ToUpper(), textMargin, 183);
            GraphicsHelper.DrawMainText(gr, "3.", 220);
            GraphicsHelper.DrawText(gr, Color.ToUpper(), textMargin, 220);
            GraphicsHelper.DrawMainText(gr, "4.", 257);
            GraphicsHelper.DrawText(gr, Owner.ToUpper(), textMargin, 257, GraphicsHelper.DefaultTextBlockWidth, 65);
            GraphicsHelper.DrawMainText(gr, "5.", 330);
            GraphicsHelper.DrawText(gr, Address, textMargin, 330, GraphicsHelper.DefaultTextBlockWidth, 85);
            GraphicsHelper.DrawMainText(gr, "6.", 425);
            var dt = DateOfIssue.ToShortDateString();

            GraphicsHelper.DrawText(gr, dt.ToUpper(), textMargin, 425);
            GraphicsHelper.DrawMainText(gr, "7.", 466);
            GraphicsHelper.DrawText(gr, PlaceOfIssue.ToUpper(), textMargin, 466);
            GraphicsHelper.DrawMainText(gr, "8.", 510);
            GraphicsHelper.DrawText(gr, PersonalNumber.ToUpper(), textMargin, 510);
        }
Пример #9
0
        public void generate()
        {
            string    path = "invoiceTemplate.xml";
            XDocument doc  = XDocument.Load(path);
            XElement  root = doc.Element("Template");

            string header = root.Element("Header").Value;

            header = string.Format(header, Company.Name, Company.FullAddress, Company.NIP, Company.REGON, Company.Phone, Company.Email, Company.Website, Company.BankName, Company.BankAccount);

            string cityOfIssue    = root.Element("DatePlace").Value;
            string dateOfIssue    = DateOfIssue.ToShortDateString();
            string dateOfDelivery = DateOfDelivery.ToShortDateString();

            cityOfIssue = string.Format(cityOfIssue, dateOfIssue, IssuePlace, dateOfDelivery);

            string title = root.Element("Title").Value;

            title = string.Format(title, Number);

            string sellerBuyer = root.Element("SellerBuyer").Value;

            sellerBuyer = string.Format(sellerBuyer, Company.FullName, Company.FullAddress, Company.NIP, Contractor.FullName, Contractor.FullAddress, Contractor.NIP);

            header += cityOfIssue += title += sellerBuyer;

            string invoiceItemsTable   = root.Element("InvoiceItemsTableHeader").Value;
            string invoiceItemsSummary = root.Element("InvoiceItemTableSummary").Value;
            string invoiceItem         = root.Element("InvoiceItem").Value;

            int i = 1;

            foreach (InvoiceItem item in InvoiceItems)
            {
                string newItem = string.Format(invoiceItem, i, item.Item.Name, item.Item.UnitOfMeasure, item.Quantity, item.Item.UnitPrice.ToString("0.00"), item.ValueNetto.ToString("0.00"), item.Item.VatRate.ToString("0.00"), item.VATValue.ToString("0.00"), item.ValueBrutto.ToString("0.00"));
                Console.WriteLine(newItem);
                invoiceItemsTable += newItem;
                i++;
            }
            invoiceItemsSummary = string.Format(invoiceItemsSummary, TotalValueNetto.ToString("0.00"), TotalVATValue.ToString("0.00"), TotalValueBrutto.ToString("0.00"));
            invoiceItemsTable  += invoiceItemsSummary;

            string taxTableHeader  = root.Element("TaxTableHeader").Value;
            string tax             = root.Element("Tax").Value;
            string taxTableSummary = root.Element("TaxTableSummary").Value;
            string taxTable        = taxTableHeader + tax + taxTableSummary;

            string priceSummary = root.Element("PriceSummary").Value;

            priceSummary = string.Format(priceSummary, TotalValueBrutto.ToString("0.00"), "słownie złotych", "groszy");
            string paymentMethod = root.Element("PaymentMethod").Value;

            paymentMethod = string.Format(paymentMethod, PaymentMethod.Name, DateOfIssue.AddDays(PaymentMethod.DueDate).ToShortDateString());
            string issuer = root.Element("Issuer").Value;

            issuer = string.Format(issuer, Company.IssuerName);
            string footer = paymentMethod + issuer;


            string output = header + invoiceItemsTable + taxTable + priceSummary + footer;

            output = output.Replace("~^~^", "{{");
            output = output.Replace("^~^~", "}}");
            output = output.Replace("~^", "{");
            output = output.Replace("^~", "}");
            File.WriteAllText("out.tex", output);

            Process process = new Process();

            process.StartInfo.FileName  = "pdflatex";
            process.StartInfo.Arguments = "out.tex";
            process.Start();
            //process.Dispose();
        }
Пример #10
0
 public override string ToString()
 {
     return(String.Format("Номер замовлення: {0}\tБібліотекар: {1} {2}\tСписок книг: {3}\tЧитач: {4} {5}\tДата видачі: {6}\tДата здачі: {7}\n\n"
                          , NumberOfOrder, Librarian.Person.FirstName, Librarian.Person.LastName, BookList.NumberOfBooks, Reader.Person.FirstName, Reader.Person.LastName, DateOfIssue.ToShortDateString(), DateOfAdmission.ToShortDateString()));
 }
Пример #11
0
        void drawPrescriptionTemplate(Graphics g)
        {
            g.PageUnit = GraphicsUnit.Millimeter;
            float lineSize  = 0.2f;
            Pen   p         = new Pen(Color.Black, lineSize);
            Pen   penDotted = new Pen(Color.Black, lineSize);

            penDotted.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;

            int       pageWidth    = 99;
            int       pageHeight   = 200;
            Point     rectLocation = new Point(0, 0);
            Size      rectSize     = new Size(pageWidth, pageHeight);
            Rectangle rectangle    = new Rectangle(rectLocation, rectSize);

            g.DrawRectangle(p, rectangle);
            g.FillRectangle(Brushes.White, rectangle);

            Point hLine00 = new Point(0, 35);
            Point hLine01 = new Point(99, 35);
            Point hLine10 = new Point(0, 74);
            Point hLine11 = new Point(99, 74);
            Point hLine20 = new Point(0, 160);
            Point hLine21 = new Point(99, 160);

            g.DrawLine(p, hLine00, hLine01);
            g.DrawLine(p, hLine10, hLine11);
            g.DrawLine(p, hLine20, hLine21);

            Point hLine30 = new Point(69, 48);
            Point hLine31 = new Point(99, 48);

            g.DrawLine(p, hLine30, hLine31);
            Point hLine110 = new Point(69, 61);
            Point hLine111 = new Point(99, 61);

            g.DrawLine(p, hLine110, hLine111);

            Point vLine00 = new Point(69, 35);
            Point vLine01 = new Point(69, 74);

            g.DrawLine(p, vLine00, vLine01);

            Point vLine10 = new Point(69, 74);
            Point vLine11 = new Point(69, 148);

            g.DrawLine(penDotted, vLine10, vLine11);

            Point hLine60 = new Point(0, 79);
            Point hLine61 = new Point(99, 79);

            g.DrawLine(penDotted, hLine60, hLine61);

            Point hLine70 = new Point(0, 93);
            Point hLine71 = new Point(99, 93);

            g.DrawLine(penDotted, hLine70, hLine71);
            Point hLine80 = new Point(0, 107);
            Point hLine81 = new Point(99, 107);

            g.DrawLine(penDotted, hLine80, hLine81);
            Point hLine90 = new Point(0, 121);
            Point hLine91 = new Point(99, 121);

            g.DrawLine(penDotted, hLine90, hLine91);
            Point hLine100 = new Point(0, 135);
            Point hLine101 = new Point(99, 135);

            g.DrawLine(penDotted, hLine100, hLine101);

            Point hLine50 = new Point(0, 148);
            Point hLine51 = new Point(99, 148);

            g.DrawLine(penDotted, hLine50, hLine51);

            Point vLine20 = new Point(35, 160);
            Point vLine21 = new Point(35, 200);

            g.DrawLine(p, vLine20, vLine21);

            Point hLine40 = new Point(0, 180);
            Point hLine41 = new Point(35, 180);

            g.DrawLine(p, hLine40, hLine41);

            int marginLeft = 3;
            int marginTop  = 3;

            Font  fontDefault = new Font("Arial", 10);
            Font  fontSmall   = new Font("Arial", 8);
            Brush brush       = Brushes.Black;

            Point ptPrescriptonStr        = new Point(marginLeft, marginTop);
            Point ptPrescriptionNumberVal = new Point(marginLeft + 30, marginTop);
            Point ptSwiadczeniodawcaVal   = new Point(marginLeft, marginTop + 5);
            Point ptSwiadczeniodawcaStr   = new Point(marginLeft, 30);
            Point ptPacjentStr            = new Point(marginLeft, 35);
            Point ptPacjentFullNameVal    = new Point(marginLeft, 40);
            Point ptPatientFullAddressVal = new Point(marginLeft, 45);
            Point ptWiek                   = new Point(marginLeft, 60);
            Point ptPeselStr               = new Point(marginLeft, 69);
            Point ptPeselVal               = new Point(marginLeft + 20, 69);
            Point ptNfzStr                 = new Point(70, 35);
            Point ptNfzVal                 = new Point(75, 40);
            Point ptUprawnieniaStr         = new Point(70, hLine30.Y);
            Point ptUprawnieniaVal         = new Point(75, hLine30.Y + 5);
            Point ptChorobyPrzewlekle      = new Point(70, hLine110.Y);
            Point ptRpStr                  = new Point(marginLeft, 75);
            Point ptRefundacjaStr          = new Point(70, 75);
            Point ptPosition0              = new Point(marginLeft, hLine70.Y - 12);
            Point ptPosition1              = new Point(marginLeft, hLine80.Y - 12);
            Point ptPosition2              = new Point(marginLeft, hLine90.Y - 12);
            Point ptPosition3              = new Point(marginLeft, hLine100.Y - 12);
            Point ptPosition4              = new Point(marginLeft, hLine50.Y - 12);
            Point ptPrescriptionNumberVal2 = new Point(27, 155);
            Point ptDaneLekarzaStr         = new Point(40, 160);
            Point ptDaneLekarzaVal         = new Point(40, 165);
            Point ptDaneLekarzaNrPrawaVal  = new Point(40, 170);
            Point ptDataWystawieniaStr     = new Point(marginLeft, 160);
            Point ptDataWystawieniaVal     = new Point(marginLeft, 165);
            Point ptDataRealizacjiStr      = new Point(marginLeft, 180);
            Point ptWydrukWlasnyStr        = new Point(70, 195);

            g.DrawString("Recepta", fontDefault, brush, ptPrescriptonStr);
            g.DrawString(PrescriptionNumber.Number, fontDefault, brush, ptPrescriptionNumberVal);
            g.DrawString(Gabinet.Nazwa + "\n" + "REGON " + Gabinet.REGON, fontDefault, brush, ptSwiadczeniodawcaVal);
            g.DrawString("Świadczeniodawca", fontDefault, brush, ptSwiadczeniodawcaStr);
            g.DrawString("Pacjent", fontDefault, brush, ptPacjentStr);
            g.DrawString(Patient.FullName, fontDefault, brush, ptPacjentFullNameVal);
            g.DrawString(Patient.FullAddress, fontDefault, brush, ptPatientFullAddressVal);
            g.DrawString("R.p.", fontDefault, brush, ptRpStr);
            g.DrawString("Refundacja", fontDefault, brush, ptRefundacjaStr);
            g.DrawString("Wiek: " + Patient.Age, fontDefault, brush, ptWiek);
            g.DrawString("PESEL", fontDefault, brush, ptPeselStr);
            g.DrawString(Patient.PESEL, fontDefault, brush, ptPeselVal);
            g.DrawString("Oddział NFZ", fontDefault, brush, ptNfzStr);
            g.DrawString(Patient.Kod, fontDefault, brush, ptNfzVal);
            g.DrawString("Uprawnienia", fontDefault, brush, ptUprawnieniaStr);
            g.DrawString(Patient.Uprawnienie, fontDefault, brush, ptUprawnieniaVal);
            g.DrawString("Ch. przewlekłe", fontDefault, brush, ptChorobyPrzewlekle);
            g.DrawString(PrescriptionNumber.Number, fontDefault, brush, ptPrescriptionNumberVal2);
            g.DrawString("Dane i podpis lekarza", fontDefault, brush, ptDaneLekarzaStr);
            g.DrawString(Doctor.FullName, fontDefault, brush, ptDaneLekarzaVal);
            g.DrawString("Nr prawa: " + Doctor.RightToPracticeNumber, fontDefault, brush, ptDaneLekarzaNrPrawaVal);
            g.DrawString("Data wystawienia", fontSmall, brush, ptDataWystawieniaStr);
            g.DrawString(DateOfIssue.ToShortDateString(), fontDefault, brush, ptDataWystawieniaVal);
            g.DrawString("Data realizacji 'od dnia'", fontSmall, brush, ptDataRealizacjiStr);
            g.DrawString("Wydruk własny", fontSmall, brush, ptWydrukWlasnyStr);

            Point[] items = new Point[5];
            items[0] = ptPosition0;
            items[1] = ptPosition1;
            items[2] = ptPosition2;
            items[3] = ptPosition3;
            items[4] = ptPosition4;

            int i = 0;

            foreach (Lek lek in Leki)
            {
                if (Leki[i] != null)
                {
                    g.DrawString(Leki[i].FullInfo, fontDefault, brush, items[i]);
                }
                i++;
            }

            Point ptBarcodeREGON  = new Point(65, 28);
            Image imgREGONBarcode = drawBarcode(Gabinet.REGON);

            g.DrawImage(imgREGONBarcode, ptBarcodeREGON);
            Point ptBarcodePrescriptionNumber  = new Point(27, 150);
            Image imgPrescriptionNumberBarcode = drawBarcode(PrescriptionNumber.Number);

            g.DrawImage(imgPrescriptionNumberBarcode, ptBarcodePrescriptionNumber);
            Point ptBarcodeRightToPractice  = new Point(45, 175);
            Image imgRightToPracticeBarcode = drawBarcode(Doctor.RightToPracticeNumber);

            g.DrawImage(imgRightToPracticeBarcode, ptBarcodeRightToPractice);
        }
Пример #12
0
 public override string ToString()
 {
     return(string.Join("\n\t", "Passport data:", string.Join(string.Empty, "Passport number: ", PassportNumber), PassportIdentification,
                        string.Join(string.Empty, "Date of issue: ", DateOfIssue.ToShortDateString()), string.Join(string.Empty, "Authority: ", Authority),
                        string.Join(string.Empty, "Date of expiry: ", DateOfExpiry.ToShortDateString())));
 }
Пример #13
0
        // typeCode = 0 - generate invoice
        // typeCode = 1 - generate invoice duplicate eith current date
        public string generate(int typeCode)
        {
            string    path = "templates/invoice.xml";
            XDocument doc  = XDocument.Load(path);
            XElement  root = doc.Element("Template");

            string dateTimeFormat = "yyyy-MM-dd";

            string header = root.Element("Header").Value;

            header = string.Format(header, Company.Name, Company.FullAddress, Company.Phone, Company.Email, Company.Website, Company.BankName, Company.BankAccountNumber);

            string title       = root.Element("Title").Value;
            string dateOfIssue = DateOfIssue.ToString(dateTimeFormat);

            if (typeCode == 1)
            {
                string duplicateTitle = " - DUPLIKAT";
                Number      = Number + duplicateTitle;
                dateOfIssue = DateTime.Now.ToString(dateTimeFormat);
            }

            title = string.Format(title, Number);

            string cityOfIssue    = root.Element("DatePlace").Value;
            string dateOfDelivery = DateOfDelivery.ToString(dateTimeFormat);

            cityOfIssue = string.Format(cityOfIssue, dateOfIssue, Company.InvoiceIssueCity, dateOfDelivery);



            string sellerBuyer = root.Element("SellerBuyer").Value;

            sellerBuyer = string.Format(sellerBuyer, Company.FullName, Company.FullAddress, Company.NIP, Contractor.FullName, Contractor.FullAddress, Contractor.NIP);

            header += cityOfIssue += title += sellerBuyer;

            string invoiceItemsTable   = root.Element("InvoiceItemsTableHeader").Value;
            string invoiceItemsSummary = root.Element("InvoiceItemTableSummary").Value;
            string invoiceItem         = root.Element("InvoiceItem").Value;

            int i = 1;

            foreach (InvoiceItem item in InvoiceItems)
            {
                string newItem = string.Format(invoiceItem, i, item.Name, item.UnitOfMeasureShortName, item.Quantity, item.Price.ToString("0.00"), item.TotalPrice.ToString("0.00"), item.VATValue.ToString("0.00"), item.TotalVATValue.ToString("0.00"), item.TotalPriceBrutto.ToString("0.00"));
                invoiceItemsTable += newItem;
                i++;
            }
            invoiceItemsSummary = string.Format(invoiceItemsSummary, TotalValue.ToString("0.00"), TotalVATValue.ToString("0.00"), TotalValueInclVat.ToString("0.00"));
            invoiceItemsTable  += invoiceItemsSummary;

            string taxTableHeader = root.Element("TaxTableHeader").Value;
            string tax            = root.Element("Tax").Value;

            tax = string.Format(tax, "23", TotalValue.ToString("0.00"), TotalVATValue.ToString("0.00"), TotalValueInclVat.ToString("0.00"));
            string taxTableSummary = root.Element("TaxTableSummary").Value;

            taxTableSummary = string.Format(taxTableSummary, TotalValue.ToString("0.00"), TotalVATValue.ToString("0.00"), TotalValueInclVat.ToString("0.00"));
            string taxTable = taxTableHeader + tax + taxTableSummary;

            string priceSummary = root.Element("PriceSummary").Value;

            priceSummary = string.Format(priceSummary, TotalValueInclVat.ToString("0.00"), getValueInWords(TotalValueInclVat));
            string paymentMethod = root.Element("PaymentMethod").Value;

            paymentMethod = string.Format(paymentMethod, PaymentMethod.Name, DateOfIssue.AddDays(PaymentMethod.DueTerm).ToString(dateTimeFormat));
            string issuer = root.Element("Issuer").Value;

            issuer = string.Format(issuer, Company.InvoiceIssuerName);
            string footer = paymentMethod + issuer;


            //string output = header + invoiceItemsTable + priceSummary + footer;
            string output = header + invoiceItemsTable + taxTable + priceSummary + footer;

            output = output.Replace("~^~^", "{{");
            output = output.Replace("^~^~", "}}");
            output = output.Replace("~^", "{");
            output = output.Replace("^~", "}");


            string time = DateTime.Now.ToFileTime().ToString();

            string outputFile = Tools.getHash(sellerBuyer + time);

            File.WriteAllText("tmp/" + outputFile + ".tex", output);

            Process process = new Process();

            process.StartInfo.WorkingDirectory = "tmp";
            process.StartInfo.FileName         = "pdflatex";
            process.StartInfo.Arguments        = outputFile + ".tex";
            process.Start();

            // wait to avoid FileNotFoundException
            //Task.Delay(5000);
            process.Dispose();
            return(outputFile + ".pdf");
        }