基于C#的Cs架构简单开发一花店的售卖系统3

花店售卖系统主要是为了熟悉CS结构开发,和C#中一些方法的使用,并不设计实用,故逻辑并不严谨,了解用法即可。

 

购买界面,就是接受主界面点击的内容之后展示出来,支持选择数量,并会自动计算金额

设计如下:

 

 

代码:

 1 using System;
 2 using System.Collections.Generic;
 3 using System.ComponentModel;
 4 using System.Data;
 5 using System.Drawing;
 6 using System.Linq;
 7 using System.Text;
 8 using System.Threading.Tasks;
 9 using System.Windows.Forms;
10 
11 namespace BS结构用户界面
12 {
13     public partial class buy : Form
14     {
15 
16         Image tp;
17         string h;
18         string jia;
19         public buy()
20         {
21             InitializeComponent();
22         }
23 
24         public buy(Image picture,string hua,string jiage)//构造函数
25         {
26             InitializeComponent();
27             tp = picture;
28             h = hua;
29             jia = jiage;
30         }
31 
32         private void button1_Click(object sender, EventArgs e)
33         {
34             int temp = int.Parse(this.textBox1.Text);
35             temp += 1;
36             string a = temp.ToString();
37             this.textBox1.Text = a;
38         }
39 
40         private void button2_Click(object sender, EventArgs e)
41         {
42             int temp = int.Parse(this.textBox1.Text);
43             if (temp  > 0)
44             {
45                 temp -= 1;
46             }
47             string a = temp.ToString();
48             this.textBox1.Text = a;
49         }
50 
51         private void buy_Load(object sender, EventArgs e)//传递主界面点击值
52         {
53             this.pictureBox1.BackgroundImage = tp;
54             this.label2.Text = h;
55             this.label3.Text = jia;
56 
57         }
58 
59         private void button3_Click(object sender, EventArgs e)//计算金额
60         {
61             string m = this.textBox1.Text;
62             string hua = this.label2.Text;
63             int s, sum,shu;
64             s = int.Parse(this.label3.Text);
65             shu = int.Parse(m);
66             sum = shu * s;
67             MessageBox.Show("您购买了"+shu+""+hua+"一共是"+sum+"");
68         }
69     }
70 }

运行结果:

选择数量后:

 

 点击购买后:

 

posted @ 2020-12-10 19:30  wumingxiaozu  阅读(244)  评论(0编辑  收藏  举报