最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C#實現(xiàn)汽車租賃系統(tǒng)項目

 更新時間:2019年01月29日 09:59:06   作者:服務(wù)器端的cookie  
這篇文章主要為大家詳細(xì)介紹了C#實現(xiàn)汽車租賃系統(tǒng)項目,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了C#實現(xiàn)汽車租賃系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下

汽車和卡車的父類

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//父類變量和方法
namespace 汽車租賃系統(tǒng)
{
 public class Inheritance
  {
   public Inheritance()
   { }
   public Inheritance(string color,double everydaymoney,string no,string name,int rentdate,string load,string rentuser,int services)
   {
     this.Color = color;
     this.EverydayMoney = everydaymoney;
     this.No = no;
     this.Name = name;
     this.RentDate = rentdate;
     this.Load = load;
 
 
     this.RentUser = rentuser;
     this.Services = services;
   }
    public string Color { get; set; }
    public double EverydayMoney { get; set; }
    public string No { get; set; }
    public string Name { get; set; }
    public int RentDate { get; set; }
    public string Load { get; set; }
    public string RentUser { get; set; }
    public int Services { get; set; }
   //父類計算租金方法
    public virtual double Vehicle()
    {
      double rentMoney;
      rentMoney = this.RentDate * this.EverydayMoney;
      return rentMoney;
    }
   
   
 }
}

汽車

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace 汽車租賃系統(tǒng)
{
  public class Car:Inheritance
  {
    public Car()
    { }
    public Car( string color,double everydaymoney,string no,string name,int rentdate,string load,string rentuser,int services)
      :base(color,everydaymoney,no,name ,rentdate,load,rentuser,services)
    {
      
    }
    //省略重寫汽車計算價格方法
    
  }
}

卡車

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
 
namespace 汽車租賃系統(tǒng)
{
  public class Truck:Inheritance
  {
    public Truck()
    { }
    public Truck( string color,double everydaymoney,string no,string name,int rentdate,string load, string rentuser,int services)
      :base(color,everydaymoney,no,name ,rentdate,load,rentuser,services)
    {
      
    }
    //省略重寫卡車計算方法
    
  }
}

