コード例 #1
0
ファイル: FormAdmin.cs プロジェクト: ricardocchaves/BD
        private void loadComboios(object sender = null, EventArgs e = null)
        {
            if (!Connection.verifySGBDConnection())
            {
                return;
            }

            boxFabricante = textBoxSearchCombFabricante.Text;
            boxTipo       = textBoxSearchCombTipo.Text;
            boxID         = textBoxSearchCombID.Text;
            if (boxFabricante.Length == 0)
            {
                boxFabricante = "null";
            }
            if (boxTipo.Length == 0)
            {
                boxTipo = "null";
            }
            if (boxID.Length == 0)
            {
                boxID = "null";
            }

            String query = "exec getComboios @id=" + boxID + ", @tipo=" + boxTipo + ", @fabricante=" + boxFabricante;

            if (!Clean.IsClean(query))
            {
                MessageBox.Show(Clean.Err());
                return;
            }

            SqlCommand    cmd    = new SqlCommand(query, Connection.get());
            SqlDataReader reader = cmd.ExecuteReader();

            listBoxComboios.Items.Clear();

            while (reader.Read())
            {
                Comboio c = new Comboio();
                c.Carruagens = reader["num_carruagens"].ToString();
                c.Fabricante = reader["fabricante"].ToString();
                c.Id         = reader["id_comboio"].ToString();
                c.Lugares    = reader["num_lug_comboio"].ToString();
                c.Tipo       = reader["tipo"].ToString();
                listBoxComboios.Items.Add(c);
            }

            currentComboio = 0;

            if (listBoxComboios.Items.Count == 0)
            {
                listBoxComboios.Items.Add("Sem comboios a apresentar");
                currentComboio = -1;
            }

            Connection.close();
            ShowComboio();
        }
コード例 #2
0
ファイル: FormAdmin.cs プロジェクト: ricardocchaves/BD
        private void ShowComboio()
        {
            if (listBoxComboios.Items.Count == 0 | currentComboio < 0)
            {
                return;
            }
            Comboio c = (Comboio)listBoxComboios.Items[currentComboio];

            textBoxCombCapacidade.Text = c.Lugares;
            textBoxCombCarruagens.Text = c.Carruagens;
            textBoxCombFabricante.Text = c.Fabricante;
            textBoxCombID.Text         = c.Id;
            textBoxCombTipo.Text       = c.Tipo;
        }