码迷,mamicode.com
首页 > 其他好文 > 详细

汽车租赁系统

时间:2015-07-12 23:20:08      阅读:277      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

技术分享

技术分享

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//总的车辆记录
public Dictionary<string,Vbstract> vbs=new Dictionary<string,Vbstract>();
//租车记录
public Dictionary<string, Vbstract> Returncar = new Dictionary<string, Vbstract>();
public void chusi()
{
Teuck tc=new Teuck("黄色",3000,"京a1365","奔驰",3,"张三",4,20){};
Teuck tc2 = new Teuck("绿色", 6000, "京p0000", "东风", 4, "李四", 6, 60) { };
Car tc1 = new Car("白色", 600, "京p0011", "奥迪A8", 2, "王五", 1) { };
Car tc3 = new Car("红色", 200, "京q0121", "凯迪拉克", 6, "赵七", 9) { };
vbs.Add(tc.LicenseNO, tc);
vbs.Add(tc2.LicenseNO, tc2);
vbs.Add(tc1.LicenseNO, tc1);
vbs.Add(tc3.LicenseNO, tc3);
chushi1();

}
public void chushi1()
{
listView1.Items.Clear();
foreach (KeyValuePair<string, Vbstract> item in vbs)
{
ListViewItem items = new ListViewItem(item.Key);
items.SubItems.Add(item.Value.Name);
items.SubItems.Add(item.Value.Color);
items.SubItems.Add(item.Value.RentDate.ToString());
items.SubItems.Add(item.Value.DailyBent.ToString());
if (item.Value is Teuck)
{
Teuck truck = item.Value as Teuck;
items.SubItems.Add(truck.Load.ToString());
}
if (item.Value is Car)
{
items.SubItems.Add("无");
}
this.listView1.Items.Add(items);
}
}

private void Form1_Load(object sender, EventArgs e)
{
this.comboBox1.Items.Add("黄");
this.comboBox1.Items.Add("绿");
this.comboBox1.Items.Add("蓝");
this.comboBox1.Items.Add("紫");
this.comboBox1.SelectedIndex = 0;

}

private void button1_Click(object sender, EventArgs e)
{
chusi();
}

private void listView2_SelectedIndexChanged(object sender, EventArgs e)
{

}

private void button2_Click(object sender, EventArgs e)
{
if (this.textBox1.Text=="")
{
MessageBox.Show("请填写租用者!");
return;
}
if (this.listView1.SelectedItems.Count == 0)
{
MessageBox.Show("请选中一行!");
return;
}

foreach (KeyValuePair<string,Vbstract> item in vbs)
{
if (item.Value.LicenseNO==this.listView1.SelectedItems[0].SubItems[0].Text.ToString())
{
if (item.Value is Teuck)
{
Teuck truck = item.Value as Teuck;
Teuck tc2 = new Teuck(item.Value.Color, item.Value.DailyBent, item.Value.LicenseNO, item.Value.Name, item.Value.RentDate, item.Value.RentUser
, item.Value.YearsOfService,truck.Load);
Returncar.Add(item.Value.LicenseNO, tc2);
MessageBox.Show("恭喜你租用卡车成功!");
vbs.Remove(item.Value.LicenseNO);
chushi1();
break;
}
else
{
Car cr = new Car(item.Value.Color, item.Value.DailyBent, item.Value.LicenseNO, item.Value.Name, item.Value.RentDate, item.Value.RentUser
, item.Value.YearsOfService);
Returncar.Add(item.Value.LicenseNO, cr);
MessageBox.Show("恭喜你租用汽车成功!");
vbs.Remove(item.Value.LicenseNO);
chushi1();
break;
}
}
}
}
public void sx()
{
foreach (KeyValuePair<string, Vbstract> item in Returncar)
{
ListViewItem items = new ListViewItem(item.Key);
items.SubItems.Add(item.Value.Name);
items.SubItems.Add(item.Value.Color);
items.SubItems.Add(item.Value.RentDate.ToString());
items.SubItems.Add(item.Value.DailyBent.ToString());
if (item.Value is Teuck)
{
Teuck truck = item.Value as Teuck;
items.SubItems.Add(truck.Load.ToString());
}
if (item.Value is Car)
{
items.SubItems.Add("无");
}
this.listView2.Items.Add(items);
}
}

private void button5_Click(object sender, EventArgs e)
{
listView2.Items.Clear();
sx();
}

private void button4_Click(object sender, EventArgs e)
{
if (this.listView2.SelectedItems.Count==0)
{
MessageBox.Show("请选中一行!");
return;
}
if (this.textBox2.Text=="")
{
MessageBox.Show("请输入租车的天数!");
return;
}
foreach (KeyValuePair<string,Vbstract> item in Returncar)
{
if (item.Value.LicenseNO.ToString()==this.listView2.SelectedItems[0].SubItems[0].Text.ToString())
{
string result=string.Format("你需要支付{0}元",double.Parse(this.listView2.SelectedItems[0].SubItems[4].Text)*int.Parse(this.textBox2.Text));
MessageBox.Show(result, "提示");
Returncar.Remove(item.Value.LicenseNO);
sx();
break;
}
}
}

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

private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
this.textBox7.Enabled = false;
}

private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
this.textBox7.Enabled = true;
}

private void button6_Click(object sender, EventArgs e)
{
if (this.textBox3.Text==""||textBox4.Text==""||textBox5.Text==""||textBox6.Text=="")
{
MessageBox.Show("请输入相关文本!");
return;
}
if (this.radioButton1.Checked)
{
Car ar = new Car(this.comboBox1.SelectedText, double.Parse(this.textBox6.Text), this.textBox3.Text, this.textBox4.Text, int.Parse(this.textBox5.Text), "Pater"
, 6);
vbs.Add(this.textBox3.Text, ar);
MessageBox.Show("入库成功!");
return;
}
if (this.radioButton2.Checked)
{
Teuck ar = new Teuck(this.comboBox1.SelectedText, double.Parse(this.textBox6.Text), this.textBox3.Text, this.textBox4.Text, int.Parse(this.textBox5.Text), "Pater"
, 6,int.Parse(this.textBox7.Text));
vbs.Add(this.textBox3.Text, ar);
MessageBox.Show("入库成功!");
return;
}

汽车租赁系统

标签:

原文地址:http://www.cnblogs.com/meixinyuan/p/4641671.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!