Esempio n. 1
0
 public int ItemTypeUpdate(ItemType itemType)
 {
     try
     {
         string commandText =
             @"UPDATE ItemType SET Name = @name, Description = @description WHERE Id = " +
             itemType.Id;
         Log.Debug("ItemTypeUpdate: [{0}], ItemType={1}", commandText, itemType.Format());
         using (sqLiteConnection)
         {
             using (SQLiteCommand sqLiteCommand = new SQLiteCommand(commandText, sqLiteConnection))
             {
                 sqLiteConnection.Open();
                 sqLiteCommand.Parameters.AddWithValue("@name", itemType.Name);
                 sqLiteCommand.Parameters.AddWithValue("@description", itemType.Description);
                 int rowsUpdated = sqLiteCommand.ExecuteNonQuery();
                 sqLiteConnection.Close();
                 return rowsUpdated;
             }
         }
     }
     catch (Exception exception)
     {
         Log.Error(exception.ToString);
         return 0;
     }
 }
Esempio n. 2
0
 private ItemType ItemTypeSelect(string commandText)
 {
     try
     {
         using (sqLiteConnection)
         {
             sqLiteConnection.Open();
             SQLiteCommand mycommand = new SQLiteCommand(sqLiteConnection) {CommandText = commandText};
             SQLiteDataReader reader = mycommand.ExecuteReader(CommandBehavior.SequentialAccess);
             while (reader.Read())
             {
                 int id = reader.GetInt32(0);
                 string name = reader.GetString(1);
                 string description = reader.GetValue(2).ToString();
                 ItemType itemType = new ItemType
                                     {
                                         Id = id,
                                         Name = name,
                                         Description = description,
                                     };
                 Log.Debug("Found ItemType: {0}", itemType.Format());
                 return itemType;
             }
             reader.Close();
             sqLiteConnection.Close();
         }
     }
     catch (Exception exception)
     {
         Log.Error(exception.ToString());
     }
     return null;
 }
Esempio n. 3
0
 public int ItemTypeInsert(ItemType itemType)
 {
     string insertCommand = String.Format(@"INSERT INTO ItemType (Name, Description) VALUES('{0}', '{1}')",
                                          itemType.Name, itemType.Description);
     return ExecuteNonQuery(insertCommand);
 }