private void ucitajVlasnika(int rowId)
        {
            Classes.Osoba vlasnik = new Classes.Osoba();
            Console.WriteLine("OIB odabranog vlasnika oružja: " + vlasniciGridView.Rows[rowId].Cells[0].Value.ToString());
            vlasnik.asocirajPodatkeIzBazeVlasnika(vlasniciGridView.Rows[rowId].Cells[0].Value.ToString());
            VlasnikInfo forma = new VlasnikInfo(vlasnik);

            forma.ShowDialog();
        }
예제 #2
0
        private void dodavanjeVlasnikaOruzjaUBazu()
        {
            Image img = new Bitmap(datotecniPut.Text);

            byte[]           byteimage = ImageToByte(img, System.Drawing.Imaging.ImageFormat.Jpeg);
            string           izvor     = "URI=file:evidencija.db";
            SQLiteConnection conn      = new SQLiteConnection(izvor);

            conn.Open();
            SQLiteCommand naredba = conn.CreateCommand();

            naredba.CommandText = "INSERT INTO VLASNIK_ORUZJA (OIB, JMBG, IME, PREZIME, SPOL, ROD, DRZAVLJANSTVO, MJESTO_RODENJA, " +
                                  "DRZAVA_RODENJA, DATUM_RODENJA, ADRESA_PREBIVALISTA, MJESTO_PREBIVALISTA, POSTANSKI_BROJ_PREBIVALISTA, DRZAVA_PREBIVALISTA, ADRESA_BORAVISTA," +
                                  "MJESTO_BORAVISTA, POSTANSKI_BROJ_BORAVISTA, DRZAVA_BORAVISTA, SERIJSKI_BROJ_ORUZJA, DATUM_ZAHTJEVA_DOZVOLE, DATUM_ISTEKA_DOZVOLE," +
                                  " DATUM_LIJECNICKOG_PREGLEDA, DATUM_ISTEKA_LIJECNICKOG_PREGLEDA, FOTOGRAFIJA) VALUES ('" + this.formaOIB.Text + "', '" +
                                  this.formaJMBG.Text + "', '" + this.formaIme.Text + "', '" + this.formaPrezime.Text + "', '" + this.comboSpol.Text + "', '" +
                                  this.comboRod.Text + "', '" + this.formaDrzavljanstvo.Text + "', '" + this.formaMjestoRodenja.Text + "', '" +
                                  this.formaDrzavaRodenja.Text + "', '" + this.datumRodenjaPicker.Value + "', '" + this.formaAdresaPrebivalista.Text + "', '" +
                                  this.formaMjestoPrebivalista.Text + "', '" + Convert.ToInt32(this.formaPostanskiBrojPrebivalista.Text) + "', '" +
                                  this.formaDrzavaPrebivalista.Text + "', '" + this.formaAdresaBoravista.Text + "', '" + this.formaMjestoBoravista.Text + "', '" +
                                  Convert.ToInt32(this.formaPostanskiBrojBoravista.Text) + "', '" + this.formaDrzavaBoravista.Text + "', '" +
                                  serijskiBroj(this.comboPodaciZaOruzje.Text) + "', '" + this.datumZahtjevaZaIzdavanjemDozvolePicker.Value + "', '" +
                                  this.datumIstekaDozvolePicker.Value + "', '" + this.datumLijecnickogPicker.Value + "', '" + this.datumIstekaLijecnickogPicker.Value + "', @imgdata);";
            SQLiteParameter parametar = new SQLiteParameter("@imgdata", System.Data.DbType.Binary);

            parametar.Value = byteimage;
            naredba.Parameters.Add(parametar);
            naredba.ExecuteNonQuery();
            naredba.Dispose();
            osoba.asocirajPodatkeIzBazeVlasnika(this.formaOIB.Text);
            if (MessageBox.Show("Vlasnik oružja " + osoba.Ime + " " + osoba.Prezime + " s komadom oružja '" + osoba.Oruzje.Proizvodjac + " " + osoba.Oruzje.Model +
                                "' sa serijskim brojem '" + osoba.Oruzje.SerijskiBroj + "' uspješno je dodan u bazu podataka vlasnika oružja. Želite li se vratiti u početni prozor?",
                                "Uspjeh!", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                FormClosed  -= dodavanjeVlasnikaOruzja_FormClosed;
                FormClosing -= dodavanjeVlasnikaOruzja_FormClosing;
                main.Show();
                this.Close();
            }
        }