Пример #1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            double totalPrices = 0;

            CashContext cc = null;

            switch (cbxType.SelectedItem.ToString())
            {
            case "正常收费":
                cc = new CashContext(new CashNormal());
                break;

            case "满300返100":
                cc = new CashContext(new CashReturn("300", "100"));
                break;

            case "打八折":
                cc = new CashContext(new CashDiscount("0.8"));
                break;
            }
            totalPrices = cc.GetResult(Convert.ToDouble(txtPrice.Text) * Convert.ToDouble(txtNum.Text));

            total += totalPrices;
            lbxList.Items.Add(
                "单价:" + txtPrice.Text + " 数量:" + txtNum.Text + " " + cbxType.SelectedItem + " 合计:" + totalPrices.ToString());
            lblResult.Text = total.ToString();
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            double totalPrices = 0;

            CashContext cc = null;

            switch (cbxType.SelectedItem.ToString())
            {
                case "正常收费":
                    cc = new CashContext(new CashNormal());
                    break;
                case "满300返100":
                    cc = new CashContext(new CashReturn("300", "100"));
                    break;
                case "打八折":
                    cc = new CashContext(new CashDiscount("0.8"));
                    break;
            }
            totalPrices = cc.GetResult(Convert.ToDouble(txtPrice.Text) * Convert.ToDouble(txtNum.Text));

            total += totalPrices;
            lbxList.Items.Add(
                "单价:" + txtPrice.Text + " 数量:" + txtNum.Text + " " + cbxType.SelectedItem + " 合计:" + totalPrices.ToString());
            lblResult.Text = total.ToString();
        }