コード例 #1
0
        //This calls the functionality to remove the selected profile
        private async void RemoveProfile()
        {
            if (dgvProfiles.RowCount > 0)
            {
                DataGridViewRow dr = dgvProfiles.CurrentRow;
                if (dr != null)
                {
                    string       profileID = dr.Cells["SpeakerID"].Value.ToString();
                    DialogResult dresult   = MessageBox.Show("Are you sure you want to remove profile ID: " + profileID + "?", "Remove Profile", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dresult == DialogResult.Yes)
                    {
                        projectOxfordSpeaker s      = new projectOxfordSpeaker();
                        functionResult       result = await s.removeSpeaker(new Guid(profileID));

                        if (result.Result == true)
                        {
                            LoadProfiles();
                        }
                        else
                        {
                            MessageBox.Show(result.Message, "Function Result: Remove Profile", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Please select a profile to remove", "Remove Profile", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                MessageBox.Show("There are no profiles available. Please press the 'Load Profiles' to check for profiles on the server or 'Create Profile' to create a new profile", "Remove Profile", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
コード例 #2
0
ファイル: frmStartup.cs プロジェクト: spefanis/CRM_Sample
        private async void btnRemoveUser_Click(object sender, EventArgs e)
        {
            //Make sure a row is selected
            if (mcbUserAccounts.SelectedValue != null)
            {
                this.Cursor = Cursors.WaitCursor;
                //Get the actual data row
                DataRowView drv = (DataRowView)mcbUserAccounts.SelectedItem;
                //Assign the required values to variables
                string ProfileID = Convert.ToString(drv["PROFILEID"].ToString());
                string Name      = Convert.ToString(drv["NAME"].ToString());
                int    ID        = Convert.ToInt32(drv["ID"]);

                //Ensure the user wasnt to delete the row
                if (MessageBox.Show("Are you sure you want to remove User ID: " + ID.ToString() + "?" + Environment.NewLine + "This will remove their profile and enrollment information and cannot be reversed.", "Remove User", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    functionResult r = new functionResult();
                    //If there is a valid profile ID, remove it from the server, else just set the result as true to continue
                    if (ProfileID.Length > 0)
                    {
                        projectOxfordSpeaker s = new projectOxfordSpeaker();
                        r = await s.removeSpeaker(new Guid(ProfileID));
                    }
                    else
                    {
                        r.Result  = true;
                        r.Message = "No Profile ID";
                    }

                    if (r.Result == true)
                    {
                        //Next remove the user from our database
                        Database db = new Database();
                        r = db.removeUser(ID.ToString());
                        //If there is no issues, reload the listing
                        if (r.Result == true)
                        {
                            LoadListing();
                        }
                        else
                        {
                            MessageBox.Show(r.Message, "Error removing from database");
                        }
                    }
                    else
                    {
                        MessageBox.Show(r.Message, "Error removing Microsoft profile");
                    }
                }

                this.Cursor = Cursors.Default;
            }
        }