コード例 #1
0
        public PainelDatabases(UserControlCentro controlCentro)
        {
            InitializeComponent();
            PainelCentro = controlCentro;
            db           = new Controls.DataGridDatabases(database.GetBasesDeDados(), PainelCentro);
            dd1.Children.Add(db);
            buttonsGeral = new Controls.ButtonsGeral();
            gridFundo.Children.Add(buttonsGeral);

            buttonsGeral.DeleteClick  += new EventHandler(EliminaBD);
            buttonsGeral.AddClick     += new EventHandler(AddNewBD);
            buttonsGeral.EditClick    += new EventHandler(EditaBD);
            buttonsGeral.RefreshClick += new EventHandler(Refresh);
            buttonsGeral.HomeClick    += new EventHandler(Home);
        }
コード例 #2
0
        public void DeleteBD()
        {
            var        o  = this.data1.SelectedItem;
            BasesDados b2 = null;

            try
            {
                b2 = (BasesDados)data1.SelectedItem;

                System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("Tem a certeza que pretende eliminar a base de dados? ",
                                                                                                "Pergunta!", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question);

                switch (result)
                {
                case System.Windows.Forms.DialogResult.Yes:
                    bool   done    = database.Delete_BasedeDados(b2.StampBaseDados);
                    string warning = "";
                    if (done == true)
                    {
                        warning = "A base de dados foi removida com sucesso!";
                    }
                    else
                    {
                        warning = "Falha ao remover a base de dados!";
                    }

                    System.Windows.Forms.MessageBox.Show(warning,
                                                         "Aviso!", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);

                    data1.ItemsSource = database.GetBasesDeDados();

                    break;

                default:
                    break;
                }
            }
            catch
            {
                System.Windows.Forms.MessageBox.Show("Tem que seleccionar uma base de dados para eliminar!",
                                                     "Aviso!", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
            }
        }