You are on page 1of 7

#include <iostream>

#include <fstream>

#include <string>

#include <vector>

using namespace std;

struct NhanVien

int manhanvien;

string tennhanvien;

string gioitinh;

int ntnamsinh;

string tthonnhan;

int hesoluong;

int sdt;

string bophanlamviec;

int tuoi;

};

void Menuchinh()

cout << "-------------------------\n";

cout << "Quan Li Nhan Vien\n";

cout << "-------------------------\n";

cout << "1. Menu Quan Li Nhan Vien\n";

cout << "2. Thoat ra\n";

cout << "Nhap Lua Chon Cua Ban: ";

}
void themnhanvien(vector<NhanVien>& NV) {

NhanVien NVien;

cout << "Nhap Ma NV ";

cin >> NVien.manhanvien;

cout << "Nhap Ten Nhan Vien: ";

cin >> NVien.tennhanvien;

cout << "Nhap Gioi Tinh (Nam/Nu): ";

cin >> NVien.gioitinh;

cout << "Nhap Ngay Sinh (dd/mm/yyyy): ";

cin >> NVien.ntnamsinh;

cout << "Nhap Tinh Trang Hon Nhan (docthan/dacuoi): ";

cin >> NVien.tthonnhan;

NV.push_back(NVien);

cout << "Nhan Vien Da Duoc Them\n";

void capnhat(vector<NhanVien>& NV) {

int manv;

cout << "Nhap Ma Nhan Vien Can Cap Nhat: ";

cin >> manv;

bool timthay = false;

for (int i = 0; i < NV.size(); i++) {

if (NV[i].manhanvien == manv) {

timthay = true;

cout << "Nhap thong tin moi cho nhan vien: " << NV[i].tennhanvien << endl;

cout << "Nhap Ten Nhan Vien: ";

cin >> NV[i].tennhanvien;

cout << "Nhap Gioi Tinh (Nam/Nu): ";

cin >> NV[i].gioitinh;

cout << "Nhap Ngay Sinh (dd/mm/yyyy): ";


cin >> NV[i].ntnamsinh;

cout << "Nhap Tinh Trang Hon Nhan (docthan/dacuoi): ";

cin >> NV[i].tthonnhan;

cout << "Nhap Bo Phan Lam Viec: ";

cin >> NV[i].bophanlamviec;

cout << "Nhap He So Luong: ";

cin >> NV[i].hesoluong;

cout << "Nhap So Dien Thoai: ";

cin >> NV[i].sdt;

NV[i].tuoi = 2023 - NV[i].ntnamsinh;

cout << "Thong Tin Nhan Vien Da Duoc Cap Nhat.\n";

break;

if (!timthay) {

cout << "Khong Tim Thay Nhan Vien Can Cap Nhat.\n";

void MenuquanliNV()

vector<NhanVien> NV;

int luachon;

do

cout << "-------------------------\n";

cout << "Menu Nhan Vien\n";

cout << "-------------------------\n";

cout << "1. Them Nhan Vien\n";


cout << "2. Cap Nhat Nhan Vien\n";

cout << "3. Xóa Nhan Vien\n";

cout << "4. Sap Xep Theo Ten Nhan Vien\n";

cout << "5. Tim Nhan Vien\n";

cout << "6. Tro Lai Man Hinh Chinh\n";

cout << "Nhap Lua Chon Cua Ban: ";

cin>>luachon;

switch (luachon) {

case 1:

themnhanvien(NV);

break;

case 2:

capnhat(NV);

break;

// case 3:

// xoanhanvien(NV);

// break;

// case 4:

// sapxep(NV);

// break;

// case 5:

// timkiem(NV);

// break;

case 6:

cout << "Tro Ve Man Hinh Chinh\n";

break;

default:

cout << "Ban Da Nhap Sai. Vui Long Nhap Lai\n";

break;

} while (luachon != 6);


}

int main(int argc, char** argv) {

vector<NhanVien> NVien;

int luachon;

do {

cout << "-------------------------\n";

cout << "He Thong Quan Li Nhan Vien\n";

cout << "-------------------------\n";

cout << "1. Display Employees\n";

cout << "2. Them Nhan Vien\n";

cout << "3. Cap Nhat Nhan Vien\n";

cout << "4. Xoa Nhan Vien\n";

cout << "5. Sap Xep Nhan vien\n";

cout << "6. Tim Nhan Vien\n";

cout << "7. Count Employees by Department\n";

cout << "8. Filter Employees by Gender\n";

cout << "9. Count Employees by Age\n";

cout << "10. Exit\n";

cout << "Enter your choice: ";

cin >> luachon;

switch (luachon) {

case 1:

Menuchinh(NV);

break;

case 2:

themnhanvien(NV);

break;

case 3:
capnhatnhanvien(NV);

break;

case 4:

xoanhanvien(NV);

break;

case 5:

sapxep(NV);

break;

case 6:

timkiem(employees);

break;

case 7:

count_employee_by_department(employees);

break;

case 8:

filter_employee_by_gender(employees);

break;

case 9:

count_employee_by_age(employees);

break;

case 10:

cout << "Thoat Chuong Trinh...\n";

break;

default:

cout << "Lua Chon Khong Hop Le, Thu lai\n";

break;

} while (luachon != 10);

return 0;
return 0;

You might also like