Example #1
0
        private void natragButton_Click(object sender, EventArgs e)
        {
            this.Close();
            GodineForm gf = new GodineForm();

            gf.Show();
        }
Example #2
0
        private void ulazButton_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;");

            con.Open();
            SqlCommand sc = new SqlCommand("SELECT [UserId] FROM [User] WHERE [User] = @User AND [Password] = @Password", con);

            SqlParameter userParam = sc.Parameters.Add("@User", SqlDbType.NVarChar, 50 /* max length of field */);

            userParam.Value = usernameTextBox.Text;
            SqlParameter passwordParam = sc.Parameters.Add("@Password", SqlDbType.NVarChar, 50 /* max length of field */);

            passwordParam.Value = passwordTextBox.Text;
            SqlDataReader reader = sc.ExecuteReader();

            while (reader.Read())
            {
                userId = reader.GetInt32(reader.GetOrdinal("UserId"));
            }

            con.Close();

            if (userId != 0)
            {
                this.Hide();
                GodineForm gf = new GodineForm();
                gf.Show();
            }
            else
            {
                MessageBox.Show("Pogrešan username ili password");
            }
            con.Close();
        }
Example #3
0
        private void obrisiGodinuButton_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    sc  = new SqlCommand("DELETE FROM [Godina] WHERE [GodinaId]='" + GodineForm.godinaId + "'", con);
            SqlCommand    sc1 = new SqlCommand("DELETE FROM [Polje] WHERE [GodinaId]='" + GodineForm.godinaId + "'", con);

            con.Open();
            sc1.ExecuteNonQuery();
            sc.ExecuteNonQuery();
            con.Close();
            MessageBox.Show("Obrisali ste godinu: " + godina + " i sva polja u njoj");
            this.Close();
            GodineForm gf = new GodineForm();

            gf.Show();
        }