Exemplo n.º 1
0
        private void initTree()
        {
            UsersEntity    entity         = _usersBS.get(UsersEntity.FIELD_USER_TYPE + "=" + UsersBS.ADMIN);
            UserTreeEntity userTreeEntity = null;

            for (int i = 0; i < entity.Tables[entity.FilledTableName].Rows.Count; i++)
            {
                userTreeEntity = new UserTreeEntity();
                DataRow dr = userTreeEntity.Tables[userTreeEntity.TableName].NewRow();
                dr[UserTreeEntity.FIELD_USER_ID]   = entity.get(UsersEntity.FIELD_ID);
                dr[UserTreeEntity.FIELD_USER_PATH] = entity.get(UsersEntity.FIELD_ID).ToString();
                userTreeEntity.Tables[userTreeEntity.TableName].Rows.Add(dr);
                _userTreeBL.add(userTreeEntity);
            }

            userTreeEntity = _userTreeBL.get();
            for (int i = 0; i < userTreeEntity.Tables[userTreeEntity.FilledTableName].Rows.Count; i++)
            {
                entity = _usersBS.get(int.Parse(userTreeEntity.get(UserTreeEntity.FIELD_USER_ID).ToString()));
                TreeNode node = new TreeNode(entity.ToString());
                node.ForeColor = Color.Green;
                node.Tag       = NodeItem.ToNodeItem(userTreeEntity, i);
                treeView1.Nodes.Add(node);
            }
        }
Exemplo n.º 2
0
        private void fillUserRefferenceCombo(int defaultValue)
        {
            UserTreeBL     userTreeBL     = new UserTreeBL();
            int            loggineduserid = int.Parse(UsersBS.loginedUser.get(UsersEntity.FIELD_ID).ToString());
            UserTreeEntity entity         = userTreeBL.get();

            cmbReferenceUserId.DataSource = null;
            cmbReferenceUserId.Items.Clear();

            var dataSource = new List <ComboBoxItem>();

            //BasicInfoUtil.AddUnKnown(dataSource);
            for (int i = 0; i < entity.Tables[entity.FilledTableName].Rows.Count; i++)
            {
                string name   = entity.get(i, UserTreeEntity.VIEW_FIELD_USER_NAME).ToString();
                string treeid = entity.get(i, UserTreeEntity.FIELD_ID).ToString();
                string userid = entity.get(i, UserTreeEntity.FIELD_USER_ID).ToString();
                dataSource.Add(new ComboBoxItem(name, treeid, userid));
            }

            cmbReferenceUserId.DataSource    = dataSource;
            cmbReferenceUserId.DisplayMember = "Text";
            cmbReferenceUserId.ValueMember   = "Value";
            for (int i = 0; i < cmbReferenceUserId.Items.Count; i++)
            {
                string c = ((ComboBoxItem)cmbReferenceUserId.Items[i]).CustomData;
                if (c != null && c.Equals(defaultValue.ToString()))
                {
                    cmbReferenceUserId.SelectedIndex = i;
                    break;
                }
            }
        }
Exemplo n.º 3
0
        private void LoadUsers()
        {
            int            logginedUserid = int.Parse(UsersBS.loginedUser.get(UsersEntity.FIELD_ID).ToString());
            UserTreeEntity entity         = null;

            if (_userTreeId <= 0)
            {
                fillUserRefferenceCombo(-1);
                rbAdmins.Enabled = false;
                rbUsers.Enabled  = false;
            }
            else
            {
                if (rbAdmins.Checked)
                {
                    entity = _userTreeBL.getByUserType(UsersBS.ADMIN);
                }
                else if (rbUsers.Checked)
                {
                    int type = int.Parse(UsersBS.loginedUser.get(UsersEntity.FIELD_USER_TYPE).ToString());
                    if (type == UsersBS.ADMIN)
                    {
                        entity = _userTreeBL.get();
                    }
                    else
                    {
                        UserTreeEntity entity1 = _userTreeBL.getByUser(logginedUserid);
                        UserTreeEntity entity2 = _userTreeBL.getParent(logginedUserid);

                        entity = joinEntities(entity1, entity2);
                    }
                }
                lstUserList.DataSource = null;
                lstUserList.Items.Clear();

                var dataSource = new List <ComboBoxItem>();
                //BasicInfoUtil.AddUnKnown(dataSource);
                string hash = "";
                if (entity != null && entity.Tables[entity.FilledTableName].Rows.Count > 0)
                {
                    for (int i = 0; i < entity.Tables[entity.FilledTableName].Rows.Count; i++)
                    {
                        string name   = entity.get(i, UserTreeEntity.VIEW_FIELD_USER_NAME).ToString();
                        string treeid = entity.get(i, UserTreeEntity.FIELD_ID).ToString();
                        string userid = entity.get(i, UserTreeEntity.FIELD_USER_ID).ToString();

                        if (hash.IndexOf(userid + ",") < 0)
                        {
                            dataSource.Add(new ComboBoxItem(name, treeid, userid));
                        }
                        hash += userid + ",";
                    }

                    lstUserList.DataSource    = dataSource;
                    lstUserList.DisplayMember = "Text";
                    lstUserList.ValueMember   = "Value";
                    lstUserList.SelectedIndex = 0;
                }
            }
        }
Exemplo n.º 4
0
        //return treeids for user of this tree -- users that is owner of nodes
        private string getSameUserIdsLikeThisNode(int treeid)
        {
            string         treeids = "";
            UserTreeEntity uEntity = _userTreeBL.get(treeid);
            int            userid  = int.Parse(uEntity.get(UserTreeEntity.FIELD_USER_ID).ToString());

            uEntity = _userTreeBL.getByUserTableId(userid);
            for (int i = 0; i < uEntity.Tables[uEntity.FilledTableName].Rows.Count; i++)
            {
                treeids += uEntity.get(i, UserTreeEntity.FIELD_ID) + ",";
            }

            return(treeids.Substring(0, treeids.Length - 1));
        }
Exemplo n.º 5
0
        private bool checkIsLetterUserEqualLogginedUser(int ownerTreeNodeId)
        {
            int            loggindeUserId = int.Parse(UsersBS.loginedUser.get(UsersEntity.FIELD_ID).ToString());
            UserTreeBL     userTree       = new UserTreeBL();
            UserTreeEntity treeEntity     = userTree.get(ownerTreeNodeId);

            if (treeEntity.Tables[treeEntity.FilledTableName].Rows.Count > 0)
            {
                int userId = int.Parse(treeEntity.get(UserTreeEntity.FIELD_USER_ID).ToString());
                if (userId.Equals(loggindeUserId))
                {
                    return(true);
                }
            }
            return(false);
        }