C#窗体程序简单制作(简单购物系统/网购系统)

C#窗体程序简单制作(简单购物系统/网购系统)

1.C#程序执行结果

在这里插入图片描述

2.程序思路:

(简单模拟)
1.点击加入购物车; 2.选择商品购买数量; 3.必须指定定物流方式;4.点击按钮。

3.C#代码

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;

namespace _8_10_网购系统
{
	/// <summary>
	/// Description of MainForm.
	/// </summary>
	public partial class MainForm : Form
	{
		public int a,b,c,d;   // 第一操作数(存储数字微调框的数字)
		public float f; // 运算符
		
		public MainForm()
		{
			InitializeComponent();
		}
		
		void Button1Click(object sender, EventArgs e)
		{
		   a = Convert.ToInt32(numericUpDown1.Value.ToString());   // 数字微调框的数字
           b = Convert.ToInt32(numericUpDown2.Value.ToString());   // 数字微调框的数字
           c = Convert.ToInt32(numericUpDown3.Value.ToString());   // 数字微调框的数字
           d = Convert.ToInt32(numericUpDown4.Value.ToString());   // 数字微调框的数字
           f = (199 * a + 119 * b + 259 * c + 139 * d);

            if (comboBox1.SelectedIndex == -1)
            {
            	MessageBox.Show("请指定物流方式!");
            }
            else
            {
            MessageBox.Show("本次购物一共"+f.ToString()+"元"+","+"使用的快递为"+comboBox1.Text+"。");
            }
		}
		
		void CheckBox1CheckedChanged(object sender, EventArgs e)   // 加入购物车 1
		{
			if (checkBox1.Checked)   { numericUpDown1.Enabled = true;}
			else { numericUpDown1.Enabled = false;}
		}
		
		void CheckBox2CheckedChanged(object sender, EventArgs e)
		{
			if (checkBox2.Checked)   { numericUpDown2.Enabled = true;}
			else { numericUpDown2.Enabled = false;}
		}
		
		void CheckBox3CheckedChanged(object sender, EventArgs e)
		{
			if (checkBox3.Checked)   { numericUpDown3.Enabled = true;}
			else { numericUpDown3.Enabled = false;}
		}
		
		void CheckBox4CheckedChanged(object sender, EventArgs e)
		{
			if (checkBox4.Checked)   { numericUpDown4.Enabled = true;}
			else { numericUpDown4.Enabled = false;}
		}
	}
}

原创文章 23 获赞 11 访问量 4192

猜你喜欢

转载自blog.csdn.net/Z_r_s/article/details/94362637