Пример #1
0
        private void Dialog_ValidateAeRoleData(object sender, AeRoleEventArgs e)
        {
            string error = string.Empty;
            InsertModifyAeRoleDialog dialog = (InsertModifyAeRoleDialog)sender;

            e.IsValid = true;

            // Clear existing errors
            dialog.ValidateAeTitle(string.Empty);
            dialog.ValidateRole(string.Empty);

            // AETitle
            if (!Leadtools.DicomDemos.Utils.IsValidApplicationEntity(e.AeRole.AeTitle, out error))
            {
                dialog.ValidateAeTitle(error);
                e.IsValid = false;
            }
            else if (e.IsInsert && (aeRoleList.MyContains(e.AeRole)))
            {
                // insert -- verify AeTile does not already exist
                dialog.ValidateAeTitle("Record already exists with this AE Title and Role.");
                e.IsValid = false;
            }
            else if (!e.IsInsert && e.IsNewAeTitle && (aeRoleList.MyContains(e.AeRole)))
            {
                // modify and the aeTitle has changed -- verify the AeTitle does not already exist
                dialog.ValidateAeTitle("Record already exists with this AE Title and Role.");
                e.IsValid = false;
            }
        }
Пример #2
0
        private bool InsertClient(InsertModifyAeRoleControlType dialogType)
        {
            bool ret = false;
            InsertModifyAeRoleDialog dialog = new InsertModifyAeRoleDialog()
            {
                DialogType = dialogType
            };

            dialog.aeRoleList = aeRoleList;

            AeInfoExtended[] aeInfoExtended = Module.AeManagementDataAccessAgent.GetAeTitles();
            dialog.aeList = aeInfoExtended.Select(x => x.AETitle).Distinct().ToList();

            Role[] roles = Module.PermissionManagementDataAccessAgent.GetRoles();
            dialog.roleList = roles.Select(x => x.Name).Distinct().ToList();

            AeAccessKey aeAccessKey = new AeAccessKey();

            if (dataGridView1.SelectedRows.Count > 0)
            {
                aeAccessKey.AeTitle = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();

                if (dialogType == InsertModifyAeRoleControlType.Modify)
                {
                    aeAccessKey.AccessKey = dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
                }
            }
            dialog.aeRole = aeAccessKey;

            dialog.ValidateAeRoleData += Dialog_ValidateAeRoleData;
            if (DialogResult.OK == dialog.ShowDialog(this))
            {
                AddRow(dialog.aeRole);
                aeRoleList.Add(dialog.aeRole);
                ret = true;
            }
            return(ret);
        }