Пример #1
0
        static void BirthdayCalculator()
        {
            var birthDay = new BirthDay();

            Console.WriteLine("Enter your Birthday:");
            Console.WriteLine("Day");
            birthDay.Day = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Month");
            birthDay.Month = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Year");
            birthDay.Year = Convert.ToInt32(Console.ReadLine());

            try
            {
                var date      = new DateTime(birthDay.Year, birthDay.Month, birthDay.Day);
                var ng        = new DateTime(DateTime.Now.Year, 12, 31);
                var remainDay = date.DayOfYear - DateTime.Now.DayOfYear;
                if (date.Year > DateTime.Now.Year)
                {
                    throw new Exception();
                }
                else if (remainDay < 0)
                {
                    remainDay = ng.DayOfYear - DateTime.Now.DayOfYear + date.DayOfYear;
                }
                Console.WriteLine($"До вашего дня рождения осталось {remainDay} дней!");
            }
            catch
            {
                Console.WriteLine("Error input value! Try again!");
                BirthdayCalculator();
            }
        }
Пример #2
0
        public override string ToString()
        {
            string result = $"Фамилия: {SecondName}\n" +
                            $"Имя: {Name}\n";

            if (Sername != "")
            {
                result += $"Отчество : {Sername}\n";
            }

            result += $"Номер телефона: {telNamber}\n" +
                      $"Страна: {Country}\n";

            if (BirthDay != DateTime.MinValue)
            {
                result += $"День рождения : {BirthDay.ToString("dd MMMM yyyy")}\n";
            }

            if (Organizaition != "")
            {
                result += $"Организация : {Organizaition}\n";
            }

            if (Position != "")
            {
                result += $"Должность : {Position}\n";
            }

            if (Notes != "")
            {
                result += $"Прочие заметки: {Notes}\n";
            }

            return(result);
        }
Пример #3
0
 public override string ToString()
 {
     return($"Full Name: {FullName}\n" +
            $"Date of Birth: {BirthDay.ToShortDateString()}\n" +
            $"Place of Birth: {PlaceOfBirth}\n" +
            $"Passport ID: {PassportId}\n");
 }
Пример #4
0
        private void Delete_Click(object sender, RoutedEventArgs e)
        {
            if (contactGrid.SelectedItems.Count > 0)
            {
                Contact contact = contactGrid.SelectedItem as Contact;

                Telephone telephone = db2.Telephones.FirstOrDefault(tel => tel.ContactId == contact.Id);
                if (telephone != null)
                {
                    db2.Telephones.Remove(telephone);
                }

                Email email = db2.Emails.FirstOrDefault(em => em.ContactId == contact.Id);
                if (email != null)
                {
                    db2.Emails.Remove(email);
                }

                BirthDay birthDay = db2.BirthDays.FirstOrDefault(day => day.Id == contact.Id);
                if (birthDay != null)
                {
                    db2.BirthDays.Remove(birthDay);
                }

                db2.Contacts.Remove(contact);

                db2.SaveChanges();
            }
        }
        public void Validate()
        {
            new AddNotifications <FuncionarioEntity>(this)
            .IfLowerOrEqualsThan(Id, 0, "Id must be greater than zero")
            .IfNullOrEmpty(Name, "Name is obligatory")
            .IfNullOrEmpty(Gender, "Gender is obligatory")
            .IfNullOrEmpty(BirthDay.ToString(), "BirthDay is obligatory")
            .IfNullOrEmpty(Salary.ToString(), "Salary is obligatory")
            .IfNullOrEmpty(Level, "Level is obligatory")
            .IfNullOrEmpty(HiringDate.ToString(), "HiringDate is obligatory")
            .IfLengthGreaterThan(Name, 64, "Name must be a maximum of 64 characters")
            .IfLengthGreaterThan(Gender, 1, "Gender must be a maximum of 1 characters")
            .IfGreaterOrEqualsThan(BirthDay, DateTime.Now, "BirthDay must be smaller than today")
            .IfLowerOrEqualsThan(Salary, 800, "Salary must be greater than R$ 800,00")
            .IfLengthGreaterThan(Level, 1, "Level must be a maximum of 1 characters")
            .IfGreaterThan(HiringDate, DateTime.Now, "HiringDate must be less than or equals today");

            if (!new string[] { "F", "M" }.Contains(Gender))
            {
                AddNotification("Gender", "Gender should be M or F");
            }

            if (!new string[] { "J", "P", "S" }.Contains(Level))
            {
                AddNotification("Level", "Level should be J, P or S");
            }
        }
