0% found this document useful (0 votes)
23 views5 pages

Windows Forms Rental Management System

The document contains code for a Windows Forms application that manages rental agreements using classes such as CPhieuThue and CXuLyPhieuThue. It includes functionality for adding, deleting, and displaying rental agreements in a DataGridView. The application supports different room types and calculates rental costs based on the duration and type of room selected.

Uploaded by

minhphat1474
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views5 pages

Windows Forms Rental Management System

The document contains code for a Windows Forms application that manages rental agreements using classes such as CPhieuThue and CXuLyPhieuThue. It includes functionality for adding, deleting, and displaying rental agreements in a DataGridView. The application supports different room types and calculates rental costs based on the duration and type of room selected.

Uploaded by

minhphat1474
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Form

using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];

namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
CXuLyPhieuThue xuly = new CXuLyPhieuThue();
public Form1()
{
InitializeComponent();
}

void hienthi()
{
BindingSource bs = new BindingSource();
[Link] = [Link]();
[Link] = bs;
}

private void btnThem_Click(object sender, EventArgs e)


{
KieuLoaiPhong loaiphong = KieuLoaiPhong.A;
if ([Link])
loaiphong = KieuLoaiPhong.B;
else if([Link])
loaiphong = KieuLoaiPhong.C;
else if ([Link])
loaiphong = KieuLoaiPhong.D;
CPhieuThue pt = new
CPhieuThue([Link],[Link],[Link],[Link],loaipho
ng);
[Link](pt);
hienthi();
}

private void btnXoa_Click(object sender, EventArgs e)


{
if([Link] == 0) {
return;
}
foreach(DataGridViewRow row in [Link])
{
string maso = [Link][0].[Link]();
[Link](maso);
hienthi();
}
}

private void Form1_Load(object sender, EventArgs e)


{

}
}
}

CPhieuThue
using System;
using [Link];
using [Link];
using [Link];
using [Link];

namespace WindowsFormsApp1
{
public enum KieuLoaiPhong { A, B, C, D }
internal class CPhieuThue
{
private string m_mapt;
private DateTime m_ngaybd;
private DateTime m_ngaykt;
private string m_tenkh;
private KieuLoaiPhong m_loaiphong;

public CPhieuThue() : this("", [Link], [Link], "", KieuLoaiPhong.A)


{

}
public CPhieuThue(string mapt, DateTime ngaybd, DateTime ngaykt, string tenkh, KieuLoaiPhong
loaiphong)
{
m_mapt = mapt;
m_ngaybd = ngaybd;
m_ngaykt = ngaykt;
m_tenkh = tenkh;
m_loaiphong = loaiphong;
}
public string Mapt { get => m_mapt; set => m_mapt = value; }
public DateTime Ngaybd { get => m_ngaybd; set => m_ngaybd = value; }
public DateTime Ngaykt { get => m_ngaykt; set => m_ngaykt = value; }
public string Tenkh { get => m_tenkh; set => m_tenkh = value; }
public KieuLoaiPhong Loaiphong { get => m_loaiphong; set => m_loaiphong = value; }
public int SoNgayThue
{
get
{
return (Ngaykt - Ngaybd).Days + 1;
}
}
public int TienThue
{
get
{
int dongia = 0;
if (Loaiphong == KieuLoaiPhong.A)
dongia = 250000;
else if (Loaiphong == KieuLoaiPhong.B)
dongia = 400000;
else if (Loaiphong == KieuLoaiPhong.C)
dongia = 600000;
else
dongia = 900000;
return SoNgayThue * dongia;
}
}
}
}

CXuLyPhieuThue
using System;
using [Link];
using [Link];
using [Link];
using [Link];

namespace WindowsFormsApp1
{
internal class CXuLyPhieuThue
{
private Dictionary<string, CPhieuThue> dsPT;
public CXuLyPhieuThue()
{
dsPT = new Dictionary<string, CPhieuThue>();
}
public List<CPhieuThue> layDSPhieuThue()
{
return [Link]();
}
public CPhieuThue tim(string ma)
{
try { return dsPT[ma]; } catch { return null; }
}
public void them(CPhieuThue pt)
{
try
{
if (pt == null)
return;
CPhieuThue a = tim([Link]);
if(a == null)
[Link]([Link], pt);
}
catch (Exception)
{

return;
}
}

public void xoa(string ma)//ham xoa bi sai, nó chỉ xóa dc 1 đối tượng
{
try
{
[Link](ma);
}catch(Exception) {
return;
}

}
public void sua(CPhieuThue pt)
{
if(pt == null) return;
CPhieuThue a = tim([Link]);
if (a == null)
return;
dsPT[[Link]] = pt;
}
}
}

You might also like