示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            // 使用工厂获得一个计算对象.
            //CashSuper csuper = CashFactory.createCashAccept(cbxType.SelectedItem.ToString());
            //double dTotalOrigin = Convert.ToDouble(txtPrice.Text)*Convert.ToDouble(txtNum.Text);
            //double dTotalHuoDong = csuper.acceptCash(dTotalOrigin);

            //total += dTotalHuoDong;

            //// 本次交易价统计.
            //lbxList.Items.Add("单价: " + txtPrice.Text + " 数量: "
            //                  + txtNum.Text +
            //                  " " + cbxType.SelectedItem + " 合计: "
            //                  + dTotalHuoDong.ToString());

            //lblResult.Text = total.ToString();

            CashContext csuper        = new CashContext(cbxType.SelectedItem.ToString());
            double      dTotalOrigin  = Convert.ToDouble(txtPrice.Text) * Convert.ToDouble(txtNum.Text);
            double      dTotalHuoDong = csuper.GetResult(dTotalOrigin);

            total += dTotalHuoDong;

            // 本次交易价统计.
            lbxList.Items.Add("单价: " + txtPrice.Text + " 数量: "
                              + txtNum.Text +
                              " " + cbxType.SelectedItem + " 合计: "
                              + dTotalHuoDong.ToString());

            lblResult.Text = total.ToString();
        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            // 使用工厂获得一个计算对象.
            //CashSuper csuper = CashFactory.createCashAccept(cbxType.SelectedItem.ToString());
            //double dTotalOrigin = Convert.ToDouble(txtPrice.Text)*Convert.ToDouble(txtNum.Text);
            //double dTotalHuoDong = csuper.acceptCash(dTotalOrigin);

            //total += dTotalHuoDong;

            //// 本次交易价统计.
            //lbxList.Items.Add("单价: " + txtPrice.Text + " 数量: "
            //                  + txtNum.Text +
            //                  " " + cbxType.SelectedItem + " 合计: "
            //                  + dTotalHuoDong.ToString());

            //lblResult.Text = total.ToString();

            CashContext csuper = new CashContext(cbxType.SelectedItem.ToString());
            double dTotalOrigin = Convert.ToDouble(txtPrice.Text) * Convert.ToDouble(txtNum.Text);
            double dTotalHuoDong = csuper.GetResult(dTotalOrigin);

            total += dTotalHuoDong;

            // 本次交易价统计.
            lbxList.Items.Add("单价: " + txtPrice.Text + " 数量: "
                              + txtNum.Text +
                              " " + cbxType.SelectedItem + " 合计: "
                              + dTotalHuoDong.ToString());

            lblResult.Text = total.ToString();
        }
示例#3
0
        static void Main(string[] args)
        {
            CashContext csuper = new CashContext("0.8");
            double totalPrices = 0d;
            totalPrices = csuper.GetResult(20*20);

            Console.WriteLine(totalPrices);
            Console.ReadKey();
        }