Пример #6
0
        public void TestGetBirthDay()
        {
            var bDay = new BirthDay(1, 7, 1987);

            Assert.AreEqual("1987-07-01", bDay.GetBirthDay());
            var bDay2 = new BirthDay(10, 10, 1990);

            Assert.AreEqual("1990-10-10", bDay2.GetBirthDay());
        }
Пример #7
0
        /// <summary>
        /// Calculates the Ages of each Household Member and sets those values in the form and in the database
        /// </summary>
        public bool calcAllHHMemAges(DateTime BaseDate)
        {
            int[] AgeGroupsTotals = new int[6] {
                0, 0, 0, 0, 0, 0
            };
            DateTime BirthDay;

            if (clsHH.UseFamilyList == true)
            {
                for (int i = 0; i < clsHHmem.RowCount; i++)
                {
                    HHMemberItem clsHHMemberItem = new HHMemberItem(clsHHmem.DSet.Tables[0].Rows[i], clsHHmem.DSet.Tables[0].Columns, null, null);
                    int          newAge          = 0;
                    if (clsHHMemberItem.Inactive == false && clsHHMemberItem.NotCounted == false)
                    {
                        newAge = clsHHMemberItem.Age;
                        if (clsHHMemberItem.UseAge == false || (clsHHMemberItem.BirthDate.ToShortDateString() != CCFBGlobal.OURNULLDATE &&
                                                                clsHHMemberItem.BirthDate.ToShortDateString() != CCFBGlobal.OUROTHERNULLDATE))
                        {
                            BirthDay = clsHHMemberItem.BirthDate;
                            if (BirthDay != null && BirthDay.ToShortDateString() != "" && BirthDay != DateTime.MaxValue)
                            {
                                newAge = CCFBGlobal.calcAge(BirthDay, BaseDate);
                                clsHHMemberItem.Age = newAge;
                            }
                        }
                        clsHHMemberItem.AgeGroup = clsHHmem.GetEFAPAgeGroup(newAge);
                        AgeGroupsTotals[clsHHMemberItem.AgeGroup]++;
                    }
                }
                int totalFamily = AgeGroupsTotals[CCFBGlobal.ageGroup_Infant]
                                  + AgeGroupsTotals[CCFBGlobal.ageGroup_Youth]
                                  + AgeGroupsTotals[CCFBGlobal.ageGroup_Teen]
                                  + AgeGroupsTotals[CCFBGlobal.ageGroup_Eighteen]
                                  + AgeGroupsTotals[CCFBGlobal.ageGroup_Adult]
                                  + AgeGroupsTotals[CCFBGlobal.ageGroup_Senior];

                if (clsHH.Infants != AgeGroupsTotals[CCFBGlobal.ageGroup_Infant] ||
                    clsHH.Youth != AgeGroupsTotals[CCFBGlobal.ageGroup_Youth] ||
                    clsHH.Teens != AgeGroupsTotals[CCFBGlobal.ageGroup_Teen] ||
                    clsHH.Eighteens != AgeGroupsTotals[CCFBGlobal.ageGroup_Eighteen] ||
                    clsHH.Adults != AgeGroupsTotals[CCFBGlobal.ageGroup_Adult] ||
                    clsHH.Seniors != AgeGroupsTotals[CCFBGlobal.ageGroup_Senior] ||
                    clsHH.TotalFamily != totalFamily)
                {
                    clsHH.Infants     = AgeGroupsTotals[CCFBGlobal.ageGroup_Infant];
                    clsHH.Youth       = AgeGroupsTotals[CCFBGlobal.ageGroup_Youth];
                    clsHH.Teens       = AgeGroupsTotals[CCFBGlobal.ageGroup_Teen];
                    clsHH.Eighteens   = AgeGroupsTotals[CCFBGlobal.ageGroup_Eighteen];
                    clsHH.Adults      = AgeGroupsTotals[CCFBGlobal.ageGroup_Adult];
                    clsHH.Seniors     = AgeGroupsTotals[CCFBGlobal.ageGroup_Senior];
                    clsHH.TotalFamily = totalFamily;
                    return(true);
                }
            }
            return(false);
        }
