private void BtnDelete_Click(object sender, RoutedEventArgs e) { MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Deseja prosseguir?", "Confirmação de exclusão", System.Windows.MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { var sessao = AuxiliarNhibernate.AbrirSessao(); var paramdb = new ParametroDB_DAO(sessao); try { paramdb.Remover(paramDB[lastIndex - 1]); paramDB.RemoveAt(lastIndex - 1); if (paramDB.Count >= 1) { StaticParametersDB.clearListBanco(); foreach (var p in paramDB) { StaticParametersDB.SetListBanco(p); } StaticParametersDB.Setcurrent(paramDB[0].Id); refreshCBO(paramDB[0], 1); } else { StaticParametersDB.clearListBanco(); StaticParametersDB.clearAllStatic(); StaticParametros.SetIntegraBanco(false); BtnDelete.Visibility = Visibility.Hidden; CboConexao.Items.Clear(); CboConexao.Items.Insert(0, "Nova conexão"); CboConexao.SelectedIndex = 0; } cleanScreen(); } catch (Exception ex) { } //this.Close(); } }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (paramDB.Count >= 1) { StaticParametersDB.clearListBanco(); foreach (var p in paramDB) { StaticParametersDB.SetListBanco(p); } foreach (var p in paramDB) { if (p.Grupo == 0 || p.Token == null || p.Token == "") { __main.Show(); return; } } StaticParametersDB.Setcurrent(paramDB[0].Id); } __main.Show(); }
private void refreshCBO(ParametroDB paramdbNew, int tipo) { BtnDelete.Visibility = Visibility.Hidden; BtnDelete.Visibility = Visibility.Hidden; if (tipo == 1) { try { CboConexao.Items.Clear(); CboConexao.Items.Insert(0, "Nova conexão"); CboConexao.SelectedIndex = 0; if (paramDB.Count > 1) { StaticParametersDB.clearListBanco(); foreach (var p in paramDB) { StaticParametersDB.SetListBanco(p); } for (int i = 0; i < paramDB.Count; i++) { CboConexao.Items.Insert(i + 1, paramDB[i].Descr); } } else { StaticParametersDB.clearListBanco(); StaticParametersDB.SetListBanco(paramDB[0]); CboConexao.Items.Insert(1, paramDB[0].Descr); } } catch (Exception e) { } } else { try { var process = new Processos(); paramDB.Add(paramdbNew); CboConexao.Items.Clear(); CboConexao.Items.Insert(0, "Nova conexão"); CboConexao.SelectedIndex = 0; if (paramDB.Count > 1) { StaticParametersDB.clearListBanco(); foreach (var p in paramDB) { StaticParametersDB.SetListBanco(p); } for (int i = 0; i < paramDB.Count; i++) { CboConexao.Items.Insert(i + 1, paramDB[i].Descr); } } else { StaticParametersDB.clearListBanco(); StaticParametersDB.SetListBanco(paramDB[0]); CboConexao.Items.Insert(1, paramDB[0].Descr); } } catch (Exception e) { } } }