public void UpdateItem(SoftwareItem si, string code) { using (con) { con.Open(); using (SQLiteCommand com = new SQLiteCommand(con)) { // SoftwareItem si = new SoftwareItem(ime, code, size, price, license, verzija); com.CommandText = "UPDATE items SET name = '" + si.ItemName + "', price = " + si.Price + ", sizeInMB=" + si.SizeInMB + ",license='" + si.LicenseKey + "',version" + "='" + si.version + "' WHERE code = '" + code + "'"; com.ExecuteNonQuery(); com.Dispose(); } con.Close(); } }
public void SaveItem(SoftwareItem si) { using (con) { con.Open(); using (SQLiteCommand com = new SQLiteCommand(con)) { com.CommandText = "INSERT INTO items(name, code, price, sizeInMB, " + "license, version, type_id)" + "VALUES ('" + si.ItemName + "', '" + si.ItemID + "', " + si.Price + ", " + si.SizeInMB + ", '" + si.LicenseKey + "', '" + si.version + "', 4)"; Console.WriteLine(com.CommandText); com.ExecuteNonQuery(); com.Dispose(); } con.Close(); } }
public SoftwareItem ReadSoftware(string code) { // SoftwareItem(string ime, string code, double velikostMB, double _price, string _licenseKey, string version_) : base(code,ime, _price, "Software Item") SoftwareItem s = new SoftwareItem(); using (con) { con.Open(); using (SQLiteCommand com = new SQLiteCommand(con)) { com.CommandText = "SELECT name, code, sizeInMB, price, license, version FROM items WHERE code ='" + code + "'"; using (SQLiteDataReader reader = com.ExecuteReader()) { while (reader.Read()) { s = new SoftwareItem(reader.GetString(0), reader.GetString(1), reader.GetDouble(2), reader.GetDouble(3), reader.GetString(4), reader.GetString(5)); } } } } return(s); }