コード例 #1
0
        private void btt_pesquisar_Click(object sender, RoutedEventArgs e)
        {
            try {
                string         cod_gaiola    = tb_codgaiola.Text;
                long           codgaiolalong = Convert.ToInt64(cod_gaiola);
                List <Gaiola2> utilG         = new List <Gaiola2>();
                utilG = Gaiola2.lerRegistos();

                foreach (var x in utilG)
                {
                    if (x.codgaiola == codgaiolalong)
                    {
                        tb_id.Text      = x.codgaiola.ToString();
                        tb_comp.Text    = x.comprimento.ToString();
                        tb_larg.Text    = x.largura.ToString();
                        tb_altura.Text  = x.altura.ToString();
                        tb_lotacao.Text = x.lotacao.ToString();
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show("Não consegui encontrar essa gaiola ." + " " + ex.Message);
            }
        }
コード例 #2
0
        public passaroEdit()
        {
            InitializeComponent();
            try
            {
                List <passaro2> utilP = new List <passaro2>();
                utilP = passaro2.lerRegistos();
                if (utilP.Count != 0)
                {
                    foreach (var x in utilP)
                    {
                        string mostrar = x.nanilha + "-" + x.nome;

                        lb_pass.Items.Add(mostrar);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Não consegui ler os pássaros." + " " + ex.Message);
            }
            try {
                List <Especie> utilE = new List <Especie>();
                utilE = Especie.lerRegistos();
                if (utilE.Count != 0)
                {
                    foreach (var x in utilE)
                    {
                        string mostrar = x.id_especie + "-" + x.nome;

                        cb_especie.Items.Add(mostrar);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Não consegui ler as especies." + " " + ex.Message);
            }
            try {
                List <Gaiola2> UtilG = new List <Gaiola2>();
                UtilG = Gaiola2.lerRegistos();
                if (UtilG.Count != 0)
                {
                    foreach (var x in UtilG)
                    {
                        string mostrar = x.codgaiola.ToString();

                        cb_gaiola.Items.Add(mostrar);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Não consegui ler as gaiolas." + " " + ex.Message);
            }
        }
コード例 #3
0
        public DeleteGaiola()
        {
            InitializeComponent();
            try {
                List <Gaiola2> utilG = new List <Gaiola2>();
                utilG = Gaiola2.lerRegistos();
                if (utilG.Count != 0)
                {
                    foreach (var x in utilG)
                    {
                        string mostrar = x.codgaiola.ToString();

                        lb_gaiola.Items.Add(mostrar);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Não consegui ler as gaiolas." + " " + ex.Message);
            }
        }
コード例 #4
0
        private void btt_deletef_Click(object sender, RoutedEventArgs e)
        {
            try {
                int codgaiola = Convert.ToInt32(tb_codgaiola.Text);
                Gaiola2.DeleteGaiola(codgaiola);
                lb_gaiola.Items.Clear();
                List <Gaiola2> utilG = new List <Gaiola2>();
                utilG = Gaiola2.lerRegistos();
                if (utilG.Count != 0)
                {
                    foreach (var x in utilG)
                    {
                        string mostrar = x.codgaiola.ToString();

                        lb_gaiola.Items.Add(mostrar);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Não consegui apagar os dados." + " " + ex.Message);
            }
        }