// 结算 protected void imgb_Salary_Click(object sender, ImageClickEventArgs e) { //根据登录者的id将购物车里的信息取出来 List <Carts> listcarts = cm.GetAllInfo(user.LoginId); int count = listcarts.Count; if (count == 0) { //如果该用户购物车为空,则提醒用户添加商品 Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请选择要购买的图书!!')</script>"); return; } //实例化银行serice类 MyBank.Service service = new MyBank.Service(); //调用方法 int res = service.SelectAccount(user.LoginId, user.LoginPwd); //判断用户名和密码是否输入正确 if (res > 0) { int res1 = service.SelectStatus(user.LoginId); //判断该账户的状态 if (res1 == 1) { int res2 = service.SelectMoney(Convert.ToDouble(ltrSalary.Text), user.LoginId); //查看余额 if (res2 > 0) { int res3 = service.UpdateMoney(user.LoginId, Convert.ToDouble(ltrSalary.Text)); //支付账单, if (res3 > 0) { //将购物车的信息加入到历史订单中 List <Carts> listcarts1 = GetChecked(); for (int i = 0; i < listcarts1.Count; i++) { OrderDetails ods = new OrderDetails(); ods.UserId = user.LoginId; ods.BookName = listcarts1[i].BookName; ods.BookCount = listcarts1[i].BookCount; ods.BookImage = listcarts1[i].BookImage; ods.BookPrice = listcarts1[i].BookPrice; ods.BuyDate = Convert.ToDateTime(DateTime.Now.ToLongDateString()); ods.Total = ods.BookPrice * Convert.ToDouble(ods.BookCount); int re = odm.AddInfoByid(ods); cm.DeleteById(listcarts1[i].BookName, user.LoginId); } BindGridView(user.LoginId); //支付成功 Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('支付成功,请查看订单!!');location.href='Order.aspx'</script>"); //Response.Redirect("Order.aspx"); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('支付失败!!')</script>"); } } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('余额不足!!')</script>"); } } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('该账户暂时不能支付!')</script>"); } } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('账号或密码输入错误!!!')</script>"); } }