예제 #1
0
        /// <summary>
        /// Generate Treelist structure
        /// </summary>
        private void GenTreeUserData()
        {
            List <GroupUser> groupUsers = GroupUser.LoadAllUserGroup();

            CreateColumns(treeMenu);
            CreateTree(treeMenu, groupUsers);
        }
예제 #2
0
        /// <summary>
        /// Load all user group from DB and fill into checked combo box
        /// </summary>
        private void LoadAllUserGroup()
        {
            try
            {
                groupUsers = GroupUser.LoadAllUserGroup();
                foreach (GroupUser u in groupUsers)
                {
                    CheckedListBoxItem listBoxItem = new CheckedListBoxItem();
                    listBoxItem.Value       = u.groupId;
                    listBoxItem.Description = u.groupName;

                    chkcbUserGroup.Properties.Items.Add(listBoxItem);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
예제 #3
0
        /// <summary>
        /// Get group access, operator level, Group user from DB and add in combobox
        /// </summary>
        private void GetComboBoxData()
        {
            try
            {
                List <GroupAccess> groupAccesses = GroupAccess.GetAllAccessGroup();
                cboAccess.Properties.DataSource    = groupAccesses;
                cboAccess.Properties.DisplayMember = "groupName";
                cboAccess.Properties.ValueMember   = "groupId";

                List <OperatorLevel> operatorLevels = OperatorLevel.GetAllOptLevel();
                cboOptLevel.Properties.DataSource    = operatorLevels;
                cboOptLevel.Properties.DisplayMember = "OptName";
                cboOptLevel.Properties.ValueMember   = "OptId";

                List <GroupUser> groupUsers = GroupUser.LoadAllUserGroup();
                cboGroup.Properties.DataSource    = groupUsers;
                cboGroup.Properties.DisplayMember = "groupName";
                cboGroup.Properties.ValueMember   = "groupId";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
예제 #4
0
        /// <summary>
        /// Show user info in gridcontrol when user choose in treelist control
        /// </summary>
        private void treeMenu_RowCellClick(object sender, DevExpress.XtraTreeList.RowCellClickEventArgs e)
        {
            try
            {
                TreeList treeList = (TreeList)sender;
                TreeListMultiSelection selectedNodes = treeList.Selection;
                //Get mode from treelist
                //G: Group
                //R: All user
                //I: One user
                string mode = selectedNodes[0].GetValue(treeList.Columns[2]).ToString();

                //Edit user group info
                MouseEventArgs me = (MouseEventArgs)e;
                if (me.Button == MouseButtons.Right)
                {
                    if (mode == "G")
                    {
                        groupUserId   = selectedNodes[0].GetValue(treeList.Columns[0]).ToString();
                        groupUserName = selectedNodes[0].GetValue(treeList.Columns[1]).ToString();
                        popupUser.ShowPopup(Control.MousePosition);
                    }
                    return;
                }

                //Load user information to grid
                string title = "";

                //Get all user
                List <GroupUser> groupUsers = GroupUser.LoadAllUserGroup();

                //Init DataTable
                InitTableStructure(dtSource);



                if (mode == "R")
                {
                    dtSource.Clear();
                    DataTable dt = new DataTable();
                    InitTableStructure(dt);

                    //Load all user to grid
                    foreach (GroupUser g in groupUsers)
                    {
                        dt = g.ToDataTable();
                        foreach (DataRow dr1 in dt.Rows)
                        {
                            dtSource.ImportRow(dr1);
                        }
                    }
                    title = "All user";
                }
                else
                if (mode == "G")
                {
                    dtSource.Clear();
                    string groupUserId = selectedNodes[0].GetValue(treeList.Columns[0]).ToString();

                    //Load user by group to grid
                    foreach (GroupUser g in groupUsers)
                    {
                        if (g.groupId == groupUserId)
                        {
                            dtSource = g.ToDataTable();
                            title    = g.groupName;
                        }
                    }
                }
                else
                if (mode == "I")
                {
                    dtSource.Clear();
                    string userId = selectedNodes[0].GetValue(treeList.Columns[0]).ToString();

                    //Load one user to grid
                    foreach (GroupUser g in groupUsers)
                    {
                        foreach (Users u in g.ListUsers)
                        {
                            if (u.Id == userId)
                            {
                                DataRow dr2 = dtSource.NewRow();
                                dr2["userId"]     = u.Id;
                                dr2["personName"] = u.Name;
                                dr2["email"]      = u.Email;
                                if (u.ListCard == null)
                                {
                                    dr2["card"] = 0;
                                }
                                else
                                {
                                    dr2["card"] = u.ListCard.Count;
                                }
                                dtSource.Rows.Add(dr2);
                                if (Convert.ToBoolean(u.Status))
                                {
                                    dr2["status"] = "Active";
                                }
                                else
                                {
                                    dr2["status"] = "Deactive";
                                }
                                title = u.Name;
                            }
                        }
                    }
                }

                gridUser.DataSource = dtSource;
                lblTitle.Text       = title;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }