示例#1
0
        void dGrid_ToolBarItemClick(object sender, ToolBarItemClickEventArgs e)
        {
            if (e.Action != Actions.Add)
            {
                return;
            }
            e.Action = Actions.Cancel;
            FBEntityService service = new FBEntityService();
            QueryExpression qeOwner = this.OrderEntity.GetQueryExpression(FieldName.OwnerID);
            QueryExpression qeDept  = this.OrderEntity.GetQueryExpression(FieldName.OwnerDepartmentID);
            QueryExpression qePost  = this.OrderEntity.GetQueryExpression(FieldName.OwnerPostID);

            qeDept.RelatedExpression          = qeOwner;
            qeOwner.RelatedExpression         = qePost;
            qeDept.QueryType                  = typeof(T_FB_TRAVELEXPAPPLYDETAIL).Name;
            service.QueryFBEntitiesCompleted += (o, ea) =>
            {
                ObservableCollection <FBEntity> listDetail     = this.OrderEntity.GetRelationFBEntities(typeof(T_FB_TRAVELEXPAPPLYDETAIL).Name);
                ObservableCollection <FBEntity> listDetailItem = ea.Result;
                listDetailItem.ToList().ForEach(item =>
                {
                    T_FB_TRAVELEXPAPPLYDETAIL t = item.Entity as T_FB_TRAVELEXPAPPLYDETAIL;
                    t.T_FB_TRAVELEXPAPPLYMASTER = this.OrderEntity.Entity as T_FB_TRAVELEXPAPPLYMASTER;
                    t.SERIALNUMBER = listDetail.Count + 1;

                    ps.ForEach(p => { t.SetObjValue(p, decimal.Parse("0")); });
                    t.TOTALCHARGE = decimal.Parse("0");

                    listDetail.Add(item);
                });
            };


            service.QueryFBEntities(qeDept);
        }