非常紧急 ,C#.net高手请帮忙
谁会C#.net??
我有东西想向高手请教。
我出现的问题.
当我click radiobtn $5 和 radiobtn $2 是 我的 A lbl 会显示 $5, B lbl 会显示 $2, C lbl 会 lbl A + lbl B = $ 7. 如果我转去click $10 我的 Albl 就会显示 $10 , 而 Clbl 就会 $5 + $2 + $10 = $17 . 同样的如过 我选回 $5 我的 总数(C lbl ) 就会回到 $5 + $2 + $10 + $5 = $22 ......问题就是我的总数只有加没减....
我想要的是这样。
当我click radiobtn $5 和 radiobtn $2 是 我的 A lbl 会显示 $5, B lbl 会显示 $2, C lbl 会 lbl A + lbl B = $ 7. 如果我转去click $10 我的 Albl 就会显示 $10 , 而 Clbl 就会 $12 . 同样的如过 我选回 $5 我的 总数(C lbl ) 就会回到 $7.
所有的操作一定不需按任何键,这是最重要的地方
---------------------------------------- -----------------
Radiobtn $5 Radiobtn $10 | | | A label
---------------------------------------- -----------------
---------------------------------------- ------------------
Radiobtn $2 Radiobtn $15 | | | B label
---------------------------------------- ------------------
Total -------------------
| | C label
------------------
以下是我的 coding.........谁可以跟我说哪里错,要怎样改
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
decimal decTotalPrice = 0;
const decimal
decFRENCHFRIESSMALL_PRICE = 1.60M,
decFRENCHFRIESMEDIUM_PRICE = 2.20M,
decFRENCHFRIESLARGE_PRICE = 3.00M,
decBURGERSSMALL_PRICE = 2.25m,
decBURGERSMEDIUM_PRICE = 3.10M,
decBURGERSLARGE_PRICE = 3.65M,
decSALADSSMALL_PRICE = 1.85M,
decSALADSMEDIUM_PRICE = 2.35M,
decSALADSLARGE_PRICE = 3.40M,
decDRINKSSMALL_PRICE = 1.65M,
decDRINKSMEDIUM_PRICE = 2.10M,
decDRINKSLARGE_PRICE = 2.80M,
decCAKESSMALL_PRICE = 2.10M,
decCAKESMEDIUM_PRICE = 2.95M,
decCAKESLARGE_PRICE = 3.85M;
private void radioBtnSmallFF_CheckedChanged(object sender, System.EventArgs e)
{
decimal decPrice = 0M;
if (radioBtnSmallFF.Checked)
{
decPrice = decFRENCHFRIESSMALL_PRICE;
lblFrenchFries.Text = decPrice.ToString("C");
decTotalPrice += decPrice;
lblTotalPrice.Text = decTotalPrice.ToString("C");
}
}
private void radioBtnSmallBG_CheckedChanged(object sender, System.EventArgs e)
{
decimal decPrice = 0M;
if (radioBtnSmallBG.Checked)
{
decPrice = decBURGERSSMALL_PRICE;
lblBurgers.Text = decPrice.ToString("C");
decTotalPrice += decPrice;
lblTotalPrice.Text = decTotalPrice.ToString("C");
}
}
private void radioBtnSmallSL_CheckedChanged(object sender, System.EventArgs e)
{
decimal decPrice = 0M;
if (radioBtnSmallSL.Checked)
{
decPrice = decSALADSSMALL_PRICE;
lblSalads.Text = decPrice.ToString("C");
decTotalPrice += decPrice;
lblTotalPrice.Text = decTotalPrice.ToString("C");
}
}
private void radioBtnSmallDR_CheckedChanged(object sender, System.EventArgs e)
{
decimal decPrice = 0M;
if (radioBtnSmallDR.Checked)
{
decPrice = decDRINKSSMALL_PRICE;
lblDrinks.Text = decPrice.ToString("C");
decTotalPrice += decPrice;
lblTotalPrice.Text = decTotalPrice.ToString("C");
}
}
private void radioBtnSmallCK_CheckedChanged(object sender, System.EventArgs e)
{
decimal decPrice = 0M;
if (radioBtnSmallCK.Checked)
{
decPrice = decCAKESSMALL_PRICE;
lblCakes.Text = decPrice.ToString("C");
decTotalPrice += decPrice;
lblTotalPrice.Text = decTotalPrice.ToString("C");
}
}
[ 本帖最后由 vzhen 于 10-4-2007 15:00 编辑 ]