protected void bt_Add_Click(object sender, ImageClickEventArgs e) { ORD_OrderCartBLL cart = (ORD_OrderCartBLL)Session["LogisticsOrderApplyDetail"]; ImageButton b = (ImageButton)sender; TextBox tbx_BookQuantity_T = (TextBox)b.Parent.FindControl("tbx_BookQuantity_T"); GridViewRow row = (GridViewRow)tbx_BookQuantity_T.Parent.Parent; int quantity = int.Parse(tbx_BookQuantity_T.Text); int product = (int)gv_List.DataKeys[row.RowIndex]["Product"]; int factor = new PDT_ProductBLL(product, true).Model.ConvertFactor; cart.ModifyQuantity(product, quantity * factor + factor); BindGrid(); }
protected void tbx_BookQuantity_T_TextChanged(object sender, EventArgs e) { ORD_OrderCartBLL cart = (ORD_OrderCartBLL)Session["LogisticsOrderApplyDetail"]; TextBox tbx_BookQuantity_T = (TextBox)sender; GridViewRow row = (GridViewRow)tbx_BookQuantity_T.Parent.Parent; int product = (int)gv_List.DataKeys[row.RowIndex]["Product"]; int quantity = 0; if (int.TryParse(((TextBox)sender).Text, out quantity)) { int factor = new PDT_ProductBLL(product, true).Model.ConvertFactor; if (factor > 0) { quantity = quantity * factor; } switch (cart.ModifyQuantity(product, quantity)) { case 0: break; case -1: MessageBox.Show(this, "购物车中不包括此产品!"); break; case -2: MessageBox.Show(this, "申请数量已超可申请数量!"); break; case -3: MessageBox.Show(this, "申请数量小于最小单次申请数量!"); break; case -4: MessageBox.Show(this, "申请数量大于最大单次申请数量!"); break; default: MessageBox.Show(this, "数量更新错误!"); break; } } else { MessageBox.Show(this, "数字格式不对,必须为整数类型!"); } BindGrid(); }