//购买商品 private void bttgoodsshooping_Click(object sender, EventArgs e) { //如果未检测到可用卡,则提示信息 if (string.IsNullOrEmpty(txtGoodsuserID.Text)) { MessageBox.Show("未检测到可用账户!"); return; } else { Userinfo userinfo = UserInfoManage.GetSelectUserinfoByID(txtGoodsuserID.Text); if (userinfo == null) { MessageBox.Show("此卡还未开通,请开卡或者换卡!"); return; } else if (string.IsNullOrEmpty(txtGoodsID.Text)) { MessageBox.Show("请先选择购买商品!"); return; } else { decimal result = userinfo.UserMoney - Convert.ToDecimal(this.txtGoodsPrice.Text); if (result < 0) { MessageBox.Show("此卡余额不足,请充值后购买!"); return; } } } UserxiaofeiInfo userxiaofei = new UserxiaofeiInfo(); userxiaofei.UsercardID = Convert.ToString(this.txtGoodsuserID.Text); userxiaofei.GoodsID = Convert.ToInt32(this.txtGoodsID.Text); userxiaofei.Userxiaomoney = Convert.ToDecimal(this.txtGoodsPrice.Text); userxiaofei.UserTime = DateTime.Now; if (UserxiaofeiInfoservice.InsertUserxiaofeiinfo(userxiaofei)) { MessageBox.Show("商品购买成功!"); } else { MessageBox.Show("商品购买失败!"); } }
//添加 public static bool InsertUserxiaofeiinfo(UserxiaofeiInfo UserxiaofeiInfo) { return(UserxiaofeiInfoservice.InsertUserxiaofeiinfo(UserxiaofeiInfo)); }
public static DataTable SelectUserxiaofeiinfo() { return(UserxiaofeiInfoservice.SelectUserxiaofeiinfo()); }