public void DodajNarudzbu(string oznakaStola) { Narudzba n = new Narudzba("0", DateTime.Now, Narudzba.OznakaPotvrde.Nepotvrdeno, StoloviPresenter.stoloviList.Find(s => s.Oznaka == oznakaStola)); DBNarudzba.SaveNarudzba(ref n); this.Add(n); }
public static void DeleteStavke(Narudzba n) { SqliteCommand com = DB.con.CreateCommand(); com.CommandText = String.Format(@"DELETE FROM Stavka_Narudzbe WHERE id_narudzba = {0}", n.ID); com.ExecuteNonQuery(); com.Dispose(); }
public static void UpdateNarudzba(Narudzba n) { SqliteCommand com = DB.con.CreateCommand(); com.CommandText = String.Format(@"UPDATE Narudzba SET broj = '{0}', oznaka_potvrde = '{1}',id_stol = {2} WHERE id = {3} ", n.Broj, n.Oznaka, (n.StolNarudzbe == null) ? "NULL" : (object)n.StolNarudzbe.ID, n.ID); com.ExecuteNonQuery(); com.Dispose(); }
public static void GetStavke(ref Narudzba n) { SqliteCommand c = DB.con.CreateCommand(); c.CommandText = String.Format(@"SELECT * FROM Stavka_Narudzbe WHERE id_narudzba = {0}", n.ID); SqliteDataReader reader = c.ExecuteReader(); while (reader.Read()) { StavkaNarudzbe ns = new StavkaNarudzbe((long)reader["id"], ArtikliPresenter.GetArtikl((long)reader["id_artikl"]), (int)reader.GetInt64(3), StavkaNarudzbe.StatusFromString((string)reader["status"])); n.Stavke.Add(ns); } c.Dispose(); }
public static void SaveStavka(Narudzba n, ref StavkaNarudzbe ns) { SqliteCommand com = DB.con.CreateCommand(); com.CommandText = String.Format(@"INSERT INTO Stavka_Narudzbe (id_narudzba, id_artikl, kolicina, status) VALUES ({0}, {1}, {2}, '{3}')" , n.ID, ns.ArtiklStavke.ID, ns.Kolicina, ns.Status); com.ExecuteNonQuery(); SqliteCommand getId = DB.con.CreateCommand(); getId.CommandText = "SELECT last_insert_rowid()"; ns.ID = (long)getId.ExecuteScalar(); com.Dispose(); }
public NarudzbeNode(Narudzba n) { Broj = n.Broj; Datum = n.Datum.ToString("g"); Ukupno = n.Ukupno().ToString("C"); if (n.StolNarudzbe != null) { OznakaStola = n.StolNarudzbe.Oznaka; } else { OznakaStola = "-"; } narudzba = n; stavkeNarudzbeNodeStore.AddList(n.Stavke, OznakaStola); }
public static void SaveNarudzba(ref Narudzba n) { SqliteCommand com = DB.con.CreateCommand(); com.CommandText = String.Format(@"INSERT INTO Narudzba (broj, datum, oznaka_potvrde, id_stol) VALUES ('{0}', '{1}', '{2}', {3})" , n.Broj, n.Datum.ToFileTime(), n.Oznaka, (n.StolNarudzbe == null) ? "NULL" : (object)n.StolNarudzbe.ID); com.ExecuteNonQuery(); com.Dispose(); SqliteCommand getId = DB.con.CreateCommand(); getId.CommandText = "SELECT last_insert_rowid()"; n.ID = (long)getId.ExecuteScalar(); getId.Dispose(); n.Broj = DateTime.Now.Year + "-" + n.ID.ToString("0000000000"); UpdateNarudzba(n); }
public static List <Narudzba> GetNarudzbe() { List <Narudzba> narudzbe = new List <Narudzba>(); SqliteCommand c = DB.con.CreateCommand(); c.CommandText = String.Format(@"SELECT id, broj, datum, oznaka_potvrde, ifnull(id_stol,0) as id_stol FROM Narudzba WHERE oznaka_potvrde = 'Nepotvrdeno' "); SqliteDataReader reader = c.ExecuteReader(); while (reader.Read()) { Narudzba n = new Narudzba((long)reader["id"], (string)reader["broj"], DateTime.FromFileTime((Int64)reader["datum"]), Narudzba.OznakaFromString((string)reader["oznaka_potvrde"]), StoloviPresenter.stoloviList.Find(s => s.ID == (long)reader["id_stol"])); DBStavkeNarudzbe.GetStavke(ref n); narudzbe.Add(n); } c.Dispose(); return(narudzbe); }
public void Add(Narudzba n) { this.AddNode(new NarudzbeNode(n)); }