汽车租赁系统

/定义一个父类保存车得信息

 

/颜色
public string Color { get; set; }
//日租金
public double DailyRent { get; set; }
//车牌号
public string LicensoNO { get; set; }
//车名
public string Name { get; set; }
//租车日期
public int RentDate { get; set; }
//租车人
public string RentUser { get; set; }
//使用时间
public int YearsOfService { get; set; }
public Abstract() { }
public Abstract(string color, double dailyrent, string licenseno, string name, int rentdate, string rentuser, int yearsOfService)
{
this.Color = color;
this.DailyRent = dailyrent;
this.LicensoNO = licenseno;
this.Name = name;
this.RentDate = rentdate;
this.RentUser = rentuser;
this.YearsOfService = yearsOfService;
}
public abstract double CalcPrice();

 

///汽车的有承载的时候从新写一个方法

//载重
public int Load { get; set; }
public Truck() { }
public Truck(string color, double dailyrent, string licenseno, string name, int rentdate, string rentuser, int yearsofservice, int load)
: base(color, dailyrent, licenseno, name, rentdate, rentuser, yearsofservice)
{
this.Load = load;
}
//计算价钱
public override double CalcPrice()
{
double totalPrice = 0;
double basicPrice = this.RentDate * this.DailyRent;
return totalPrice;
}

///初始话汽车信息

Car c1 = new Car()
{
LicensoNO = "湘A888888",
Name = "法拉利A5",
Color = "白色",
DailyRent = 5000,
YearsOfService = 2
};
vehices.Add(c1.LicensoNO, c1);

Car c2 = new Car()
{
LicensoNO = "湘A666666",
Name = "保时捷A5",
Color = "红色",
DailyRent = 4000,
YearsOfService = 2
};
vehices.Add(c2.LicensoNO, c2);

Truck t1 = new Truck
{
LicensoNO = "湘B666666",
Name = "东风A5",
Color = "蓝色",
DailyRent = 2000,
YearsOfService = 2,
Load = 120
};
vehices.Add(t1.LicensoNO, t1);
new1(vehices, listView1);
}

///

public void new1(Dictionary<string, Abstract> ab, ListView lvlist)
{

//ListViewItem list = null;
lvlist.Items.Clear();

foreach (Abstract item in ab.Values)
{
ListViewItem lv = new ListViewItem();
lv.Text = item.LicensoNO;
lv.SubItems.Add(item.Name);
lv.SubItems.Add(item.Color);
lv.SubItems.Add(item.YearsOfService.ToString());
lv.SubItems.Add(item.DailyRent.ToString());
//判断 是 轿车 还是卡车 是卡车 显示载重 ,轿车就显示 无
if (item is Truck){
lv.SubItems.Add((item as Truck).Load.ToString());
}else{
lv.SubItems.Add("无");
}
lvlist.Items.Add(lv);
}

}

private void tabPage3_Click(object sender, EventArgs e)
{
if (radioButton1.Checked)
{
textBox7.Enabled = false;
}

else
{
textBox7.Enabled = true;
}
}

private void label9_Click(object sender, EventArgs e)
{

}

#region 新车入库
public void xinxi()
{
if (textBox3.Text.Trim() == "" || textBox4.Text.Trim() == "" || textBox5.Text.Trim() == "" || textBox6.Text.Trim() == "" || textBox7.Text.Trim() == "" || comboBox1.Text == "")
{

MessageBox.Show("请填写信息!!");
return;
}
Abstract VS = null;
VS.LicensoNO = textBox3.Text.Trim();
VS.Name = textBox4.Text.Trim();
VS.Color = comboBox1.Text.Trim();
VS.YearsOfService = Convert.ToInt32(textBox5.Text.Trim());
VS.DailyRent = Convert.ToDouble(textBox6.Text.Trim());

}
#endregion

private void button4_Click(object sender, EventArgs e)
{
jiesuan();
}
#region 结算
public void jiesuan()
{
if (textBox2.Text.Trim() == "")
{
MessageBox.Show("请输入租用的天数");
textBox2.Focus();
return;
}
if (listView2.SelectedItems.Count <= 0)
{
MessageBox.Show("请选择你要结算的车辆");
return;
}
string lin = listView2.SelectedItems[0].Text;
//MessageBox.Show(lin);
rentVehles[lin].RentDate = int.Parse(textBox2.Text);
double tota = rentVehles[lin].CalcPrice();
string msg = string.Format("您的总价是{0}.",tota.ToString());
MessageBox.Show(msg, "注意!", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
#endregion

private void button1_Click(object sender, EventArgs e)
{
new1(vehices,listView1);
}

private void button2_Click(object sender, EventArgs e)
{
zu();
}

private void button6_Click(object sender, EventArgs e)
{
xinxi();
}
private void button3_Click(object sender, EventArgs e)
{
this.Close();
}

private void button5_Click(object sender, EventArgs e)
{
new1(rentVehles,listView2);
}

转载于:https://www.cnblogs.com/BaoWangZe/p/8888012.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值