public string DoTKAction(decimal tkmoney, int id) { string lycResult = ""; try { using (FamilyCaiWuDBEntities db2 = new FamilyCaiWuDBEntities()) { Apply_Sub s = db2.Apply_Sub.Where(c => c.ID == id).SingleOrDefault(); if (s == null) { throw new Exception("此记账信息已不存在,无法执行退款操作!"); } if (s.InOutType != "out" || s.CashOrBank != 1) { throw new Exception("此记账信息不是【银行支出记账】,无法执行退款操作!"); } if (s.UserBankID == null || s.UserBankID.Value == 0) { throw new Exception("此记账信息不是【银行记账】,无法执行退款操作!"); } if (tkmoney == s.iMoney) { throw new Exception("退款金额与原记账金额相同,请直接执行删除操作!"); } if (tkmoney > s.iMoney) { throw new Exception("退款金额大于原记账金额,无法执行退款操作!"); } //1. 修改原记账信息的 备注、记账金额字段 decimal newMoney = s.iMoney - tkmoney; s.CAdd = s.CAdd + ";原记账金额:" + s.iMoney + " 元,现在退款:" + tkmoney + " 元,最终记账金额是:" + newMoney + " 元;"; s.iMoney = newMoney; //2. 修改对应的银行余额信息 UserBank ub = db2.UserBanks.Where(c => c.ID == s.UserBankID.Value).SingleOrDefault(); if (ub == null) { throw new Exception("此记账信息中的银行信息已不存在,无法执行退款操作!"); } ub.NowMoney = ub.NowMoney + tkmoney; //3. 修改记账主信息的支出合计 Apply_Main m = db2.Apply_Main.Where(c => c.ID == s.ApplyMain_BillCode).SingleOrDefault(); if (m != null) { m.ApplyOutMoney = m.ApplyOutMoney - tkmoney; } db2.SaveChanges(); } lycResult = WebComm.ReturnAlertMessage(ActionReturnStatus.成功, "退款成功!", "ApplyInfoListNav", "", CallBackType.none, ""); } catch (Exception ex) { lycResult = WebComm.ReturnAlertMessage(ActionReturnStatus.失败, "退款失败!" + ex.Message, "", "", CallBackType.none, ""); } return(lycResult); }
public ActionResult List(Apply_Main am) { int pageNO = 1; if (Request.Form["pageNum"] != null) { int.TryParse(Request.Form["pageNum"], out pageNO); } BindComboxUser(); string ApplyDate_Begin = Request.Form["ApplyDate_Begin"]; string ApplyDate_End = Request.Form["ApplyDate_End"]; ViewBag.beginDate = ApplyDate_Begin; ViewBag.endDate = ApplyDate_End; List <Apply_Main> list = GetApply_MainList(pageNO, am, ApplyDate_Begin, ApplyDate_End); return(View(viewFolder + "List.cshtml", list)); }
public string DeleteConfirmed() { try { string ids = Request["ids"] ?? ""; int[] idList = WebComm.GetIntArrayByString(ids); foreach (int item in idList) { Apply_Main am = db.Apply_Main.Find(item); db.Apply_Main.Remove(am); } db.SaveChanges(); return(WebComm.ReturnAlertMessage(ActionReturnStatus.成功, "删除成功", "UserSRList", "", CallBackType.none, "")); } catch (Exception ex) { return(WebComm.ReturnAlertMessage(ActionReturnStatus.失败, "删除失败!" + ex.Message, "", "", CallBackType.none, "")); } }
/// <summary> /// 获取用户开户行列表 /// </summary> /// <param name="currentPage">当前页码</param> /// <param name="uBank">查询实体</param> /// <returns></returns> private List <Apply_Main> GetApply_MainList(int currentPage, Apply_Main AM, string beginDate, string endDate) { var amList = db.Apply_Main.AsQueryable(); User loginUser = Session[SessionList.FamilyManageUser.ToString()] as User; //区分用户加载数据,如果不是超级管理员,只能查看自己的数据 if (!UserPower.adminUserCode.Contains(loginUser.cUserCode)) { amList = amList.Where(ub => ub.ApplyUserID == loginUser.ID); } #region 条件筛选 if (AM != null && !string.IsNullOrEmpty(AM.ApplyUserID.ToString()) && AM.ApplyUserID > 0) { amList = amList.Where(ub => ub.ApplyUserID == AM.ApplyUserID); } //如果用户选择了开始时间和结束时间 if (!string.IsNullOrEmpty(beginDate) && !string.IsNullOrEmpty(endDate)) { int[] beginArr = WebComm.GetIntArrayByStringArray(beginDate.Split('-')); int[] endArr = WebComm.GetIntArrayByStringArray(endDate.Split('-')); DateTime bDate, dDate; bDate = Convert.ToDateTime(beginDate); dDate = Convert.ToDateTime(endDate); int beginYear = beginArr[0]; int beginMonth = beginArr[1]; int beginDay = beginArr[2]; int endYear = endArr[0]; int endMonth = endArr[1]; int endDay = endArr[2]; //amList = amList.Where(a => a.iyear >= beginYear && a.imonth >= beginMonth && a.iday >= beginDay) // .Where(a => a.iyear <= endYear && a.imonth <= endMonth && a.iday <= endDay); amList = amList.Where(a => a.ApplyDate >= bDate && a.ApplyDate <= dDate); } //如果只选择了开始时间 else if (!string.IsNullOrEmpty(beginDate) && string.IsNullOrEmpty(endDate)) { DateTime bDate; bDate = Convert.ToDateTime(beginDate); //int[] beginArr = WebComm.GetIntArrayByStringArray(beginDate.Split('-')); //int beginYear = beginArr[0]; //int beginMonth = beginArr[1]; //int beginDay = beginArr[2]; //amList = amList.Where(a => a.iyear >= beginYear && a.imonth >= beginMonth && a.iday >= beginDay); amList = amList.Where(a => a.ApplyDate >= bDate); } #endregion SetPagerOptions(amList.Count(), currentPage); List <Apply_Main> list = amList.OrderBy(b => b.ID).Skip((currentPage - 1) * pageSize).Take(pageSize).ToList(); //添加合计行 Apply_Main applySum = new Apply_Main(); applySum.Apply_Sub = null; applySum.ApplyDate = new DateTime(); applySum.ApplyInMoney = list.Sum(l => l.ApplyInMoney); applySum.ApplyOutMoney = list.Sum(l => l.ApplyOutMoney); applySum.ApplyUserID = loginUser.ID; applySum.CreateDate = null; applySum.ID = 0; applySum.iday = 0; applySum.imonth = 0; applySum.iNowCashMoney = 0; applySum.iyear = 0; applySum.User = null; list.Insert(0, applySum); return(list); }