基本信息
源码名称:C# 设计模式之【策略模式】 实例源码
源码大小:0.29M
文件格式:.zip
开发语言:C#
更新时间:2015-08-27
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Reflection; namespace 商场管理软件 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } DataSet ds;//用于存放配置文件信息 double total = 0.0d;//用于总计 private void Form1_Load(object sender, EventArgs e) { //读配置文件 ds = new DataSet(); ds.ReadXml(Application.StartupPath "\\CashAcceptType.xml"); //将读取到的记录绑定到下拉列表框中 foreach (DataRowView dr in ds.Tables[0].DefaultView) { cbxType.Items.Add(dr["name"].ToString()); } cbxType.SelectedIndex = 0; } private void btnOk_Click(object sender, EventArgs e) { CashContext cc = new CashContext(); //根据用户的选项,查询用户选择项的相关行 DataRow dr = ((DataRow[])ds.Tables[0].Select("name='" cbxType.SelectedItem.ToString() "'"))[0]; //声明一个参数的对象数组 object[] args =null; //若有参数,则将其分割成字符串数组,用于实例化时所用的参数 if (dr["para"].ToString() != "") args = dr["para"].ToString().Split(','); //通过反射实例化出相应的算法对象 cc.setBehavior((CashSuper)Assembly.Load("商场管理软件").CreateInstance("商场管理软件." dr["class"].ToString(), false, BindingFlags.Default, null, args, null, null)); double totalPrices = 0d; totalPrices = cc.GetResult(Convert.ToDouble(txtPrice.Text) * Convert.ToDouble(txtNum.Text)); total = total totalPrices; lbxList.Items.Add("单价:" txtPrice.Text " 数量:" txtNum.Text " " cbxType.SelectedItem " 合计:" totalPrices.ToString()); lblResult.Text = total.ToString(); } private void btnClear_Click(object sender, EventArgs e) { total = 0d; txtPrice.Text = "0.00"; txtNum.Text = "1"; lbxList.Items.Clear(); lblResult.Text = "0.00"; } } }