             newGasStat.entityKey = returnedGasStat.entityKey
         })
     }
+    
+    func _queryForTankRecord(carID: NSNumber, userID: NSNumber) {
+        let query = GTLQueryGasstats.queryForTankrecordListByCarUser() as GTLQueryGasstats
+        query.limit = 1
+        query.userId = userID.longLongValue
+        query.carId = carID.longLongValue
+        UIApplication.sharedApplication().networkActivityIndicatorVisible = true
+        service.executeQuery(query, completionHandler: { (ticket, response, error) -> Void in
+            UIApplication.sharedApplication().networkActivityIndicatorVisible = false
+            self.initialQueryComplete = true
+            self._refreshControl?.endRefreshing()
+            if error != nil {
+                self._showErrorDialog(error!)
+            } else {
+                let recordCollection = response as GTLGasstatsTankRecordCollection
+                if recordCollection.items() != nil {
+                    var records = recordCollection.items() as [GTLGasstatsTankRecord]
+                    self.tankRecord = records[0]
+                } else {
+                    self.tankRecord = GTLGasstatsTankRecord()
+                    self.tankRecord.avgTank = 0
+                    self.tankRecord.bestTank = 0
+                    self.tankRecord.lastTank = 0
+                    self.tankRecord.carId = carID
+                    self.tankRecord.userId = userID
+                }
+            }
+        })
+    }
+    
+    func _insertTankRecord(record: GTLGasstatsTankRecord) {
+        let query = GTLQueryGasstats.queryForTankrecordInsertWithObject(record) as GTLQueryGasstats
+        if isLocalHostTesting {
+            query.JSON = record.JSON
+            query.bodyObject = nil
+        }
+        UIApplication.sharedApplication().networkActivityIndicatorVisible = true
+        service.executeQuery(query, completionHandler: { (ticket, response, error) -> Void in
+            UIApplication.sharedApplication().networkActivityIndicatorVisible = false
+            if error != nil {
+                self._showErrorDialog(error!)
+                return
+            }
+            let returnedRecord = response as GTLGasstatsTankRecord
+            record.entityKey = returnedRecord.entityKey
+        })
+    }
+    
+    func _queryForGasstats(carId : NSNumber, userId : NSNumber) {
+        let query = GTLQueryGasstats.queryForGasstatListByCarUser() as GTLQueryGasstats
+        query.userId = userId.longLongValue
+        query.carId = carId.longLongValue
+        UIApplication.sharedApplication().networkActivityIndicatorVisible = true
+        service.executeQuery(query, completionHandler: { (ticket, response, error) -> Void in
+            UIApplication.sharedApplication().networkActivityIndicatorVisible = false
+            self.initialQueryComplete = true
+            self._refreshControl?.endRefreshing()
+            if error != nil {
+                self._showErrorDialog(error!)
+            } else {
+                let statCollection = response as GTLGasstatsGasStatCollection
+                var stats = [GTLGasstatsGasStat]()
+                if statCollection.items() != nil{
+                    stats = statCollection.items() as [GTLGasstatsGasStat]
+                    self.statCount = NSNumber.init(integer: stats.count)
+                }
+            }
+        })
+    }
 	
 	// MARK: - Picker View Methods
 	func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {

	}
	
	func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
		// TODO: set current car to car at position 'row' in array of user's cars
	}
	
	func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String!{

    }
    
    @IBAction func pressedLogIt(sender: AnyObject){
        _queryForGasstats(NSNumber.init(integer: carPicker.selectedRowInComponent(0)), userId: self.user_id)
        _queryForTankRecord(NSNumber.init(integer: carPicker.selectedRowInComponent(0)), userID: tankRecord.userId)
        var miles = (milesTextField.text as NSString).floatValue
        var gallons = (gallonsTextField.text as NSString).floatValue
        var cost = (costTextField.text as NSString).floatValue
