Glenpl

kalendarz

Nov 20th, 2014
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 8.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <conio.h>
  4. #include <windows.h>
  5. #include "czas.h"
  6. #include "obsluga_pliku.h"
  7.  
  8. HANDLE u = GetStdHandle(STD_OUTPUT_HANDLE);
  9. #define kolor SetConsoleTextAttribute
  10.  
  11. using namespace std;
  12.  
  13. int main()
  14. {
  15.     // main objects of 'czas' class, used in
  16.     // main menu and submenu 'kalendarz'
  17.     czas zegarek, path;
  18.  
  19.     zegarek.aktualizuj_czas();
  20.     // it will serve text files
  21.     obsluga_pliku plik(zegarek.data_raw());
  22.  
  23.     for(;;)
  24.     {
  25.         char a;
  26.         do
  27.         {
  28.             bool plan,note;
  29.             system("cls");
  30.             zegarek.aktualizuj_czas();
  31.             path.aktualizuj_czas();
  32.             kolor(u,8);
  33.             cout<<"                         ";
  34.             cout<<zegarek.dayweek_nd()<<", "<<zegarek.data_full();
  35.             kolor(u,7);
  36.             cout<<endl<<endl<<"Plan na dzisiaj: "<<endl<<endl;
  37.             obsluga_pliku plik(zegarek.data_raw());
  38.             plan = plik.file_empty();
  39.             plik.file_wyswietl();
  40.             plik.changepath(zegarek.data_raw() + "n");
  41.             plik.file_wyswietl();
  42.             note = plik.file_empty();
  43.             if(plan)
  44.             {
  45.                 cout<<"Brak planow ";
  46.                 if(note)
  47.                     cout<<"i notatek";
  48.             }
  49.  
  50.             kolor(u,8);
  51.             cout<<"-----------------------------------------";
  52.             cout<<"---------------------------------------\n";
  53.             kolor(u,7);
  54.             cout<<"Plan na jutro: "<<endl<<endl;
  55.             path.set_dzien((path.get_dzien()) +1);
  56.             path.fix_czas();
  57.             plik.changepath(path.data_raw());
  58.             plik.file_wyswietl();
  59.             plan = plik.file_empty();
  60.             plik.changepath(path.data_raw() + "n");
  61.             plik.file_wyswietl();
  62.             note = plik.file_empty();
  63.             if(plan)
  64.             {
  65.                 cout<<"Brak planow ";
  66.                 if(note)
  67.                     cout<<"i notatek";
  68.             }
  69.  
  70.             kolor(u,8);
  71.             cout<<"-----------------------------------------";
  72.             cout<<"---------------------------------------\n";
  73.             kolor(u,7);
  74.             cout<<"Plan na pojutrze: "<<endl<<endl;
  75.             path.set_dzien((path.get_dzien()) +1);
  76.             path.fix_czas();
  77.             plik.changepath(path.data_raw());
  78.             plik.file_wyswietl();
  79.             plan = plik.file_empty();
  80.             plik.changepath(path.data_raw() + "n");
  81.             plik.file_wyswietl();
  82.             note = plik.file_empty();
  83.             if(plan)
  84.             {
  85.                 cout<<"Brak planow ";
  86.                 if(note)
  87.                     cout<<"i notatek";
  88.             }
  89.  
  90.             kolor(u,8);
  91.             cout<<"\n----------------------------------------";
  92.             cout<<"----------------------------------------\n";
  93.             kolor(u,7);
  94.             cout<<"1. Pokaz pelny kalendarz\n";
  95.             cout<<"2. Zarzadzaj notatkami\n";
  96.             cout<<"3. Generuj plany\n";
  97.             cout<<"4. Ustawienia\n\n";
  98.             kolor(u,8);
  99.             cout<<"Twoj wybor: ";
  100.             a = getch();
  101.         }
  102.         while((a != '1') && (a != '2') && (a != '3') && (a != '4'));
  103.  
  104.         system("cls");
  105.         kolor(u,8);
  106.         cout<<"                         ";
  107.         cout<<zegarek.dayweek_nd()<<", "<<zegarek.data_full();
  108.         kolor(u,7);
  109.  
  110.         //kalendarz
  111.         if(a == '1')
  112.         {
  113.             string jak;
  114.             int jak_dlugo = -1;
  115.             do
  116.             {
  117.                 system("cls");
  118.                 kolor(u,8);
  119.                 cout<<"                        ";
  120.                 cout<<zegarek.dayweek_nd()<<", "<<zegarek.data_full();
  121.                 kolor(u,7);
  122.                 cout<<"\n\nNa ile dni kalendarz wyswietlic (1-365): ";
  123.                 cin>>jak;
  124.                 jak_dlugo = stoi(jak);
  125.                 for(unsigned i = 0; i < jak.length(); i++)
  126.                     if((jak[i] > 57) || (jak[i] < 47))
  127.                         jak_dlugo = 1000;
  128.             }
  129.             while(jak_dlugo < 1 || jak_dlugo > 365);
  130.  
  131.             path.aktualizuj_czas();
  132.             path.set_dzien(path.get_dzien() - 1);
  133.  
  134.             for(int i = 0; i < jak_dlugo; i++)
  135.             {
  136.                 path.set_dzien((path.get_dzien()) + 1);
  137.                 path.fix_czas();
  138.                 plik.changepath(path.data_raw());
  139.                 bool c = false;
  140.                 if(!plik.file_empty())
  141.                 {
  142.                     c = true;
  143.                     cout<<endl;
  144.                     cout<<path.data()<<", "<<path.dayweek_nm()<<"\n";
  145.                     plik.file_wyswietl();
  146.                 }
  147.                 plik.changepath(path.data_raw() + "n");
  148.                 if(!plik.file_empty())
  149.                 {
  150.                     if(c == false)
  151.                     {
  152.                         cout<<endl;
  153.                         cout<<path.data()<<", "<<path.dayweek_nm()<<"\n";
  154.                     }
  155.                     plik.file_wyswietl();
  156.                 }
  157.             }
  158.  
  159.             cout<<endl<<endl<<"Nacisnij 'ESC' aby zamknac kalendarz.";
  160.             char b;
  161.             do
  162.             {
  163.                 b = getch();
  164.             }
  165.             while(b != 27);
  166.         }
  167.         //notatki
  168.         if(a == '2')
  169.         {
  170.             for(;;)
  171.             {
  172.                 cout<<endl<<endl;
  173.                 cout<<"1. Dodaj notatke\n";
  174.                 cout<<"2. Edytuj notatke\n";
  175.                 cout<<"3. Usun notatke\n";
  176.                 cout<<"4. Anuluj\n\n";
  177.  
  178.                 kolor(u,8);
  179.                 cout<<"Twoj wybor: ";
  180.                 kolor(u,7);
  181.                 char b;
  182.                 b = getch();
  183.  
  184.                 if(b == '4')
  185.                     break;
  186.  
  187.                 else if ((b == '1')||(b == '2')||(b == '3'))
  188.                 {
  189.                     czas notatka_zeg;
  190.                     notatka_zeg.aktualizuj_czas();
  191.                     obsluga_pliku notatka(notatka_zeg.data_raw());
  192.  
  193.                     string data_notatki;
  194.                     cout<<endl<<endl;
  195.                     cout<<"Podaj date notatki (RRRR.MM.DD): ";
  196.                     cin>>data_notatki;
  197.  
  198.                     notatka_zeg.set_rok(stoi(data_notatki.substr(0,4)));
  199.                     data_notatki.erase(0,5);
  200.                     notatka_zeg.set_miesiac(stoi(data_notatki.substr(0,2)));
  201.                     data_notatki.erase(0,3);
  202.                     notatka_zeg.set_dzien(stoi(data_notatki.substr(0,2)));
  203.                     data_notatki.erase(0,2);
  204.  
  205.                     notatka.changepath(notatka_zeg.data_raw() + "n");
  206.  
  207.                     cout<<endl<<endl<<notatka.filepath_show();
  208.  
  209.                     if(b == '1')
  210.                     {
  211.                         notatka.file_wyswietl();
  212.                         cout<<"\n\nPlik utworzony!\n\n"<<"Czy chcesz go teraz edytowac?";
  213.                         cout<<"\n1. Nie";
  214.                         cout<<"\n2. Tak";
  215.                         kolor(u,8);
  216.                         cout<<"\n\nTwoj wybor: ";
  217.                         kolor(u,7);
  218.                         b = getch();
  219.                     }
  220.                     if(b == '2')
  221.                     {
  222.                         break;
  223.                     }
  224.                     if(b == '3')
  225.                     {
  226.                         notatka.file_remove();
  227.                         cout<<"\n\nNotatka usunieta!";
  228.                         getch();
  229.                         break;
  230.                     }
  231.                 }
  232.                 else
  233.                 {
  234.                     cout<<"\n\nNie ma takiej opcji!";
  235.                     getch();
  236.                 }
  237.             }
  238.         }
  239.         //generator planu
  240.         if(a == '3')
  241.         {
  242.  
  243.         }
  244.         //ustawienia
  245.         if(a == '4')
  246.         {
  247.             cout<<endl<<endl;
  248.             cout<<"1. Edytuj schemat dnia\n";
  249.             cout<<"2. Edytuj kolory napisow menu\n";
  250.             cout<<"3. Edytuj kolory notatek\n";
  251.             cout<<"4. Edytuj kolory planow dnia\n";
  252.             cout<<"5. Edytuj opcje generatora planow\n";
  253.             cout<<"6. Zaawansowane\n\n";
  254.             kolor(u,8);
  255.             cout<<"Twoj wybor: ";
  256.             char b;
  257.             b = getch();
  258.  
  259.             if(b == '1')
  260.             {
  261.             }
  262.             if(b == '2')
  263.             {
  264.             }
  265.             if(b == '3')
  266.             {
  267.             }
  268.             if(b == '4')
  269.             {
  270.             }
  271.             if(b == '5')
  272.             {
  273.             }
  274.             if(b == '6')
  275.             {
  276.             }
  277.         }
  278.     }
  279.  
  280.     getch();
  281.     return 0;
  282. }
Advertisement
Add Comment
Please, Sign In to add comment