//public decimal GetCacheSKByProject(int projectid) //{ // List<DDShouKuan> ddShouKuans = db.DDShouKuan.Where(d => d.SKFangShi == "现金" && d.ProjectID == projectid && d.SKState != "InValid").ToList(); // return ddShouKuans.Sum(d => d.SKMoney); //} //public decimal GetBankSKByProject(int projectid) //{ // List<DDShouKuan> ddShouKuans = db.DDShouKuan.Where(d => d.SKFangShi != "现金" && d.ProjectID == projectid && d.SKState != "InValid").ToList(); // return ddShouKuans.Sum(d => d.SKMoney); //} public DDShouKuan UpdateSingle(int id, DDShouKuanReq data) { DDShouKuan model = db.DDShouKuan.Find(id); SetDDShouKuan(model, data); db.SaveChanges(); return(model); }
/// <summary> /// 设置model,如果不为空就设置,如果为空则和之前一样 /// </summary> /// <param name="target"></param> /// <param name="source"></param> /// <returns></returns> public DDShouKuan SetDDShouKuan(DDShouKuan model, DDShouKuanReq data) { if (data.HeTongID != null) { model.HeTongID = data.HeTongID.Value; } if (!string.IsNullOrEmpty(data.HeTongNumber)) { model.HeTongNumber = data.HeTongNumber; } if (!string.IsNullOrEmpty(data.HeTongName)) { model.HeTongName = data.HeTongName; } if (data.KhID != null) { model.KhID = data.KhID.Value; } if (!string.IsNullOrEmpty(data.KhName)) { model.KhName = data.KhName; } if (!string.IsNullOrEmpty(data.SKName)) { model.SKName = data.SKName; } if (data.SKMoney != null) { model.SKMoney = data.SKMoney.Value; } if (!string.IsNullOrEmpty(data.SKPayOnlieNumber)) { model.SKPayOnlieNumber = data.SKPayOnlieNumber; } if (data.SKDateTime != null && data.SKDateTime != DateTime.MinValue && data.SKDateTime != SqlDateTime.MinValue.Value) { model.SKDateTime = data.SKDateTime.Value; } //if (!string.IsNullOrEmpty(data.SKInfos)) model.SKInfos = data.SKInfos; if (!string.IsNullOrEmpty(data.ServerMsg)) { model.ServerMsg = data.ServerMsg; } if (data.projectid != null) { model.ProjectID = data.projectid.Value; } if (!string.IsNullOrEmpty(data.optName)) { model.optName = data.optName; } if (data.optDateTime != null && data.optDateTime != DateTime.MinValue && data.optDateTime != SqlDateTime.MinValue.Value) { model.optDateTime = data.optDateTime.Value; } if (!string.IsNullOrEmpty(data.SKClass)) { model.SKClass = data.SKClass; } if (!string.IsNullOrEmpty(data.SKState)) { model.SKState = data.SKState; } if (!string.IsNullOrEmpty(data.SKFangShi)) { model.SKFangShi = data.SKFangShi; } if (!string.IsNullOrEmpty(data.SKNumber)) { model.SKNumber = data.SKNumber; } if (data.JiaoGeId != null) { model.JiaoGeId = data.JiaoGeId.Value; } return(model); }