コード例 #1
0
        public RoleDataSet.RoleRow GetRoleByName(string role, bool createIfNotFound)
        {
            RoleDataSet roleDataset = new RoleDataSet();

            int numberOfRoles = FillByName(roleDataset.Role, role);

            if (numberOfRoles > 0)
            {
                return(roleDataset.Role[0]);
            }
            else
            {
                if (createIfNotFound && !string.IsNullOrEmpty(role))
                {
                    RoleDataSet.RoleRow roleRow = roleDataset.Role.NewRoleRow();
                    roleRow.Name = role;
                    roleDataset.Role.AddRoleRow(roleRow);
                    Update(roleRow);
                    //Updating, um ID zu erhalten
                    roleDataset.Role.Clear();
                    numberOfRoles = FillByName(roleDataset.Role, role);
                    if (numberOfRoles > 0)
                    {
                        return(roleDataset.Role[0]);
                    }
                }

                return(null);
            }
        }
コード例 #2
0
        public RoleDataSet.RoleRow GetRoleById(int id)
        {
            RoleDataSet roleDataset = new RoleDataSet();

            int numberOfRoles = FillById(roleDataset.Role, id);

            if (numberOfRoles > 0)
            {
                return(roleDataset.Role[0]);
            }
            else
            {
                return(null);
            }
        }
コード例 #3
0
        private void FillRolesInComboBox()
        {
            Cursor.Current = Cursors.WaitCursor;
            RoleTableAdapter roleAdapter = new RoleTableAdapter(dataBase);
            RoleDataSet      roleDataset = new RoleDataSet();

            roleAdapter.Fill(roleDataset.Role);
            roleDataset.Role.DefaultView.Sort = "Name ASC";
            comboBoxRole.DataSource           = roleDataset.Role.DefaultView;
            comboBoxRole.DisplayMember        = "Name";
            comboBoxRole.ValueMember          = "Name";

            if (participant.Role != null)
            {
                comboBoxRole.SelectedValue = participant.Role;
            }

            Cursor.Current = Cursors.Default;

            UpdateWindowState();
        }