Beispiel #1
0
        private void natragButton_Click(object sender, EventArgs e)
        {
            this.Close();
            DetaljiPoljaForm dp = new DetaljiPoljaForm();

            dp.Show();
        }
Beispiel #2
0
        private void spremiPromjeneButton_Click(object sender, EventArgs e)
        {
            SqlConnection con                = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Trgy\Documents\Visual Studio 2012\Projects\EvidencijaPolja\EvidencijaPolja\BazaPodataka.mdf;Integrated Security=True;");
            SqlCommand    scLokacijaPolja    = new SqlCommand("UPDATE [Polje] SET [LokacijaPolja]='" + lokacijaPoljaTextBox.Text + "' WHERE [PoljeId]='" + PoljaForm.poljeId + "'", con);
            SqlCommand    scPovrsinaPolja    = new SqlCommand("UPDATE [Polje] SET [PovrsinaPolja]='" + povrsinaPoljaTextBox.Text + "' WHERE [PoljeId]='" + PoljaForm.poljeId + "'", con);
            SqlCommand    scTipZitarice      = new SqlCommand("UPDATE [Polje] SET [TipZitarice]='" + tipZitariceTextBox.Text + "' WHERE [PoljeId]='" + PoljaForm.poljeId + "'", con);
            SqlCommand    scPotrosenoGnojivo = new SqlCommand("UPDATE [Polje] SET [Gnojivo]='" + potrosenoGnojivoTextBox.Text + "' WHERE [PoljeId]='" + PoljaForm.poljeId + "'", con);
            SqlCommand    scPesticidi        = new SqlCommand("UPDATE [Polje] SET [Pesticidi]='" + pesticidiTextBox.Text + "' WHERE [PoljeId]='" + PoljaForm.poljeId + "'", con);
            SqlCommand    scHerbicidi        = new SqlCommand("UPDATE [Polje] SET [Herbicidi]='" + herbicidiTextBox.Text + "' WHERE [PoljeId]='" + PoljaForm.poljeId + "'", con);
            SqlCommand    scGorivo           = new SqlCommand("UPDATE [Polje] SET [Gorivo]='" + potrosenoGorivoTextBox.Text + "' WHERE [PoljeId]='" + PoljaForm.poljeId + "'", con);
            SqlCommand    scTroskoviSjeme    = new SqlCommand("UPDATE [Polje] SET [TrosakSjemena]='" + troskoviSjemeTextBox.Text + "' WHERE [PoljeId]='" + PoljaForm.poljeId + "'", con);
            SqlCommand    scTroskoviGnojivo  = new SqlCommand("UPDATE [Polje] SET [TrosakGnojiva]='" + troskoviGnojivoTextBox.Text + "' WHERE [PoljeId]='" + PoljaForm.poljeId + "'", con);
            SqlCommand    scTroskoviSpriceva = new SqlCommand("UPDATE [Polje] SET [TrosakSpriceva]='" + troskoviSpricTextBox.Text + "' WHERE [PoljeId]='" + PoljaForm.poljeId + "'", con);
            SqlCommand    scTroskoviGorivo   = new SqlCommand("UPDATE [Polje] SET [TrosakGoriva]='" + troskoviGorivoTextBox.Text + "' WHERE [PoljeId]='" + PoljaForm.poljeId + "'", con);
            SqlCommand    scOstaliTroskovi   = new SqlCommand("UPDATE [Polje] SET [OstaliTroskovi]='" + ostaliTroskoviTextBox.Text + "' WHERE [PoljeId]='" + PoljaForm.poljeId + "'", con);
            SqlCommand    scPrinos           = new SqlCommand("UPDATE [Polje] SET [Prinos]='" + prinosTextBox.Text + "' WHERE [PoljeId]='" + PoljaForm.poljeId + "'", con);
            SqlCommand    scCijenaOtkupa     = new SqlCommand("UPDATE [Polje] SET [CijenaOtkupa]='" + cijenaOtkupaTextBox.Text + "' WHERE [PoljeId]='" + PoljaForm.poljeId + "'", con);

            try
            {
                con.Open();
                scLokacijaPolja.ExecuteNonQuery();
                scPovrsinaPolja.ExecuteNonQuery();
                scTipZitarice.ExecuteNonQuery();
                scPotrosenoGnojivo.ExecuteNonQuery();
                scPesticidi.ExecuteNonQuery();
                scHerbicidi.ExecuteNonQuery();
                scGorivo.ExecuteNonQuery();
                scTroskoviSjeme.ExecuteNonQuery();
                scTroskoviGnojivo.ExecuteNonQuery();
                scTroskoviSpriceva.ExecuteNonQuery();
                scTroskoviGorivo.ExecuteNonQuery();
                scOstaliTroskovi.ExecuteNonQuery();
                scPrinos.ExecuteNonQuery();
                scCijenaOtkupa.ExecuteNonQuery();
                con.Close();
                MessageBox.Show("Promjene spremljene!");
                this.Close();
                DetaljiPoljaForm dp = new DetaljiPoljaForm();
                dp.Show();
            }
            catch (System.Data.SqlClient.SqlException)
            {
                MessageBox.Show("Greška prilikom unosa!");
            }
        }
Beispiel #3
0
        private void poljaListBox_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            SqlConnection  con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Trgy\Documents\Visual Studio 2012\Projects\EvidencijaPolja\EvidencijaPolja\BazaPodataka.mdf;Integrated Security=True;");
            SqlDataAdapter sda = new SqlDataAdapter("SELECT [PoljeId] FROM [Polje] WHERE [ImePolja]='" + poljaListBox.Text + "'", con);
            DataTable      dt  = new DataTable();

            sda.Fill(dt);

            DataTableReader dtr = new DataTableReader(dt);

            while (dtr.Read())
            {
                poljeId = dtr.GetInt32(dtr.GetOrdinal("PoljeId"));
            }
            this.Close();
            DetaljiPoljaForm dp = new DetaljiPoljaForm();

            dp.Show();
        }