主界面

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace 汽車租賃系統(tǒng)
{
  public partial class Main : Form
  {
    public Main()
    {
      InitializeComponent();
 
    }
    Inheritance inheri = new Inheritance();
    //保存未租車的集合
    Dictionary<string, Inheritance> rentDic = new Dictionary<string, Inheritance>();
    //保存已租車的集合
    Dictionary<string, Inheritance> rentedDic = new Dictionary<string, Inheritance>();
    //將未租車集合綁定到listview容器中
 
    //將數(shù)據(jù)綁定到listview容器上
    public void BangDing(ListView listview,Dictionary<string ,Inheritance> dic)
    {
      listview.FullRowSelect = true;
      ListViewItem items;
      listview.Items.Clear();
 
      foreach (Inheritance item in dic.Values)
      {
 
        items = new ListViewItem();
        items.Text = item.No;
        items.SubItems.Add(item.Name);
        items.SubItems.Add(item.Color);
        items.SubItems.Add(item.Services.ToString());
        items.SubItems.Add(item.EverydayMoney.ToString());
        items.SubItems.Add(item.Load);
        listview.Items.Add(items);
      }
    }
    //進(jìn)行未租車集合初始化
    public void AddRent()
    {
 
      Car car1 = new Car("黑色", 100, "001", "奧迪", 0, "無","",3);
      Car car2 = new Car("黑色", 100, "002", "奧迪", 0, "無","",3);
      Truck truck1 = new Truck("紅色", 200, "A001", "一汽", 0, "20","",6);
      rentDic.Add(car1.No, car1);
      rentDic.Add(car2.No, car2);
      rentDic.Add(truck1.No, truck1);
      
    }
 
 
    //顯示未租車信息
    private void button2_Click(object sender, EventArgs e)
    {
 
      BangDing(listView1,rentDic);
    }
 
    private void Main_Load(object sender, EventArgs e)
    {
      AddRent();
    }
 
    //進(jìn)行租車操作
    private void button1_Click(object sender, EventArgs e)
    {
      string key = this.listView1.SelectedItems[0].Text;
      rentDic[key].RentUser = this.textBox1.Text;
      rentedDic.Add(rentDic[key].No,rentDic[key]);
      if (rentDic.ContainsKey(key))
      {
        rentDic.Remove(key);
      }
      BangDing(listView1,rentDic);
      MessageBox.Show("已出租");
 
 
    }
    
 
    private void button4_Click(object sender, EventArgs e)
    {
      BangDing(listView2,rentedDic);
    }
    //進(jìn)行還車結(jié)算
    public void JieSuan()
    {
      string key = this.listView2.SelectedItems[0].Text;
      rentedDic[key].RentDate = Convert.ToInt32(this.textBox2.Text);
      rentDic.Add(rentedDic[key].No,rentedDic[key]);
      double rentMoney = rentedDic[key].Vehicle();
      if (rentedDic.ContainsKey(key))
      {
        rentedDic.Remove(key);
      }
 
 
      BangDing(listView2,rentedDic);
      MessageBox.Show("租金為:",rentMoney.ToString());
      
 
    
    }
    private void button5_Click(object sender, EventArgs e)
    {
      JieSuan();
    }
    //新車入庫操作
    private void button6_Click(object sender, EventArgs e)
    {
      string no = this.textBox3.Text;
      string name = this.textBox4.Text;
      string color = this.textBox5.Text;
      int services = Convert.ToInt32(this.textBox6.Text);
      double renteverydaymoney = Convert.ToInt32(this.textBox7.Text);
      string load = this.textBox8.Text;
      //進(jìn)行類型判斷
      if (load=="無")
      {
        inheri = new Car(color,renteverydaymoney,no,name,0,load,"",services);
      }
      else
      {
        inheri = new Truck(color,renteverydaymoney,no,name,0,load,"",services);
      }
       
      rentDic.Add(inheri.No,inheri);
      MessageBox.Show("添加成功","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
     //進(jìn)行文本清空操作
      foreach (TabPage page in tabControl1.TabPages)
      { 
 
        foreach (Control control in page.Controls)
        {
          if (control is TextBox)
          {
            control.Text="";
 
          }
 
        }
      }
      
    }
  }
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 探秘Unity游戲開發(fā)中的狀態(tài)設(shè)計模式

    探秘Unity游戲開發(fā)中的狀態(tài)設(shè)計模式

    這篇文章主要介紹了探秘Unity游戲開發(fā)中的狀態(tài)設(shè)計模式,狀態(tài)模式是Unity游戲開發(fā)中常用的一種設(shè)計模式,可以幫助開發(fā)者更好地管理游戲?qū)ο鬆顟B(tài),提高游戲的可維護性和可擴展性
    2023-05-05
  • DataGridView不顯示最下面的新行、判斷新增行、刪除行操作

    DataGridView不顯示最下面的新行、判斷新增行、刪除行操作

    這篇文章介紹了DataGridView不顯示最下面的新行、判斷新增行、刪除行的操作方法,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-02-02
  • C#學(xué)習(xí)筆記整理_深入剖析構(gòu)造函數(shù)、析構(gòu)函數(shù)

    C#學(xué)習(xí)筆記整理_深入剖析構(gòu)造函數(shù)、析構(gòu)函數(shù)

    下面小編就為大家?guī)硪黄狢#學(xué)習(xí)筆記整理_深入剖析構(gòu)造函數(shù)、析構(gòu)函數(shù)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2016-09-09
  • C#多線程系列之多階段并行線程

    C#多線程系列之多階段并行線程

    本文詳細(xì)講解了C#多線程的多階段并行線程,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-02-02
  • C# wpf 實現(xiàn)窗口任意區(qū)域點擊拖動

    C# wpf 實現(xiàn)窗口任意區(qū)域點擊拖動

    在wpf要實現(xiàn)此功能簡單形式還是比較容易的,但是有一些細(xì)節(jié)需要專門處理,比如與按鈕的點擊事件沖突問題,解決事件沖突問題后拖動的靈敏度,可復(fù)用性等,這篇文章主要介紹了C# wpf 實現(xiàn)窗口任意區(qū)域點擊拖動,需要的朋友可以參考下
    2024-03-03
  • C#設(shè)計模式實現(xiàn)之生成器模式和責(zé)任鏈模式

    C#設(shè)計模式實現(xiàn)之生成器模式和責(zé)任鏈模式

    學(xué)完設(shè)計模式之后,你就感覺它會慢慢地影響到你寫代碼的思維方式,下面這篇文章主要給大家介紹了關(guān)于C#設(shè)計模式實現(xiàn)之生成器模式和責(zé)任鏈模式的相關(guān)資料,需要的朋友可以參考下
    2021-08-08
  • 共享鎖using范圍的實現(xiàn)方法

    共享鎖using范圍的實現(xiàn)方法

    共享鎖using范圍的實現(xiàn)方法,需要的朋友可以參考一下
    2013-04-04
  • C#中AS和IS關(guān)鍵字的用法

    C#中AS和IS關(guān)鍵字的用法

    這篇文章主要介紹了C#中AS和IS關(guān)鍵字的用法的相關(guān)資料,需要的朋友可以參考下
    2016-03-03
  • 教你創(chuàng)建一個帶診斷工具的.NET鏡像

    教你創(chuàng)建一個帶診斷工具的.NET鏡像

    本文編寫的初衷是因為在群里有很多小伙伴遇到生產(chǎn)環(huán)境性能問題的時候,.NET的runtime鏡像中沒有帶一些工具,安裝和使用起來很麻煩,所以分享一些我們公司內(nèi)部一些技巧,對.NET鏡像帶診斷工具相關(guān)知識感興趣的朋友一起看看吧
    2022-07-07
  • C# 向Word中設(shè)置/更改文本方向的方法(兩種)

    C# 向Word中設(shè)置/更改文本方向的方法(兩種)

    在一般情況下word中輸入的文字都是橫向的,今天小編給大家?guī)韮煞N方法來設(shè)置更改文本方向的方法,非常不錯,對c# word 更改文本方向的知識感興趣的朋友一起看看吧
    2016-08-08

最新評論

同仁县| 大名县| 扎赉特旗| 本溪| 马尔康县| 乐都县| 永平县| 酉阳| 新巴尔虎左旗| 兴安盟| 香港| 景宁| 弥勒县| 华蓥市| 涿州市| 永德县| 大渡口区| 中卫市| 伊宁县| 太康县| 永平县| 静安区| 大关县| 通化市| 芮城县| 界首市| 旌德县| 友谊县| 乌拉特前旗| 习水县| 锦屏县| 那曲县| 扶绥县| 封丘县| 濉溪县| 准格尔旗| 屏南县| 盱眙县| 定结县| 巴南区| 彰武县|