Bài này lâu rùi post lên cho mọi người xem có sai sót gì thì pm cho mình nha
- Code:
using System;
public class NhanVien
{
// Khởi dựng (bước 2)
public NhanVien(string maSo, string hoVaTen, DateTime ngaySinh, DateTime ngayVaoCongTy, string soDienThoai, float heSoLuong, int luongCoBan)
{
this.maSo = maSo;
this.hoVaTen = hoVaTen;
this.ngaySinh = ngaySinh;
this.ngayVaoCongTy = ngayVaoCongTy;
this.soDienThoai = soDienThoai;
this.heSoLuong = heSoLuong;
NhanVien.luongCoBan = luongCoBan;
}
public NhanVien(string maSo, string hoVaTen, DateTime ngaySinh, DateTime ngayVaoCongTy, string soDienThoai, float heSoLuong)
{
this.maSo = maSo;
this.hoVaTen = hoVaTen;
this.ngaySinh = ngaySinh;
this.ngayVaoCongTy = ngayVaoCongTy;
this.soDienThoai = soDienThoai;
this.heSoLuong = heSoLuong;
luongCoBan = 0;
}
public NhanVien(string maSo, string hoVaTen, DateTime ngaySinh, DateTime ngayVaoCongTy, float heSoLuong, int luongCoBan)
{
this.maSo = maSo;
this.hoVaTen = hoVaTen;
this.ngaySinh = ngaySinh;
this.ngayVaoCongTy = ngayVaoCongTy;
this.heSoLuong = heSoLuong;
NhanVien.luongCoBan = luongCoBan;
this.soDienThoai = "Khong co so dien thoai";
}
// Phương thức (bước 3)
public virtual void HienThiThongTin()
{
Console.WriteLine("Ma so nhan vien: " + maSo);
Console.WriteLine("Ho va ten: " + hoVaTen);
Console.WriteLine("Ngay sinh: {0}/{1}/{2} ", ngaySinh.Day, ngaySinh.Month, ngaySinh.Year);
Console.WriteLine("Ngay vao cong ty: {0}/{1}/{2}", ngayVaoCongTy.Day, ngayVaoCongTy.Month, ngayVaoCongTy.Year);
Console.WriteLine("Dien thoai: " + soDienThoai);
Console.WriteLine("He so luong: " + heSoLuong);
Console.WriteLine("Luong co ban: " + luongCoBan);
}
public string MaSo()
{
return maSo;
}
public DateTime NgayVaoCongTy
{
get
{
return ngayVaoCongTy;
}
set
{
ngayVaoCongTy = value;
}
}
public string TenNhanVien()
{
string[] st = hoVaTen.Split(' ');
return st[st.Length - 1];
}
public string SoDienThoai
{
get { return soDienThoai; }
set { soDienThoai = value; }
}
public int ThamNien()
{
DateTime tgHienTai = DateTime.Now;
int soThang = (tgHienTai.Year - ngayVaoCongTy.Year) * 12 + (tgHienTai.Month - ngayVaoCongTy.Month);// (t2.Year*12 + t2.Month - t1.Year*12 - t1.Month); lưu ý Math.Round(0.5)-->0; Math.Round(1.5)-->2
int soNam = soThang / 12;
if (soThang % 12 >= 6)
soNam++;
return soNam;
}
public virtual int TienThuong()
{
int tienThuong;
int thamNien = ThamNien();
if (thamNien < 1)
tienThuong = 0;
else if (thamNien < 6)
tienThuong = thamNien * luongCoBan;
else
tienThuong = 6 * luongCoBan;
return tienThuong;
}
public virtual int TienBaoHiem()
{
return (int)(heSoLuong * luongCoBan * 7 / 100);
}
public virtual int TienLuongTruocThue()
{
return (int)(TienThuong() + heSoLuong * luongCoBan);
}
public int ThuNhapChiuThue()
{
int thuNhapChiuThue = TienLuongTruocThue() - 4000000 - TienBaoHiem();
if (thuNhapChiuThue < 0)
thuNhapChiuThue = 0;
return thuNhapChiuThue;
}
public int TienThueThuNhapCaNhan()
{
int thuNhapChiuThue = ThuNhapChiuThue();
double tienThue;
if (thuNhapChiuThue <= 5000000)
tienThue = thuNhapChiuThue * 0.05;
else if (thuNhapChiuThue <= 10000000)
tienThue = 5000000 * 0.05 + (thuNhapChiuThue - 5000000) * 0.1;
else if (thuNhapChiuThue <= 18000000)
tienThue = 5000000 * 0.05 + 5000000 * 0.1 + (thuNhapChiuThue - 10000000) * 0.15;
else if (thuNhapChiuThue <= 32000000)
tienThue = 5000000 * 0.05 + 5000000 * 0.1 + 8000000 * 0.15 + (thuNhapChiuThue - 18000000) * 0.2;
else if (thuNhapChiuThue <= 52000000)
tienThue = 5000000 * 0.05 + 5000000 * 0.1 + 8000000 * 0.15 + 14000000 * 0.2 + (thuNhapChiuThue - 32000000) * 0.25;
else if (thuNhapChiuThue <= 80000000)
tienThue = 5000000 * 0.05 + 5000000 * 0.1 + 8000000 * 0.15 + 14000000 * 0.2 + 20000000 * 0.25 + (thuNhapChiuThue - 52000000) * 0.3;
else
tienThue = 5000000 * 0.05 + 5000000 * 0.1 + 8000000 * 0.15 + 14000000 * 0.2 + 20000000 * 0.25 + 28000000 * 0.3 + (thuNhapChiuThue - 80000000) * 0.35;
return (int)tienThue;
}
public virtual int TienLuongThucLinh()
{
int luong = TienLuongTruocThue() - TienBaoHiem() - TienThueThuNhapCaNhan();
if (luong < 2000000)
luong = 2000000;
return luong;
}
// Thuộc tính (bước 1)
public readonly string maSo;
public readonly string hoVaTen;
protected DateTime ngaySinh;
protected DateTime ngayVaoCongTy;
protected string soDienThoai;
protected float heSoLuong;
public static int luongCoBan = 512000;
}
- Code:
using System;
class KyThuat : NhanVien
{
public KyThuat(string maSo, string hoVaTen, DateTime ngaySinh, DateTime ngayVaoCongTy, string soDienThoai, float heSoLuong, int luongCoBan, byte bacNghe, byte soNgayLamViec, DateTime gioVaoCa, DateTime gioRaCa, byte heSoPhat)
:base( maSo, hoVaTen, ngaySinh, ngayVaoCongTy, soDienThoai,heSoLuong, luongCoBan)
{
this.bacNghe = bacNghe;
this.soNgayLamViec = soNgayLamViec;
this.gioVaoCa = gioVaoCa;
this.gioRaCa = gioRaCa;
this.heSoPhat = heSoPhat;
}
public KyThuat(string maSo, string hoVaTen, DateTime ngaySinh, DateTime ngayVaoCongTy, string soDienThoai, float heSoLuong, int luongCoBan, byte bacNghe, byte soNgayLamViec, byte heSoPhat)
: base(maSo, hoVaTen, ngaySinh, ngayVaoCongTy, soDienThoai, heSoLuong, luongCoBan)
{
this.bacNghe = bacNghe;
this.soNgayLamViec = soNgayLamViec;
this.gioVaoCa = DateTime.Parse("7:30:00 AM");
this.gioRaCa = DateTime.Parse("16:00:00 PM");
this.heSoPhat = heSoPhat;
}
public KyThuat(string maSo, string hoVaTen, DateTime ngaySinh, DateTime ngayVaoCongTy, string soDienThoai, float heSoLuong, byte bacNghe, byte soNgayLamViec, DateTime gioVaoCa, DateTime gioRaCa, byte heSoPhat)
: base(maSo, hoVaTen, ngaySinh, ngayVaoCongTy, soDienThoai, heSoLuong)
{
this.bacNghe = bacNghe;
this.soNgayLamViec = soNgayLamViec;
this.gioVaoCa = gioVaoCa;
this.gioRaCa = gioRaCa;
this.heSoPhat = heSoPhat;
}
public KyThuat(string maSo, string hoVaTen, DateTime ngaySinh, DateTime ngayVaoCongTy, string soDienThoai, float heSoLuong, byte bacNghe, byte soNgayLamViec, byte heSoPhat)
: base(maSo, hoVaTen, ngaySinh, ngayVaoCongTy, soDienThoai, heSoLuong)
{
this.bacNghe = bacNghe;
this.soNgayLamViec = soNgayLamViec;
this.gioVaoCa = DateTime.Parse("7:30:00 AM");
this.gioRaCa = DateTime.Parse("16:00:00 PM");
this.heSoPhat = heSoPhat;
}
public KyThuat(string maSo, string hoVaTen, DateTime ngaySinh, DateTime ngayVaoCongTy, float heSoLuong, int luongCoBan, byte bacNghe, byte soNgayLamViec, DateTime gioVaoCa, DateTime gioRaCa, byte heSoPhat)
: base(maSo, hoVaTen, ngaySinh, ngayVaoCongTy, heSoLuong, luongCoBan)
{
this.bacNghe = bacNghe;
this.soNgayLamViec = soNgayLamViec;
this.gioVaoCa = gioVaoCa;
this.gioRaCa = gioRaCa;
this.heSoPhat = heSoPhat;
}
public KyThuat(string maSo, string hoVaTen, DateTime ngaySinh, DateTime ngayVaoCongTy, float heSoLuong, int luongCoBan, byte bacNghe, byte soNgayLamViec, byte heSoPhat)
: base(maSo, hoVaTen, ngaySinh, ngayVaoCongTy, heSoLuong, luongCoBan)
{
this.bacNghe = bacNghe;
this.soNgayLamViec = soNgayLamViec;
this.gioVaoCa = DateTime.Parse("7:30:00");
this.gioRaCa = DateTime.Parse("16:00:00");
this.heSoPhat = heSoPhat;
}
public byte SoNgayLamViec
{
get { return soNgayLamViec; }
set { soNgayLamViec = value; }
}
public byte BacNghe
{
get { return bacNghe; }
}
public byte TongGioLamViec()
{
int phutLamViec;
phutLamViec= (gioRaCa.Hour-gioVaoCa.Hour) * 60 + gioRaCa.Minute - gioVaoCa.Minute;
return (byte)(soNgayLamViec * ((phutLamViec - 45) / 60));
}
public int TienPhat()
{
float tienPhat=0;
if (TongGioLamViec() < 180)
tienPhat = (180 - TongGioLamViec()) * bacNghe * luongCoBan / 180 * heSoPhat;
return (int)tienPhat;
}
public override int TienBaoHiem()
{
return (int)(bacNghe * luongCoBan * 7 / 100);
}
public override int TienLuongTruocThue()
{
float tien;
tien=TienThuong() + bacNghe*luongCoBan - TienPhat();
return (int)tien;
}
public override int TienLuongThucLinh()
{
int luong = TienLuongTruocThue() - TienBaoHiem() -base.TienThueThuNhapCaNhan();
if (luong < 3000000)
luong = 3000000;
return luong;
}
public override void HienThiThongTin()
{
base.HienThiThongTin();
Console.WriteLine("Bac nghe: " + bacNghe);
Console.WriteLine("So ngay lam viec: " + soNgayLamViec);
Console.WriteLine("Gio vao ca: {0}:{1}:{2}", gioVaoCa.Hour, gioVaoCa.Minute, gioVaoCa.Second);
Console.WriteLine("Gio ra ca: {0}:{1}:{2}", gioRaCa.Hour, gioRaCa.Minute, gioRaCa.Second);
Console.WriteLine("He so phat: " + heSoPhat);
Console.WriteLine("Tong gio lam viec: " + TongGioLamViec());
Console.WriteLine("Tien phat: " + TienPhat());
Console.WriteLine("Tien thuong: " + base.TienThuong());
Console.WriteLine("Tien bao hiem: " + TienBaoHiem());
Console.WriteLine("Tien luong truoc thue: " + TienLuongTruocThue());
Console.WriteLine("Thu nhap chiu thue: " + base.ThuNhapChiuThue());
Console.WriteLine("Thu nhap ca nhan: " + base.TienThueThuNhapCaNhan());
Console.WriteLine("Tien luong thuc lanh: " + TienLuongThucLinh());
Console.WriteLine();
}
byte bacNghe;
byte soNgayLamViec;
DateTime gioVaoCa;
DateTime gioRaCa;
byte heSoPhat;
}
- Code:
using System;
class TesterKyThuat
{
//public static void Main()
//{
////nhan vien ky thuat
//KyThuat[] k = new KyThuat[2];
//k[0] = new KyThuat("k1", "Nguyen thanh Luan", new DateTime(1980, 3, 8), new DateTime(2000, 4, 2), 0, 512000, 4, 30, DateTime.Parse("8:30:00 AM"), DateTime.Parse("17:00:00 PM"), 2);
//k[1] = new KyThuat("k2", "Bui thuy An", new DateTime(1976, 12, 6), new DateTime(1998, 10, 25), "0933876345", 0, 512000, 4, 10, 3);
http://Console.WriteLine("\t\tThong tin nhan vien ky thuat");
//foreach (KyThuat n in k)
// n.HienThiThongTin();
http://Console.ReadLine();
//}
}
- Code:
using System;
class KinhDoanh : NhanVien
{
public KinhDoanh(string maSo, string hoVaTen, DateTime ngaySinh, DateTime ngayVaoCongTy, string soDienThoai, float heSoLuong, int soLuongSanPham, int donGia, int dinhMucDoanhThu)
: base(maSo, hoVaTen, ngaySinh, ngayVaoCongTy, soDienThoai, heSoLuong)
{
this.soLuongSanPham = soLuongSanPham;
this.donGia=donGia;
this.dinhMucDoanhThu = dinhMucDoanhThu;
}
public KinhDoanh(string maSo, string hoVaTen, DateTime ngaySinh, DateTime ngayVaoCongTy, string soDienThoai, float heSoLuong, int soLuongSanPham, int donGia)
: base(maSo, hoVaTen, ngaySinh, ngayVaoCongTy, soDienThoai, heSoLuong)
{
this.soLuongSanPham = soLuongSanPham;
this.donGia = donGia;
dinhMucDoanhThu = 0;
}
public KinhDoanh(string maSo, string hoVaTen, DateTime ngaySinh, DateTime ngayVaoCongTy, float heSoLuong, int luongCoBan, int soLuongSanPham, int donGia, int dinhMucDoanhThu)
:base(maSo, hoVaTen, ngaySinh, ngayVaoCongTy, heSoLuong, luongCoBan)
{
this.soLuongSanPham = soLuongSanPham;
this.donGia=donGia;
this.dinhMucDoanhThu = dinhMucDoanhThu;
}
public KinhDoanh(string maSo, string hoVaTen, DateTime ngaySinh, DateTime ngayVaoCongTy, float heSoLuong, int luongCoBan, int soLuongSanPham, int donGia)
: base(maSo, hoVaTen, ngaySinh, ngayVaoCongTy, heSoLuong, luongCoBan)
{
this.soLuongSanPham = soLuongSanPham;
this.donGia = donGia;
dinhMucDoanhThu = 0;
}
public int DinhMucDoanhThu
{
get { return dinhMucDoanhThu; }
set { dinhMucDoanhThu = value; }
}
public int DoanhThu()
{
return soLuongSanPham * donGia;
}
public override int TienThuong()
{
double tienThuong;
if (DoanhThu() <= dinhMucDoanhThu)
tienThuong=0;
else if (DoanhThu() <= 2 * dinhMucDoanhThu)
tienThuong = 0.2 * (DoanhThu() - dinhMucDoanhThu);
else
tienThuong = 0.5 * (DoanhThu() - 2 * dinhMucDoanhThu);
return (int)tienThuong;
}
public override int TienLuongThucLinh()
{
int luong = base.TienLuongTruocThue() - base.TienBaoHiem() - base.TienThueThuNhapCaNhan();
if (luong < 2500000)
luong = 2500000;
else if (dinhMucDoanhThu == 0)
luong = 200000;
return luong;
}
public override void HienThiThongTin()
{
base.HienThiThongTin();
Console.WriteLine("So luong san pham: " + soLuongSanPham);
Console.WriteLine("Don gia: " + donGia);
Console.WriteLine("Dinh muc doanh thu: " + dinhMucDoanhThu);
Console.WriteLine("Doanh thu: " + DoanhThu());
Console.WriteLine("Tien thuong: " + TienThuong());
Console.WriteLine("Tien bao hiem: " + base.TienBaoHiem());
Console.WriteLine("Tien luong truoc thue: " + base.TienLuongTruocThue());
Console.WriteLine("Thu nhap chiu thue: " + base.ThuNhapChiuThue());
Console.WriteLine("Thu nhap ca nhan: " + base.TienThueThuNhapCaNhan());
Console.WriteLine("Tien luong thuc lanh: " + TienLuongThucLinh());
Console.WriteLine();
}
int soLuongSanPham;
int donGia;
int dinhMucDoanhThu;
}
- Code:
using System;
class TesterKinhDoanh
{
//public static void Main()
//{
// KinhDoanh[] kd = new KinhDoanh[3];
// kd[0] = new KinhDoanh("kd1","Nguyen thi thu Ha",new DateTime(1965,4,27),new DateTime(1985,2,3),(float)4.5,512000,20,200000);
// kd[1] = new KinhDoanh("kd2","Tran thanh Tien",new DateTime(1988,1,8),new DateTime(2005,12,5),"0122334455",3.4f,231,50000,530000);
// kd[2] = new KinhDoanh("kd3", "Nguyen thi Thu", new DateTime(1982, 10, 4), new DateTime(2000, 11, 21), "9009112223", (float)3.2, 512000, 32, 90000);
// foreach (KinhDoanh n in kd)
// n.HienThiThongTin();
// Console.ReadLine();
//}
}