123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444 |
- using Avalonia.Controls;
- using Avalonia.Interactivity;
- using Avalonia.Media;
- using Avalonia.Media.Imaging;
- using System;
- using System.Data;
- using System.Diagnostics;
- using System.Runtime.Intrinsics.Arm;
- using Avalonia.Threading;
- using System.Runtime.InteropServices;
- using System.Threading.Tasks;
- using Tmds.DBus.Protocol;
- using System.IO;
- using System.Linq;
- using static System.Runtime.InteropServices.JavaScript.JSType;
- using Avalonia.Input;
- using System.Reflection.Metadata.Ecma335;
- using System.Text.RegularExpressions;
- using System.Text;
- namespace AvaloniaApplication1
- {
- public struct DateB
- {
- public string dayB;
- public string mounthB;
- public string yearB;
- }
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
- }
- public void Button_Click(object source, RoutedEventArgs args)
- {
- string date = dateT.SelectedDate.ToString();
- if (date == "")
- {
- Error.Text = "Âû ââåëè íåñóùåñòâóþùóþ äàòó";
- }
- else
- {
- int day = int.Parse(date.Substring(0, 2));
- int mounth = int.Parse(date.Substring(3, 2));
- int year = int.Parse(date.Substring(6, 4));
- DateTime BD = new DateTime(year, mounth, day);
- DateTime ToDay = DateTime.Now;
- if (BD > ToDay)
- {
- Error.Text = "Âû ââåëè áóäóùóþ äàòó";
- }
- else
- {
- Error.Text = "";
- int Vis = 0;
- int DbWeek = 0;
- DateTime dayW;
- int age = ToDay.Year - BD.Year;
- int months = ToDay.Month - BD.Month;
- int days = ToDay.Day - BD.Day;
- if (ToDay.Month < BD.Month || (ToDay.Month == BD.Month && ToDay.Day < BD.Day))
- {
- age--;
- }
- if (days < 0)
- {
- months--;
- days += DateTime.DaysInMonth(ToDay.Year, ToDay.Month - 1);
- }
- if (months < 0)
- {
- months += 12;
- }
- VisY.Text = "Âèñîêîñíûå ãîäû: ";
- string DayOfWeek = BD.DayOfWeek.ToString();
- for (int i = year; i <= ToDay.Year; i++)
- {
- if (i % 4 == 0)
- {
- VisY.Text = VisY.Text + i + " ";
- Vis++;
- }
- dayW = new DateTime(i, mounth, day);
- if (dayW.DayOfWeek.ToString() == DayOfWeek && dayW != BD && dayW != ToDay)
- {
- DbWeek++;
- }
- }
- if (DayOfWeek == "Monday")
- {
- DayOfWeek = "Ïîíåäåëüíèê";
- }
- if (DayOfWeek == "Tuesday")
- {
- DayOfWeek = "Âòîðíèê";
- }
- if (DayOfWeek == "Wednesday")
- {
- DayOfWeek = "Ñðåäà";
- }
- if (DayOfWeek == "Thursday")
- {
- DayOfWeek = "×åòâåðã";
- }
- if (DayOfWeek == "Friday")
- {
- DayOfWeek = "Ïÿòíèöà";
- }
- if (DayOfWeek == "Saturday")
- {
- DayOfWeek = "Ñóááîòà";
- }
- if (DayOfWeek == "Sunday")
- {
- DayOfWeek = "Âîñêðåñåíüå";
- }
- dayOfWeek.Text = "Äåíü íåäåëè: " + DayOfWeek;
- yearT.Text = "Êîëè÷åñòâî ëåò: " + age.ToString();
- mounthT.Text = "Êîëè÷åñòâî ìåñÿöåâ: " + months.ToString();
- daysT.Text = "Êîëè÷åñòâî äíåé: " + days.ToString();
- DBW.Text = "Êîëè÷åñòâî îòïðàçäíîâàííûõ äíåé ðîæäåíèé â " + DayOfWeek + ": " + DbWeek;
- Viss.Text = "Êîëè÷åñòâî âèñîêîñíûõ ãîäîâ: " + Vis;
- }
- if (Zod.IsChecked == false && Vost.IsChecked == false)
- {
- }
- if (Vost.IsChecked == true)
- {
- Znak.Text = "Çíàê âîñòî÷íîãî êàëåíäàðÿ: " + Vostoch(year);
- }
- if (Zod.IsChecked == true)
- {
- Znak.Text = "Çíàê çîäèàêà: " + Zodiac(day, mounth);
- }
- }
- }
- public string Vostoch(int year)
- {
- string[] ZnakV = new string[]
- {
- "Îáåçüÿíà", "Ïåòóõ",
- "Ñîáàêà", "Ñâèíüÿ","Êðûñà", "Áûê", "Òèãð", "Êðîëèê", "Äðàêîí",
- "Çìåÿ", "Ëîøàäü", "Êîçà"
- };
- int index = year % 12;
- return ZnakV[index];
- }
- public string Zodiac(int day, int mounth)
- {
- string Zod = " ";
- if (day >= 21 && day <= 31 && mounth == 3 || day <= 19 && mounth == 4)
- {
- Zod = "Îâåí";
- }
- else if (day >= 20 && day<=30 && mounth == 4 || day <= 20 && mounth == 5)
- {
- Zod = "Òåëåö";
- }
- else if (day >= 21 && day<=31 && mounth == 5 || day <= 20 && mounth == 6)
- {
- Zod = "Áëèçíåöû";
- }
- else if (day >= 21 && day <= 30 && mounth == 6 || day <= 22 && mounth == 7)
- {
- Zod = "Ðàê";
- }
- else if (day >= 23 && day <= 31 && mounth == 7 || day <= 22 && mounth == 8)
- {
- Zod = "Ëåâ";
- }
- else if (day >= 23 && day <= 31 && mounth == 8 || day <= 22 && mounth == 9)
- {
- Zod = "Äåâà";
- }
- else if (day >= 23 && day <= 30 && mounth == 9 || day <= 22 && mounth == 10)
- {
- Zod = "Âåñû";
- }
- else if (day >= 23 && day <= 31 && mounth == 10 || day <= 21 && mounth == 11)
- {
- Zod = "Ñêîðïèîí";
- }
- else if (day >= 22 && day <= 30 && mounth == 11 || day <= 21 && mounth == 12)
- {
- Zod = "Ñòðåëåö";
- }
- else if (day >= 22 && day <= 31 && mounth == 12 || day <= 19 && mounth == 1)
- {
- Zod = "Êîçåðîã";
- }
- else if (day >= 20 && day<=31 && mounth == 1 || day <= 18 && mounth == 2)
- {
- Zod = "Âîäîëåé";
- }
- else if (day >= 19 && day<=28 && mounth == 2 || day <= 20 && mounth == 3)
- {
- Zod = "Ðûáû";
- }
- else
- {
- Zod = "Äåíü íå ñóùåñòâóåò èëè ìåñÿö íå ñóùåñòâóåò";
- }
- return Zod;
- }
- [Obsolete]
- public async void Filee(object source, RoutedEventArgs args)
- {
- string header = "";
- string path;
- int k = 0;
- OpenFileDialog OFD = new OpenFileDialog();
- OFD.AllowMultiple = false;
- OFD.Filters.Add(new FileDialogFilter() { Name = "CSV ôàéëû", Extensions = { "csv" } });
- var result = await OFD.ShowAsync(this);
- if (result != null)
- {
- Error.Text = "Ñ÷èòûâàíèå óñïåøíî";
- path = result[0];
- string[] lines = File.ReadAllLines(path);
- if (lines.Length > 0)
- {
- DateB[] dateB = new DateB[lines.Length - 1];
- Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
- using (StreamReader sr = new StreamReader(path, Encoding.GetEncoding(1251)))
- {
- string line = sr.ReadLine();
- header = line;
- line = sr.ReadLine();
- while (line != null)
- {
- string[] strs = line.Split(";").ToArray();
- dateB[k].dayB = strs[0];
- dateB[k].mounthB = strs[1];
- dateB[k].yearB = strs[2];
- k++;
- line = sr.ReadLine();
- }
- };
- int s = 0;
- using (StreamWriter sw = new StreamWriter("Output.csv", false, Encoding.GetEncoding(1251)))
- {
- sw.WriteLine(header + ";" + "Çíàê çîäèàêà" + ";" + "Âîñòî÷íûé êàëåíäàðü");
- for (int i = 0; i<k; i++)
- {
- bool isNumericMounthNotInt = Regex.IsMatch(dateB[i].mounthB, @"^(\d+|0),\d+$");
- bool isNumericDayNotInt = Regex.IsMatch(dateB[i].dayB, @"^(\d+|0),\d+$");
- bool isNumericYearNotInt = Regex.IsMatch(dateB[i].yearB, @"^(\d+|0),\d+$");
- bool isNumericDayDate = Regex.IsMatch(dateB[i].dayB, @"^\d{2}\.\d{2}\.\d{4}$");
- bool isNumericMounthDate = Regex.IsMatch(dateB[i].mounthB, @"^\d{2}\.\d{2}\.\d{4}$");
- bool isNumericYearDate = Regex.IsMatch(dateB[i].yearB, @"^\d{2}\.\d{2}\.\d{4}$");
- bool isNumericDayOtr = Regex.IsMatch(dateB[i].dayB, @"^-?\d+$");
- bool isNumericMounthOtr = Regex.IsMatch(dateB[i].mounthB, @"^-?\d+$");
- bool isNumericYearOtr = Regex.IsMatch(dateB[i].yearB, @"^-?\d+$");
- bool isNumericDay = Regex.IsMatch(dateB[i].dayB, @"^\d+$");
- bool isNumericMounth = Regex.IsMatch(dateB[i].mounthB, @"^\d+$");
- bool isNumericYear = Regex.IsMatch(dateB[i].yearB, @"^\d+$");
- if (isNumericDay == true & isNumericMounth == true && isNumericYear == true)
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + Zodiac(int.Parse(dateB[i].dayB), int.Parse(dateB[i].mounthB)) + ";" + Vostoch(int.Parse(dateB[i].yearB)));
- }
- else if (isNumericDay == true & isNumericMounth == false && isNumericYear == true)
- {
- if(dateB[i].mounthB == "")
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Ìåñÿö íå óêàçàí" + ";" + Vostoch(int.Parse(dateB[i].yearB)));
- }
- else if(isNumericMounthOtr == true)
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Ìåñÿö ÿâëÿåòñÿ îòðèöàòåëüíûì ÷èñëîì" + ";" + Vostoch(int.Parse(dateB[i].yearB)));
- }
- else if(dateB[i].mounthB != " ")
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Ìåñÿö íå ÿâëÿåòñÿ ÷èñëîì" + ";" + Vostoch(int.Parse(dateB[i].yearB)));
- }
- else if(isNumericMounthDate == true)
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Â ìåñÿöå óêàçàíà ïîëíàÿ äàòà" + ";" + Vostoch(int.Parse(dateB[i].yearB)));
- }
- }
- else if (isNumericDay == false & isNumericMounth == true && isNumericYear == true)
- {
- if (dateB[i].dayB == "")
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Äåíü íå óêàçàí" + ";" + Vostoch(int.Parse(dateB[i].yearB)));
- }
- else if (isNumericDayOtr == true)
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Äåíü ÿâëÿåòñÿ îòðèöàòåëüíûì ÷èñëîì" + ";" + Vostoch(int.Parse(dateB[i].yearB)));
- }
- else if (dateB[i].dayB != " ")
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Äåíü íå ÿâëÿåòñÿ ÷èñëîì" + ";" + Vostoch(int.Parse(dateB[i].yearB)));
- }
- else if(isNumericDayDate == true)
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Â äíå óêàçàíà ïîëíàÿ äàòà" + ";" + Vostoch(int.Parse(dateB[i].yearB)));
- }
- }
- else if (isNumericDay == true & isNumericMounth == true && isNumericYear == false)
- {
- if (dateB[i].yearB == "")
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + Zodiac(int.Parse(dateB[i].dayB), int.Parse(dateB[i].mounthB)) + ";" + "Ãîä íå óêàçàí");
- }
- else if (isNumericYearOtr == true)
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + Zodiac(int.Parse(dateB[i].dayB), int.Parse(dateB[i].mounthB)) + ";" + "Ãîä ÿâëÿåòñÿ îòðèöàòåëüíûì ÷èñëîì");
- }
- else if (dateB[i].yearB != " ")
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + Zodiac(int.Parse(dateB[i].dayB), int.Parse(dateB[i].mounthB)) + ";" + "Ãîä íå ÿâëÿåòñÿ ÷èñëîì");
- }
- else if(isNumericYearDate == true)
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + Zodiac(int.Parse(dateB[i].dayB), int.Parse(dateB[i].mounthB)) + ";" + "Â ãîäå óêàçàíà ïîëíàÿ äàòà");
- }
- }
- else if (isNumericDay == false && isNumericMounth == false && isNumericYear == false)
- {
- if (dateB[i].dayB == "" && dateB[i].mounthB == "" && dateB[i].yearB == "")
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Äåíü è ìåñÿö íå óêàçàíû" + ";" + "Ãîä íå óêàçàí");
- }
- else if (dateB[i].dayB == "" && dateB[i].mounthB == "" && isNumericYearOtr == true)
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Äåíü è ìåñÿö íå óêàçàíû" + ";" + "Ãîä ÿâëÿåòñÿ îòðèöàòåëüíûì ÷èñëîì");
- }
- else if (dateB[i].dayB == "" && isNumericMounthOtr == true && dateB[i].yearB == "")
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Äåíü íå óêàçàí. Ìåñÿö ÿâëÿåòñÿ îòðèöàòåëüíûì ÷èñëîì" + ";" + "Ãîä íå óêàçàí");
- }
- else if (isNumericDayOtr == true && dateB[i].mounthB == "" && dateB[i].yearB == "")
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Äåíü ÿâëÿåòñÿ îòðèöàòåëüíûì ÷èñëîì. Ìåñÿö íå óêàçàí" + ";" + "Ãîä íå óêàçàí");
- }
- else if (isNumericDayDate == true && dateB[i].mounthB == "" && dateB[i].yearB == "")
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Â äíå óêàçàíà ïîëíàÿ äàòà. Ìåñÿö íå óêàçàí" + ";" + "Ãîä íå óêàçàí");
- }
- else if (dateB[i].dayB == "" && dateB[i].mounthB == "" && dateB[i].yearB != "")
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Äåíü è ìåñÿö íå óêàçàíû" + ";" + "Ãîä íå ÿâëÿåòñÿ ÷èñëîì");
- }
- else if (isNumericDayOtr == true && isNumericMounthOtr == true && isNumericYearOtr == true)
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Äåíü è ìåñÿö ÿâëÿþòñÿ îòðèöàòåëüíûìè ÷èñëàìè" + ";" + "Ãîä ÿâëÿåòñÿ îòðèöàòåëüíûì ÷èñëîì");
- }
- else if (isNumericDayDate == true && isNumericMounthDate == true && isNumericYearDate == true)
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Â äíå è ìåñÿöå óêàçàíà ïîëíàÿ äàòà" + ";" + "Â ãîäå óêàçàíà ïîëíàÿ äàòà");
- }
- else if(isNumericDayNotInt == true && isNumericMounthNotInt == true && isNumericYearNotInt == true)
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + " äíå è ìåñÿöå óêàçàíû íå ÷èñëà" + ";" + " ãîäå óêàçàíî íå ÷èñëî");
- }
- }
- else if (isNumericDay == false & isNumericMounth == false && isNumericYear == true)
- {
- if (dateB[i].dayB == "" && dateB[i].mounthB == "")
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Äåíü è ìåñÿö íå óêàçàíû" + ";" + Vostoch(int.Parse(dateB[i].yearB)));
- }
- else if (isNumericDayOtr == true && dateB[i].mounthB == "")
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Äåíü ÿâëÿåòñÿ îòðèöàòåëüíûì ÷èñëîì. Ìåñÿö íå óêàçàí" + ";" + Vostoch(int.Parse(dateB[i].yearB)));
- }
- else if (dateB[i].dayB == "" && isNumericMounthOtr == true)
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Äåíü íå óêàçàí. Ìåñÿö ÿâëÿåòñÿ îòðèöàòåëüíûì ÷èñëîì" + ";" + Vostoch(int.Parse(dateB[i].yearB)));
- }
- else if (dateB[i].dayB != "" && dateB[i].mounthB == "")
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Äåíü íå ÿâëÿåòñÿ ÷èñëîì. Ìåñÿö íå óêàçàí" + ";" + Vostoch(int.Parse(dateB[i].yearB)));
- }
- else if (dateB[i].dayB == "" && dateB[i].mounthB != "")
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Äåíü íå óêàçàí. Ìåñÿö íå ÿâëÿåòñÿ ÷èñëîì" + ";" + Vostoch(int.Parse(dateB[i].yearB)));
- }
- else if (isNumericDayOtr == true && isNumericMounthOtr == true)
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Äåíü è ìåñÿö ÿâëÿþòñÿ îòðèöàòåëüíûìè ÷èñëàìè" + ";" + Vostoch(int.Parse(dateB[i].yearB)));
- }
- }
- else if (isNumericDay == true & isNumericMounth == false && isNumericYear == false)
- {
- if (dateB[i].mounthB == "" && dateB[i].yearB == "")
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Ìåñÿö íå óêàçàí" + ";" + "Ãîä íå óêàçàí");
- }
- else if (isNumericMounthOtr == true && dateB[i].yearB == "")
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Ìåñÿö ÿâëÿåòñÿ îòðèöàòåëüíûì ÷èñëîì" + ";" + "Ãîä íå óêàçàí");
- }
- else if(isNumericMounthNotInt == true && dateB[i].yearB == "")
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Ìåñÿö ÿâëÿåòñÿ íå öåëûì ÷èñëì" + ";" + "Ãîä íå óêàçàí");
- }
- else if (isNumericMounthOtr == true && isNumericYearOtr == true)
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Ìåñÿö ÿâëÿåòñÿ îòðèöàòåëüíûì ÷èñëîì" + ";" + "Ãîä ÿâëÿåòñÿ îòðèöàòåëüíûì ÷èñëîì");
- }
- else if (dateB[i].mounthB != "" && isNumericYearOtr == true)
- {
- sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Ìåñÿö íå ÿâëÿåòñÿ ÷èñëîì" + ";" + "Ãîä ÿâëÿåòñÿ îòðèöàòåëüíûì ÷èñëîì");
- }
-
- }
- }
- };
- Process.Start(new ProcessStartInfo
- {
- FileName = "Output.csv",
- UseShellExecute = true
- });
- }
- else
- {
- Error.Text = "Âûáðàííûé ôàéë ïóñò";
- }
- }
- }
- }
- }
|