public ActionResult UpdateTollRoadSum(UpdateDataDailyViewModel args) { args.StationType = 1; try { ReportFactory.Instance.log.WriteLog(OperationType.Update, Utility.GetReportNameByType(1), Utility.GetFormatDate(args.DataDate, null)); return Json(ReportFactory.Instance.report1.Update(args)); } catch (Exception ex) { CustomResult ret = new CustomResult(); ret.ResultKey = 0; ret.ResultValue = ex.Message; return Json(ret); } }
/// <summary> /// 批量修改 /// </summary> /// <param name="args"></param> /// <returns></returns> public CustomResult Update(UpdateDataDailyViewModel args) { CustomResult pReturnValue = new CustomResult(); pReturnValue.ResultKey = (byte)EResult.Fail; pReturnValue.ResultValue = TipInfo.UpdateFaile; if (args.DataInfo == null) { pReturnValue.ResultKey = (byte)EResult.Succeed; pReturnValue.ResultValue = TipInfo.DataNull; return pReturnValue; } List<UpdateDataDailyInfo> pNewUpdateData = new List<UpdateDataDailyInfo>(); using (DataSubmittedEntities db = new DataSubmittedEntities()) { var pReportData = db.RP_Daily.Where(s => s.CalcuTime == args.DataDate && s.StaType == args.StationType).ToList(); using (TransactionScope transaction = new TransactionScope()) { try { foreach (var item in args.DataInfo) { //获取查询日期当天的数据 if (item.VehType == SystemConst.SmallCar) item.VehType = "0"; if (item.VehType == SystemConst.OtherCar) item.VehType = "1"; if (item.VehType == SystemConst.Truk) item.VehType = "2"; if (item.VehType == SystemConst.Green) item.VehType = "3"; int ptemp = int.Parse(item.VehType); RP_Daily pDataTemp = new RP_Daily(); if (pReportData.Where(i => i.VehType == ptemp).Count() == 1) { pDataTemp = pReportData.Where(i => i.VehType == ptemp).SingleOrDefault(); if (item.ExEn == SystemConst.In)//入口 { pDataTemp.InNum = item.VehNum;//出口 } else { pDataTemp.OutNum = item.VehNum; pDataTemp.ChagFee = item.CarChag * 10000;//转为元,存到数据库 } pDataTemp.UpdDate = DateTime.Now; pDataTemp.State = 1; if (SessionManage.GetLoginUser() != null) { pDataTemp.UpdBy = SessionManage.GetLoginUser().UserName; } } } db.SaveChanges(); transaction.Complete(); pReturnValue.ResultKey = (byte)EResult.Succeed; pReturnValue.ResultValue = TipInfo.UpdateSuccess; } catch (Exception ex) { Common.SystemLog.GetInstance().Log.Info(TipInfo.UpdateDataRepeat, ex); pReturnValue.ResultKey = (byte)EResult.Fail; pReturnValue.ResultValue = TipInfo.UpdateDataRepeat; } return pReturnValue; } } }