C# 汽车租赁 系统 可实现 租车 还车 结算 以及 新入车辆

来源:互联网 发布:windows优化大师64 编辑:程序博客网 时间:2024/06/10 00:30
使用系统;使用System.Collections.Generic;使用System.Linq;使用System.Text;namespace汽车租赁系统新{    /// <summary>    ///汽车父类    /// </ summary> 公共抽象类车辆    {        public string No {get; 组; }}        public string Name {get; 组; }}        public string Color {get; 组; }}        public int Shijian {get; 组; }}        public double zujing {get; 组; }}        public string Zaizhong {get; 组; }}        公共车辆()        {        }}        public Vehicle(string no,string name,string color,int sj,double zj,string zz)        {            否。            this.Name = name;            this.Color = color;            this.Shijian = sj;            zu;            zaizhong = zz;        }}        public abstract double jiesuan();    }}}}使用系统;使用System.Collections.Generic;使用System.Linq;使用System.Text;namespace汽车租赁系统新{   公共类汽车:车辆    {       public Car()       {       }}       public Car(string no,string name,string color,int sj,double zj,string zz)           :base(no,name,color,sj,zj,zz)       {       }}       public override double jiesuan()       {           double zj;           zj = Zujing * Shijian;           return zj;       }}    }}}}使用系统;使用System.Collections.Generic;使用System.Linq;使用System.Text;namespace汽车租赁系统新{   公共类卡车:车辆    {       公共卡车()       {       }}       public Truck(string no,string name,string color,int sj,double zj,string zz)           :base(no,name,color,sj,zj,zz)       {       }}       public override double jiesuan()       {           double zj;           zj = Zujing * Shijian;           return zj;       }}       }}}}使用系统;使用System.Collections.Generic;使用System.Linq;使用System.Text;namespace汽车租赁系统新{   公共类公共    {       public static Vehicle gongchang(string no,string name,string color,int sj,double zj,string zz,string type)        {           车辆v = null;           开关(类型)           {               case“c”:                   v = new Car(no,name,color,sj,zj,zz);                   打破;               case“t”:                   v = new Truck(no,name,color,sj,zj,zz);                   打破;           }}           return v;       }}    }}}}
使用系统;使用System.Collections.Generic;使用System.ComponentModel;使用System.Data;使用System.Drawing;使用System.Linq;使用System.Text;使用System.Windows.Forms;namespace汽车租赁系统新{    public partial class Form1:Form    {        public Form1()        {            InitializeComponent();        }}        //保存可租车的车辆信息        字典<string,Vehicle> ve;       //保存已租车的车辆信息        字典<string,Vehicle> ve2;        private void Form1_Load(object sender,EventArgs e)        {          ve = new Dictionary <string,Vehicle>();            Car car = new Car(“京A1”,“宝马”,“白色”,3,250,“无”);            卡车tk =新卡车(“京A2”,“宝马”,“白色”,3,250,“无”);            ve.Add(car.No,car);            ve.Add(tk.No,tk);            //////           ve2 = new Dictionary <string,Vehicle>();            Car car2 = new Car(“A3”,“宝马”,“白色”,3,250,“无”);            卡车tk2 =新卡车(“京A43”,“宝马”,“白色”,3,250,“无”);            ve2.Add(car2.No,car2);            ve2Add(tk2.No,tk2);                    }}        private void button1_Click(object sender,EventArgs e)        {                        shuaXin();        }}        private void shuaXin()        {            listView1.Items.Clear();            foreach(车辆项目在ve.Values)            {                ListViewItem lv = new ListViewItem(item.No);                lv.SubItems.Add(item.Name);                lv.SubItems.Add(item.Color);                lv.SubItems.Add(item.Shijian.ToString());                lv.SubItems.Add(item.Zujing.ToString());                lv.SubItems.Add(item.Zaizhong);                listView1.Items.Add(lv);            }}        }}        private void button3_Click(object sender,EventArgs e)        {            shuaXin2();        }}        private void shuaXin2()        {            listView2.Items.Clear();            foreach(车辆项目在ve2.Values)            {                ListViewItem lv = new ListViewItem(item.No);                lv.SubItems.Add(item.Name);                lv.SubItems.Add(item.Color);                lv.SubItems.Add(item.Shijian.ToString());                lv.SubItems.Add(item.Zujing.ToString());                lv.SubItems.Add(item.Zaizhong);                listView2.Items.Add(lv);            }}        }}        private void button2_Click(object sender,EventArgs e)        {            string s = this.textZuche.Text.Trim();            if(string.IsNullOrEmpty(s))            {                MessageBox.Sconnection(“请输入租车人的姓名”,“提示”,MessageBoxButtons.OK,MessageBoxIcon.Information);                返回;            }}             if(this.listView1.SelectedItems.Count == 0)            {                MessageBox.Show(“请选择车辆”,“提示”,MessageBoxButtons.OK,MessageBoxIcon.Information);                返回;            }}             其他             {                 string key = listView1.SelectedItems [0] .Text;                 ve [key] .Name = s;                 ve2.Add(ve [key] .No,ve [key]);                 if(ve.ContainsKey(key))                 {                     ve.Remove(key);                 }}                 shuaXin();                 MessageBox.Show(“已出租”);             }}        }}        private void button4_Click(object sender,EventArgs e)        {            string s = this.textJiesuan.Text.Trim();            if(string.IsNullOrEmpty(s))            {                MessageBox.Show(“请输入结算的天数”,“提示”,MessageBoxButtons.OK,MessageBoxIcon.Information);                返回;            }}            else if(this.listView2.SelectedItems.Count == 0)            {                MessageBox.Sut(“请选择一辆车进行计算”,“提示”,MessageBoxButtons.OK,MessageBoxIcon.Information);                返回;            }}            其他             {                string key = this.listView2.SelectedItems [0] .Text;                ve2 [key] .Shijian = int.Parse(s);          double b = ve2 [key] .jiesuan();                ve.Add(ve2 [key] .No,ve2 [key]);                if(ve2.ContainsKey(key))                {                    ve2.Remove(key);                }}                shuaXin2();                MessageBox.Show(“结算费用为”+ b.ToString(),“提示”);            }}        }}        private void radiojiaoche_CheckedChanged(object sender,EventArgs e)        {            if(this.radiojiaoche.Checked)            {                this.txtZaizhong.Enabled = false;            }}        }}        private void button5_Click(object sender,EventArgs e)        {            string na = this.txtChepaihao.Text;            string name = this.txtChexing.Text;            int sj = int .Parse(this.txtShiyongshijian.Text);          double zj = double.Parse(this.txtZujing.Text);            string zz = this.txtZaizhong.Text;            string colcor = this.cbmColor.Text;            string type = null;            if(this.radiojiaoche.Checked)            {                type =“c”;            }}            if(this.radioKache.Checked)            {                type =“t”;            }}            车辆v =公共广场(na,name,colcor,sj,zj,zz,type);            ve.Add(v.No,v);          DialogResult result = MessageBox.Show(“添加成功!!”,“提示”,MessageBoxButtons.OK,MessageBoxIcon.Information);          if(result == DialogResult.OK)          {              this.txtChepaihao.Text =“”;              this.txtChexing.Text =“”;              this.cbmColor.Text =“”;              this.txtShiyongshijian.Text =“”;              this.txtZaizhong.Text =“”;              this.txtZujing.Text =“”;          }}        }}           }}}}


0 0
原创粉丝点击