Пример #8
0
        private bool AreFieldsValid()
        {
            bool isName          = Name.Validate();
            bool isPhoneNumber   = PhoneNumber.Validate();
            bool isEmailValid    = Email.Validate();
            bool isPasswordValid = Password.Validate();
            bool isBirthday      = BirthDay.Validate();

            return(isName && isPhoneNumber && isEmailValid && isPasswordValid && isBirthday);
        }
Пример #9
0
        private static BirthDay ConvertDayVMtoDay(BirthDayVM vmDay)
        {
            BirthDay day = new BirthDay()
            {
                BirthDayId = vmDay.BirthDayId,
                Date       = vmDay.Date
            };

            return(day);
        }
Пример #10
0
        public void TestBirthDayProperty()
        {
            var bDay = new BirthDay(1, 7, 1987);

            bDay.Day  = 11;
            bDay.Mon  = 11;
            bDay.Year = 1911;
            Assert.AreEqual(11, bDay.Day);
            Assert.AreEqual(11, bDay.Mon);
            Assert.AreEqual(1911, bDay.Year);
        }
 public override int GetHashCode()
 {
     unchecked
     {
         int hashcode = WorkPosition.GetHashCode() +
                        WorkExperience.GetHashCode() +
                        BirthDay.GetHashCode() +
                        FirstName.GetHashCode() +
                        MiddleName.GetHashCode() +
                        LastName.GetHashCode();
         return(hashcode);
     }
 }
Пример #12
0
 private static BirthDayVM ConvertDayToEditDayVM(BirthDay day)
 {
     if (day != null)
     {
         BirthDayVM dayVM = new BirthDayVM()
         {
             BirthDayId = day.BirthDayId,
             Date       = day.Date
         };
         return(dayVM);
     }
     return(null);
 }
Пример #13
0
        bool AreFieldsValid()
        {
            bool isFirstNameValid         = FirstName.Validate();
            bool isLastNameValid          = LastName.Validate();
            bool isBirthDayValid          = BirthDay.Validate();
            bool isPhoneNumberValid       = PhoneNumber.Validate();
            bool isEmailValid             = Email.Validate();
            bool isPasswordValid          = Password.Validate();
            bool isTermsAndConditionValid = TermsAndCondition.Validate();

            return(isFirstNameValid && isLastNameValid && isBirthDayValid &&
                   isPhoneNumberValid && isEmailValid && isPasswordValid && isTermsAndConditionValid);
        }
Пример #14
0
        private void Create_Click(object sender, RoutedEventArgs e)
        {
            ContactAdding window = new ContactAdding();

            window.Owner = this;

            if (window.ShowDialog() == true)
            {
                if (window.NameTextBox.Text != "" && window.NameTextBox.Text != "-" && window.NameTextBox.Text != "нет" && window.NameTextBox.Text != " ")
                {
                    Contact contact = new Contact {
                        Name = window.NameTextBox.Text, MainTelephone = window.PhoneTextBox.Text
                    };
                    db2.Contacts.Add(contact);
                    db2.SaveChanges();

                    Telephone telephone = new Telephone {
                        Name = window.NameTextBox.Text, telephone = window.PhoneTextBox.Text, Contact = contact
                    };
                    if (telephone.telephone == "")
                    {
                        telephone.telephone = "-";
                    }
                    db2.Telephones.Add(telephone);

                    Email email = new Email {
                        Name = window.NameTextBox.Text, email = window.EmailTextBox.Text, Contact = contact
                    };
                    if (email.email == "")
                    {
                        email.email = "-";
                    }
                    db2.Emails.Add(email);

                    BirthDay birthDay = new BirthDay {
                        Id = contact.Id, Name = window.NameTextBox.Text, Birthday = window.BirthDayTextBox.Text, Contact = contact
                    };
                    if (birthDay.Birthday == "")
                    {
                        birthDay.Birthday = "-";
                    }
                    db2.BirthDays.Add(birthDay);

                    db2.SaveChanges();
                }
                else
                {
                    MessageBox.Show("Введите имя!");
                }
            }
        }
