Ejemplo n.º 1
0
        private void dodavanjeOruzjaUBazu()
        {
            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 ORUZJE (SERIJSKI_BROJ, MODEL, PROIZVODAC, TIP, KALIBAR, VRIJEDNOST, MASA, VISINA, SIRINA," +
                                  "DULJINA, DULJINA_CIJEVI, GODINA_PROIZVODNJE, SLIKA) VALUES ('" + this.formaSerijskiBroj.Text + "', '" + this.formaModel.Text +
                                  "', '" + this.formaProizvodac.Text + "', '" + this.comboTipOruzja.Text + "', '" + this.formaKalibar.Text + "', '" +
                                  Convert.ToDecimal(this.formaVrijednost.Text) + "', '" + Convert.ToDecimal(this.formaMasa.Text) + "', '" +
                                  Convert.ToDecimal(this.formaVisina.Text) + "', '" + Convert.ToDecimal(this.formaSirina.Text) + "', '" +
                                  Convert.ToDecimal(this.formaDuljina.Text) + "', '" + Convert.ToDecimal(this.formaDuljinaCijevi.Text) + "', '" +
                                  this.yearPicker.Text + "', @imgdata)";
            SQLiteParameter parametar = new SQLiteParameter("@imgdata", System.Data.DbType.Binary);

            parametar.Value = byteimage;
            naredba.Parameters.Add(parametar);
            naredba.ExecuteNonQuery();
            naredba.Dispose();
            oruzje.asocirajPodatkeIzBaze(this.formaSerijskiBroj.Text);
            if (MessageBox.Show("Uspješno ste dodali " + oruzje.Model + " proizvođača " + oruzje.Proizvodjac + " sa serijskim brojem '" + oruzje.SerijskiBroj + "' u bazu podataka oružja. Povratak na početni prozor?", "Uspjeh!", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                FormClosed  -= dodavanjeOruzja_FormClosed;
                FormClosing -= dodavanjeOruzja_FormClosing;
                pom.Show();
                this.Close();
            }
        }
Ejemplo n.º 2
0
        private void ucitajOruzje(int rowId)
        {
            Classes.Oruzje oruzje = new Classes.Oruzje();
            oruzje.asocirajPodatkeIzBaze(oruzjeGridView.Rows[rowId].Cells[0].Value.ToString());
            OruzjeInfo forma = new OruzjeInfo(oruzje);

            forma.ShowDialog();
        }