Exemplo n.º 1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            molOrder = bllOrder.GetModel1(int.Parse(Request["ID"]));
                molOrderinfo = bllOrderinfo.GetModel1(Int32.Parse(molOrder.U_ID.ToString())); //在Orderinfo中获取U_ID
                DataTable num = bllOrderinfo.GetList("U_ID = '" + molOrder.U_ID + "'").Tables[0]; //根据order表获得orderinfo,创建一个数据表给num
                for (int i = 0; i < num.Rows.Count; i++)
                {

                    DataTable Goods = bllgoods.GetList("Goods_ID = '" + num.Rows[i]["Goods_ID"].ToString() + "'").Tables[0];    //根据获取到的Goods_ID创建一个数据表给Goods
                    molgoods.Goods_ID = Int32.Parse(num.Rows[i]["Goods_ID"].ToString());
                    molgoods.Stock = Int32.Parse(Goods.Rows[0]["Stock"].ToString()) - Int32.Parse(num.Rows[i]["Goods_Num"].ToString());  //遍历之后减库存
                    molgoods.Sales_volume = Int32.Parse(Goods.Rows[0]["Sales_volume"].ToString()) + Int32.Parse(num.Rows[i]["Goods_Num"].ToString());  //遍历之后加销量
                    bllgoods.Updatestock(molgoods);

                }
                molOrder.Style = "已付款";
                bllOrder.Update(molOrder);
                Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('付款成功!');location.href='PersonalOrder.aspx';</script>");
        }
Exemplo n.º 2
0
        /// <summary>
        /// 得到U_ID 
        /// </summary>
        public TtNum1.Model.Orderinfo GetModel1(int U_ID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1  ");
            strSql.Append(" OrderInfo_ID,U_ID,Goods_ID,Goods_Name,Goods_Num,Goods_Money,Style,IN_group_buying ");
            strSql.Append(" from Orderinfo ");
            strSql.Append(" where U_ID=" + U_ID + "");
            TtNum1.Model.Orderinfo model = new TtNum1.Model.Orderinfo();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["OrderInfo_ID"] != null && ds.Tables[0].Rows[0]["OrderInfo_ID"].ToString() != "")
                {
                    model.OrderInfo_ID = int.Parse(ds.Tables[0].Rows[0]["OrderInfo_ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["U_ID"] != null && ds.Tables[0].Rows[0]["U_ID"].ToString() != "")
                {
                    model.U_ID = int.Parse(ds.Tables[0].Rows[0]["U_ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Goods_ID"] != null && ds.Tables[0].Rows[0]["Goods_ID"].ToString() != "")
                {
                    model.Goods_ID = int.Parse(ds.Tables[0].Rows[0]["Goods_ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Goods_Name"] != null && ds.Tables[0].Rows[0]["Goods_Name"].ToString() != "")
                {
                    model.Goods_Name = ds.Tables[0].Rows[0]["Goods_Name"].ToString();
                }

                if (ds.Tables[0].Rows[0]["Goods_Num"] != null && ds.Tables[0].Rows[0]["Goods_Num"].ToString() != "")
                {
                    model.Goods_Num = int.Parse(ds.Tables[0].Rows[0]["Goods_Num"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Goods_Money"] != null && ds.Tables[0].Rows[0]["Goods_Money"].ToString() != "")
                {
                    model.Goods_Money = int.Parse(ds.Tables[0].Rows[0]["Goods_Money"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Style"] != null && ds.Tables[0].Rows[0]["Style"].ToString() != "")
                {
                    model.Style = ds.Tables[0].Rows[0]["Style"].ToString();
                }
                if (ds.Tables[0].Rows[0]["IN_group_buying"] != null && ds.Tables[0].Rows[0]["IN_group_buying"].ToString() != "")
                {
                    model.IN_group_buying = int.Parse(ds.Tables[0].Rows[0]["IN_group_buying"].ToString());
                }

                return model;
            }
            else
            {
                return null;
            }
        }