Пример #15
0
        public override string ToString()
        {
            var sb = new StringBuilder();

            sb.AppendLine($"FirstName: {FirstName}");
            sb.AppendLine($"LastName: {LastName}");
            sb.AppendLine($"BirthDay: {BirthDay.ToShortDateString()}");
            sb.AppendLine($"Gender: {Gender}");
            sb.AppendLine($"Status: {Status}");
            sb.AppendLine($"Recommendations: {Recommendations}");
            sb.AppendLine($"Owns: {Owns}");

            return(sb.ToString().Trim());
        }
Пример #16
0
 private static BirthDayVM ConvertDayToDayVM(BirthDay day, bool isPrivate)
 {
     if (day != null)
     {
         if (!isPrivate)
         {
             BirthDayVM dayVM = new BirthDayVM()
             {
                 BirthDayId = day.BirthDayId,
                 Date       = day.Date
             };
             return(dayVM);
         }
     }
     return(null);
 }
Пример #17
0
 private void Delete_birthday_click(object sender, RoutedEventArgs e)
 {
     if (AccountGrid.SelectedItems.Count > 0)
     {
         BirthDay birthDay = AccountGrid.SelectedItem as BirthDay;
         if (birthDay != null)
         {
             db2.BirthDays.Remove(birthDay);
             db2.SaveChanges();
         }
     }
     else
     {
         MessageBox.Show("Данных нет");
     }
 }
        public void AddTest()
        {
            Birthdays birthdays = new Birthdays(new List <BirthDay>()
            {
                new BirthDay {
                    Surname = "Alex", Name = "Text", Birthday = new DateTime(1980, 1, 1)
                },
            });
            BirthDay test = new BirthDay {
                Surname = "Test", Name = "Test", Birthday = new DateTime(1981, 1, 1)
            };

            birthdays.Add(test.Surname, test.Name, test.Birthday);
            Assert.AreEqual(2, birthdays.Count);
            Assert.AreEqual(test, birthdays[1]);
        }
        public void EditTest()
        {
            Birthdays birthdays = new Birthdays(new List <BirthDay>()
            {
                new BirthDay {
                    Surname = "Alex", Name = "Text", Birthday = new DateTime(1980, 1, 1)
                },
            });
            BirthDay test = new BirthDay {
                Surname = "Test", Name = "Test", Birthday = new DateTime(1981, 1, 1)
            };

            birthdays.Edit(0, test.Surname, test.Name, test.Birthday);
            Assert.AreEqual(1, birthdays.Count);
            Assert.AreEqual(test, birthdays[0]);
            Assert.ThrowsException <ApplicationException>(() => birthdays.Edit(2, test.Surname, test.Name, test.Birthday));
        }
        public void DeleteTest()
        {
            BirthDay test = new BirthDay {
                Surname = "Max", Name = "Faq", Birthday = new DateTime(1980, 1, 1)
            };
            Birthdays birthdays = new Birthdays(new List <BirthDay>()
            {
                new BirthDay {
                    Surname = "Alex", Name = "Text", Birthday = new DateTime(1980, 1, 1)
                },
                test,
            });

            birthdays.Delete(0);
            Assert.AreEqual(1, birthdays.Count);
            Assert.AreEqual(test, birthdays[0]);
            Assert.ThrowsException <ApplicationException>(() => birthdays.Delete(2));
        }
    protected void txt_IDCode_TextChanged(object sender, EventArgs e)
    {
        DateTime     BirthDay; int Sex;
        TextBox      txt_birthday = UC_DetailView1.FindControl("PM_Promotor_Birthday") != null ? (TextBox)UC_DetailView1.FindControl("PM_Promotor_Birthday") : null;
        DropDownList ddl_sex      = UC_DetailView1.FindControl("PM_Promotor_Sex") != null ? (DropDownList)UC_DetailView1.FindControl("PM_Promotor_Sex") : null;

        if (Tools.DoVerifyIDCode(((TextBox)sender).Text, out BirthDay, out Sex) && ((TextBox)sender).Text.Trim().Length == 18)
        {
            if (txt_birthday != null)
            {
                txt_birthday.Text = BirthDay.ToString("yyyy-MM-dd");
            }
            if (ddl_sex != null)
            {
                ddl_sex.SelectedValue = Sex.ToString();
            }


            if (DateTime.Now < BirthDay.AddYears(16) || DateTime.Now > BirthDay.AddYears(50))
            {
                int year = DateTime.Now.Year - BirthDay.Year;
                if (BirthDay.AddYears(year) > DateTime.Now)
                {
                    year++;
                }
                MessageBox.Show(this, "对不起,该导购年龄不符合规则(16~49岁),该人员年龄:" + year);
                return;
            }
        }
        else
        {
            MessageBox.Show(this, "身份证号码错误!");
            ((TextBox)sender).Text = "";
            if (txt_birthday != null)
            {
                txt_birthday.Text = "";
            }
            if (ddl_sex != null)
            {
                ddl_sex.SelectedValue = "0";
            }
            return;
        }
    }
