public ActionResult Trans(FormCollection FC) { //根据账号获取账号的详细信息 int account = Convert.ToInt32(Session["Account"]); UserInfo userInfo = ur1.GetUserDetail(account); string balance = FC["recmoney"]; string recaccount = FC["recaccount"]; UserInfo uinfo = new UserInfo(); if (string.IsNullOrEmpty(FC["recaccount"])) { return(Content("<script>alert('必须输入转账账号!');document.location.href='../Trade/Trans';</script>")); } if (!Regex.IsMatch(FC["recaccount"], @"^\d{8}$")) { ViewBag.error = "转账账户必须为8位"; return(View(userInfo)); } if (ur1.GetUserDetail(Convert.ToInt32(FC["recaccount"])) == null) { return(Content("<script>alert('用户不存在!');document.location.href='../Trade/Trans';</script>")); } if (string.IsNullOrEmpty(FC["recmoney"])) { return(Content("<script>alert('必须输入转账金额!');document.location.href='../Trade/Trans';</script>")); } if (int.Parse(FC["recmoney"]) < 0) { return(Content("<script>alert('转账金额必须大于零元!');document.location.href='../Trade/Trans';</script>")); } uinfo.Account = Convert.ToInt32(recaccount); uinfo.Balance = Convert.ToDecimal(balance); string tradePWD = FC["tradePWD"]; //userInfo.CreateDate = DateTime.Now; if (tradePWD != userInfo.TradePass) { ViewBag.error = "密码错误!!"; return(View(userInfo)); } ur.Outmoney(account, Convert.ToDecimal(balance)); ur.TransInmoney(uinfo); //记录交易的信息,为其提供具体信息 TradeInfo tInfo = new Bank.Models.TradeInfo(); tInfo.Account = userInfo.Account; tInfo.TradeType = 2; tInfo.MoneyNum = Convert.ToDecimal(balance); tInfo.CreateDate = DateTime.Now; ur.AdminInmoney(tInfo); return(RedirectToAction("Menu", "Users")); }
// [Login] public ActionResult OutMoney(FormCollection FC) { //根据账号获取账户信息 int account = Convert.ToInt32(Session["Account"]); UserInfo userInfo = ur1.GetUserDetail(account); string balance = FC["yue"]; string tradePWD = FC["tradePWD"]; //判断界面信息是否输入 if (string.IsNullOrEmpty(FC["yue"])) { return(Content("<script>alert('必须输入取款金额!');document.location.href='../Trade/OutMoney';</script>")); } if (!Regex.IsMatch(FC["yue"], @"^[0-9]*$")) { ViewBag.show = "取款金额输入格式不对!"; return(View(userInfo)); } if (string.IsNullOrEmpty(FC["tradePWD"])) { return(Content("<script>alert('必须输入取款密码!');document.location.href='../Trade/OutMoney';</script>")); } if (int.Parse(FC["yue"]) < 0) { return(Content("<script>alert('取款金额必须大于零元!');document.location.href='../Trade/OutMoney';</script>")); } if (Convert.ToDecimal(FC["yue"]) > userInfo.Balance) { ViewBag.show = "您的余额并不足!"; return(View(userInfo)); } if (tradePWD == userInfo.TradePass) { ur.Outmoney(account, Convert.ToDecimal(balance)); //记录取款信息 TradeInfo tInfo = new Bank.Models.TradeInfo(); tInfo.Account = userInfo.Account; tInfo.TradeType = 0; //附上默认值 tInfo.MoneyNum = Convert.ToDecimal(balance); tInfo.CreateDate = DateTime.Now; //创建时间为当前的时间 ur.AdminInmoney(tInfo); return(RedirectToAction("Menu", "Users")); } else { ViewBag.show = "密码错误!!!"; return(View(userInfo)); } }
// [Login] public ActionResult InMoney(FormCollection FC) { try { int account = Convert.ToInt32(Session["Account"]); UserInfo userInfo = ur1.GetUserDetail(account); //判断界面是否输入信息 if (string.IsNullOrEmpty(FC["balance"])) { return(Content("<script>alert('必须输入存款金额!');document.location.href='../Trade/InMoney';</script>")); } if (int.Parse(FC["balance"]) < 0) { return(Content("<script>alert('存款金额必须大于零元!');document.location.href='../Trade/InMoney';</script>")); } if (FC["balance"] != null) { decimal ba = Convert.ToDecimal(FC["balance"]); ur.Inmoney(account, ba); //记录存款信息 TradeInfo tInfo = new Bank.Models.TradeInfo(); tInfo.Account = userInfo.Account; tInfo.TradeType = 1;//附上默认值 tInfo.MoneyNum = ba; tInfo.CreateDate = DateTime.Now; //调用方法 实现存款 ur.AdminInmoney(tInfo); return(RedirectToAction("Menu", "Users")); } else { return(View(userInfo)); } } catch (Exception) { ViewBag.show = "请输入正确的格式!"; return(View()); } }