在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
存款取款功能 1.DAL--transInfo增加add方法--增加交易记录 /// <summary> /// 增加一条数据 /// </summary> public bool Add(Model.transInfo model) { StringBuilder strSql=new StringBuilder(); StringBuilder strSql1=new StringBuilder(); StringBuilder strSql2=new StringBuilder(); if (model.transDate != null) { strSql1.Append("transDate,"); strSql2.Append("'"+model.transDate+"',"); } if (model.cardID != null) { strSql1.Append("cardID,"); strSql2.Append("'"+model.cardID+"',"); } if (model.transType != null) { strSql1.Append("transType,"); strSql2.Append("'"+model.transType+"',"); } if (model.transMoney != null) { strSql1.Append("transMoney,"); strSql2.Append(""+model.transMoney+","); } if (model.remark != null) { strSql1.Append("remark,"); strSql2.Append("'"+model.remark+"',"); } strSql.Append("insert into transInfo("); strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1)); strSql.Append(")"); strSql.Append(" values ("); strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1)); strSql.Append(")"); int rows=DbHelperSQL.ExecuteSql(strSql.ToString()); if (rows > 0) { return true; } else { return false; } } 2.DAL--cardinfo增加UpdateBalance方法--更新账户余额 public bool UpdateBalance(string CardID, decimal MoneyNum,string remark) { //增加交易记录 Model.transInfo t = new Model.transInfo(); t.cardID = CardID; t.transDate = DateTime.Now; t.transMoney = Math.Abs(MoneyNum); t.transType = "存入"; t.remark = remark; string sql = "update cardinfo set balance=balance+" + MoneyNum + " where cardID='" + CardID + "' and IsReportLoss=0"; if (MoneyNum < 0) { //先判断余额是否足 Model.cardinfo c = GetModel(CardID); if (c != null) { if(c.balance<Math.Abs( MoneyNum)) { return false; } } else { return false; } t.transType = "支取"; } if (DbHelperSQL.ExecuteSql(sql) >= 1)//存取款成功 则增加交易记录 { DAL.transInfo dalt = new DAL.transInfo(); dalt.Add(t); return true; } return false; } 3.BLL--cardinfo增加UpdateBalance方法 /// <summary> /// 存取款 /// <param name = "CardID" ></ param > /// < param name="MoneyNum">负数为取款</param> /// <returns></returns> /// </summary> public bool UpdateBalance(string CardID, decimal MoneyNum,string remark) { return dal.UpdateBalance(CardID, MoneyNum,remark); } 4.WinF--getMoney窗体 1)为窗体类增加卡号字段 2)编写取款按钮单击方法 代码如下: 5.WinF--SetMoney窗体 1)为窗体类增加卡号字段 2)编写存款按钮单击方法 代码如下: 6.WinF--main窗体---编写存款、取款菜单项代码 |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论