您的位置:首页 > 编程语言 > C#

C#加油站计费系统

2020-08-13 16:54 2456 查看

namespace WindowsFormsApplication11
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
System.Collections.ArrayList rooms = new System.Collections.ArrayList();
rooms.Add(new Room("93#", 5));
rooms.Add(new Room("95#", 6));
rooms.Add(new Room("97#", 7));
rooms.Add(new Room("99#", 8));

cbRoom.DataSource = rooms;
cbRoom.DisplayMember = "RoomType";
cbRoom.ValueMember = "Price";
}
public class Room
{

public string RoomType { get; set; }
public decimal Price { get; set; }

public Room(string type, decimal price)
{
this.RoomType = type;
this.Price = price;
}
}

private void button1_Click(object sender, EventArgs e)
{
int number = int.Parse(textBox2.Text);
decimal price = (decimal)cbRoom.SelectedValue;
decimal a = (decimal)number * price;
textBox3.Text = a.ToString("c");
}

}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: