- Code:
using System;
class ConNguoi
{
public ConNguoi(string maSo, string ten, string hoLot, int soCon, string soDienThoai, DateTime ngaySinh)
{
this.maSo = maSo;
this.ten = ten;
this.hoLot = hoLot;
this.soCon = soCon;
this.soDienThoai = soDienThoai;
this.ngaySinh = ngaySinh;
}
public ConNguoi(string maSo, string ten, string hoLot, int soCon, DateTime ngaySinh)
{
this.maSo = maSo;
this.ten = ten;
this.hoLot = hoLot;
this.soCon = soCon;
this.soDienThoai = "Khong co so dien thoai";
this.ngaySinh = ngaySinh;
}
public ConNguoi(string maSo, string ten, string hoLot, string soDienThoai, DateTime ngaySinh)
{
this.maSo = maSo;
this.ten = ten;
this.hoLot = hoLot;
this.soDienThoai = soDienThoai;
this.ngaySinh = ngaySinh;
}
public ConNguoi(string maSo, string ten, string hoLot, DateTime ngaySinh)
{
this.maSo = maSo;
this.ten = ten;
this.hoLot = hoLot;
this.soDienThoai = "Khong co so dien thoai";
this.ngaySinh = ngaySinh;
}
public string getHoTen()
{
return hoLot + " " + ten;
}
public string getSoDienThoai()
{
return soDienThoai;
}
public DateTime getNgaySinh
{
get { return ngaySinh; }
set { ngaySinh = value; }
}
public void getChiTiet()
{
Console.WriteLine("\t\tMa so: " + maSo);
Console.WriteLine("Ho ten: " + getHoTen());
Console.WriteLine("So con: " + soCon);
Console.WriteLine("So dien thoai: " + soDienThoai);
Console.WriteLine("Ngay sinh: {0}/{1}/{2}", ngaySinh.Day, ngaySinh.Month, ngaySinh.Year);
}
public string getMaSo()
{
return maSo;
}
string maSo;
string ten;
string hoLot;
int soCon;
string soDienThoai;
DateTime ngaySinh;
}
- Code:
using System;
class NhanVien:ConNguoi
{
public NhanVien(string maSo, string ten, string hoLot, int soCon, string soDienThoai, DateTime ngaySinh, DateTime ngayVaoCongTy, float heSoLuong, int luongCoBan)
: base(maSo, ten, hoLot, soCon, soDienThoai, ngaySinh)
{
this.ngayVaoCongTy = ngayVaoCongTy;
this.heSoLuong = heSoLuong;
this.luongCoBan = luongCoBan;
}
public NhanVien(string maSo, string ten, string hoLot, int soCon, DateTime ngaySinh, DateTime ngayVaoCongTy, float heSoLuong, int luongCoBan)
: base(maSo, ten, hoLot, soCon, ngaySinh)
{
this.ngayVaoCongTy = ngayVaoCongTy;
this.heSoLuong = heSoLuong;
this.luongCoBan = luongCoBan;
}
public NhanVien(string maSo, string ten, string hoLot, string soDienThoai, DateTime ngaySinh, DateTime ngayVaoCongTy, float heSoLuong, int luongCoBan)
: base(maSo, ten, hoLot, soDienThoai, ngaySinh)
{
this.ngayVaoCongTy = ngayVaoCongTy;
this.heSoLuong = heSoLuong;
this.luongCoBan = luongCoBan;
}
public NhanVien(string maSo, string ten, string hoLot, DateTime ngaySinh, DateTime ngayVaoCongTy, float heSoLuong, int luongCoBan)
: base(maSo, ten, hoLot, ngaySinh)
{
this.ngayVaoCongTy = ngayVaoCongTy;
this.heSoLuong = heSoLuong;
this.luongCoBan = luongCoBan;
}
public void HienThi()
{
Console.WriteLine("Ngay vao cong ty: {0}/{1}/{2}", ngayVaoCongTy.Day, ngayVaoCongTy.Month, ngayVaoCongTy.Year);
Console.WriteLine("He so luong: {0}", heSoLuong);
Console.WriteLine("Luong co ban: {0}", luongCoBan);
}
public DateTime NgayVaoCongTy
{
get { return ngayVaoCongTy; }
set { ngayVaoCongTy = value; }
}
public float HeSoLuong
{
get { return heSoLuong; }
set { heSoLuong = value; }
}
public int LuongCoBan
{
get { return luongCoBan; }
set { luongCoBan = value; }
}
DateTime ngayVaoCongTy;
float heSoLuong;
int luongCoBan;
}
- Code:
using System;
class TienLuong : NhanVien
{
public TienLuong(string maSo, string ten, string hoLot, int soCon, string soDienThoai, DateTime ngaySinh, DateTime ngayVaoCongTy, float heSoLuong, int LuongCoBan, string viTriNhanVien, float heSoChucVu)
: base(maSo, ten, hoLot, soCon, soDienThoai, ngaySinh, ngayVaoCongTy, heSoLuong, LuongCoBan)
{
this.viTriNhanVien = viTriNhanVien;
this.heSoChucVu = heSoChucVu;
}
public TienLuong(string maSo, string ten, string hoLot, int soCon, string soDienThoai, DateTime ngaySinh, DateTime ngayVaoCongTy, float heSoLuong, int LuongCoBan, int gioDay, int thuLaoGiangDay)
: base(maSo, ten, hoLot, soCon, soDienThoai, ngaySinh, ngayVaoCongTy, heSoLuong, LuongCoBan)
{
this.viTriNhanVien = "Giang vien";
this.gioDay = gioDay;
this.thuLaoGiangDay = thuLaoGiangDay;
}
public TienLuong(string maSo, string ten, string hoLot, int soCon, DateTime ngaySinh, DateTime ngayVaoCongTy, float heSoLuong, int luongCoBan, string viTriNhanVien, float heSoChucVu)
: base(maSo, ten, hoLot, soCon, ngaySinh, ngayVaoCongTy, heSoLuong, luongCoBan)
{
this.viTriNhanVien = viTriNhanVien;
this.heSoChucVu = heSoChucVu;
}
public TienLuong(string maSo, string ten, string hoLot, int soCon, DateTime ngaySinh, DateTime ngayVaoCongTy, float heSoLuong, int luongCoBan, int gioDay, int thuLaoGiangDay)
: base(maSo, ten, hoLot, soCon, ngaySinh, ngayVaoCongTy, heSoLuong, luongCoBan)
{
this.viTriNhanVien = "Giang vien";
this.gioDay = gioDay;
this.thuLaoGiangDay = thuLaoGiangDay;
}
public TienLuong(string maSo, string ten, string hoLot, string soDienThoai, DateTime ngaySinh, DateTime ngayVaoCongTy, float heSoLuong, int luongCoBan, string viTriNhanVien, float heSoChucVu)
: base(maSo, ten, hoLot, soDienThoai, ngaySinh, ngayVaoCongTy, heSoLuong, luongCoBan)
{
this.viTriNhanVien = viTriNhanVien;
this.heSoChucVu = heSoChucVu;
}
public TienLuong(string maSo, string ten, string hoLot, string soDienThoai, DateTime ngaySinh, DateTime ngayVaoCongTy, float heSoLuong, int luongCoBan, int gioDay, int thuLaoGiangDay)
: base(maSo, ten, hoLot, soDienThoai, ngaySinh, ngayVaoCongTy, heSoLuong, luongCoBan)
{
this.viTriNhanVien = "Giang vien";
this.gioDay = gioDay;
this.thuLaoGiangDay = thuLaoGiangDay;
}
public TienLuong(string maSo, string ten, string hoLot, DateTime ngaySinh, DateTime ngayVaoCongTy, float heSoLuong, int luongCoBan, string viTriNhanVien, float heSoChucVu)
: base(maSo, ten, hoLot, ngaySinh, ngayVaoCongTy, heSoLuong, luongCoBan)
{
this.viTriNhanVien = viTriNhanVien;
this.heSoChucVu = heSoChucVu;
}
public TienLuong(string maSo, string ten, string hoLot, DateTime ngaySinh, DateTime ngayVaoCongTy, float heSoLuong, int luongCoBan, int gioDay, int thuLaoGiangDay)
: base(maSo, ten, hoLot, ngaySinh, ngayVaoCongTy, heSoLuong, luongCoBan)
{
this.viTriNhanVien = "Giang vien";
this.gioDay = gioDay;
this.thuLaoGiangDay = thuLaoGiangDay;
}
public int ThamNien()
{
int soThang, soNam;
DateTime tgHienTai = DateTime.Now;
soThang = (tgHienTai.Year - NgayVaoCongTy.Year) * 12 + (tgHienTai.Month - NgayVaoCongTy.Month);
soNam = soThang / 12;
if (soThang % 12 > 5)
soNam++;
return soNam;
}
public int TienThuong()
{
double tienThuong;
if (ThamNien() < 1)
tienThuong = 0;
if (ThamNien() >= 1 && ThamNien() < 6)
tienThuong = ThamNien() * LuongCoBan;
else
tienThuong = 6 * LuongCoBan;
return (int)tienThuong;
}
public int TienLuongTruocThue()
{
return (int)(TienThuong() + HeSoLuong * LuongCoBan);
}
public int TienBaoHiem()
{
return (int)(0.07 * HeSoLuong * LuongCoBan);
}
public int ThuNhapChiuThue()
{
double giamTruGiaCanh = 4000000, tienThue;
tienThue = TienLuongTruocThue() - giamTruGiaCanh - TienBaoHiem();
if (tienThue < 0)
tienThue = 0;
return (int)tienThue;
}
public int TienThueThuNhapCaNhan()
{
double tien, trieu = 1000000;
if (ThuNhapChiuThue() <= 5 * trieu)
tien = 0.05 * ThuNhapChiuThue();
else
if (ThuNhapChiuThue() > 5 * trieu && ThuNhapChiuThue() <= 10 * trieu)
tien = 0.05 * 5 * trieu + (ThuNhapChiuThue() - 5 * trieu) * 0.1;
else
if (ThuNhapChiuThue() > 10 * trieu && ThuNhapChiuThue() <= 18 * trieu)
tien = 0.15 * (5 * trieu + ThuNhapChiuThue() - 10 * trieu);
else
if (ThuNhapChiuThue() > 18 * trieu && ThuNhapChiuThue() <= 32 * trieu)
tien = 0.15 * 13 * trieu + (ThuNhapChiuThue() - 18 * trieu) * 0.2;
else
if (ThuNhapChiuThue() > 32 * trieu && ThuNhapChiuThue() <= 52 * trieu)
tien = 0.15 * 13 * trieu + 0.20 * 14 * trieu + (ThuNhapChiuThue() - 32 * trieu) * 0.25;
else
if (ThuNhapChiuThue() > 52 * trieu && ThuNhapChiuThue() <= 80 * trieu)
tien = 0.15 * 13 * trieu + 0.20 * 14 * trieu + 0.25 * 20 * trieu + (ThuNhapChiuThue() - 52 * trieu) * 0.3;
else
tien = 0.15 * 13 * trieu + 0.20 * 14 * trieu + 0.25 * 20 * trieu + 0.3 * 28 * trieu + (ThuNhapChiuThue() - 80 * trieu) * 0.35;
return (int)tien;
}
public int TienThuLao()
{
double tien=0;
if (viTriNhanVien == "Giang vien")
{
if (gioDay > 80)
tien = HeSoLuong * LuongCoBan * 2 / 80 * (gioDay - 80) * thuLaoGiangDay;
}
else
{
if (viTriNhanVien == "Truong phong" || viTriNhanVien == "Pho phong")
tien = 0.4 * LuongCoBan * heSoChucVu;
}
return (int)tien;
}
public int TienLuongThucLanh()
{
double tien, trieu = 1000000;
tien = TienLuongTruocThue() +TienThuLao() - TienBaoHiem() - TienThueThuNhapCaNhan();
if (tien < 2 * trieu)
tien = 2 * trieu;
return (int)tien;
}
public void ThongTinNhanVien()
{
getChiTiet();
HienThi();
Console.WriteLine("Vi tri nhan vien: "+ viTriNhanVien);
Console.WriteLine("He so chuc vu: "+ heSoChucVu);
Console.WriteLine("Gio day: "+ gioDay);
Console.WriteLine("Tien thu lao tren tiet: "+ thuLaoGiangDay);
Console.WriteLine("Tham nien: "+ ThamNien());
Console.WriteLine("Tien thuong: "+TienThuong());
Console.WriteLine("Tien luong truoc thue: "+ TienLuongTruocThue());
Console.WriteLine("Tien bao hiem: "+ TienBaoHiem());
Console.WriteLine("Thu nhap chiu thue: "+ ThuNhapChiuThue());
Console.WriteLine("Tien thue thu nhap ca nhan: "+ TienThueThuNhapCaNhan());
Console.WriteLine("Tien thu lao day them gio: "+ TienThuLao());
Console.WriteLine("Tien luong thuc lanh: "+TienLuongThucLanh());
Console.WriteLine();
}
string viTriNhanVien;
float heSoChucVu;
int gioDay;
int thuLaoGiangDay;
}
- Code:
using System;
class tester
{
public static void Main()
{
TienLuong[] t= new TienLuong[8];
t[0] = new TienLuong("NV1", "Hai", "Nguyen Thanh", 2, "01223446447", new DateTime(1960, 10, 23), new DateTime(1985, 3, 5),(float) 5.2, 620000, "Hieu truong", (float)2.5);
t[1] = new TienLuong("NV2", "Thuy", "Bui Thi", 1, "0938675643", new DateTime(1962, 1, 15), new DateTime(1988, 8, 1), (float)3.7, 620000, "Hieu pho", (float)2);
t[2] = new TienLuong("NV3", "Tuan", "Tran Anh", 2, "0978245256", new DateTime(1960, 5, 6), new DateTime(181, 9, 14), (float)4.9, 620000, "Hieu pho", (float)2);
t[3] = new TienLuong("NV4", "Vu", "Nguyen Hoai", "0978223546", new DateTime(1978, 2, 19), new DateTime(1992, 5, 29), (float)3.2, 540000, 102, 350000);
t[4] = new TienLuong("NV5", "Nga", "Tran Thuy", 1,"0913223897", new DateTime(1977,4, 25), new DateTime(1994, 11, 30), (float)2.9, 540000, 90, 27000);
t[5] = new TienLuong("NV6", "Oanh", "Bui Kim", new DateTime(1967, 7,27), new DateTime(1980, 7, 6), (float)4.5, 540000, 125, 450000);
t[6] = new TienLuong("NV7", "Nam", "Do Thanh", "122267899346", new DateTime(1980, 4, 26), new DateTime(2000, 12,3), (float)2.4, 620000, "Nhan vien hanh chanh",(float)2.1);
t[7] = new TienLuong("NV8", "Hong", "Mai Thi", new DateTime(1982, 8, 9), new DateTime(2005, 3, 21), (float)2.0, 620000, "Nhan vien hanh chanh", (float)2.1);
Console.WriteLine("\t\tThong tin nhan vien trong truong hoc");
foreach (TienLuong n in t)
n.ThongTinNhanVien();
Console.ReadLine();
}
}