首页 新闻 会员 周边 捐助

变态的问题(急)

0
悬赏园豆:15 [已关闭问题] 关闭于 2008-12-06 12:05

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PB.Business;
using PB.Common;
using PB.Entity;
using System.Text;
using WebMessageBox;

public partial class olclass_order : UserPageBase
{
    public string type;
    public  string isyc="yc";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            Assignment();
        }
    }

    public void Assignment()
    {
        dropArea.DataSource = UserJY.GetAreaList();
        dropArea.DataBind();

        chkDistrib.DataSource = UserJY.GetDistribTypeList();
        chkDistrib.DataBind();
        chkDistrib.SelectedValue = "1";
       
        //读取购物车里的商品
        List<OrderGoodInfo> cartgoods = carts.GetGoodList();
        Repeater1.DataSource = cartgoods;
        Repeater1.DataBind();
      
        foreach(OrderGoodInfo info1 in cartgoods)
        {
          
  if (info1.Type == 2)
                isyc = "";
            break;
        }
        lblsum.Text = lblcheapmoney.Text = carts.GetAmount().ToString();

        LinkButton2.Enabled = carts.GetAmount() > 0;
    }

    public string GetType(int id)
    {
        if (id == 1)
        {
            return type = "课程";
        }
        else
        {
            return type = "图书";
        }
    }

    public string GetTitle(string title, int num)
    {
        if (title.Length > num)
        {
            return title.Substring(0, num) + "....";
        }
        else
        {
            return title;
        }
    }

    protected void ImageButton1_Click(object sender, EventArgs e)
    {
        List<OrderGoodInfo> cartgoods = carts.GetGoodList();
        Decimal balance = UserJY.GetUserAccount(userid).Balance;
        Decimal amount = carts.GetAmount();
        int orderid = orders.GenerateOrderNumber(userid);

        //配送信息
        DistributionInfo distrib = new DistributionInfo();
        distrib.Address = tbAddress.Text.Trim();
        distrib.Area = int.Parse(dropArea.SelectedValue);
        distrib.Email = tbEmail.Text.Trim();
        distrib.FName = tbFName.Text.Trim();
        distrib.Post = tbPost.Text.Trim();
        distrib.Tel = tbTel.Text.Trim();
        distrib.Type = int.Parse(chkDistrib.SelectedValue);

        //添加订单
        orders.AddOrder(orderid, userid, cartgoods, amount, distrib);

        //如果用户帐户上有钱,直接从账户上扣除
        if (balance >= amount)
        {
            //更新账户余额
            UserJY.UpdateUserAccount(userid, balance - amount, amount);
            //结算账单
            orders.Pay(orderid);
            //插入商品权限
            foreach (OrderGoodInfo good in cartgoods)
                ClassAuthorization.Add(userid, good.GoodId, good.Type, 1);

        }

        MessageBox.Show("购买成功", "buysuccess.aspx?orderid=" + orderid.ToString() + "&distrib=" + Utils.UrlEncode(chkDistrib.SelectedItem.Text) + "&isyc=" + isyc);

    }

  }
今天在公司遇到个很奇怪的问题,希望能得到园子里各位高手的帮助,
我的本意是,根据全局isyc的默认值是"yc",在经过那个循环后,break,在我用断点调试的时候,
    foreach(OrderGoodInfo info1 in cartgoods)
        {
          
  if (info1.Type == 2)
                isyc = "";
            break;
        }
走到这那,当时的isyc =""
可不知道为什么,当我要传ID的时候,那个isyc 又变成了"yc"
如果我有描述的不是很清楚的地方请联系我QQ75618538。E_mail:epwqgdnvrhok@163.com

悟〈--觉的主页 悟〈--觉 | 初学一级 | 园豆:145
提问于:2008-12-06 11:15
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册