public void Dispose() { Finalize(); _columnNameList.Clear(); _cmd = null; _vd = null; }
public void AddScore(string player, int xscore) // Creates a command to by calling the function to add score data to the saved file from the database { try { using (var conn = new SQLite.SQLiteConnection(dbPath)) { var cmd = new SQLite.SQLiteCommand(conn); string s = "Insert into scoretbl(player,score) values ('" + player + "'," + xscore + ")"; Console.WriteLine("the string sent to db is : " + s); cmd.CommandText = s; cmd.ExecuteNonQuery(); } } catch (Exception e) { Console.WriteLine("Error: " + e.Message); } }
public List <Score> GetScore() // Creates a command to by calling the function to populate data of scores from the saved file from the database { try { using (var conn = new SQLite.SQLiteConnection(dbPath)) { var cmd = new SQLite.SQLiteCommand(conn); cmd.CommandText = "Select * from scoretbl"; var ScoreList = cmd.ExecuteQuery <Score>(); return(ScoreList); } } catch (Exception e) { Console.WriteLine("Error: " + e.Message); return(null); } }
//Add to main app //Spinner Selection Statements //34 Lines of code private void Spinner1_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e) { Spinner spinner = (Spinner)sender; type = String.Format("{0}", spinner.GetItemAtPosition(e.Position)); // Toast.MakeText(this, type, ToastLength.Long).Show(); using (var conn = new SQLite.SQLiteConnection(dbPath)) { Spinner spinnerz = FindViewById <Spinner>(Resource.Id.spinner2); List <string> catechismFiles = new List <string>(); var cmd = new SQLite.SQLiteCommand(conn); if (type.ToUpper() == "ALL") { cmd.CommandText = "select * from DocumentTitle"; } else { cmd.CommandText = LayoutString(type.ToUpper()); //"Select documenttype.*,documenttitle.* from documenttitle natural join documenttype where documenttitle.documenttypeid= documenttype.documenttypeid and documenttype.DocumentTypeName='CATECHISM' "; } var r = cmd.ExecuteQuery <DocumentTitle>(); List <string> items = new List <string>(); foreach (var item in r) { items.Add(item.Title); } var adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, items); adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); spinnerz.ItemSelected += Spinner2_ItemSelected; spinnerz.Adapter = adapter; switch (type.ToUpper()) { case "ALL": this.allOpen = true; this.confessionOpen = false; this.catechismOpen = false; this.creedOpen = false; this.helpOpen = false; break; case "CONFESSION": this.allOpen = false; this.confessionOpen = true; this.catechismOpen = false; this.creedOpen = false; this.helpOpen = false; break; case "CATECHISM": this.allOpen = false; this.confessionOpen = false; this.catechismOpen = true; this.creedOpen = false; this.helpOpen = false; break; case "CREED": allOpen = false; creedOpen = true; catechismOpen = false; confessionOpen = false; helpOpen = false; break; } Toast.MakeText(this, type, ToastLength.Short).Show(); } }
private void PopulateTable() { //Connect to db CreateDB(DbPath); var conn = new SQLite.SQLiteConnection(DbPath); var cmd = new SQLite.SQLiteCommand(conn); var results = conn.Table <Balance>().Where(x => true).OrderByDescending(x => x.Id); var DataSource = new BalanceTableDataSource(); double totalBalance = 0; foreach (var r in results) { DataSource.Balances.Add(new Balance(r.Id, r.Date, r.Desc, r.Amount)); totalBalance += r.Amount; } //populate table BalanceTable.DataSource = DataSource; BalanceTable.Delegate = new BalanceTableDelegate(this, DataSource); // populate initial double initialValue = 1000; try { initialValue = conn.Table <InitialValue>().OrderByDescending(x => x.id).First().Value; } catch (Exception e) { conn.Insert(new InitialValue(initialValue)); } InitialLabel.StringValue = string.Format("(Init. amt: {0})", initialValue); //Populate total TotalLabel.StringValue = string.Format("结余: {0}", initialValue + totalBalance); }
public void SetCmd(SQLite.SQLiteCommand cmd) { _cmd = cmd; _vd = _cmd.M_Prepare(); }
public static void InsertGuidedImage(SQLiteConnection conn, int checkListTransID, byte[] image) { Object[] obs = new object[] { image, checkListTransID }; SQLite.SQLiteCommand cmd = conn.CreateCommand("insert into GuidedImage(Image,CheckListTransID) values(@Image,@checkListTransID);", obs); cmd.ExecuteNonQuery(); }
/// <summary> /// Inserts the image for inspection location identification. /// </summary> /// <param name="conn">Conn.</param> /// <param name="inspectionTransID">Inspection trans I.</param> /// <param name="Image">Image.</param> public static void InsertImageForInspection(SQLiteConnection conn, int inspectionTransID, byte[] Image) { Object[] obs = new object[] { Image, inspectionTransID }; SQLite.SQLiteCommand cmd = conn.CreateCommand("insert into LocationImage(Image,InspectionTransID) values(@Image,@inspectionTransID);", obs); cmd.ExecuteNonQuery(); }
protected override void OnCreate(Bundle savedInstanceState) { //base.OnCreate(); base.OnCreate(savedInstanceState); string[] permissions = new string[2]; permissions[0] = Manifest.Permission.WriteExternalStorage; permissions[1] = Manifest.Permission.ReadExternalStorage; // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); Spinner spinner1 = FindViewById <Spinner>(Resource.Id.spinner1), spinner2 = FindViewById <Spinner>(Resource.Id.spinner2); ActivityCompat.RequestPermissions(this, permissions, 1); if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.WriteExternalStorage) == (int)Permission.Granted) { if (!File.Exists(dbPath)) { using (BinaryReader br = new BinaryReader(Android.App.Application.Context.Assets.Open(dbName))) { using (BinaryWriter bw = new BinaryWriter(new FileStream(dbPath, FileMode.Create))) { byte[] buffer = new byte[2048]; int len = 0; while ((len = br.Read(buffer, 0, buffer.Length)) > 0) { bw.Write(buffer, 0, len); } } } } // We have permission, go ahead and use the camera. using (var conn = new SQLite.SQLiteConnection(dbPath)) { // var cmd2= new SQLite.SQLiteCommand(conn); var cmd = new SQLite.SQLiteCommand(conn); //var cmd1 = new SQLite.SQLiteCommand(conn); cmd.CommandText = "select * from DocumentType"; var docTypes = cmd.ExecuteQuery <DocumentType>(); cmd.CommandText = "select * from DocumentTitle"; var r = cmd.ExecuteQuery <DocumentTitle>(); List <string> items = new List <string>(); items.Add("All"); foreach (var item in docTypes) { items.Add(item.DocumentTypeName); } var adapter1 = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, items); adapter1.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); spinner1.ItemSelected += Spinner1_ItemSelected; spinner1.Adapter = adapter1; items = new List <string>(); foreach (var item in r) { items.Add(item.Title); } var adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, items); adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); spinner2.ItemSelected += Spinner2_ItemSelected; spinner2.Adapter = adapter; SearchView search = FindViewById <SearchView>(Resource.Id.searchView1); search.SetImeOptions(Android.Views.InputMethods.ImeAction.Go); search.QueryTextSubmit += Search_QueryTextSubmit; } } else { ActivityCompat.RequestPermissions(this, permissions, 1); this.Recreate(); } FindViewById <FloatingActionButton>(Resource.Id.searchFAB).Click += delegate { Search(FindViewById <SearchView>(Resource.Id.searchView1).Query); }; }
//Modify Existing Code on Main App //207 Lines of Code private void Search(string query) { int docCount = 1; bool truncate = false; Log.Info("Search()", String.Format("Search Begins" + "")); searchFragmentActivity = new SearchFragmentActivity(); // RadioButton radio = FindViewById<RadioButton>(Resource.Id.viewAllRadio); using (var conn = new SQLite.SQLiteConnection(dbPath)) { var cmd = new SQLite.SQLiteCommand(conn); var searchStr = new SQLite.SQLiteCommand(conn); bool proofs = true, answers = true, searchAll = false, viewDocs = false; CheckBox answerCheck = FindViewById <CheckBox>(Resource.Id.AnswerBox), proofCheck = FindViewById <CheckBox>(Resource.Id.proofBox), searchCheck = FindViewById <CheckBox>(Resource.Id.searchAllCheckBox); RadioButton viewRadio = FindViewById <RadioButton>(Resource.Id.viewAllRadio); Spinner spinner = FindViewById <Spinner>(Resource.Id.spinner1), spinner2 = FindViewById <Spinner>(Resource.Id.spinner2); spinner.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(Spinner1_ItemSelected); spinner2.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(Spinner2_ItemSelected); string fileString = "", accessString = ""; accessString = TableAccess(""); if (searchCheck.Checked) { searchAll = true; } else { searchAll = false; accessString = TableAccess(string.Format(" where documentname = '{0}' ", fileName)); } //Data filters if (allOpen) { if (searchAll) { fileString = TableAccess("");//"select * from Documenttitlelist"; } else { fileString = TableAccess(string.Format("Where Documentname='{0}'", fileName));//String.Format("select * from DocumentTableList where DocumentName='{0}'", fileName); } } if (catechismOpen) { if (searchAll) { fileString = TableAccess("Where documentTypeName='CATECHISM'"); //"and DocumentTypeName='CATECHISM'"); } else { fileString = TableAccess(String.Format("where DocumentTypeName='CATECHISM' and DocumentName='{0}' ", fileName)); } } if (confessionOpen) { if (searchAll) { fileString = TableAccess("where DocumentTypeName='CONFESSION' "); } else { fileString = TableAccess(String.Format("where DocumentTypeName='CONFESSION' and DocumentName='{0}' ", fileName)); } } if (creedOpen) { if (searchAll) { fileString = TableAccess("where DocumentTypeName='CREED' "); } else { fileString = TableAccess(string.Format("where DocumentTypeName='CREED' and DocumentName='{0}' ", fileName)); } } //Proofs enabled if (proofCheck.Checked) { proofs = true; } else { proofs = false; } //Read Document if (viewRadio.Checked) { viewDocs = true; } else { viewDocs = false; } cmd.CommandText = fileString; searchStr.CommandText = accessString; var r = cmd.ExecuteQuery <DocumentTitle>(); var searchFields = searchStr.ExecuteQuery <Document>(); documentList = new DocumentList(); //Add Entries to DocumentList for (int x = 0; x < searchFields.Count; x++) { DocumentTitle docTitle = new DocumentTitle(); docTitle.DocumentID = searchFields[x].DocumentID; for (int y = 0; y < r.Count; y++) { if (!r[y].DocumentID.Equals(docTitle.DocumentID)) { foreach (DocumentTitle doc in r) { if (doc.DocumentID == docTitle.DocumentID) { docTitle.Title = doc.Title; } else { continue; } } } else { docTitle.Title = r[y].CompareIDs(docTitle.DocumentID); } } searchFields[x].DocumentName = docTitle.Title; Document document = new Document(); document.ChName = searchFields[x].ChName; document.DocDetailID = searchFields[x].DocDetailID; document.DocumentText = Formatter(searchFields[x].DocumentText); document.DocumentName = searchFields[x].DocumentName; document.ChNumber = searchFields[x].ChNumber; document.ChProofs = Formatter(searchFields[x].ChProofs); document.Tags = searchFields[x].Tags; documentList.Add(document); } if (FindViewById <CheckBox>(Resource.Id.truncateCheck).Checked) { truncate = true; } if (viewRadio.Checked != true && query != "" && FindViewById <RadioButton>(Resource.Id.topicRadio).Checked) { if (FindViewById <RadioButton>(Resource.Id.topicRadio).Checked) { stopwatch.Start(); FilterResults(documentList, truncate, true, proofs, searchAll, query); documentList.Reverse(); stopwatch.Stop(); } } else if (FindViewById <RadioButton>(Resource.Id.chapterRadio).Checked & query != "") { int searchInt = Int32.Parse(query); FilterResults(this.documentList, truncate, answers, proofs, searchAll, searchInt); } else if (viewDocs) { if (!FindViewById <CheckBox>(Resource.Id.searchAllCheckBox).Checked) { query = "Results for All"; } else { query = "View All"; } } if (documentList.Count > 1) { SetContentView(Resource.Layout.search_results); ViewPager viewPager = FindViewById <ViewPager>(Resource.Id.viewpager); SearchAdapter adapter = new SearchAdapter(SupportFragmentManager, documentList, query, truncate); searchFragmentActivity.DisplayResults(documentList, viewPager, adapter, query, 0, truncate); } else { stopwatch.Stop(); if (this.documentList.Count == 0) { #region Error Logging Log.Info("Search()", String.Format("No Results were found for {0}", query)); Toast.MakeText(this, String.Format("No results were found for {0}", query), ToastLength.Long).Show(); #endregion #region Variable Declaration and Assignment SetContentView(Resource.Layout.errorLayout); TextView errorMsg = FindViewById <TextView>(Resource.Id.errorTV); errorMsg.Text = String.Format("No Search Results were found for {0}\r\n\r\n" + "Go back to home page to search for another topic", query); #endregion #region Dialog Box Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this); alert.SetTitle("No Results Found"); alert.SetMessage(String.Format("No Results were found for {0}.\r\n\r\n" + "Do you want to go back and search for another topic?", query)); alert.SetPositiveButton("Yes", (senderAlert, args) => { intent = new Intent(this, Class); searchFragmentActivity = null; this.OnStop(); this.Finish(); StartActivity(intent); }); alert.SetNegativeButton("No", (senderAlert, args) => { alert.Dispose(); }); Dialog dialog = alert.Create(); dialog.Show(); #endregion } else { //SetTitle(); Document document = this.documentList[this.documentList.Count - 1]; SetContentView(Resource.Layout.confession_results); TextView chapterBox = FindViewById <TextView>(Resource.Id.chapterText); TextView proofBox = FindViewById <TextView>(Resource.Id.proofText); TextView chNumbBox = FindViewById <TextView>(Resource.Id.confessionChLabel); TextView docTitleBox = FindViewById <TextView>(Resource.Id.documentTitleLabel); chapterBox.Text = document.DocumentText; chNumbBox.Text = String.Format("Chapter {0} : {1}", document.ChNumber.ToString(), document.ChName); proofBox.Text = document.ChProofs; docTitleBox.Text = document.DocumentName; TextView proofView = FindViewById <TextView>(Resource.Id.proofLabel); ChangeColor(true, Android.Graphics.Color.Black, chapterBox, proofBox, chNumbBox, docTitleBox); ChangeColor(proofView, false, Android.Graphics.Color.Black); shareList = docTitleBox.Text + newLine + chNumbBox.Text + newLine + chapterBox.Text + newLine + "Proofs" + newLine + proofBox.Text; FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.shareActionButton); ChangeColor(fab, Android.Graphics.Color.Black); fab.Click += ShareContent; } } } }
//App Loading screen protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); SetTitle(Resource.String.app_name); AppCenter.Start("c8e96422-f89a-45cf-b331-0c3bc585ee00", typeof(Analytics), typeof(Crashes)); SetTheme(Resource.Style.AppTheme); SearchView search = FindViewById <SearchView>(Resource.Id.searchView1); search.SetImeOptions(Android.Views.InputMethods.ImeAction.Go); search.QueryTextSubmit += Search_QueryTextSubmit; string[] permissions = new string[2]; permissions[0] = Manifest.Permission.WriteExternalStorage; permissions[1] = Manifest.Permission.ReadExternalStorage; // Set our view from the "main" layout resource Spinner spinner1 = FindViewById <Spinner>(Resource.Id.spinner1), spinner2 = FindViewById <Spinner>(Resource.Id.spinner2); //ActivityCompat.RequestPermissions(this, permissions, 1); if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.WriteExternalStorage) == (int)Permission.Granted) { if (!File.Exists(dbPath)) { using (BinaryReader binreader = new BinaryReader(Android.App.Application.Context.Assets.Open(dbName))) { using (BinaryWriter binwriter = new BinaryWriter(new FileStream(dbPath, FileMode.Create))) { byte[] buffer = new byte[2048]; int len = 0; while ((len = binreader.Read(buffer, 0, buffer.Length)) > 0) { binwriter.Write(buffer, 0, len); } } } } using (var conn = new SQLite.SQLiteConnection(dbPath)) { var cmd = new SQLite.SQLiteCommand(conn); cmd.CommandText = "select * from DocumentType"; var docTypes = cmd.ExecuteQuery <DocumentType>(); cmd.CommandText = "select * from DocumentTitle"; var r = cmd.ExecuteQuery <DocumentTitle>(); List <string> items = new List <string>(); items.Add("All"); foreach (var item in docTypes) { items.Add(item.DocumentTypeName); } var adapter1 = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, items); adapter1.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); spinner1.ItemSelected += Spinner1_ItemSelected; spinner1.Adapter = adapter1; items = new List <string>(); foreach (var item in r) { items.Add(item.Title); } var adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, items); adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); spinner2.ItemSelected += Spinner2_ItemSelected; spinner2.Adapter = adapter; search.SetImeOptions(Android.Views.InputMethods.ImeAction.Go); search.QueryTextSubmit += Search_QueryTextSubmit; FindViewById(Resource.Id.helpButton).Click += delegate { SetContentView(Resource.Layout.main); creedOpen = false; catechismOpen = false; confessionOpen = false; helpOpen = true; // SetContentView(Resource.Layout.main); FindViewById <TextView>(Resource.Id.appTitle).Text = "Help Page"; FindViewById <TextView>(Resource.Id.searchByLabel).Text = GetString(Resource.String.catechism_help); FindViewById <TextView>(Resource.Id.catechismPgh).Text = "Hitting the No Answers Checkbox will remove answers from your search results, '\n" + "thus affecting the overall search results on the page.\n" + " Hit the No proofs checkbox to exclude proofs from the search results\n"; FindViewById <TextView>(Resource.Id.confessionHelp).Text = GetString(Resource.String.confession_help); FindViewById <TextView>(Resource.Id.confessionPgh).Text = GetString(Resource.String.confessionPgh); FindViewById <TextView>(Resource.Id.creedHelp).Text = "Creed Help:"; FindViewById <TextView>(Resource.Id.creedPgh).Text = GetString(Resource.String.creedPgh); FindViewById <TextView>(Resource.Id.otherStuff).Text = "Other Stuff:"; FindViewById <TextView>(Resource.Id.otherPgh).Text = GetString(Resource.String.other_pgh); FindViewById <TextView>(Resource.Id.sourceTV).Text = "All documents listed below are public domain, the websites below helped me with collecting them. \n A big thanks for inspiration for this app came from this website." + "\n\nApostle's Creed: https://reformed.org/documents/apostles_creed.html " + "\n1618 Belgic Confession: https://reformed.org/documents/BelgicConfession.html " + "\n1646 Westminster Confession of Faith: https://reformed.org/documents/wcf_with_proofs/index.html" + "\n1689 London Baptist Confession of Faith: https://reformed.org/documents/baptist_1689.html" + "\n1658 Savoy Declaration of Faith and Order: https://reformed.org/documents/Savoy_Declaration/index.html" + "\nWestminster Shorter Catechism: https://reformed.org/documents/wsc/index.html" + " \nWestminster Larger Catechism: https://reformed.org/documents/wlc_w_proofs/index.html " + "\nHeidelberg Catechism: https://reformed.org/documents/heidelberg.html " + "\nNicean Creed: https://reformed.org/documents/nicene.html " + "\nAthanasian Creed: https://reformed.org/documents/athanasian.html "; FindViewById(Resource.Id.floatingActionButton).Click += delegate { this.Recreate(); }; }; } } else { ActivityCompat.RequestPermissions(this, permissions, 1); this.Recreate(); } FindViewById <FloatingActionButton>(Resource.Id.searchFAB).Click += delegate { Search(FindViewById <SearchView>(Resource.Id.searchView1).Query); }; }