Ejemplo n.º 1
0
        private void AttachSubject(List <OrderEntity> list, OrderEntity orderEntity, TreeViewItem treeViewItem)
        {
            List <OrderEntity> result = null;

            if (orderEntity != null)
            {
                result = list.Where(item =>
                {
                    T_FB_SUBJECT subjectSource = item.Entity as T_FB_SUBJECT;
                    T_FB_SUBJECT subjectTarget = orderEntity.Entity as T_FB_SUBJECT;
                    if (subjectSource.T_FB_SUBJECT2 != null)
                    {
                        return(subjectSource.T_FB_SUBJECT2.SUBJECTID == subjectTarget.SUBJECTID);
                    }
                    return(false);
                }).ToList <OrderEntity>();
            }
            else
            {
                result = (from item in list
                          where (item.Entity as T_FB_SUBJECT).T_FB_SUBJECT2 == null
                          select item).ToList <OrderEntity>();
            }


            if (result.Count > 0)
            {
                foreach (OrderEntity oEntity in result)
                {
                    TreeViewItem objTreeNode = treeViewItem.Items.AddObject <OrderEntity>(oEntity, subjectTemplate);

                    AttachSubject(list, oEntity, objTreeNode);
                }
            }
        }
Ejemplo n.º 2
0
        private void Delete()
        {
            if (currentTreeViewItem.HasItems)
            {
                CommonFunction.NotifySelection("当前记录有子结点,不能被删除");
                return;
            }

            Action action = () =>
            {
                if (this.CurrentOrderEntity.FBEntityState == FBEntityState.Added)
                {
                    OrderEntity orderEntity = this.EntityList.FirstOrDefault(item => { return(object.Equals(item, this.currentOrderEntity)); });
                    if (orderEntity != null)
                    {
                        this.EntityList.Remove(orderEntity);
                    }
                    else
                    {
                        FBEntity     fbEntity = this.CurrentOrderEntity.FBEntity;
                        T_FB_SUBJECT subject  = fbEntity.Entity as T_FB_SUBJECT;
                        this.dictTreeViewItem[subject.T_FB_SUBJECTTYPE].DeleteFBEntity(fbEntity);
                    }
                    this.CurrentOrderEntity = null;
                }
                else
                {
                    this.CurrentOrderEntity.FBEntityState = FBEntityState.Deleted;
                }

                Type           type  = this.currentTreeViewItem.Parent.GetType();
                PropertyInfo   p     = type.GetProperty("Items");
                ItemCollection items = (ItemCollection)p.GetValue(this.currentTreeViewItem.Parent, null);

                //beyond
                TreeViewItem tempcurrentTreeViewItem = currentTreeViewItem.Parent as TreeViewItem;

                items.Remove(this.currentTreeViewItem);

                //beyond this.currentTreeViewItem
                if (items.Count > 0)
                {
                    this.currentTreeViewItem = items[0] as TreeViewItem;
                }
                else
                {
                    this.currentTreeViewItem = tempcurrentTreeViewItem;
                }

                this.CurrentOrderEntity = currentTreeViewItem.DataContext as OrderEntity;

                //  this.CurrentEditForm.Save();
            };

            CommonFunction.AskDelete(string.Empty, action);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取T_FB_SUBJECT信息
        /// </summary>
        /// <param name="strSubjectId">主键索引</param>
        /// <returns></returns>
        public T_FB_SUBJECT GetSubjectByID(string strSubjectId)
        {
            if (string.IsNullOrEmpty(strSubjectId))
            {
                return(null);
            }

            SubjectDAL    dalSubject = new SubjectDAL();
            StringBuilder strFilter  = new StringBuilder();
            List <string> objArgs    = new List <string>();

            if (!string.IsNullOrEmpty(strSubjectId))
            {
                strFilter.Append(" SUBJECTID == @0");
                objArgs.Add(strSubjectId);
            }

            T_FB_SUBJECT entRd = dalSubject.GetSubjectRdByMultSearch(strFilter.ToString(), objArgs.ToArray());

            return(entRd);
        }
Ejemplo n.º 4
0
        private void lkSubject_FindClick(object sender, EventArgs e)
        {
            if (lkOrg.DataContext == null)
            {
                return;
            }

            Dictionary <string, string> cols = new Dictionary <string, string>();

            cols.Add("SUBJECTCODE", "SUBJECTCODE");
            cols.Add("SUBJECTNAME", "SUBJECTNAME");

            StringBuilder strfilter = new StringBuilder();
            ObservableCollection <object> objArgs = new ObservableCollection <object>();

            switch (strOrgType.ToUpper())
            {
            case "COMPANY":
                strfilter.Append(" OWNERCOMPANYID == @0");
                break;

            case "DEPARTMENT":
                strfilter.Append(" OWNERDEPARTMENTID == @0");
                break;

            case "POST":
                strfilter.Append(" OWNERPOSTID == @0");
                break;

            case "PERSONNAL":
                strfilter.Append(" OWNERPOSTID == @0");
                break;
            }

            if (strOrgType.ToUpper() == "PERSONNAL" && lkOrg.DataContext != null)
            {
                SMT.Saas.Tools.PersonnelWS.T_HR_EMPLOYEE entEmp = lkOrg.DataContext as SMT.Saas.Tools.PersonnelWS.T_HR_EMPLOYEE;
                if (entEmp != null)
                {
                    strOrgId = entEmp.OWNERPOSTID;
                }
            }

            objArgs.Add(strOrgId);

            LookupForm lookup = new LookupForm(FBAEnumsBLLPrefixNames.Execution,
                                               typeof(T_FB_SUBJECT[]), cols, "MonthlyBudgetAnalysis", strfilter.ToString(), objArgs);

            lookup.SelectedClick += (o, ev) =>
            {
                ObservableCollection <object> entList = lookup.SelectedObj as ObservableCollection <object>;

                StringBuilder strIDlist   = new StringBuilder();
                StringBuilder strNamelist = new StringBuilder();

                foreach (var obj in entList)
                {
                    T_FB_SUBJECT ent = obj as T_FB_SUBJECT;
                    strIDlist.Append(ent.SUBJECTID + ";");
                    strNamelist.Append(ent.SUBJECTNAME + ";");
                }

                strSearchSubjects        = strIDlist.ToString();
                lkSubject.TxtLookUp.Text = strNamelist.ToString();
            };

            lookup.Show <string>(DialogMode.Default, SMT.SAAS.Main.CurrentContext.Common.ParentLayoutRoot, "", (result) => { });
        }
Ejemplo n.º 5
0
 public static T_FB_SUBJECT CreateT_FB_SUBJECT(string sUBJECTID, string sUBJECTNAME, string sUBJECTCODE, decimal aCTIVED, string cREATEUSERID, global::System.DateTime cREATEDATE, string uPDATEUSERID, global::System.DateTime uPDATEDATE, decimal eDITSTATES)
 {
     T_FB_SUBJECT t_FB_SUBJECT = new T_FB_SUBJECT();
     t_FB_SUBJECT.SUBJECTID = sUBJECTID;
     t_FB_SUBJECT.SUBJECTNAME = sUBJECTNAME;
     t_FB_SUBJECT.SUBJECTCODE = sUBJECTCODE;
     t_FB_SUBJECT.ACTIVED = aCTIVED;
     t_FB_SUBJECT.CREATEUSERID = cREATEUSERID;
     t_FB_SUBJECT.CREATEDATE = cREATEDATE;
     t_FB_SUBJECT.UPDATEUSERID = uPDATEUSERID;
     t_FB_SUBJECT.UPDATEDATE = uPDATEDATE;
     t_FB_SUBJECT.EDITSTATES = eDITSTATES;
     return t_FB_SUBJECT;
 }
Ejemplo n.º 6
0
 public void AddToT_FB_SUBJECT(T_FB_SUBJECT t_FB_SUBJECT)
 {
     base.AddObject("T_FB_SUBJECT", t_FB_SUBJECT);
 }
Ejemplo n.º 7
0
        private List <string> CheckSubject(T_FB_SUBJECT entitySubject)
        {
            #region 处理 Subject


            List <string> errMsg        = new List <string>();
            var           subjectTypeID = entitySubject.T_FB_SUBJECTTYPE.SUBJECTTYPEID;
            string        code          = entitySubject.SUBJECTCODE;
            if (string.IsNullOrEmpty(code))
            {
                errMsg.Add("科目编号不能为空");
            }

            string name = entitySubject.SUBJECTNAME;
            if (string.IsNullOrEmpty(name))
            {
                errMsg.Add("科目类别不能为空");
            }

            foreach (OrderEntity orderEntity in this.EntityList)
            {
                if (errMsg.Count > 0)
                {
                    break;
                }
                var subjects = orderEntity.GetRelationFBEntities(typeof(T_FB_SUBJECT).Name);

                #region 科目名称
                // 相同的科目名称在不同的科目类别中,是否可以保存
                var canSameSubjectName = DataCore.GetSetting("CanSameSubjectName") == "1";
                if (!canSameSubjectName)
                {
                    var subjectFind = subjects.FirstOrDefault(fbEntity =>
                    {
                        T_FB_SUBJECT entity = fbEntity.Entity as T_FB_SUBJECT;
                        if (entity == null)
                        {
                            return(false);
                        }
                        bool isRightType  = entity.GetType().Name == "T_FB_SUBJECT";
                        bool isNotItselft = !object.Equals(entity, entitySubject);
                        bool isSameName   = name == entity.SUBJECTNAME;
                        return(isRightType && isNotItselft && isSameName);
                    });

                    if (subjectFind != null)
                    {
                        errMsg.Add("科目名称已存在,不可重复");
                    }
                }

                #endregion

                #region 科目编号
                var subjectFind2 = subjects.FirstOrDefault(fbEntity =>
                {
                    T_FB_SUBJECT entity = fbEntity.Entity as T_FB_SUBJECT;
                    bool isRightType    = entity.GetType().Name == "T_FB_SUBJECT";
                    bool isNotItselft   = !object.Equals(entity, entitySubject);
                    bool isSameCode     = code == entity.SUBJECTCODE;

                    return(isRightType && isNotItselft && isSameCode);
                });

                if (subjectFind2 != null)
                {
                    errMsg.Add("科目编号已存在,不可重复");
                }
                #endregion
            }
            #endregion

            return(errMsg);
        }
Ejemplo n.º 8
0
        public bool CheckData(ObservableCollection <FBEntity> listSaveNew)
        {
            bool pass = true;

            #region old
            //listSaveNew.ToList().ForEach(item =>
            //    {
            //        // 要删除的实体
            //        if (item.FBEntityState == EntityState.Deleted)
            //        {
            //            return;
            //        }
            //        T_FB_SUBJECTTYPE entitySubjectType = item.Entity as T_FB_SUBJECTTYPE;

            //        pass &= SetErrorFlag(entitySubjectType, CheckSubjectType(entitySubjectType));

            //        var subjects = item.GetRelationFBEntities(typeof(T_FB_SUBJECT).Name);
            //        subjects.ToList().ForEach(fbEntitySubject =>
            //            {
            //                // 要删除的实体
            //                if (fbEntitySubject.FBEntityState == EntityState.Deleted)
            //                {
            //                    return;
            //                }
            //                T_FB_SUBJECT entitySubject = fbEntitySubject.Entity as T_FB_SUBJECT;
            //                pass &= SetErrorFlag(entitySubject, CheckSubject(entitySubject));
            //            });
            //    });
            #endregion

            #region beyond
            listSaveNew.ToList().ForEach(item =>
            {
                // 要删除的实体
                if (item.FBEntityState == FBEntityState.Deleted)
                {
                    return;
                }
                T_FB_SUBJECTTYPE entitySubjectType = item.Entity as T_FB_SUBJECTTYPE;

                pass &= SetErrorFlag(entitySubjectType, CheckSubjectType(entitySubjectType));
                if (!pass)
                {
                    return;
                }
                var subjects = item.GetRelationFBEntities(typeof(T_FB_SUBJECT).Name);
                subjects.ToList().ForEach(fbEntitySubject =>
                {
                    // 要删除的实体
                    if (fbEntitySubject.FBEntityState == FBEntityState.Deleted)
                    {
                        return;
                    }
                    T_FB_SUBJECT entitySubject = fbEntitySubject.Entity as T_FB_SUBJECT;
                    pass &= SetErrorFlag(entitySubject, CheckSubject(entitySubject));
                    if (!pass)
                    {
                        return;
                    }
                });
            });

            #endregion
            return(pass);
        }
Ejemplo n.º 9
0
        private List<string> CheckSubject(T_FB_SUBJECT entitySubject)
        {
            #region 处理 Subject
          
            
            List<string> errMsg = new List<string>();
            var subjectTypeID = entitySubject.T_FB_SUBJECTTYPE.SUBJECTTYPEID;
            string code = entitySubject.SUBJECTCODE;
            if (string.IsNullOrEmpty(code))
            {
                errMsg.Add("科目编号不能为空");
            }

            string name = entitySubject.SUBJECTNAME;
            if (string.IsNullOrEmpty(name))
            {
                errMsg.Add("科目类别不能为空");
            }

             foreach (OrderEntity orderEntity in this.EntityList)
             {
                 if (errMsg.Count > 0)
                 {
                     break;
                 }
                var subjects = orderEntity.GetRelationFBEntities(typeof(T_FB_SUBJECT).Name);

                #region 科目名称
                // 相同的科目名称在不同的科目类别中,是否可以保存
                var canSameSubjectName = DataCore.GetSetting("CanSameSubjectName") == "1";
                if (!canSameSubjectName)
                {
                    var subjectFind = subjects.FirstOrDefault(fbEntity =>
                    {
                        T_FB_SUBJECT entity = fbEntity.Entity as T_FB_SUBJECT;
                        if (entity == null)
                        {
                            return false;
                        }
                        bool isRightType = entity.GetType().Name == "T_FB_SUBJECT";
                        bool isNotItselft = !object.Equals(entity, entitySubject);
                        bool isSameName = name == entity.SUBJECTNAME;
                        return isRightType && isNotItselft && isSameName;
                    });

                    if (subjectFind != null)
                    {
                        errMsg.Add("科目名称已存在,不可重复");
                    }
                }
                
                #endregion

                #region 科目编号
                var subjectFind2 = subjects.FirstOrDefault(fbEntity =>
                {
                    T_FB_SUBJECT entity = fbEntity.Entity as T_FB_SUBJECT;
                    bool isRightType = entity.GetType().Name == "T_FB_SUBJECT";
                    bool isNotItselft = !object.Equals(entity, entitySubject);
                    bool isSameCode = code == entity.SUBJECTCODE;

                    return isRightType && isNotItselft && isSameCode;
                });

                if ( subjectFind2 != null)
                {
                    errMsg.Add("科目编号已存在,不可重复");
                }
                #endregion
            }
            #endregion

            return errMsg;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 选择预算科目
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lkSubject_FindClick(object sender, EventArgs e)
        {
            string filter = string.Empty;
            ObservableCollection <object> paras = new ObservableCollection <object>();
            string          strOrgType          = string.Empty;
            string          strOrgID            = string.Empty;
            OrgSelectEntity ose = lkOrg.DataContext as OrgSelectEntity;

            if (ose == null)
            {
                Utility.ShowCustomMessage(MessageTypes.Message, Utility.GetResourceStr("WARNING"), "请选择机构后再进行查询");
                return;
            }
            else if (ose.IsMultipleType)
            {
                Utility.ShowCustomMessage(MessageTypes.Caution, Utility.GetResourceStr("WARNING"), "请选择相同类型的机构,如全是公司或全是人员");
                return;
            }

            ose.GetSqlValue(ref filter, ref paras);
            var intOrgType = (int)ose.SelectedOrgType;


            Dictionary <string, string> cols = new Dictionary <string, string>();

            cols.Add("SUBJECTCODE", "SUBJECTCODE");
            cols.Add("SUBJECTNAME", "SUBJECTNAME");


            if (intOrgType == 3)
            {
                paras.Clear();
                List <string> filters = new List <string>();
                foreach (var item in ose.SelectedValue)
                {
                    var entEmp = item.ObjectInstance as SMT.Saas.Tools.PersonnelWS.T_HR_EMPLOYEE;
                    var temp   = string.Format("(OWNERPOSTID=@{0})", paras.Count);
                    paras.Add(entEmp.OWNERPOSTID);
                    filters.Add(temp);
                }
                filter = "( " + string.Join(" or ", filters) + " )";
            }

            LookupForm lookup = new LookupForm(FBAEnumsBLLPrefixNames.Execution,
                                               typeof(T_FB_SUBJECT[]), cols, "T_FB_BUDGETCHECK", filter, paras);

            lookup.SelectedClick += (o, ev) =>
            {
                if (lookup.SelectedObj == null)
                {
                    return;
                }

                ObservableCollection <object> entList = lookup.SelectedObj as ObservableCollection <object>;

                StringBuilder strIDlist   = new StringBuilder();
                StringBuilder strNamelist = new StringBuilder();

                foreach (var obj in entList)
                {
                    T_FB_SUBJECT ent = obj as T_FB_SUBJECT;

                    strIDlist.Append(ent.SUBJECTID + ";");
                    strNamelist.Append(ent.SUBJECTNAME + ";");
                }

                strSearchSubjects        = strIDlist.ToString();
                lkSubject.TxtLookUp.Text = strNamelist.ToString();
            };

            lookup.Show <string>(DialogMode.Default, SMT.SAAS.Main.CurrentContext.Common.ParentLayoutRoot, "", (result) => { });
        }