public async Task <JsonResult> Edit([FromBody] Event2 event2) { AppIdentityUser _user = await _userManager.FindByNameAsync(User.Identity.Name); BrhScalp brhScalp = new BrhScalp(); var ParentType = typeof(BrhScalp); var Properties = ParentType.GetProperties(); foreach (var Propertie in Properties) { //循环遍历属性 if (Propertie.CanRead && Propertie.CanWrite) { //进行属性拷贝 Propertie.SetValue(brhScalp, Propertie.GetValue(event2, null), null); } } _context.Update(brhScalp); _context.SaveChanges(); var total = _context.BrhScalp.Where(x => x.ImprestAccountsId == brhScalp.ImprestAccountsId && !x.IsMove).Sum(x => x.TotalPrice); var brhImprestAccount = _context.BrhImprestAccounts.SingleOrDefault(x => x.ImprestAccountsId == brhScalp.ImprestAccountsId); brhImprestAccount.Equity = brhImprestAccount.Balance - total; _context.Update(brhImprestAccount); await _context.SaveChangesAsync(); return(Json(event2)); }
/// <summary> /// 获取特定的工具夹实体 /// </summary> /// <param name="tongsEntity"></param> /// <returns></returns> public TongsEntityVo GetTongsEntity(TongsEntity tongsEntity) { TongsEntityVo result = new TongsEntityVo(); TongsEntity tongs = tongsEntityDao.selectTongsEntityByCodeAndSeq(tongsEntity); TongsDefinition p = new TongsDefinition(); p.Code = tongs.Code; TongsDefinition tongsDefinition = tongsDefinitionDao.selectTongsDefinitionByCode(p); var ParentType = typeof(TongsEntity); var Properties = ParentType.GetProperties(); foreach (var Propertie in Properties) { if (Propertie.CanRead && Propertie.CanWrite) { Propertie.SetValue(result, Propertie.GetValue(tongs, null), null); } } result.FamilyId = tongsDefinition.FamilyId; result.Name = tongsDefinition.Name; result.Model = tongsDefinition.Model; result.PartNo = tongsDefinition.PartNo; result.UserdFor = tongsDefinition.UserdFor; result.Upl = tongsDefinition.Upl; result.OwnerId = tongsDefinition.OwnerId; result.Remark = tongsDefinition.Remark; result.PmPeriod = tongsDefinition.PmPeriod; return(result); }
/// <summary> /// 子类复制父类的值 /// </summary> /// <param name="target"></param> /// <param name="parent"></param> /// <param name="nullreset">父类属性值为空时是否覆盖子类</param> /// <param name="valuereset">子类属性有值时是否被覆盖</param> public static void CopyParent(this object target, object parent, bool nullreset = true, bool valuereset = true) { var ParentType = parent.GetType(); var Properties = ParentType.GetProperties(); var tProperties = target.GetType().GetProperties(); foreach (var Propertie in Properties) { if (Propertie.CanRead && Propertie.CanWrite) { var tp = tProperties.FirstOrDefault(p => p.Name == Propertie.Name); if (tp == null) { continue; } var pvalue = Propertie.GetValue(parent, null); var tvalue = tp.GetValue(target, null); if (!valuereset && tvalue != null) { continue; } if (!nullreset && pvalue == null) { continue; } tp.SetValue(target, Propertie.GetValue(parent, null), null); } } }
public IActionResult GetProjectDetailInfo(int id) { ProjectDetailInfo projectDetailInfo = new ProjectDetailInfo(); Entity.ProjectInfo projectInfo = _projectInfoService.Queryable().Where(x => x.id == id).First(); List <HeatStep> heatSteps = _heatStepService.Queryable().Where(x => x.project_id == projectInfo.id).ToList(); List <TmSig> tmSigs = _tmSigService.Queryable().Where(x => x.project_id == projectInfo.id).ToList(); List <Pid> pids = _pidService.Queryable().Where(x => x.project_id == projectInfo.id).ToList(); var ParentType = typeof(Entity.ProjectInfo); var Properties = ParentType.GetProperties(); foreach (var Propertie in Properties) { //循环遍历属性 if (Propertie.CanRead && Propertie.CanWrite) { //进行属性拷贝 Propertie.SetValue(projectDetailInfo, Propertie.GetValue(projectInfo, null), null); } } projectDetailInfo.heatStep1 = heatSteps[0]; projectDetailInfo.heatStep2 = heatSteps[1]; projectDetailInfo.heatStep3 = heatSteps[2]; projectDetailInfo.heatStep4 = heatSteps[3]; projectDetailInfo.tmSig1 = tmSigs[0]; projectDetailInfo.tmSig2 = tmSigs[1]; projectDetailInfo.tmSig3 = tmSigs[2]; projectDetailInfo.tmSig4 = tmSigs[3]; projectDetailInfo.pid1 = pids[0]; projectDetailInfo.pid2 = pids[1]; return(Json(projectDetailInfo)); }
/// <summary> /// 获取所有工具夹实体 /// </summary> /// <param name="tongsEntity"></param> /// <returns></returns> public List <TongsEntityVo> GetTongsEntities(TongsEntity tongsEntity) { List <TongsEntity> tongsList = tongsEntityDao.selectAllTongsEntitys(tongsEntity).ToList(); List <TongsEntityVo> result = new List <TongsEntityVo>(tongsList.Count()); for (int i = 0; i < tongsList.Count(); i++) { TongsDefinition p = new TongsDefinition(); p.Code = tongsList[i].Code; TongsDefinition tongsDefinition = tongsDefinitionDao.selectTongsDefinitionByCode(p); var ParentType = typeof(TongsEntity); var Properties = ParentType.GetProperties(); foreach (var Propertie in Properties) { if (Propertie.CanRead && Propertie.CanWrite) { Propertie.SetValue(result[i], Propertie.GetValue(tongsList[i], null), null); } } result[i].FamilyId = tongsDefinition.FamilyId; result[i].Name = tongsDefinition.Name; result[i].Model = tongsDefinition.Model; result[i].PartNo = tongsDefinition.PartNo; result[i].UserdFor = tongsDefinition.UserdFor; result[i].Upl = tongsDefinition.Upl; result[i].OwnerId = tongsDefinition.OwnerId; result[i].Remark = tongsDefinition.Remark; result[i].PmPeriod = tongsDefinition.PmPeriod; } return(result); }
public static void CreateCells(this IRow row, object data) { Type t = data.GetType(); int i = 0; foreach (var Propertie in t.GetProperties()) { var cell = row.CreateCell(i++); cell.SetCellValue(Convert.ChangeType(Propertie.GetValue(data), Propertie.PropertyType).ToString()); } }
public async Task <JsonResult> Edit([FromBody] BranchModel branchModel) { AppIdentityUser _user = await _userManager.FindByNameAsync(User.Identity.Name); BrhFrontDeskAccounts brhFrontDeskAccounts = new BrhFrontDeskAccounts(); BrhFrontPaymentDetial bfp = new BrhFrontPaymentDetial(); var rtotal = _context.BrhFrontPaymentDetials.Where(x => x.FrontDeskAccountsId == branchModel.FrontDeskAccountsId).Sum(x => x.PayAmount); if (branchModel.PayAmount != 0) { bfp.FrontDeskAccountsId = branchModel.FrontDeskAccountsId; bfp.PayWay = branchModel.PayWay; bfp.PayDate = branchModel.PayDate; bfp.PayAmount = branchModel.PayAmount; } else { bfp.PayAmount = 0; } branchModel.Received = rtotal + bfp.PayAmount; if (branchModel.Receivable == branchModel.Received) { branchModel.IsFinish = true; } else { branchModel.IsFinish = false; } var ParentType = typeof(BrhFrontDeskAccounts); var Properties = ParentType.GetProperties(); foreach (var Propertie in Properties) { //循环遍历属性 if (Propertie.CanRead && Propertie.CanWrite) { //进行属性拷贝 Propertie.SetValue(brhFrontDeskAccounts, Propertie.GetValue(branchModel, null), null); } } if (branchModel.PayAmount != 0) { brhFrontDeskAccounts.BrhFrontPaymentDetial.Add(bfp); } _context.Update(brhFrontDeskAccounts); _context.SaveChanges(); Event eve = branchModel; return(Json(eve)); }
/// <summary> /// ��������-���ำֵ������ /// </summary> /// <typeparam name="TParent"></typeparam> /// <typeparam name="TChild"></typeparam> /// <param name="parent"></param> /// <returns></returns> public static void AutoCopy <TParent, TChild>(TParent parent, TChild child) where TChild : TParent, new() { var ParentType = typeof(TParent); var Properties = ParentType.GetProperties(); foreach (var Propertie in Properties) { //ѭ���������� if (Propertie.CanRead && Propertie.CanWrite) { //�������Կ��� Propertie.SetValue(child, Propertie.GetValue(parent, null), null); } } }
public static TChild AutoCopy <TParent, TChild>(TParent parent) where TChild : TParent, new() { TChild child = new TChild(); var ParentType = typeof(TParent); var Properties = ParentType.GetProperties(); foreach (var Propertie in Properties) { if (Propertie.CanRead && Propertie.CanWrite) { Propertie.SetValue(child, Propertie.GetValue(parent, null), null); } } return(child); }
/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="value"></param> /// <returns></returns> public static T ToChild <T>(this object value) where T : new() { T model = new T(); var ParentType = value.GetType(); var Properties = ParentType.GetProperties(); foreach (var Propertie in Properties) { if (Propertie.CanRead && Propertie.CanWrite) { Propertie.SetValue(model, Propertie.GetValue(value, null), null); } } return(model); }
/// <summary> /// 父类转子类 /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> public virtual T Parse <T>() where T : new() { T obj = new T(); var ParentType = this.GetType(); var Properties = ParentType.GetProperties(); foreach (var Propertie in Properties) { if (Propertie.CanRead && Propertie.CanWrite) { Propertie.SetValue(obj, Propertie.GetValue(this, null), null); } } return(obj); }
/// <summary> /// 构造 /// </summary> /// <param name="zhgd_Iot_discharge_Current"></param> //public static Zhgd_iot_discharge_working Get_Zhgd_iot_discharge_working(Zhgd_iot_discharge_current zhgd_Iot_discharge_Current) //{ // Zhgd_iot_discharge_working z = zhgd_Iot_discharge_Current as Zhgd_iot_discharge_working; // return z; //} public static Zhgd_iot_discharge_working Get_Zhgd_iot_discharge_working(Zhgd_iot_discharge_current parent) { Zhgd_iot_discharge_working child = new Zhgd_iot_discharge_working(); var ParentType = typeof(Zhgd_iot_discharge_current); var Properties = ParentType.GetProperties(); foreach (var Propertie in Properties) { if (Propertie.CanRead && Propertie.CanWrite) { Propertie.SetValue(child, Propertie.GetValue(parent, null), null); } } return(child); }
/// <summary> /// 将系统时间转换成UTC时间 /// </summary> /// <param name="device"></param> public static void ConventLocalToUTCTime <T>(T device) { var type = device.GetType(); var Properties = type.GetProperties(); foreach (var Propertie in Properties) { if (Propertie.CanRead && Propertie.CanWrite) { if (Propertie.PropertyType == typeof(DateTime?)) { Propertie.SetValue(device, ((DateTime?)Propertie.GetValue(device, null))?.ToUniversalTime(), null); } } } }
public static T1 PropertieCopy <T1>(this T1 t1, T1 t2) { var ParentType = typeof(T1); var Properties = ParentType.GetProperties(); foreach (var Propertie in Properties) { //循环遍历属性 if (Propertie.CanRead && Propertie.CanWrite) { //进行属性拷贝 Propertie.SetValue(t2, Propertie.GetValue(t1, null), null); } } return(t1); }
public static T AutoCopy <T>(T source) where T : new() { T target = new T(); var Properties = typeof(T).GetProperties(); foreach (var Propertie in Properties) { //循环遍历属性 if (Propertie.CanRead && Propertie.CanWrite) { //进行属性拷贝 Propertie.SetValue(target, Propertie.GetValue(source, null), null); } } return(target); }
/// <summary> /// 自动将基类对象复制到扩展继承类中,左侧为父类(基类),右侧为子类(扩展类), 参数为父类(基类)对象,子类(扩展类)未赋值的属性默认为null /// </summary> /// <typeparam name="TParent">父类(基类)</typeparam> /// <typeparam name="TChild">扩展业务逻辑继承的子类</typeparam> /// <param name="parent">基类对象</param> /// <returns>返回扩展的子类</returns> public static TChild AutoCopyToChild <TParent, TChild>(TParent parent) where TChild : new() { TChild ext_model = new TChild(); var ParentType = typeof(TParent); var parentProp = ParentType.GetProperties(); foreach (var Propertie in parentProp) { //循环遍历属性 if (Propertie.CanRead && Propertie.CanWrite) { //进行属性拷贝 Propertie.SetValue(ext_model, Propertie.GetValue(parent, null), null); } } return(ext_model); }
/// <summary> /// 自动将子类对象复制到父类中,左侧为父类,右侧为子类, 参数为子类对象 /// </summary> /// <typeparam name="TParent">父类</typeparam> /// <typeparam name="TChild">扩展业务逻辑继承的子类</typeparam> /// <param name="child">子类对象</param> /// <returns>返回基类对象</returns> public static TParent AutoCopyToBase <TParent, TChild>(TChild child) where TParent : new() { TParent base_model = new TParent(); var ParentType = typeof(TParent); var Properties = ParentType.GetProperties(); foreach (var Propertie in Properties) { //循环遍历属性 if (Propertie.CanRead && Propertie.CanWrite) { //进行属性拷贝 Propertie.SetValue(base_model, Propertie.GetValue(child, null), null); } } return(base_model); }
public static TChild ToChild <TParent, TChild>(this TParent parent) where TChild : TParent, new() { TChild child = new TChild(); var ParentType = typeof(TParent); var Properties = ParentType.GetProperties(); foreach (var Propertie in Properties) { //循环遍历属性 if (Propertie.CanRead && Propertie.CanWrite) { //进行属性拷贝 Propertie.SetValue(child, Propertie.GetValue(parent, null), null); } } return(child); }
/// <summary> /// 复制对象副本 /// </summary> /// <typeparam name="TObject"></typeparam> /// <param name="originalObj"></param> /// <returns></returns> public TObject AutoCopy <TObject>(TObject originalObj) where TObject : new() { TObject newObj = new TObject(); var OriginalType = typeof(TObject); var Properties = OriginalType.GetProperties(); foreach (var Propertie in Properties) { //循环遍历属性 if (Propertie.CanRead && Propertie.CanWrite) { //进行属性拷贝 Propertie.SetValue(newObj, Propertie.GetValue(originalObj, null), null); } } return(newObj); }
/// <summary> /// 类型转换 /// </summary> /// <typeparam name="TOrign"></typeparam> /// <typeparam name="TGoal"></typeparam> /// <param name="parent"></param> /// <returns></returns> public static TGoal ConvertTo <TOrign, TGoal>(TOrign parent) where TGoal : TOrign, new() { var child = new TGoal(); var ParentType = typeof(TOrign); var Properties = ParentType.GetProperties(); foreach (var Propertie in Properties) { //循环遍历属性 if (Propertie.CanRead && Propertie.CanWrite) { //进行属性拷贝 Propertie.SetValue(child, Propertie.GetValue(parent, null), null); } } return(child); }
public TChild EntityCopy <TParent, TChild>(TParent parent) where TChild : TParent, new() { // The following 1st line is not possible without new() constraint: TChild child = new TChild(); var ParentType = typeof(TParent); var Properties = ParentType.GetProperties(); foreach (var Propertie in Properties) { //循环遍历属性 if (Propertie.CanRead && Propertie.CanWrite) { //进行属性拷贝 Propertie.SetValue(child, Propertie.GetValue(parent, null), null); } } return(child); }
public ViewModelCourse AutoCopy(Course parent) { ViewModelCourse child = new ViewModelCourse(); var ParentType = typeof(Course); var Properties = ParentType.GetProperties(); foreach (var Propertie in Properties) { if (Propertie.CanRead && Propertie.CanWrite) { Propertie.SetValue(child, Propertie.GetValue(parent, null), null); } } return(child); }
public async Task <JsonResult> Create([FromBody] Event2 event2) { AppIdentityUser _user = await _userManager.FindByNameAsync(User.Identity.Name); var ScalpId = Convert.ToInt64(_user.BranchId.ToString() + ConvertJson.DateTimeToStamp(DateTime.Now).ToString()); event2.EnteringDate = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("China Standard Time")); event2.ScalpId = ScalpId; event2.id = ScalpId.ToString(); event2.resourceId = event2.HouseNumber; event2.start = event2.StartDate.ToShortDateString(); event2.end = event2.EndDate.ToShortDateString(); var brhScalp = new BrhScalp(); var ParentType = typeof(BrhScalp); var Properties = ParentType.GetProperties(); foreach (var Propertie in Properties) { //循环遍历属性 if (Propertie.CanRead && Propertie.CanWrite) { //进行属性拷贝 Propertie.SetValue(brhScalp, Propertie.GetValue(event2, null), null); } } _context.Add(brhScalp); await _context.SaveChangesAsync(); var total = _context.BrhScalp.Where(x => x.ImprestAccountsId == brhScalp.ImprestAccountsId && !x.IsMove).Sum(x => x.TotalPrice); var brhImprestAccount = _context.BrhImprestAccounts.SingleOrDefault(x => x.ImprestAccountsId == brhScalp.ImprestAccountsId); brhImprestAccount.Equity = brhImprestAccount.Balance - total; _context.Update(brhImprestAccount); await _context.SaveChangesAsync(); return(Json(event2)); }
public async Task <JsonResult> GetMonthData([FromBody] FncBranch fncBranch) { var frontList = _context.BrhFrontDeskAccounts.Where(x => x.Branch == fncBranch.BranchName && x.State != StateType.已删除 && DateTime.Compare(x.StartDate.Date, DateTime.Now.Date) <= 0).ToList(); var earningList = _context.BrhEarningRecord.Where(x => x.Branch == fncBranch.BranchName).ToList(); var expendList = _context.BrhExpendRecord.Where(x => x.Branch == fncBranch.BranchName).ToList(); var stewardList = _context.BrhStewardAccounts.Where(x => x.Branch == fncBranch.BranchName).ToList(); var start = frontList.Select(x => x.StartDate).Min().Date; start = start.AddDays(1 - start.Day); var end = frontList.Select(x => x.EndDate).Max().Date; if (DateTime.Compare(end, DateTime.Now) < 0) { end = DateTime.Now.AddDays(1).Date; } end = end.AddDays(1 - end.Day); var ms = (end.Year * 12 + end.Month) - (start.Year * 12 + start.Month); if (ms == 0) { return(Json(new { })); } var monthDataList = new List <MonthData>(); var fncMonthDataList = _context.FncMonthData.Where(x => x.BranchId == fncBranch.BranchId).ToList(); var monthData_Month = fncMonthDataList.Select(x => x.Month.ToString("yyyy-MM")).ToList(); for (var i = 0; i <= ms; i++) { var fncMonthData = new FncMonthData(); var cFrontList = frontList.Where(x => DateTime.Compare(start.AddMonths(i), x.StartDate) <= 0 && DateTime.Compare(x.StartDate, start.AddMonths(i + 1)) < 0).ToList(); var cEarningList = earningList.Where(x => DateTime.Compare(start.AddMonths(i), x.EnteringDate) <= 0 && DateTime.Compare(x.EnteringDate, start.AddMonths(i + 1)) < 0).ToList(); var cExpendList = expendList.Where(x => DateTime.Compare(start.AddMonths(i), x.EnteringDate) <= 0 && DateTime.Compare(x.EnteringDate, start.AddMonths(i + 1)) < 0).ToList(); var cStewardList = stewardList.Where(x => DateTime.Compare(start.AddMonths(i), x.EnteringDate) <= 0 && DateTime.Compare(x.EnteringDate, start.AddMonths(i + 1)) < 0).ToList(); if (!monthData_Month.Contains(start.AddMonths(i).ToString("yyyy-MM"))) { fncMonthData.BranchId = fncBranch.BranchId; fncMonthData.Earning = cEarningList.Select(x => x.Amount).Sum(); fncMonthData.Expend = cExpendList.Select(x => x.Amount).Sum(); fncMonthData.HouseAmount = cFrontList.Select(x => x.TotalPrice).Sum(); fncMonthData.HouseCount = cFrontList.Select(x => x.Count).Sum(); if (i != ms) { fncMonthData.HouseTotal = DateTime.DaysInMonth(start.AddMonths(i).Year, start.AddMonths(i).Month) * fncBranch.Count; } else { fncMonthData.HouseTotal = DateTime.Now.Day * fncBranch.Count; } if (fncMonthData.HouseTotal != 0) { fncMonthData.Rate = (double)fncMonthData.HouseCount / (double)fncMonthData.HouseTotal; fncMonthData.ValidAverage = fncMonthData.HouseAmount / fncMonthData.HouseTotal; } else { fncMonthData.Rate = 0; fncMonthData.ValidAverage = 0; } if (fncMonthData.HouseCount != 0) { fncMonthData.Average = fncMonthData.HouseAmount / fncMonthData.HouseCount; } else { fncMonthData.Average = 0; } fncMonthData.Month = start.AddMonths(i); fncMonthData.SaleAmount = cStewardList.Select(x => x.Amount).Sum(); fncMonthData.SaleProfit = cStewardList.Select(x => x.Profit).Sum(); _context.Add(fncMonthData); fncMonthDataList.Add(fncMonthData); } else if (i == ms - 1) { var tempMonthData = fncMonthDataList.SingleOrDefault(x => DateTime.Compare(x.Month, start.AddMonths(i)) == 0); tempMonthData.BranchId = fncBranch.BranchId; tempMonthData.Earning = cEarningList.Select(x => x.Amount).Sum(); tempMonthData.Expend = cExpendList.Select(x => x.Amount).Sum(); tempMonthData.HouseAmount = cFrontList.Select(x => x.TotalPrice).Sum(); tempMonthData.HouseCount = cFrontList.Select(x => x.Count).Sum(); tempMonthData.HouseTotal = DateTime.DaysInMonth(start.AddMonths(i).Year, start.AddMonths(i).Month) * fncBranch.Count; if (tempMonthData.HouseTotal != 0) { tempMonthData.Rate = (double)tempMonthData.HouseCount / (double)tempMonthData.HouseTotal; tempMonthData.ValidAverage = tempMonthData.HouseAmount / tempMonthData.HouseTotal; } else { tempMonthData.Rate = 0; tempMonthData.ValidAverage = 0; } if (tempMonthData.HouseCount != 0) { tempMonthData.Average = tempMonthData.HouseAmount / tempMonthData.HouseCount; } else { tempMonthData.Average = 0; } tempMonthData.Month = start.AddMonths(i); tempMonthData.SaleAmount = cStewardList.Select(x => x.Amount).Sum(); tempMonthData.SaleProfit = cStewardList.Select(x => x.Profit).Sum(); _context.Update(tempMonthData); } else if (i == ms) { var tempMonthData = fncMonthDataList.SingleOrDefault(x => DateTime.Compare(x.Month, start.AddMonths(i)) == 0); tempMonthData.BranchId = fncBranch.BranchId; tempMonthData.Earning = cEarningList.Select(x => x.Amount).Sum(); tempMonthData.Expend = cExpendList.Select(x => x.Amount).Sum(); tempMonthData.HouseAmount = cFrontList.Select(x => x.TotalPrice).Sum(); tempMonthData.HouseCount = cFrontList.Select(x => x.Count).Sum(); tempMonthData.HouseTotal = DateTime.Now.Day * fncBranch.Count; if (tempMonthData.HouseTotal != 0) { tempMonthData.Rate = (double)tempMonthData.HouseCount / (double)tempMonthData.HouseTotal; tempMonthData.ValidAverage = tempMonthData.HouseAmount / tempMonthData.HouseTotal; } else { tempMonthData.Rate = 0; tempMonthData.ValidAverage = 0; } if (tempMonthData.HouseCount != 0) { tempMonthData.Average = tempMonthData.HouseAmount / tempMonthData.HouseCount; } else { tempMonthData.Average = 0; } tempMonthData.Month = start.AddMonths(i); tempMonthData.SaleAmount = cStewardList.Select(x => x.Amount).Sum(); tempMonthData.SaleProfit = cStewardList.Select(x => x.Profit).Sum(); _context.Update(tempMonthData); } await _context.SaveChangesAsync(); } foreach (var fncMonthData1 in fncMonthDataList) { var monthData1 = new MonthData(); var ParentType = typeof(FncMonthData); var Properties = ParentType.GetProperties(); foreach (var Propertie in Properties) { if (Propertie.CanRead && Propertie.CanWrite) { Propertie.SetValue(monthData1, Propertie.GetValue(fncMonthData1, null), null); } } var fncMonthData2 = fncMonthDataList.SingleOrDefault(x => x.Month.ToString("yyyy-MM") == fncMonthData1.Month.AddMonths(-1).ToString("yyyy-MM")); if (fncMonthData2 != null) { monthData1.环比增长额 = fncMonthData1.HouseAmount - fncMonthData2.HouseAmount; monthData1.环比增长率 = (double)monthData1.环比增长额 / (double)fncMonthData2.HouseAmount; monthData1.出环比增长额 = (decimal)(fncMonthData1.Rate - fncMonthData2.Rate); monthData1.出环比增长率 = (double)monthData1.出环比增长额 / fncMonthData2.Rate; monthData1.均环比增长额 = fncMonthData1.Average - fncMonthData2.Average; monthData1.均环比增长率 = (double)monthData1.均环比增长额 / (double)fncMonthData2.Average; monthData1.环比增长额 = fncMonthData1.ValidAverage - fncMonthData2.ValidAverage; monthData1.环比增长率 = (double)monthData1.环比增长额 / (double)fncMonthData2.ValidAverage; monthData1.支环比增长额 = fncMonthData1.Expend - fncMonthData2.Expend; monthData1.支环比增长率 = (double)monthData1.支环比增长额 / (double)fncMonthData2.Expend; monthData1.外环比增长额 = fncMonthData1.SaleAmount - fncMonthData2.SaleAmount; monthData1.外环比增长率 = (double)monthData1.外环比增长额 / (double)fncMonthData2.SaleAmount; monthData1.外利环比增长额 = fncMonthData1.SaleProfit - fncMonthData2.SaleProfit; monthData1.外利环比增长率 = (double)monthData1.外利环比增长额 / (double)fncMonthData2.SaleProfit; } else { monthData1.环比增长额 = 0; monthData1.环比增长率 = 0; monthData1.出环比增长额 = 0; monthData1.出环比增长率 = 0; monthData1.均环比增长额 = 0; monthData1.均环比增长率 = 0; monthData1.环比增长额 = 0; monthData1.环比增长率 = 0; monthData1.支环比增长额 = 0; monthData1.支环比增长率 = 0; monthData1.外环比增长额 = 0; monthData1.外环比增长率 = 0; monthData1.外利环比增长额 = 0; monthData1.外利环比增长率 = 0; } var fncMonthData3 = fncMonthDataList.SingleOrDefault(x => x.Month.ToString("yyyy-MM") == fncMonthData1.Month.AddYears(-1).ToString("yyyy-MM")); if (fncMonthData3 != null) { monthData1.比增长额 = fncMonthData1.HouseAmount - fncMonthData3.HouseAmount; monthData1.比增长率 = (double)monthData1.比增长额 / (double)fncMonthData3.HouseAmount; monthData1.出同比增长额 = (decimal)(fncMonthData1.Rate - fncMonthData3.Rate); monthData1.出同比增长率 = (double)monthData1.出同比增长额 / fncMonthData3.Rate; monthData1.均同比增长额 = fncMonthData1.Average - fncMonthData3.Average; monthData1.均同比增长率 = (double)monthData1.均同比增长额 / (double)fncMonthData3.Average; monthData1.比增长额 = fncMonthData1.ValidAverage - fncMonthData3.ValidAverage; monthData1.比增长率 = (double)monthData1.比增长额 / (double)fncMonthData3.ValidAverage; monthData1.支同比增长额 = fncMonthData1.Expend - fncMonthData3.Expend; monthData1.支同比增长率 = (double)monthData1.支同比增长额 / (double)fncMonthData3.Expend; monthData1.外同比增长额 = fncMonthData1.SaleAmount - fncMonthData3.SaleAmount; monthData1.外同比增长率 = (double)monthData1.外同比增长额 / (double)fncMonthData3.SaleAmount; monthData1.外利同比增长额 = fncMonthData1.SaleProfit - fncMonthData3.SaleProfit; monthData1.外利同比增长率 = (double)monthData1.外利同比增长额 / (double)fncMonthData3.SaleProfit; } else { monthData1.比增长额 = 0; monthData1.比增长率 = 0; monthData1.出同比增长额 = 0; monthData1.出同比增长率 = 0; monthData1.均同比增长额 = 0; monthData1.均同比增长率 = 0; monthData1.比增长额 = 0; monthData1.比增长率 = 0; monthData1.支同比增长额 = 0; monthData1.支同比增长率 = 0; monthData1.外同比增长额 = 0; monthData1.外同比增长率 = 0; monthData1.外利同比增长额 = 0; monthData1.外利同比增长率 = 0; } monthDataList.Add(monthData1); } monthDataList = monthDataList.OrderBy(x => x.Month).ToList(); var front2List = _context.BrhFrontDeskAccounts.Where(x => x.Branch == fncBranch.BranchName && x.State != StateType.已删除 && x.StartDate.Month != x.EndDate.AddDays(-1).Month).ToList(); return(Json(new { monthDataList, monthData_Month, front2List })); }
/// <summary> /// 1.获取交叉数据绑定后台视图模型 /// -- 基本数据从Ticket表中获取 /// -- 再依据外键进行相应数据列匹配和选取(根据FORM请求进行数据筛选后再绑定) /// -- 取出所有数据后绑定报表文件展示 /// </summary> /// <returns></returns> public IActionResult CrossReport() { TDContext context = new TDContext(); List <Ticket> tickets = new List <Ticket>(); if (searchCondition.DateFrom != null && searchCondition.DateFrom.ToString() != "" && searchCondition.DateTo.ToString() != "" && searchCondition.DateTo != null) { tickets = context.Ticket.Where(t => t.TicketDate <searchCondition.DateTo && t.TicketDate> searchCondition.DateFrom).ToList(); } else { tickets = context.Ticket.FromSql("select * from Ticket").ToList(); } List <TicketView> tList = new List <TicketView>(); foreach (Ticket tic in tickets) { TicketView tView = new TicketView(); # region 产品过滤 Product product = new Product(); if (searchCondition.Product != null && searchCondition.Product != "") { product = context.Product.Where(p => p.ProductID == tic.ProductID && p.ProductName == searchCondition.Product).FirstOrDefault(); if (product == null) { continue; //问题 - 没有要不要显示? } } else { product = context.Product.Where(p => p.ProductID == tic.ProductID).FirstOrDefault(); } tView.Product = product; #endregion #region 区域过滤 办事处过滤 Corp issuer = context.Corp.Where(c => c.CorpID == tic.IssuerID).FirstOrDefault(); if (issuer.CorpLevel != "办事处") { //父企业 Corp parentCorp = context.Corp.Where(c => c.CorpID == issuer.ParentCorpID).FirstOrDefault(); if (searchCondition.Office != null && searchCondition.Office != "" && searchCondition.Office != parentCorp.CorpName) { continue; } //区域信息 Area areaInfo = context.Area.Where(a => a.AreaId == parentCorp.AreaID).FirstOrDefault(); if (searchCondition.Area != null && searchCondition.Area != "" && searchCondition.Area != areaInfo.AreaName) { continue; } //组合信息 IssuerArea i = new IssuerArea(); i.IssuerID = issuer.CorpID; i.IssuerParentArea = areaInfo.AreaName; i.IssuerParentName = parentCorp.CorpName; tView.IssuerArea = i; } else { //无父企业直接获得 IssuerArea i = new IssuerArea(); i.IssuerID = issuer.CorpID; i.IssuerParentArea = issuer.AreaName; if (searchCondition.Area != null && searchCondition.Area != "" && searchCondition.Area != issuer.AreaName) { continue; } i.IssuerParentName = issuer.CorpName; if (searchCondition.Office != null && searchCondition.Office != "" && searchCondition.Office != issuer.CorpName) { continue; } tView.IssuerArea = i; } #endregion #region 补全 var ParentType = typeof(Ticket); var Properties = ParentType.GetProperties(); foreach (var Propertie in Properties) { //循环遍历属性 if (Propertie.CanRead && Propertie.CanWrite) { //进行属性拷贝 Propertie.SetValue(tView, Propertie.GetValue(tic, null), null); } } #endregion tList.Add(tView); }