public ActionResult Create(MemCards mc) { try { MemCardsBLL bll = new MemCardsBLL(); MemCards refererMc = new MemCards(); Users user = Session["user"] as Users; mc.S_ID = user.S_ID; mc.MC_Password = mc.MC_Password ?? "123456"; mc.MC_IsPast = Request.Form["MC_IsPast"] == "on" ? true : false; mc.MC_IsPointAuto = Request.Form["MC_IsPointAuto"] == "on" ? true : false; //积分兑换等级 if (mc.MC_IsPointAuto == true) { var level = bll.MenCardLevel(mc); mc.CL_ID = level.CL_ID; } if (mc.MC_RefererName != null) { mc.MC_RefererID = bll.GetExchange(mc.MC_RefererCard).MC_ID; //被推荐人增加积分 mc.MC_Point = mc.MC_Point + 100; //推荐人增加积分 refererMc.MC_Point = bll.GetExchange(mc.MC_RefererCard).MC_Point + 100; refererMc.MC_ID = bll.GetExchange(mc.MC_RefererCard).MC_ID; bll.Edit(refererMc, "MC_Point"); } mc.MC_TotalCount = 0; mc.MC_TotalMoney = 0; mc.MC_CreateTime = DateTime.Now; bll.Add(mc); bll.SaveChanges(); return Json(new { result = "ok" }); } catch { return Json(new { result = "error" }); } }
public ActionResult Transfer(string TL_FromMC_CardID, string TL_ToMC_CardID, int TL_TransferMoney, string TL_Remark) { MemCardsBLL mcBll = new MemCardsBLL(); TransferLogsBLL tfBll = new TransferLogsBLL(); TransferLogs tf = new TransferLogs(); MemCards mcTo = new MemCards(); MemCards mcFrom = new MemCards(); try { MemCards uTo = mcBll.GetExchange(TL_ToMC_CardID); MemCards uFrom = mcBll.GetExchange(TL_FromMC_CardID); Users user = Session["user"] as Users; using (TransactionScope ts = new TransactionScope()) { //修改转出卡号信息 mcTo.MC_ID = uFrom.MC_ID; mcTo.MC_Point = uFrom.MC_Point - TL_TransferMoney; //修改转入卡号信息 mcFrom.MC_ID = uTo.MC_ID; mcFrom.MC_Point = uTo.MC_Point + TL_TransferMoney; mcBll.Edit(mcFrom, "MC_Point"); mcBll.Edit(mcTo, "MC_Point"); mcBll.SaveChanges(); //转账信息表添加数据 tf.S_ID = user.S_ID; tf.U_ID = user.U_ID; tf.TL_FromMC_ID = mcBll.SelectWhere(m => m.MC_CardID == TL_FromMC_CardID).Select(m => m.MC_ID).FirstOrDefault(); tf.TL_FromMC_CardID = TL_FromMC_CardID; tf.TL_ToMC_ID = mcBll.SelectWhere(m => m.MC_CardID == TL_ToMC_CardID).Select(m => m.MC_ID).FirstOrDefault(); tf.TL_ToMC_CardID = TL_ToMC_CardID; tf.TL_TransferMoney = TL_TransferMoney; tf.TL_Remark = TL_Remark; tf.TL_CreateTime = DateTime.Now; tfBll.Add(tf); tfBll.SaveChanges(); ts.Complete(); } return Json(new { result = "ok" }); } catch { return Json(new { result = "error" }); } }