コード例 #1
0
ファイル: DBController.cs プロジェクト: MeTaXaS4/smartOrderPC
        /// <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;
        }
コード例 #2
0
 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();
 }
コード例 #3
0
ファイル: DBController.cs プロジェクト: MeTaXaS4/smartOrderPC
 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();
     });
 }