private void buttonDodajObjekat_Click(object sender, EventArgs e)
 {
     DodajObjekat newObj = new DodajObjekat(this, sqlite, flag);
     newObj.Show();
 }
Exemple #2
0
 private void objekatToolStripMenuItem_Click(object sender, EventArgs e)
 {
     DodajObjekat newObj = new DodajObjekat(this, sqlite);
     newObj.Show();
 }
        private void button1_Click(object sender, EventArgs e)
        {
            SQLiteCommand check = sqlite.CreateCommand();
            check.CommandText = "select count(*) from OBJEKAT where vojnaPosta="+Convert.ToInt32(comboBoxVPPosiljaoca.Text)+";";
            int broj = Convert.ToInt32(check.ExecuteScalar());
            if (broj == 0)
            {
                MessageBox.Show("Objekat sa Vojnom postom ne postoji, molim vas unesite novi objekat");
                DodajObjekat dob = new DodajObjekat(this, sqlite, 3);
                dob.Show();
                return;
            }
            check = sqlite.CreateCommand();
            check.CommandText = "select count(*) from OBJEKAT where vojnaPosta=" + Convert.ToInt32(comboBoxVPPrimaoca.Text) + ";";
             broj = Convert.ToInt32(check.ExecuteScalar());
            if (broj == 0)
            {
                MessageBox.Show("Objekat sa Vojnom postom ne postoji, molim vas unesite novi objekat");
                DodajObjekat dob = new DodajObjekat(this, sqlite, 3);
                dob.Show();
                return;
            }

            check = sqlite.CreateCommand();
            check.CommandText = "select count(*) from OBJEKAT where vojnaPosta=" + Convert.ToInt32(labelVPPrevoznika.Text) + ";";
             broj = Convert.ToInt32(check.ExecuteScalar());
            if (broj == 0)
            {
                MessageBox.Show("Objekat sa Vojnom postom ne postoji, molim vas unesite novi objekat");
                DodajObjekat dob = new DodajObjekat(this, sqlite, 3);
                dob.Show();
                return;
            }

            DateTime vremePocetka=dateTimePicker1.Value.Date;
            vremePocetka.AddHours(Convert.ToDouble(numericUpDown1.Value));
            vremePocetka.AddMinutes(Convert.ToDouble(numericUpDown2.Value));

            DateTime vremeZavrsetka = dateTimePicker2.Value.Date;
            vremeZavrsetka.AddHours(Convert.ToDouble(numericUpDown3.Value));
            vremeZavrsetka.AddMinutes(Convert.ToDouble(numericUpDown4.Value));

            String posiljalac = comboBoxObjekatUtovara.Text;
            String primalac = comboBoxObjekatIstovara.Text;

            SQLiteCommand posiljalacID = sqlite.CreateCommand();
            posiljalacID.CommandText = "select objekatID from OBJEKAT where imeObjekta='" + posiljalac + "'";
            int posiljalacId = Convert.ToInt32(posiljalacID.ExecuteScalar());

            SQLiteCommand primalacID = sqlite.CreateCommand();
            primalacID.CommandText = "select objekatID from OBJEKAT where imeObjekta='" + primalac + "'";
            int primalacId = Convert.ToInt32(primalacID.ExecuteScalar());

            /*String kategorija = labelKategorijaTereta.Text;
            SQLiteCommand kategorijaID = sqlite.CreateCommand();
            kategorijaID.CommandText = "select kategorijaTID from KATEGORIJA_TERETA where nazivKatTereta='" + kategorija + "'";
            int kategorijaId = Convert.ToInt32(kategorijaID.ExecuteScalar());

            SQLiteCommand addTeret = sqlite.CreateCommand();
            addTeret.CommandText = "insert into TERET (UN, kategorijaID, naziv,proizvodjac) values ("+labelTeretUn.Text+","+kategorijaId+",'"+comboBoxTereti.Text+"','"+labelProizvodjac.Text+"')";
            addTeret.ExecuteNonQuery();

            addTeret.CommandText = @"select last_insert_rowid()";
            int teretID = Convert.ToInt32(addTeret.ExecuteScalar());*/

            SQLiteCommand objPrev = sqlite.CreateCommand();
            objPrev.CommandText = "select objekatID from OBJEKAT where vojnaPosta=" + labelVPPrevoznika.Text + "";
            int objekatPrevoznikaID = Convert.ToInt32(objPrev.ExecuteScalar());

            SQLiteCommand addPrevoznik = sqlite.CreateCommand();
            addPrevoznik.CommandText = "insert into PREVOZNIK (prevoznoSredstvo, registracioniBr, objekatPrevoznikaID, vozac) values ('"+textBoxPrevoznoSredstvo.Text+"','"+textBoxRegBr.Text+"',"+objekatPrevoznikaID+", '"+textBoxVozac.Text+"');";
            addPrevoznik.ExecuteNonQuery();

            addPrevoznik.CommandText = @"select last_insert_rowid()";
            int prevoznikID = Convert.ToInt32(addPrevoznik.ExecuteScalar());

            String pocetak = System.Convert.ToDateTime(vremePocetka).ToString("yyyy-MM-dd HH:mm:ss");
            String zavrsetak = System.Convert.ToDateTime(vremeZavrsetka).ToString("yyyy-MM-dd HH:mm:ss");

            SQLiteCommand relacija = sqlite.CreateCommand();
            relacija.CommandText = "insert into RELACIJA_KRETANJA (utovarID, istovarID, vremeUtovara, vremeIstovara) values (" + posiljalacId + "," + primalacId + ", '" + pocetak + "','"+zavrsetak+"')";
            relacija.ExecuteNonQuery();
            relacija.CommandText = @"select last_insert_rowid()";
            int relacijaID = Convert.ToInt32(relacija.ExecuteScalar());

            SQLiteCommand add = sqlite.CreateCommand();
            add.CommandText = "insert into TRANSPORT ( jedinica, posiljalac, primalac, prevoznik, relacija, VPPosiljaoca, VPPrimaoca ) values ('" + comboBoxjedinice.Text + "'," + posiljalacId + "," + primalacId + "," + prevoznikID + "," + relacijaID + "," + comboBoxVPPosiljaoca.Text + "," + comboBoxVPPrimaoca.Text + ");";
            add.ExecuteNonQuery();
            add.CommandText = @"select last_insert_rowid()";
            int transportID = Convert.ToInt32(add.ExecuteScalar());
            foreach (TERET_U_TRANSPORTU t in tereti)
            {
                add.CommandText = "insert into TERET_U_TRANSPORTU (teretID,transportID,kolicina,mernaJedinica,brojJedinicaPakovanja,vrstaPakovanja) values("+t.teretID+","+transportID+","+t.kolicina+",'"+t.mernaJedinica+"',"+t.brojJedinicaPakovanja+",'"+t.vrstaPakovanja+"');";
                add.ExecuteNonQuery();
            }
            form1.populateTable();
            this.Close();
        }
 private void button5_Click(object sender, EventArgs e)
 {
     DodajObjekat dob = new DodajObjekat(this, sqlite, 1);
     dob.Show();
 }
Exemple #5
0
 public DodajGrad(DodajObjekat form1, SQLiteConnection conn, int flag)
 {
     InitializeComponent();
     this.objekat = form1;
     sqlite = conn;
 }