public string CreateDB() { var output = ""; output += "Creating Database if it doesn't exist"; string dpPath = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "ScoutingApp.db3"); //Create New Database var db = new SQLiteConnection(dpPath); db.CreateTable <ScoresTable>(); ScoresTable st = new ScoresTable(); output += "\n Database Created"; return(output); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); string dpPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "ScoutingApp.db3"); var db = new SQLiteConnection(dpPath); db.CreateTable <ScoresTable>(); ScoresTable st = new ScoresTable(); SetContentView(Resource.Layout.truescores_layout); listviewS = FindViewById <ListView>(Resource.Id.listViewSS); listS = db.Table <ScoresTable>().OrderBy(item => item.TotalScore).ToList(); ScoresViewAdapter adapterS = new ScoresViewAdapter(this, listS); listviewS.Adapter = adapterS; }
private void Create_Click(object sender, EventArgs e) { try { string dpPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "ScoutingApp.db3"); var db = new SQLiteConnection(dpPath); db.CreateTable <PitsTable>(); PitsTable tbl = new PitsTable(); db.CreateTable <ISTable>(); ISTable ist = new ISTable(); ScoresTable st = new ScoresTable(); int finalScore; int firstScore; int secondScore; secondScore = 0; finalScore = 0; firstScore = 0; int number = Int32.Parse(teamNumber.Text); tbl.Team = number; st.Team = number; ist.Team = number; //interesting issue-- it's not storing anything for the ints tbl.RobotWeight = weight.Text; if (mech.Checked) { tbl.Drivetrain = "Mechanum"; firstScore = 1; } if (holo.Checked) { tbl.Drivetrain = "Holonomic"; firstScore = 2; } if (tank.Checked) { tbl.Drivetrain = "Tank"; firstScore = 3; } if (swerve.Checked) { tbl.Drivetrain = "Swerve"; firstScore = 4; } if (slide.Checked) { tbl.Drivetrain = "Slide"; firstScore = 0; } tbl.Notes = notes.Text; db.Insert(tbl); Toast.MakeText(this, "Record Added Successfully", ToastLength.Short).Show(); items = db.Table <PitsTable>().OrderBy(item => item.Team).ToList(); PitsViewAdapter adapterP = new PitsViewAdapter(this, items); listviewP.Adapter = adapterP; int numberW = Int32.Parse(weight.Text); if (numberW < 50) { secondScore = 1; } if (numberW >= 50) { secondScore = 3; } finalScore = firstScore + secondScore; ist.Score = finalScore; st.TotalScore = finalScore; System.Diagnostics.Debug.WriteLine(finalScore); db.Insert(tbl); db.Insert(ist); db.Insert(st); } catch (Exception ex) { Toast.MakeText(this, ex.ToString(), ToastLength.Long).Show(); } }