private void tsbDelete_Click(object sender, EventArgs e) { if (TabProfiles.SelectedIndex == 0) { try{ if (lstProfiles.SelectedValue != null) { ProfileHelper profileHelper = new ProfileHelper(); Profile profile = new Profile { IdProfile = Int32.Parse(lstProfiles.SelectedValue.ToString()) }; DialogResult r = MessageBox.Show(this, String.Format(TranslateUtil.GetMsgConfirmDelete(), ((Profile)lstProfiles.SelectedItem).ProfileName), this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (r == DialogResult.Yes) { profileHelper.Delete(profile); profileSelected = null; LoadProfiles(); } } else { MessageBox.Show(this, TranslateUtil.GetMsgSelectProfile(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }catch {} } }
private void lstProfiles_Click(object sender, EventArgs e) { try { profileSelected = profiles[Int32.Parse(lstProfiles.SelectedIndex.ToString())]; lblIPAddress.Text = !profileSelected.IpAddress.Trim().Equals(String.Empty) ? profileSelected.IpAddress : TranslateUtil.GetAutomaticallyTxt(); lblDNSServer.Text = !profileSelected.DnsServerSearchOrder.Trim().Equals(String.Empty) ? profileSelected.DnsServerSearchOrder : TranslateUtil.GetAutomaticallyTxt(); lblGateway.Text = !profileSelected.DefaultIpGateway.Trim().Equals(String.Empty) ? profileSelected.DefaultIpGateway : TranslateUtil.GetAutomaticallyTxt(); if (profileSelected.Description.Length > 25) { lblNetworkInterface.Text = profileSelected.Description.Substring(0, 23) + "..."; } else { lblNetworkInterface.Text = profileSelected.Description; } } catch { //MessageBox.Show(TranslateUtil.GetMsgSelectProfile()); } }