1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
|
#include <iostream>
#include <string>
#include <fstream>
#include <cstdio>
using namespace std;
void input();
void search();
int displayAll();
void fired();
void searchByDate();
int main() {
int choice;
system("cls");
system("title Angajati Grivita");
system("color 0f");
cout << "--------------------Meniu--------------------" << endl;
cout << "1. Adauga angajat." << endl;
cout << "2. Cauta angajat si arata informatii despre el." << endl;
cout << "3. Arata toti angajatii." << endl;
cout << "4. Sterge un angajat." << endl;
cout << "5. Cauta un angajat dupa..." << endl;
cout << "Raspuns: ";
cin >> choice;
if (choice < 6) {
switch (choice) {
case 1:
system("color E");
input();
break;
case 2:
system("color B");
search();
break;
case 3:
system("color A");
displayAll();
break;
case 4:
system("color C");
fired();
break;
case 5:
system("color D");
searchByDate();
break;
case 6:
return 0;
break;
}
}
else if (choice > 6) {
return 0;
}
}
void input() {
system("cls");
string fname;
string lname;
string functie;
string calificare;
string filename;
string ques;
int empId, age, dataNasterii, dataAngajarii, zileConcediu, salariu;
long long codNumeric;
//Intrebarile pentru a adauga un angajat.
cout << "Introdu numele de familie al angajatului: ";
cin >> fname;
cout << "Introdu prenumele angajatului: ";
cin >> lname;
cout << "Introdu functia angajatului: ";
cin >> functie;
cout << "Introdu calificarea angajatului: ";
cin >> calificare;
cout << "Creeaza-i un numar matricol: ";
cin >> empId;
cout << "Introdu data nasterii angajatului: ";
cin >> dataNasterii;
cout << "Introdu varsta angajatului: ";
cin >> age;
cout << "Introdu data angajarii angajatului: ";
cin >> dataAngajarii;
cout << "Introdu cate zile de concediu are angajatul: ";
cin >> zileConcediu;
cout << "Introdu CNP-ul angajatului: ";
cin >> codNumeric;
cout << "Introdu Salariul angajatului: ";
cin >> salariu;
string empId2 = to_string(empId);
empId2.append(".txt");
ofstream newemployee(empId2);
newemployee << fname << " " << lname << " " << functie << " " << calificare << " " << empId << " " << dataNasterii << " " << age << " " << salariu << " " << dataAngajarii << " " << zileConcediu << " " << codNumeric << endl;
newemployee.close();
ofstream dir("directory.txt", ios::app);
dir << fname << " " << lname << " " << functie << " " << calificare << " " << empId << " " << dataNasterii << " " << age << " " << salariu << " " << dataAngajarii << " " << zileConcediu << " " << codNumeric << endl;
dir.close();
system("cls");
main();
}
void search() {
system("cls");
string fname;
string lname;
string functie;
string calificare;
string filename;
string ques;
int empId, dataNasterii, age, dataAngajarii, zileConcediu, salariu, thrw;
long long codNumeric;
cout << "Introdu numarul matricol al angajatului dorit: ";
cin >> empId;
string empId2 = to_string(empId);
empId2.append(".txt");
ifstream newemployee(empId2);
while (newemployee >> fname >> lname >> functie >> calificare >> thrw >> dataNasterii >> age >> salariu >> dataAngajarii >> zileConcediu >> codNumeric) {
int fnameLenght = fname.size();
int lnameLenght = lname.size();
int totalLenght = fnameLenght + lnameLenght;
string answer;
cout << "Acesta este angajatul cautat? [y/n]" << endl;
cout << fname << " " << lname << endl;
cin >> answer;
if (answer == "y" || answer == "Y") {
system("cls");
cout << "Nume: " << fname << " " << lname << endl;
cout << "Varsta: " << age << endl;
cout << "Salariul: " << salariu << endl;
cout << "Functie: " << functie << endl;
cout << "Calificare: " << calificare << endl;
cout << "Numar Matricol: " << empId << endl;
cout << "Cod numeric: " << codNumeric << endl;
string answer2;
cout << "Vrei sa te intorci la meniu? [y/n] "; cin >> answer2;
if (answer2 == "y" || answer2 == "Y") {
main();
}
else if (answer2 == "n" || answer2 == "N") {
search();
}
main();
}
else if (answer == "n" || answer == "N")
search();
}
}
int displayAll() {
system("cls");
string fname;
string lname;
string functie;
string calificare;
string filename;
string ques;
string answer2;
int empId, dataNasterii, age, dataAngajarii, zileConcediu, salariu, thrw;
long long codNumeric;
cout << "Lista cu toti angajatii" << endl;
cout << "-----------------------" << endl;
ifstream dir("directory.txt");
while (dir >> fname >> lname >> functie >> calificare >> empId >> dataNasterii >> age >> salariu >> dataAngajarii >> zileConcediu >> codNumeric) {
cout << "Nume: " << fname << " " << lname << endl;
cout << "Functie: " << functie << endl;
cout << "Calificare: " << calificare << endl;
cout << "Numar matricol: " << empId << endl;
cout << "Data nasterii: " << dataNasterii << endl;
cout << "Varsta: " << age << " ani" << endl;
cout << "Salariu: " << salariu << " lei " << endl;
cout << "Data angajarii: " << dataAngajarii << endl;
cout << "Zile concediu: " << zileConcediu << endl;
cout << "CNP: " << codNumeric << endl;
cout << " " << endl;
}
cout << "Vrei sa mergi la meniu?[y,n], daca alegi 'n' programul se inchide: "; cin >> answer2;
if (answer2 == "y" || answer2 == "Y") {
main();
}
else if (answer2 == "n" || answer2 == "N")
return 0;
}
void searchByDate(){
system("cls");
string fname;
string lname;
string functie;
string calificare;
string filename;
string ques;
long long ziDeNastere; // , anComun, zileConcediu2, salariu2, varsta;
int empId, dataNasterii, age, dataAngajarii, zileConcediu, salariu, thrw, decision;
long long codNumeric;
cout << "Vrei sa vezi care sunt angajatii care au: \n1.Data de nastere comuna \n2.An de nastere comun\n3.Acelasi numar de zile de concediu\n4.Acelasi salariu\n5.Aceeasi varsta.\n Raspuns: ";
cin >> decision;
if (decision < 6) {
switch (decision) {
case 1:
system("cls");
cout << "Introdu data de nastere care te intereseaza: "; cin >> ziDeNastere;
ifstream dir("directory.txt");
while (dir >> fname >> lname >> functie >> calificare >> empId >> dataNasterii >> age >> salariu >> dataAngajarii >> zileConcediu >> codNumeric) {
system("cls");
if (ziDeNastere == dataNasterii) {
string decision2;
cout << fname << " " << lname << endl;
cout << "Vrei sa mai cauti angajati dupa anumite criterii? [y/n] \n Raspuns: "; cin >> decision2;
if (decision2 == "y" || decision2 == "Y") {
searchByDate();
}
else if (decision2 == "n" || decision2 == "N") {
main();
}
}
else if (ziDeNastere != dataNasterii) {
cout << "Nu sunt angajati nascuti in aceeasi data." << endl;
string decision3;
cout << "Vrei sa cauti iar? [y,n]";
cin >> decision3;
if (decision3 == "y" || decision3 == "Y") {
searchByDate();
}
else if (decision3 == "n" || decision3 == "") {
main();
}
}
}
break;
}
}
else if (decision > 6) {
string decision4;
system("cls");
cout << "Nu exista acea categorie. Vrei sa reiei procedura? [y,n]";
cin >> decision4;
if (decision4 == "y" || decision4 == "Y") {
searchByDate();
}
else if (decision4 == "n" || decision4 == "N") {
main();
}
}
}
|