Пример #22
0
        public string getVCard()
        {
            string result = "BEGIN:VCARD\r\nVERSION:3.0\r\n";

            result += getNamevCard() + "\r\n";          //N:
            result += "FN:" + Fullname + "\r\n";        //FN:

            foreach (var ad in Addresses)               //ADR:
            {
                result += ad.getvCardString + "\r\n";
            }

            foreach (var em in Emails)                  //EMAIL:
            {
                result += "EMAIL:" + em.Address + "\r\n";
            }

            foreach (var tel in Numbers)                //TEL:
            {
                result += tel.getvCardString + "\r\n";
            }

            foreach (string url in Urls)                //URL
            {
                result += "URL:" + url + "\r\n";
            }

            result += BirthDay.Year != 1 ? "BDAY:" + BirthDay.ToShortDateString() + "\r\n" : "";
            result += Note != "" ? "NOTE:" + Note + "\r\n" : "";
            result += Organization != "" ? "ORG:" + Organization + "\r\n" : "";
            result += RoleInOrg != "" ? "ROLE:" + RoleInOrg + "\r\n" : "";
            result += JobTitle != "" ? "TITLE:" + JobTitle + "\r\n" : "";
            result += TimeZone != "" ? "TZ:" + TimeZone + "\r\n" : "";
            result += Revision.Year == 1 ? "REV:" + Revision.ToString() + "\r\n" : "";
            result += Photo != null?getImagevCard() : "";

            result += "\r\n";

            result += "END:VCARD\r\n";
            return(result);
        }
 public override string ToString()
 {
     return($"{LastName} {FirstName} {MiddleName}, дата рождения: {BirthDay.ToShortDateString()}, {UserAge} лет/год(а) ");
 }
Пример #24
0
 public override string ToString()
 {
     return(String.Format(ID + "; " + Surname + "; " + Name + "; " + SecondName + "; " + BirthDay.ToShortDateString() + "; " + EmploymentDate.ToShortDateString() + "; " + Position + "; " + Division + "; " + Room + "; " + Phone + "; " + Email + "; " + Salary + "; " + Notes));
 }
Пример #25
0
 public override string ToString()
 {
     return(Surname + " " + Name + " " + SecondName + " (" + Sex + ", " + BirthDay.ToShortDateString() + ")");
 }
