コード例 #1
0
        /// <summary>
        ///  Method for showing entry from xml-file
        /// </summary>
        /// <param name="childnode">XmlNode</param>
        /// <returns>Educational card</returns>
        public EducationalCard XMLShowEducationalCard(XmlNode childnode)
        {
            EducationalCard card = new EducationalCard();

            foreach (XmlNode childnode1 in childnode.ChildNodes)
            {
                if (childnode1.Name == "number")
                {
                    card.Number = Convert.ToInt32(childnode1.InnerText);
                }
                if (childnode1.Name == "surname")
                {
                    card.Surname = childnode1.InnerText;
                }
                if (childnode1.Name == "name")
                {
                    card.Name = childnode1.InnerText;
                }
                if (childnode1.Name == "middlename")
                {
                    card.Middlename = childnode1.InnerText;
                }
                if (childnode1.Name == "startYear")
                {
                    card.StartYear = Convert.ToDateTime(childnode1.InnerText);
                }
                if (childnode1.Name == "institutionName")
                {
                    card.InstitutionName = childnode1.InnerText;
                }
            }
            return(card);
        }
コード例 #2
0
ファイル: Menu.cs プロジェクト: hodanovich-irina/Task
        /// <summary>
        /// Data input
        /// </summary>
        /// <returns>Educational card</returns>
        private static EducationalCard CreateEducationalCard()
        {
            int Num = Number;

            Console.WriteLine("Образовательная карта:");
            Console.WriteLine("Введите имя:");
            string Name = Console.ReadLine();

            Console.WriteLine("Введите фамилию:");
            string Surname = Console.ReadLine();

            Console.WriteLine("Введите отчество:");
            string Middlename = Console.ReadLine();

            Console.WriteLine("Введите дату начала обучения:");
            DateTime StartYear = Convert.ToDateTime(Console.ReadLine());

            Console.WriteLine("Введите наименование учереждения образования:");
            string          InstitutionName = Console.ReadLine();
            EducationalCard educationalCard = new EducationalCard(Name, Surname, Num, Middlename, StartYear, InstitutionName);

            cards.Add(educationalCard);
            Console.WriteLine("Ваша карта:\n" + educationalCard.ToString());
            return(educationalCard);
        }
コード例 #3
0
        /// <summary>
        /// Method for adding a new entry in xml-file
        /// </summary>
        /// <param name="card">Educational card</param>
        public void XMLCreateEducationalCard(EducationalCard card)
        {
            XmlDocument xDoc = new XmlDocument();

            xDoc.Load(@"../../XMLFileCardInf.xml");
            XmlElement xRoot    = xDoc.DocumentElement;
            XmlElement userElem = xDoc.CreateElement("educationalCard");
            XmlElement a1       = xDoc.CreateElement("number");
            XmlElement a2       = xDoc.CreateElement("surname");
            XmlElement a3       = xDoc.CreateElement("name");
            XmlElement a4       = xDoc.CreateElement("middlename");
            XmlElement a5       = xDoc.CreateElement("startYear");
            XmlElement a6       = xDoc.CreateElement("institutionName");

            a1.AppendChild(xDoc.CreateTextNode(card.Number.ToString()));
            a2.AppendChild(xDoc.CreateTextNode(card.Surname));
            a3.AppendChild(xDoc.CreateTextNode(card.Name));
            a4.AppendChild(xDoc.CreateTextNode(card.Middlename));
            a5.AppendChild(xDoc.CreateTextNode(card.StartYear.ToShortDateString()));
            a6.AppendChild(xDoc.CreateTextNode(card.InstitutionName));
            userElem.AppendChild(a1);
            userElem.AppendChild(a2);
            userElem.AppendChild(a3);
            userElem.AppendChild(a4);
            userElem.AppendChild(a5);
            userElem.AppendChild(a6);
            xRoot.AppendChild(userElem);
            xDoc.Save(@"../../XMLFileCardInf.xml");
        }
コード例 #4
0
        public void TestEquals()
        {
            EducationalCard card = new EducationalCard()
            {
                Number          = 1,
                Name            = "Alex",
                Surname         = "Ivanov",
                Middlename      = "Ivanovich",
                StartYear       = new DateTime(2002, 10, 10),
                InstitutionName = "BSU"
            };

            EducationalCard card1 = new EducationalCard();

            var actual = card.Equals(card1);

            Assert.IsFalse(actual);
        }
コード例 #5
0
ファイル: Menu.cs プロジェクト: hodanovich-irina/Task
        /// <summary>
        /// Show main menu
        /// </summary>
        public static void ShowMenu()
        {
            WorkWithXML work = new WorkWithXML();

            Number = work.GetLastNumber() + 1;
            bool flag = true;
            int  navigation;

            while (flag)
            {
                Console.WriteLine("\nCоздание универсальной электронной карты:\n\t1. Банковская карта;\n\t2. Образовательная карта;\n\t3. Страховой полис;\n\t4. Медицинская карта;\n\t5. Паспорт;\n\t6. Просмотреть записи;\n\t7. Выйти.");

                Console.WriteLine("\nВведите № операции для выполнения: ");
                navigation = Convert.ToInt32(Console.ReadLine());
                switch (navigation)
                {
                case 1:
                    BankCard    card     = CreateBankCard();
                    XMLBankCard bankCard = new XMLBankCard();
                    bankCard.XMLCreateBankCard(card);
                    break;

                case 2:
                    EducationalCard    card1           = CreateEducationalCard();
                    XMLEducationalCard educationalCard = new XMLEducationalCard();
                    educationalCard.XMLCreateEducationalCard(card1);
                    break;

                case 3:

                    InsurancePolicy    card2           = CreateInsurancePolicy();
                    XMLInsurancePolicy insurancePolicy = new XMLInsurancePolicy();
                    insurancePolicy.XMLCreateInsurancePolicy(card2);
                    break;

                case 4:
                    MedicalCard    card3       = CreateMedicalCard();
                    XMLMedicalCard medicalCard = new XMLMedicalCard();
                    medicalCard.XMLCreateMedicalCard(card3);
                    break;

                case 5:
                    Passport    card4    = CreatePassport();
                    XMLPassport passport = new XMLPassport();
                    passport.XMLCreatePassport(card4);
                    break;

                case 6:
                    foreach (var v in work.ShowXML())
                    {
                        Console.WriteLine(v.ToString());
                    }
                    Console.ReadKey();
                    break;

                case 7:
                    flag = false;
                    break;

                default:
                    Console.WriteLine("№ операции неверный,нажмите любую клавишу для продолжения и введите цифру от 1 до 7");
                    break;
                }
            }
        }