Confirm to delete
This commit is contained in:
parent
1d342897ab
commit
d64348ca5f
|
@ -151,13 +151,23 @@ namespace RDP_Portal {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonDelete_Click(object sender, EventArgs e) {
|
private void buttonDelete_Click(object sender, EventArgs e) {
|
||||||
var selectedItems = (Profile) listBox.SelectedItem;
|
// show confirm dialog
|
||||||
selectedItems.Delete();
|
var confirmResult = MessageBox.Show(
|
||||||
_config.Profiles.Remove(selectedItems);
|
"Are you sure to delete this profile?",
|
||||||
_config.Save();
|
"Confirm",
|
||||||
if (_config.Profiles.Count == 0) {
|
MessageBoxButtons.YesNo);
|
||||||
AddNewProfile();
|
|
||||||
SelectProfile(true);
|
// if confirm delete
|
||||||
|
if (confirmResult == DialogResult.Yes) {
|
||||||
|
var selectedItems = (Profile) listBox.SelectedItem;
|
||||||
|
selectedItems.Delete();
|
||||||
|
_config.Profiles.Remove(selectedItems);
|
||||||
|
_config.Save();
|
||||||
|
|
||||||
|
if (_config.Profiles.Count == 0) {
|
||||||
|
AddNewProfile();
|
||||||
|
SelectProfile(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue