/// <summary> /// 查询卡通过传入的User查询。User:Id,Password,Identify /// </summary> /// <param name="user">传入登录信息,账号Id,Password,Identify</param> /// <returns></returns> public DepositorAndCard QueryCardsService(User user) { DepositorAndCard cards = new DepositorAndCard(); //函数将要返回的对象 Cards card = new Cards(); //接受查询结果数据 Depositors depositor = new Depositors(); //接受查询结果数据 card = CardsAccess.QueryCardsData(user); if (card != null) //查询不空 { if (card.Cid != user.Id) //不是要查询的对象 { cards = null; } else { cards.Duid = (int)card.Cuid;//返回对象装入值 cards.Dcid = card.Cid; cards.Dname = idcardService.QueryService(card.Cicid).Icname; } } else { cards = null; } return(cards); }
/// <summary> /// 根据封装登录信息的对象User(卡或储户) /// </summary> /// <param name="user">Id,Password,Identify</param> /// <returns>Depositors</returns> public DepositorAndCard QueryDepositorsService(User user) { Depositors depositor = new Depositors(); //接受返回值 DepositorAndCard depositors = new DepositorAndCard(); //函数将要返回的对象 depositor = accessDepositors.QueryDepositorsData(user); if (depositor != null) { if (depositor.Uid != user.Id) { depositors = null; } else { depositors.Duid = depositor.Uid; depositors.Dcid = depositor.Ucid; if (depositor.Ucid == null) { depositors.Dname = "您还没有绑定银行卡"; } else { depositors.Dname = idcardService.QueryService(depositor.Uicid).Icname; } } } else { depositors = null; } return(depositors); }
/// <summary> /// 增加定期存款记录,并向FixBalance表添加存款数据,分别向fixbalanceService,recordsService提出需求。 /// </summary> /// <param name="depositorAndCard">传入从cooike中获取的储户和储户银行卡信息。其对象为DepositorAndCard</param> /// <param name="fix">Fyear,FfixBalanceRate,FfixBalance,FfixBalance</param> /// <param name="mid">传入业务办理员账号Mid</param> public void AddFixBalanceService(DepositorAndCard depositorAndCard, Fixbalances fix, int mid) { fix.Fcid = (int)depositorAndCard.Dcid; fix.Fmid = mid; fixbalanceService.AddFixBalanceService(fix); recordsService.AddRecordsService(depositorAndCard, 0, 3, (double)fix.FfixBalance, mid); //此处的0没有意义 }
/// <summary> /// 增加活期存款记录Records,并向修改cards表中的数据,分别向cardServive,recordsService提出需求。 /// </summary> /// <param name="dAndC">传入从cooike中获取的储户和储户银行卡信息。其对象为DepositorAndCard</param> /// <param name="card">CflowBalance</param> /// <param name="mid">传入业务办理员账号Mid</param> public void AddFlowBalanceService(DepositorAndCard dAndC, Cards card, int mid) { Cards cardss = new Cards(); cardss.CflowBalance = cardServive.FlowBalanceService((int)dAndC.Dcid)[1] + card.CflowBalance; //修改活期余额 cardss.Cid = (int)dAndC.Dcid; cardServive.UpdataFlowBalanceService(cardss); //更新 recordsService.AddRecordsService(dAndC, cardServive.CheakCardsService((int)dAndC.Dcid).Cicid, 2, (double)card.CflowBalance, mid); //Records生成记录 }
/// <summary> /// 活期存款 /// </summary> /// <param name="dAndC">cooike中当前账户信息:Cid,Uid,Name</param> /// <param name="money">前端出入ATM数钱器输入的活期存款金额</param> public void AddFloatBalanceService(DepositorAndCard dAndC, double money) { double moneys = money;//记录存款额 //money += (double)CardsAccess.CardsData((int)dAndC.Dcid).CflowBalance;//将存款额和原来的余额加起来,等待更新 money += FlowBalanceService((int)dAndC.Dcid)[1]; CardsAccess.UpdateCardsData((int)dAndC.Dcid, money); //更新余额 recordsService.AddRecordsService(dAndC, CardsAccess.CardsData((int)dAndC.Dcid).Cicid, 2, moneys, 0); //增加记录。0代表ATM }
/// <summary> /// 接受页面参数,准备判断应该登录那个系统 /// </summary> /// <param name="user">传入登录信息,账号Id,Password,Identify</param> /// <returns></returns> public IActionResult SignIn(User user) { user.Password = MD5Encrypt64(user.Password);//接到登录信息,给密码加密 //此处分类,让储户,管理员分别登录到自己的界面, //还有ATM系统登录(利用卡号登录) #region 储户新版本 if (user.Identify == "depository") { dAndC = depositorServive.QueryDepositorsService(user);//验证信息 if (dAndC != null) { return(RedirectToAction("Login", "Depositors", dAndC)); } else { return(Redirect(Url.Action("PasswordError", "Errors"))); } } #endregion #region ATM-银行卡 else if (user.Identify == "cards") { dAndC = cardServive.QueryCardsService(user);//验证信息 if (dAndC != null) { return(RedirectToAction("Login", "Cards", dAndC)); } else { return(Redirect(Url.Action("PasswordError", "Errors"))); } } #endregion #region 管理员或行长 else { manager = managerServive.QueryManagersService(user);//验证信息 if (manager == null || manager.Mpassword != user.Password) { return(Redirect(Url.Action("PasswordError", "Errors"))); } else if (user.Identify == "manager") { return(RedirectToAction("Login", "Managers", manager)); } else { return(RedirectToAction("Login", "Governors", manager)); } } #endregion }
//2.将返回的信息进行处理,然后登陆系统主页 /// <summary> /// 绑定银行卡并返回主页 /// </summary> /// <param name="depositor">前端传入DepositorAndCard对象,属性:Dcid,Dicid</param> /// <returns></returns> public IActionResult UpdataBand(DepositorAndCard depositor) { DepositorAndCard depositor1 = new DepositorAndCard(); depositor.Duid = DAndC().Duid; depositor1 = depositorServive.UpdataBandService(depositor);//绑定 if (depositor1 != null) { return(RedirectToAction("Login", "Depositors", depositor1)); } else { return(Redirect(Url.Action("DepositoryNotExistError", "Errors"))); } }
/// <summary> /// 接受前端页面的User信息 /// </summary> /// <param name="card">User型对象:Id,Password</param> /// <returns></returns> public IActionResult BusinessLogin(User card) { card.Password = MD5Encrypt64(card.Password);//Md5加密 DepositorAndCard dAndC = new DepositorAndCard(); dAndC = managerServive.LoginCardsService(card); if (dAndC != null)//不空,证明验证成功 { AddCooikeOfDAndC(dAndC); return(View());//返回业务办理页面 } else { return(RedirectToAction("CardsLoginError", "Errors")); } }
//2.将返回的信息进行处理,然后登陆系统主页 /// <summary> /// 增加储户,并登录到储户系统 /// </summary> /// <param name="depositor">传入前端页面填写的信息,参数对象Depositors:Uid,Uicid,Upassword </param> /// <returns></returns> public IActionResult AddLogin(Depositors depositor) { depositor.Upassword = MD5Encrypt64(depositor.Upassword); DepositorAndCard depositors = new DepositorAndCard(); depositors = depositorServive.AddService(depositor); if (depositors != null) { cooikeAdd(depositors); return(RedirectToAction("Login", "Depositors", depositors)); } else { return(Redirect(Url.Action("DepositoryExistError", "Errors"))); } }
/// <summary> /// 从浏览器获取DepositorAndCard对象的值:Dcid,Dname,Duid /// </summary> /// <returns>返回DepositorAndCard对象</returns> public DepositorAndCard DAndC() { DepositorAndCard dAndC = new DepositorAndCard(); this.Request.Cookies.TryGetValue("Cid", out string Cid); int cid = int.Parse(Cid); this.Request.Cookies.TryGetValue("Uid", out string Uid); int uid = int.Parse(Uid); this.Request.Cookies.TryGetValue("Name", out string Name); string name = Name; dAndC.Dcid = cid; dAndC.Dname = name; dAndC.Duid = uid; return(dAndC); }
/// <summary> /// ATM活期取款功能 /// </summary> /// <param name="dAndC"></param> /// <param name="identity">传入操作类型,此处为1,为取款</param> /// <param name="money">传入取钱金额</param> /// <returns></returns> public bool DrawalService(DepositorAndCard dAndC, int identity, double money) { List <Double> record = new List <Double>(); record = FlowBalanceService((int)dAndC.Dcid); //查询银行卡活期的余额 if (record[1] >= money) //可取 { //1.修改卡的表项,//取钱, record[1] = record[1] - money; //使用计算的余额减去要取余额。 CardsAccess.UpdateCardsData((int)dAndC.Dcid, record[1]); //更新余额 AddRecordsService(dAndC, CardsAccess.CardsData((int)dAndC.Dcid).Cicid, identity, money); //增加记录 return(true); } else { return(false);//不可取 } }
/// <summary> /// 判断是否增加储户成功 /// </summary> /// <param name="depositor">表单填写的储户信息Uid,Uname,UPassword</param> /// <returns>DepositorAndCard</returns> public DepositorAndCard AddService(Depositors depositor) { DepositorAndCard depositors = new DepositorAndCard(); Depositors depositor1 = new Depositors(); depositor1 = accessDepositors.CheakData(depositor.Uid);//查询有没有该储户 if (depositor1 != null) { depositors = null; } else { accessDepositors.AddData(depositor); depositors.Duid = depositor.Uid; depositors.Dname = "请绑定银行卡"; } return(depositors); }
/// <summary> /// 绑定银行卡,数据访问层,根据储户账号Uid,修改Ucid /// </summary> /// <param name="depositor">前端传入DepositorAndCard对象,属性:Duid,Dname,Dcid</param> public void UpdataBandData(DepositorAndCard depositor) { using (var dbContext = new bankContext()) { //修改数据库信息最好有一些事务操作 using (var transaction = dbContext.Database.BeginTransaction()) { try { var sql = @"Update Depositors SET Ucid = {0},Uicid={1} WHERE Uid = {2}"; dbContext.Database.ExecuteSqlCommand(sql, depositor.Dcid, depositor.Dicid, depositor.Duid); dbContext.SaveChanges(); transaction.Commit(); } catch (Exception e) { Console.WriteLine(e.Message); transaction.Rollback(); } } } }
/// <summary> /// 查询银行卡登录 /// </summary> /// <param name="user">传入登录信息,账号Id,Password,Identify</param> /// <returns></returns> public DepositorAndCard QueryCardsData(User user) { Cards card = new Cards(); //接受查询到的数据 DepositorAndCard dAndC = new DepositorAndCard(); //函数将返回DepositorAndCard对象 using (var dbContext = new bankContext()) { card = dbContext.Cards.FirstOrDefault(a => a.Cid == user.Id); if (card != null && card.Cpassword == user.Password) { using (var viewContext = new ViewContext()) { dAndC = viewContext.DepositorAndCard.FirstOrDefault(a => a.Dcid == card.Cid);//返回储户和该用户默认的卡号组成的视图 } } else { dAndC = null; } } return(dAndC); }
/// <summary> /// 记录表Records中增加记录,该层为访问层,传入参数:DepositorAndCard,操作类型int v,double money, int mid /// </summary> /// <param name="dAndC">传入从cooike中获取的储户和储户银行卡信息。其对象为DepositorAndCard</param> /// <param name="v">出入参数v代表类型,1:代表取款,2:代表活期存款,其他:代表定期存款。每次传入一个类型的值,其他两项字段默认为0</param> /// <param name="money">金额</param> /// <param name="mid">业务办理员</param> public void AddData(DepositorAndCard dAndC, int icid, int v, double money, int mid) { using (var dbContext = new bankContext()) { //修改数据库信息最好有一些事务操作 using (var transaction = dbContext.Database.BeginTransaction()) { try { Records records = new Records(); records.Rcid = (int)dAndC.Dcid; records.Ruid = dAndC.Duid; records.Rmid = mid; records.Ricid = icid; if (v == 1) { records.Rwithdrawals = money; } else if (v == 2) { records.RflowDeposit = money; } else { records.RfixDeposit = money; } dbContext.Add(records); dbContext.SaveChanges(); transaction.Commit(); } catch (Exception e) { Console.WriteLine(e.Message); transaction.Rollback(); } } } }
/// <summary> /// 查询银行卡登录 /// </summary> /// <param name="user">传入登录信息,账号Id,Password,Identify</param> /// <returns></returns> public DepositorAndCard QueryDepositorData(User user) { Depositors depositors = new Depositors(); //接受查询到的数据 DepositorAndCard dAndC = new DepositorAndCard(); //函数将返回DepositorAndCard对象 using (var dbContext = new bankContext()) { depositors = dbContext.Depositors.FirstOrDefault(a => a.Uid == user.Id); //判断是否为正确 if (depositors != null && depositors.Upassword == user.Password) { using (var viewContext = new ViewContext()) //视图查询环境 { dAndC = viewContext.DepositorAndCard.FirstOrDefault(a => a.Dcid == depositors.Ucid); //返回储户和该用户默认的卡号组成的视图 } } else { dAndC = null; } } return(dAndC); }
/// <summary> /// 储户绑定卡号,先找到该储户,然后找到该储户要绑定的银行卡,最后绑定 /// </summary> /// <param name="depositor">前端传入DepositorAndCard对象,属性:Duid,Dname,Dcid</param> /// <returns></returns> public DepositorAndCard UpdataBandService(DepositorAndCard depositor) { Idcard idcard = new Idcard(); DepositorAndCard DAndC = new DepositorAndCard(); //返回对象 Cards card = new Cards(); //接受返回数据 Depositors depositor1 = new Depositors(); //接受查询到的数据 depositor1 = accessDepositors.CheakData(depositor.Duid); //查询有没有该储户 if (depositor1 != null) //有数据 { if (depositor1.Uid == depositor.Duid) //判断查找到的储户是不是我们要找的 { card = cardsService.CheakCardsService((int)depositor.Dcid); if (card != null && card.Cuid == depositor.Duid && card.Cicid == depositor.Dicid) //判断查找到的银行卡是不是我们要找的 { accessDepositors.UpdataBandData(depositor); //更新绑定卡号 idcard = idcardService.QueryService(card.Cicid); DAndC.Dname = idcard.Icname; DAndC.Dcid = depositor.Dcid; DAndC.Duid = depositor.Duid; } else { DAndC = null; } } else { DAndC = null; } } else { DAndC = null; } return(DAndC); }
/// <summary> /// 记录表Records中增加记录,业务逻辑层,CardsService对象将任务交给recordsService来处理 /// </summary> /// <param name="dAndC">传入从cooike中获取的储户和储户银行卡信息。其对象为DepositorAndCard</param> /// <param name="v">出入参数v代表类型,1:代表取款,2:代表活期存款,其他:代表定期存款。每次传入一个类型的值,其他两项字段默认为0</param> /// <param name="money">金额</param> /// <param name="mid">业务办理员</param> public void AddRecordsService(DepositorAndCard dAndC, int Icid, int v, double money) { //此处零代表的是记录表中Mid填为0,代表取款是在ATM中进行的。 recordsService.AddRecordsService(dAndC, Icid, v, money, 0); }
//public static RecordsService recordsService = new RecordsService(); #endregion #region “登录”功能 已实现 /// <summary> /// “登录”功能,向cooike中加入信息 /// </summary> /// <param name="card">传入DepositorAndCard类型的参数</param> /// <returns>返回主页,带参数</returns> public IActionResult Login(DepositorAndCard card) { AddCooikeOfDAndC(card); return(View("Login", card)); }
public static Transferrecords transferrecords = new Transferrecords();//代码需求 #endregion #region “登录”功能 已实现 /// <summary> /// “登录”功能 /// </summary> /// <param name="depositor">传入的是DepositorAndCard类型的数据</param> /// <returns>返回主页</returns> public IActionResult Login(DepositorAndCard depositor) { cooikeAdd(depositor); return(View("Login", depositor)); }
/// <summary> /// 向浏览器cooike中加入值DepositorAndCard /// </summary> /// <param name="card1">传入DepositorAndCard对象</param> public void cooikeAdd(DepositorAndCard depositor) { this.Response.Cookies.Append("Uid", depositor.Duid.ToString()); this.Response.Cookies.Append("Cid", depositor.Dcid.ToString()); this.Response.Cookies.Append("Name", depositor.Dname.ToString()); }
/// <summary> /// 向浏览器cooike中加入值DepositorAndCard /// </summary> /// <param name="card1">传入DepositorAndCard对象</param> public void AddCooikeOfDAndC(DepositorAndCard card1) { this.Response.Cookies.Append("Uid", card1.Duid.ToString()); this.Response.Cookies.Append("Cid", card1.Dcid.ToString()); this.Response.Cookies.Append("Name", card1.Dname.ToString()); }
/// <summary> /// 记录表Records中增加记录,业务逻辑层 /// </summary> /// <param name="dAndC">传入从cooike中获取的储户和储户银行卡信息。其对象为DepositorAndCard</param> /// <param name="v">出入参数v代表类型,1:代表取款,2:代表活期存款,其他:代表定期存款。每次传入一个类型的值,其他两项字段默认为0</param> /// <param name="money">金额</param> /// <param name="mid">业务办理员,0代表ATM操作,1代表是储户操作,Rmid有值(管理员账号)时代表柜台管理员操作,默认为储户系统转账</param> public void AddRecordsService(DepositorAndCard dAndC, int icid, int v, double money, int mid) { accessRecords.AddData(dAndC, icid, v, money, mid); }