public FBEntity ReSubmitT_FB_COMPANYBUDGETAPPLYMASTER(T_FB_COMPANYBUDGETAPPLYMASTER entity) { FBEntity fbEntity = GetFBEntityByEntityKey(entity.EntityKey); fbEntity.FBEntityState = FBEntityState.ReSubmit; var master = fbEntity.Entity as T_FB_COMPANYBUDGETAPPLYMASTER; var details = fbEntity.GetRelationFBEntities(typeof(T_FB_COMPANYBUDGETAPPLYDETAIL).Name); T_FB_COMPANYBUDGETAPPLYMASTER resultEntity = master.CopyEntity(); resultEntity.COMPANYBUDGETAPPLYMASTERID = Guid.NewGuid().ToString(); resultEntity.COMPANYBUDGETAPPLYMASTERCODE = "自动生成"; resultEntity.CHECKSTATES = (int)CheckStates.UnSubmit; resultEntity.ISVALID = "0"; // 未汇总 resultEntity.T_FB_COMPANYBUDGETSUMDETAIL = null; var result = resultEntity.ToFBEntity(); var resultDetails = result.GetRelationFBEntities(typeof(T_FB_COMPANYBUDGETAPPLYDETAIL).Name); var tempDetails = details.ToEntityList <T_FB_COMPANYBUDGETAPPLYDETAIL>(); foreach (var item in tempDetails) { T_FB_COMPANYBUDGETAPPLYDETAIL detail = item.CopyEntity(); detail.COMPANYBUDGETAPPLYDETAILID = Guid.NewGuid().ToString(); detail.T_FB_COMPANYBUDGETAPPLYMASTER = resultEntity; FBEntity detailFBEntity = detail.ToFBEntity(); detailFBEntity.FBEntityState = FBEntityState.Added; resultDetails.Add(detailFBEntity); } result.FBEntityState = FBEntityState.ReSubmit; return(result); }
public static List <FBEntity> GetRelationFBEntities(this FBEntity fbEntity, string entityType, Func <FBEntity, bool> predicate) { ObservableCollection <FBEntity> list = fbEntity.GetRelationFBEntities(entityType); List <FBEntity> listResult = list.FindAll(predicate); return(listResult); }
/// <summary> /// 根据 entityType , 返回对应的有关系的 FBEntity的集合, /// </summary> /// <param name="fbEntity"></param> /// <param name="entityType">有关系的对象集合类型</param> /// <returns>如果不存在,将会创建相应的集合</returns> public static List <T> GetEntityList <T>(this FBEntity fbEntity, Func <object, T> func = null) where T : class { var list = fbEntity.GetRelationFBEntities(typeof(T).Name).ToList(); if (func == null) { func = item => item as T; } return(list.CreateList(item => func(item.Entity))); }
/// <summary> /// 添加 有关系的集合FBEntity /// </summary> /// <param name="fbEntity"></param> /// <param name="listNew"></param> public static void AddFBEntities <T>(this FBEntity fbEntity, IList <FBEntity> listNew) { string entityName = typeof(T).Name; List <FBEntity> list = fbEntity.GetRelationFBEntities(entityName); foreach (FBEntity item in listNew) { list.Add(item); } }
protected override void OnLoadDataComplete() { var details = this.OrderEntity.GetRelationFBEntities(typeof(T_FB_COMPANYBUDGETSUMDETAIL).Name); List <T_FB_COMPANYBUDGETAPPLYDETAIL> listDetail = new List <T_FB_COMPANYBUDGETAPPLYDETAIL>(); this.OrderEntity.FBEntity.OrderDetailBy <T_FB_COMPANYBUDGETAPPLYDETAIL>(item => { return(item.T_FB_COMPANYBUDGETAPPLYMASTER.OWNERDEPARTMENTID); }); details.ToList().ForEach(item => { var cDetail = (item.Entity as T_FB_COMPANYBUDGETSUMDETAIL).T_FB_COMPANYBUDGETAPPLYDETAIL; item.AddFBEntities <T_FB_COMPANYBUDGETAPPLYDETAIL>(cDetail.ToFBEntityList()); item.OrderDetailBy <T_FB_COMPANYBUDGETAPPLYDETAIL>(detail => { return(detail.T_FB_SUBJECT != null ? detail.T_FB_SUBJECT.SUBJECTCODE : string.Empty); }); listDetail.AddRange(cDetail); }); var detailSum = from item in listDetail group item by item.T_FB_SUBJECT into p select new V_SubjectCompanySum { T_FB_SUBJECT = p.Key, BUDGETMONEY = p.Sum(sumItem => sumItem.BUDGETMONEY), T_FB_COMPANYBUDGETAPPLYDETAIL = listDetail.Where(de => de.T_FB_SUBJECT == p.Key).ToList() }; var detailsTwo = this.OrderEntity.GetRelationFBEntities(typeof(V_SubjectCompanySum).Name); foreach (var ds in detailSum) { FBEntity fbDetail = ds.ToFBEntity(); var listDetails = fbDetail.GetRelationFBEntities(typeof(T_FB_COMPANYBUDGETAPPLYDETAIL).Name); fbDetail.AddFBEntities <T_FB_COMPANYBUDGETAPPLYDETAIL>(ds.T_FB_COMPANYBUDGETAPPLYDETAIL.ToFBEntityList()); fbDetail.OrderDetailBy <T_FB_COMPANYBUDGETAPPLYDETAIL>(item => { return(item.T_FB_COMPANYBUDGETAPPLYMASTER.OWNERDEPARTMENTID); }); detailsTwo.Add(fbDetail); } this.OrderEntity.FBEntity.OrderDetailBy <V_SubjectCompanySum>(item => { return(item.T_FB_SUBJECT.SUBJECTCODE); }); }
public static void OrderDetailBy <T>(this FBEntity fbEntity, Func <T, object> keySelector) where T : EntityObject { var details = fbEntity.GetRelationFBEntities(typeof(T).Name); var result = details.OrderBy(item => { return(keySelector(item.Entity as T)); }).ToList(); details.Clear(); details.AddRange(result); }
public FBEntity ReSubmitT_FB_EXTENSIONALORDER(T_FB_EXTENSIONALORDER entity) { FBEntityBLL bll = this; FBEntity fbOldEntity = GetFBEntityByEntityKey(entity.EntityKey); var master = fbOldEntity.Entity as T_FB_EXTENSIONALORDER; var details = fbOldEntity.GetRelationFBEntities(typeof(T_FB_EXTENSIONORDERDETAIL).Name); details.ForEach(item => { bll.InnerRemove(item.Entity); }); master.INNERORDERID = string.Empty; master.CHECKSTATES = (int)CheckStates.Approving; master.TOTALMONEY = entity.TOTALMONEY; var result = master.ToFBEntity(); List <FBEntity> listDetail = entity.T_FB_EXTENSIONORDERDETAIL.ToList().CreateList(item => { T_FB_EXTENSIONORDERDETAIL detail = new T_FB_EXTENSIONORDERDETAIL(); detail.EXTENSIONORDERDETAILID = Guid.NewGuid().ToString(); detail.APPLIEDMONEY = item.APPLIEDMONEY; detail.CHARGETYPE = item.CHARGETYPE; detail.CREATEDATE = DateTime.Now; detail.CREATEUSERID = item.CREATEUSERID; detail.REMARK = item.REMARK; detail.T_FB_SUBJECT = item.T_FB_SUBJECT; detail.UPDATEUSERID = item.UPDATEUSERID; detail.USABLEMONEY = item.USABLEMONEY; detail.T_FB_EXTENSIONALORDER = entity; FBEntity fbEntityDetail = detail.ToFBEntity(); fbEntityDetail.FBEntityState = FBEntityState.Added; return(fbEntityDetail); }); result.AddFBEntities <T_FB_EXTENSIONORDERDETAIL>(listDetail); result.FBEntityState = FBEntityState.ReSubmit; SaveT_FB_EXTENSIONALORDER(result); return(result); }
public void Save() { ObservableCollection <FBEntity> listOfFBEntity = new ObservableCollection <FBEntity>(); for (int i = 0; i < EntityList.Count; i++) { OrderEntity item = EntityList[i]; FBEntity fbEntitySave = item.GetModifiedFBEntity(); ObservableCollection <FBEntity> listSave = null; if (fbEntitySave.Entity.GetType() == typeof(VirtualDepartment)) { listSave = fbEntitySave.GetRelationFBEntities(typeof(T_FB_SUBJECTDEPTMENT).Name); //活动经费 // CheckMoneyAssign(listSave); } else { listSave = fbEntitySave.GetRelationFBEntities(typeof(T_FB_SUBJECTPOST).Name); // 删除 不是active的岗位项目记录 //listSave.RemoveAll(itemRemove => //{ // bool isAdded = itemRemove.FBEntityState == FBEntityState.Added; // // bool isNew = (itemRemove.Entity as T_FB_SUBJECTPOST).ACTIVED != 1; // //return isAdded && isNew; // return isAdded; //}); } listSave.ToList().ForEach(fbEntity => { bool tf = true;//外键为空的不处理 #region 公共参数赋值 if (fbEntity.IsNewEntity()) { fbEntity.FBEntityState = FBEntityState.Added; fbEntity.SetObjValue("Entity.CREATECOMPANYID", item.LoginUser.Company.Value); fbEntity.SetObjValue("Entity.CREATECOMPANYNAME", item.LoginUser.Company.Text); fbEntity.SetObjValue("Entity.CREATEDEPARTMENTID", item.LoginUser.Department.Value); fbEntity.SetObjValue("Entity.CREATEDEPARTMENTNAME", item.LoginUser.Department.Text); fbEntity.SetObjValue("Entity.CREATEPOSTID", item.LoginUser.Post.Value); fbEntity.SetObjValue("Entity.CREATEPOSTNAME", item.LoginUser.Post.Text); fbEntity.SetObjValue("Entity.CREATEUSERID", item.LoginUser.Value); fbEntity.SetObjValue("Entity.CREATEUSERNAME", item.LoginUser.Text); fbEntity.SetObjValue("Entity.EDITSTATES", decimal.Parse("1")); } fbEntity.SetObjValue("Entity.UPDATEUSERID", item.LoginUser.Value); fbEntity.SetObjValue("Entity.UPDATEUSERNAME", item.LoginUser.Text); #endregion T_FB_SUBJECTPOST sp = fbEntity.Entity as T_FB_SUBJECTPOST; // 去除实体之间的关联,如有关联存在,上传服务端时,会有异常 if (sp == null) { T_FB_SUBJECTDEPTMENT sd = fbEntity.Entity as T_FB_SUBJECTDEPTMENT; if (sd.T_FB_SUBJECTCOMPANY != null && sd.T_FB_SUBJECT != null) { sd.T_FB_SUBJECTCOMPANYReference.EntityKey = sd.T_FB_SUBJECTCOMPANY.EntityKey; sd.T_FB_SUBJECTCOMPANY = null; sd.T_FB_SUBJECTReference.EntityKey = sd.T_FB_SUBJECT.EntityKey; sd.T_FB_SUBJECT = null; sd.T_FB_SUBJECTPOST = null; fbEntity.CollectionEntity.Clear(); } else { tf = false; } } else { if (sp.T_FB_SUBJECTDEPTMENT != null && sp.T_FB_SUBJECT != null) { EntityKey parentKey = sp.T_FB_SUBJECTDEPTMENT.EntityKey; if (parentKey.EntityKeyValues == null) { EntityKeyMember em = new EntityKeyMember(); em.Key = "SUBJECTDEPTMENTID"; em.Value = sp.T_FB_SUBJECTDEPTMENT.SUBJECTDEPTMENTID; EntityKey newKey = new EntityKey(); newKey.EntityContainerName = parentKey.EntityContainerName; newKey.EntitySetName = parentKey.EntitySetName; newKey.EntityKeyValues = new ObservableCollection <EntityKeyMember>(); newKey.EntityKeyValues.Add(em); parentKey = newKey; } sp.T_FB_SUBJECTDEPTMENTReference = new EntityReferenceOfT_FB_SUBJECTDEPTMENTZ5CrhPbu(); sp.T_FB_SUBJECTDEPTMENTReference.EntityKey = parentKey; sp.T_FB_SUBJECTDEPTMENT = null; sp.T_FB_SUBJECTReference = new EntityReferenceOfT_FB_SUBJECTZ5CrhPbu(); sp.T_FB_SUBJECTReference.EntityKey = sp.T_FB_SUBJECT.EntityKey; sp.T_FB_SUBJECT = null; // 清除已删除实体,这些实体会在 T_FB_SUBJECTDEPTMENT 实体中处理 . fbEntity.GetRelationFBEntities(Args.DELETE_ENTITYTYPE).Clear(); } else { tf = false; } } if (tf) { listOfFBEntity.Add(fbEntity); } }); } if (listOfFBEntity.Count > 0) { this.CurrentOrderEntity = new OrderEntity(typeof(VirtualCompany)); this.orderEntityService.SaveList(listOfFBEntity); } else { CloseProcess(); } }
private void SetRowDetailTemplate() { if (this.orderDetailGridInfo.RowDetailDataPanel != null) { #region RowDetailTemplate DataTemplate dt = DataTemplateHelper.GetEmptyGrid(); this.ADGrid.RowDetailsTemplate = dt; this.ADGrid.LoadingRowDetails += (o, e) => { IDataPanel panel = this.orderDetailGridInfo.RowDetailDataPanel; IControlAction control = panel.GetUIElement(); Grid grid = e.DetailsElement as Grid; grid.Background = e.Row.Background; if (grid.Children.Count == 0) { Border border = new Border(); border.Style = (Style)Application.Current.Resources["DetailShow_1"]; grid.Children.Add(border); if (control.GetType() == typeof(DetailGrid)) { DetailGrid dgrid = control as DetailGrid; border.Child = dgrid; // dgrid.Margin = new Thickness(80, 0, 0, 0); control.InitControl(this.operationType); } else { border.Child = (control as UIElement); OperationTypes cOpType = this.operationType; if (this.operationType == OperationTypes.Audit) { cOpType = OperationTypes.Edit; } control.InitControl(cOpType); } } DependencyObject dObj = VisualTreeHelper.GetChild(e.DetailsElement,0); UIElement curControl = (dObj as Border).Child; if (curControl.GetType() == typeof(DetailGrid)) { DetailGrid dgrid = curControl as DetailGrid; string entityType = dgrid.OrderDetailGridInfo.OrderDetailEntityInfo.Entity.Type; FBEntity source = e.Row.DataContext as FBEntity; ; if (source != null) { ObservableCollection<FBEntity> list = source.GetRelationFBEntities(entityType); if (list.Count > 0) { dgrid.ItemsSource = list; } else { dgrid.Visibility = Visibility.Collapsed; } } } if (LoadRowDetailComplete != null) { ActionCompletedEventArgs<UIElement> args = new ActionCompletedEventArgs<UIElement>(curControl); LoadRowDetailComplete(o, args); } }; #endregion } }