/// <summary> /// sinartisi pou fortonei apo tin basi ola ta characteristics /// </summary> public static List<Characteristics> LoadCharacteristics() { List<Characteristics> characteristics = new List<Characteristics>(); DBOpenClose(() => { string sql = "select * from characteristics"; SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection); SQLiteDataReader reader = command.ExecuteReader(); try { while (reader.Read()) { Characteristics characteristic = new Characteristics(reader.GetInt32(0), reader.GetString(1), reader.GetDouble(2)); characteristics.Add(characteristic); } } catch (Exception ex) { Console.WriteLine("LoadCharacteristics " + ex.Message); } }); return characteristics; }
private void btnDialogOk_Click(object sender, RoutedEventArgs e) { Characteristics characteristic = new Characteristics(-1, txtName.Text, Convert.ToDouble(txtCost.Text)); DBController.AddCharacteristics(characteristic); this.DialogResult = true; this.Close(); }
internal static void AddCharacteristics(Characteristics characteristic) { DBOpenClose(() => { //string sql = "insert into users (name, password) values ('" + name + "', '" + password + "')"; string sql = "insert into characteristics (name,cost) values ('" + characteristic.Name + "', " + characteristic.Cost.ToString(CultureInfo.InvariantCulture) + ")"; SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection); command.ExecuteNonQuery(); }); }