public static void CheckUniqueOznaka(Stol st, string NewOznaka) { if (stoloviList.Find(s => s.Oznaka == NewOznaka && s.ID != st.ID) != null) { throw new ArgumentException("Oznaka stola mora biti jedinstvena."); } }
public Narudzba(string broj, DateTime datum, OznakaPotvrde oznaka, Stol stol = null) { Broj = broj; Datum = datum; Oznaka = oznaka; StolNarudzbe = stol; Stavke = new List <StavkaNarudzbe>(); }
public static void UpdateStol(Stol s) { SqliteCommand com = DB.con.CreateCommand(); com.CommandText = String.Format(@"UPDATE Stol SET oznaka = '{0}', broj_stolica = {1} WHERE id = {2} ", s.Oznaka, s.BrojStolica, s.ID); com.ExecuteNonQuery(); com.Dispose(); }
public static void DeleteStol(Stol s) { SqliteCommand com = DB.con.CreateCommand(); System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(typeof(DBNarudzba).TypeHandle); com.CommandText = String.Format(@"UPDATE Narudzba SET id_stol = NULL WHERE id_stol = {0}", s.ID); com.ExecuteNonQuery(); com.CommandText = String.Format(@"DELETE FROM Stol WHERE id = {0}", s.ID); com.ExecuteNonQuery(); com.Dispose(); }
public static void SaveStol(ref Stol s) { SqliteCommand com = DB.con.CreateCommand(); com.CommandText = String.Format(@"INSERT INTO Stol (oznaka, broj_stolica) VALUES ('{0}', {1})" , s.Oznaka, s.BrojStolica); com.ExecuteNonQuery(); com.Dispose(); SqliteCommand getId = DB.con.CreateCommand(); getId.CommandText = "SELECT last_insert_rowid()"; s.ID = (long)getId.ExecuteScalar(); getId.Dispose(); }
public static List <Stol> GetStolove() { List <Stol> stolovi = new List <Stol>(); SqliteCommand c = DB.con.CreateCommand(); c.CommandText = String.Format(@"SELECT * FROM Stol"); SqliteDataReader reader = c.ExecuteReader(); while (reader.Read()) { Stol s = new Stol((long)reader["id"], (string)reader["oznaka"], (int)reader.GetInt64(2)); stolovi.Add(s); } c.Dispose(); return(stolovi); }
public static void Delete(Stol s) { stoloviList.Remove(s); DBStol.DeleteStol(s); MainWindow.stolChanged(); }
public static void Add(Stol s) { stoloviList.Add(s); DBStol.SaveStol(ref s); MainWindow.stolChanged(); }
protected void Data_Received(object o, DragDataReceivedArgs args) { bool success = false; Gtk.Widget source = Gtk.Drag.GetSourceWidget(args.Context); string data = System.Text.Encoding.UTF8.GetString(args.SelectionData.Data); switch (args.Info) { case 0: // uri-list string[] uri_list = Regex.Split(data, "\r\n"); foreach (string u in uri_list) { //if(u.Length > 0) //System.Console.WriteLine("Got URI {0}", u); } success = true; break; case 1: // table success = true; string name = "NewTable"; if (source is Button) // Samo razmještaj stola { name = (source as Button).Name; } else //Drag&Drop novog stola - INSERT { int brojStolica; switch (data) { case "Table2Chair": brojStolica = 2; break; case "Table4Chair": brojStolica = 4; break; case "Table6Chair": brojStolica = 6; break; case "Table8Chair": brojStolica = 8; break; default: brojStolica = 2; break; } bool notUnique = true; for (int i = 1; notUnique; i++) { name = "NewTable" + i; Stol s = new Stol(name, brojStolica); try { StoloviPresenter.CheckUniqueOznaka(s, name); StoloviPresenter.Add(s); notUnique = false; } catch (ArgumentException) {} } entryOznaka.Text = ""; } AddNewTableButtonImage(name, data, args.X, args.Y, size); SaveToXml(); break; } Gtk.Drag.Finish(args.Context, success, true, args.Time); }
public Narudzba(long id, string broj, DateTime datum, OznakaPotvrde oznaka, Stol stol = null) : this(broj, datum, oznaka, stol) { ID = id; }