private void ArtikalJedan_Load(object sender, EventArgs e) { try { baza.OtvoriKonekciju(); OleDbCommand cmd = new OleDbCommand(); /* * dodao zbog zatvaranja formi * */ cmd.Connection = baza.Connection; cmd.CommandText = "select * from artikal"; OleDbDataReader reader = cmd.ExecuteReader(); artikal.Clear(); while (reader.Read()) { Artikal a = new Artikal(); a.Id_artikla = int.Parse(reader["id_artikla"].ToString()); a.Naziv = reader["naziv"].ToString(); a.Cena = int.Parse(reader["cena"].ToString()); a.Popust = int.Parse(reader["popust"].ToString()); a.Id_grupa = int.Parse(reader["id_grupa"].ToString()); artikal.Add(a); } //ovaj deo sam morao jer mi upit baca problem kada pretrazujem prozivode // koji imaju to ime sa naziv like ime, ili naziv in ime....... foreach (Artikal a in artikal) { if (a.Naziv == ime) { nasArtikal = a; } } textBox1.Text = nasArtikal.Naziv; textBox2.Text = nasArtikal.Cena.ToString(); textBox3.Text = nasArtikal.Popust.ToString(); } catch (Exception ex) { MessageBox.Show("Greska je " + ex); } finally { baza.ZatvoriKonekciju(); } }
private void FormicaRacuni_Load(object sender, EventArgs e) { try { baza.OtvoriKonekciju(); OleDbCommand cmd = new OleDbCommand(); cmd.Connection = baza.Connection; cmd.CommandText = "select * from racun"; OleDbDataReader reader = cmd.ExecuteReader(); racun.Clear(); while (reader.Read()) { Racun r = new Racun(); r.Cena = int.Parse(reader["cena"].ToString()); r.Datum = DateTime.Parse(reader["datum"].ToString()); r.Vreme = DateTime.Parse(reader["vreme"].ToString()); //ajde ovo ispravi leba ti racun.Add(r); } listBox1.DataSource = racun; } catch (Exception ex) { MessageBox.Show("Greska je " + ex); } finally { baza.ZatvoriKonekciju(); } }
private void FormaArtikli_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'prodavnicaDataSet.racun' table. You can move, or remove it, as needed. this.racunTableAdapter.Fill(this.prodavnicaDataSet.racun); // TODO: This line of code loads data into the 'prodavnicaDataSet.grupa' table. You can move, or remove it, as needed. this.grupaTableAdapter.Fill(this.prodavnicaDataSet.grupa); try { racun(); baza.OtvoriKonekciju(); OleDbCommand cmd = new OleDbCommand(); cmd.Connection = baza.Connection; cmd.CommandText = "select * from artikal where id_grupa=" + grupa; OleDbDataReader reader = cmd.ExecuteReader(); artikli.Clear(); while (reader.Read()) { Artikal a = new Artikal(); a.Id_artikla = int.Parse(reader["id_artikla"].ToString()); a.Naziv = reader["naziv"].ToString(); a.Cena = int.Parse(reader["cena"].ToString()); a.Popust = int.Parse(reader["popust"].ToString()); a.Id_grupa = int.Parse(reader["id_grupa"].ToString()); artikli.Add(a); } } catch (Exception ex) { MessageBox.Show("Greska je " + ex); } finally { baza.ZatvoriKonekciju(); } for (int i = 0; i < artikli.Count(); i++) { Button button = new Button(); button.Width = 92; button.Height = 62; button.Text = artikli[i].Naziv; button.Name = artikli[i].Id_grupa.ToString(); button.Click += new EventHandler(otvoriArtikal); flowLayoutPanel1.Controls.Add(button); } }
private void Form1_Load(object sender, EventArgs e) { try { racun(); baza.OtvoriKonekciju(); OleDbCommand cmd = new OleDbCommand(); cmd.Connection = baza.Connection; cmd.CommandText = "select * from grupa"; OleDbDataReader reader = cmd.ExecuteReader(); grupe.Clear(); while (reader.Read()) { Grupa g = new Grupa(); g.Id_grupa = int.Parse(reader["id_grupa"].ToString()); g.Naziv = reader["naziv"].ToString(); grupe.Add(g); } } catch (Exception ex) { MessageBox.Show("Greska je " + ex); } finally { baza.ZatvoriKonekciju(); } for (int i = 0; i < grupe.Count(); i++) { Button button = new Button(); button.Width = 92; button.Height = 62; button.Text = grupe[i].Naziv; button.Name = grupe[i].Id_grupa.ToString(); button.Click += new EventHandler(otvoriArtikle); flowLayoutPanel1.Controls.Add(button); //dodao ih i postavio im ime da bih mogao da u sledecoj formi //povucem ime i izvucem iz baze odredjene prozivode } }
private void DodavanjeProizvoda_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'prodavnicaDataSet.artikal' table. You can move, or remove it, as needed. this.artikalTableAdapter.Fill(this.prodavnicaDataSet.artikal); try { baza.OtvoriKonekciju(); OleDbCommand cmd = new OleDbCommand(); cmd.Connection = baza.Connection; cmd.CommandText = "select * from grupa"; OleDbDataReader reader = cmd.ExecuteReader(); grupe.Clear(); while (reader.Read()) { Grupa g = new Grupa(); g.Id_grupa = int.Parse(reader["id_grupa"].ToString()); g.Naziv = reader["naziv"].ToString(); grupe.Add(g); } if (comboBox1.Items.Count > 0) { comboBox1.DataSource = null; comboBox1.Items.Clear(); } comboBox1.DataSource = grupe; comboBox1.DisplayMember = "naziv"; comboBox1.ValueMember = "id_grupa"; } catch (Exception ex) { MessageBox.Show("Greska je " + ex); } finally { baza.ZatvoriKonekciju(); } }