Пример #26
0
 /// <summary>
 /// Write a vCard to a string
 /// </summary>
 /// <param name="vCardString">An empty string passed by reference</param>
 internal void WriteV2ObjectToString(ref string vCardString)
 {
     vCardString += "BEGIN:VCARD" + Environment.NewLine;
     vCardString += "VERSION:2.1" + Environment.NewLine;
     vCardString += "N:" + Firstname + ";" + Surname + ";" + Othernames + Environment.NewLine;
     vCardString += "FN:" + FormattedName + Environment.NewLine;
     vCardString += "ORG:" + Organization + Environment.NewLine;
     vCardString += "TITLE:" + Title + Environment.NewLine;
     vCardString += "URL:" + URL + Environment.NewLine;
     vCardString += "NICKNAME:" + NickName + Environment.NewLine;
     vCardString += "KIND:" + Kind.ToString().ToUpper() + Environment.NewLine;
     vCardString += "GENDER:" + Gender + Environment.NewLine;
     vCardString += "LANG:" + Language + Environment.NewLine;
     vCardString += "BIRTHPLACE:" + BirthPlace + Environment.NewLine;
     vCardString += "DEATHPLACE:" + DeathPlace + Environment.NewLine;
     vCardString += "TZ:" + TimeZone + Environment.NewLine;
     vCardString += "BDAY:" + BirthDay.Year + BirthDay.ToString("00") + BirthDay.ToString("00");
     foreach (PhoneNumber phoneNumber in PhoneNumbers)
     {
         vCardString += Environment.NewLine;
         if (phoneNumber.Type == PhoneNumberType.None)
         {
             vCardString += "TEL:" + phoneNumber.Number;
         }
         else if (phoneNumber.Type == PhoneNumberType.MainNumber)
         {
             vCardString += "TEL;MAIN-NUMBER:" + phoneNumber.Number;
         }
         else
         {
             vCardString += "TEL;" + phoneNumber.Type.ToString().ToUpper() + ":" + phoneNumber.Number;
         }
     }
     foreach (EmailAddress email in EmailAddresses)
     {
         vCardString += Environment.NewLine;
         if (email.Type == EmailType.None)
         {
             vCardString += "EMAIL:" + email.Email.Address;
         }
         else
         {
             vCardString += "EMAIL;" + email.Type.ToString().ToUpper() + ":" + email.Email.Address;
         }
     }
     foreach (Address address in Addresses)
     {
         vCardString += Environment.NewLine;
         if (address.Type == AddressType.None)
         {
             vCardString += "ADR:" + address.Location;
         }
         else
         {
             vCardString += "ADR;" + address.Type.ToString().ToUpper() + ":" + address.Location;
         }
     }
     foreach (Photo photo in Pictures)
     {
         vCardString += Environment.NewLine;
         vCardString += "PHOTO;" + photo.Encoding;
         if (photo.Type == PhotoType.URL)
         {
             vCardString += ":" + photo.PhotoURL;
         }
         else if (photo.Type == PhotoType.Image)
         {
             vCardString += ";ENCODING=BASE64:" + photo.ToBase64String();
         }
     }
     foreach (Expertise expertise in Expertises)
     {
         vCardString += Environment.NewLine;
         vCardString += "EXPERTISE;LEVEL=" + expertise.Level.ToString().ToLower() + ":" + expertise.Area;
     }
     foreach (Hobby hobby in Hobbies)
     {
         vCardString += Environment.NewLine;
         vCardString += "HOBBY;LEVEL=" + hobby.Level.ToString().ToLower() + ":" + hobby.Activity;
     }
     foreach (Interest interest in Interests)
     {
         vCardString += Environment.NewLine;
         vCardString += "INTEREST;LEVEL=" + interest.Level.ToString().ToLower() + ":" + interest.Activity;
     }
     vCardString += Environment.NewLine;
     vCardString += "END:VCARD";
 }
Пример #27
0
 public string GetAllInfo()
 {
     return($"{FullName} {country} {city} {BirthDay.ToString()} {Group}");
 }
Пример #28
0
 public override string ToString()
 {
     return($"{FullName} {BirthDay.ToShortDateString()} {Phone} {Email} {Address} {Debt}");
 }
Пример #29
0
 public override string ToString()
 {
     return("Person:\nName: " + Name + "\nBirth Day: " + BirthDay.ToString("d") + "\nGender: " + IsGender() + "\n\n");
 }
Пример #30
0
 public override string ToString()
 {
     return("\n\nPerson:\nName: " + Name + "\nBirth Day: " + BirthDay.ToString("d") + "\nGender: " + IsGender() + "\nSalary: " + Salary + " PLN" + "\nProfession: " + Profession + "\nRoom Number: " + Room.RoomNumber);
 }