public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { string dbPath_login = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "user.db3"); SQLiteConnection db_login = new SQLiteConnection(dbPath_login); string dbPath_attributes = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "attributes.db3"); SQLiteConnection db_attributes = new SQLiteConnection(dbPath_attributes); MyAttributes myAttributes = db_attributes.Get <MyAttributes>(1); string fileName_pastQs = "pastqs_" + myAttributes.attribute1 + ".db3"; string dbPath_pastQs = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), fileName_pastQs); SQLiteConnection db_pastQs = new SQLiteConnection(dbPath_pastQs); SQLite_Tables.PastQueue thisQueue = db_pastQs.Query <SQLite_Tables.PastQueue>("SELECT * FROM PastQueue WHERE studentid = ?", studentid).First(); StudentTable thisStudent = db_login.Get <StudentTable>(studentid); view = inflater.Inflate(Resource.Layout.StudentProfileRecView, container, false); TextView candidateName = view.FindViewById <TextView>(Resource.Id.candidateName); TextView candidateEmail = view.FindViewById <TextView>(Resource.Id.candidateEmail); TextView school = view.FindViewById <TextView>(Resource.Id.schoolText); TextView major = view.FindViewById <TextView>(Resource.Id.majorText); TextView gradterm = view.FindViewById <TextView>(Resource.Id.gradtermText); TextView gpa = view.FindViewById <TextView>(Resource.Id.gpaText); EditText notes = view.FindViewById <EditText>(Resource.Id.notes); ImageView star = view.FindViewById <ImageView>(Resource.Id.star); ImageView heart = view.FindViewById <ImageView>(Resource.Id.heart); Button nextButton = view.FindViewById <Button>(Resource.Id.nextButton); ImageView backButton = view.FindViewById <ImageView>(Resource.Id.backButton); Button hideKeyboard = view.FindViewById <Button>(Resource.Id.hideKeyboard); LinearLayout rootLayout = view.FindViewById <LinearLayout>(Resource.Id.rootLayout); hideKeyboard.Visibility = ViewStates.Invisible; hideKeyboard.Click += (sender, e) => { InputMethodManager imm = (InputMethodManager)this.Activity.GetSystemService(Context.InputMethodService); imm.HideSoftInputFromWindow(notes.WindowToken, 0); rootLayout.RequestFocus(); hideKeyboard.Visibility = ViewStates.Invisible; }; notes.FocusChange += (sender, e) => { hideKeyboard.Visibility = ViewStates.Visible; }; candidateName.Text = thisStudent.name; candidateEmail.Text = thisStudent.email; school.Text = thisStudent.school; major.Text = thisStudent.major; gradterm.Text = thisStudent.gradterm; gpa.Text = thisStudent.gpa; notes.Text = thisQueue.notes; int newRating = thisQueue.rating; if (thisQueue.rating == 1) { star.SetImageResource(Resource.Drawable.starfilled); } else if (thisQueue.rating == 2) { heart.SetImageResource(Resource.Drawable.heartfilled); } nextButton.Visibility = ViewStates.Gone; heart.Click += (sender, e) => { if (newRating == 2) { heart.SetImageResource(Resource.Drawable.heartunfilled); newRating = 0; } else { heart.SetImageResource(Resource.Drawable.heartfilled); star.SetImageResource(Resource.Drawable.starunfilled); newRating = 2; } }; star.Click += (sender, e) => { if (newRating == 1) { star.SetImageResource(Resource.Drawable.starunfilled); newRating = 0; } else { star.SetImageResource(Resource.Drawable.starfilled); heart.SetImageResource(Resource.Drawable.heartunfilled); newRating = 1; } }; backButton.Click += (sender, e) => { SQLite_Tables.PastQueue newQueue = new SQLite_Tables.PastQueue(); newQueue.id = thisQueue.id; newQueue.studentid = thisQueue.studentid; newQueue.rating = newRating; newQueue.notes = notes.Text; db_pastQs.InsertOrReplace(newQueue); Android.Support.V4.App.FragmentTransaction trans = FragmentManager.BeginTransaction(); if (source == "Profile") { trans.Replace(Resource.Id.profile_root_frame, new ProfileFragment()); } else if (source == "PastQs") { trans.Replace(Resource.Id.qs_root_frame, new PastQs()); } //trans.Replace(Resource.Id.qs_root_frame, new PastQs()); trans.Commit(); }; return(view); }
private void NextButton_Click(object sender, EventArgs e) { string dbPath_attributes = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "attributes.db3"); SQLiteConnection db_attributes = new SQLiteConnection(dbPath_attributes); MyAttributes myAttributes = db_attributes.Get <MyAttributes>(1); string dbPath_login = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "user.db3"); SQLiteConnection db_login = new SQLiteConnection(dbPath_login); string myCompanyQFilename = "qs_" + myAttributes.cfid.ToString() + "_" + myAttributes.attribute1 + ".db3"; string dbPath_myCompanyQ = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), myCompanyQFilename); var db_myCompanyQ = new SQLiteConnection(dbPath_myCompanyQ); int studentid = db_myCompanyQ.Get <SQLite_Tables.Queue>(1).studentid; StudentTable thisStudentAttributes = db_login.Get <StudentTable>(studentid); LoginTable thisStudentLogin = db_login.Query <LoginTable>("SELECT * FROM LoginTable WHERE email = ?", thisStudentAttributes.email).First(); string fileName_studentQ = "myqs_" + thisStudentLogin.cfid + "_" + thisStudentLogin.id.ToString() + ".db3"; string dbPath_studentQ = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), fileName_studentQ); var db_studentQ = new SQLiteConnection(dbPath_studentQ); SQLite_Tables.MyQueue thisQ = db_studentQ.Query <SQLite_Tables.MyQueue>("SELECT * FROM MyQueue WHERE company = ?", myAttributes.attribute1).First(); int thisQid = thisQ.id; int numStudentQs = db_studentQ.Table <SQLite_Tables.MyQueue>().Count(); // Check to see if this student is already in past Q's string fileName_pastQs = "pastqs_" + myAttributes.attribute1 + ".db3"; string dbPath_pastQs = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), fileName_pastQs); var db_pastQs = new SQLiteConnection(dbPath_pastQs); string fileName_studentpastQs = "pastqs_" + thisStudentLogin.id.ToString() + ".db3"; string dbPath_studentpastQs = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), fileName_studentpastQs); var db_studentpastQs = new SQLiteConnection(dbPath_studentpastQs); var queryResults = db_pastQs.Query <SQLite_Tables.PastQueue>("SELECT * FROM PastQueue WHERE studentid = ?", studentid); if (queryResults.Count == 0) { SQLite_Tables.PastQueue pastQ = new SQLite_Tables.PastQueue(); pastQ.studentid = studentid; pastQ.notes = notes.Text; pastQ.rating = rating; db_pastQs.Insert(pastQ); SQLite_Tables.MyPastQueue studentpastQ = new SQLite_Tables.MyPastQueue(); studentpastQ.company = myAttributes.attribute1; db_studentpastQs.Insert(studentpastQ); } db_studentQ.Delete <SQLite_Tables.MyQueue>(thisQ.id); for (int i = thisQid; i <= numStudentQs - 1; i++) { SQLite_Tables.MyQueue currentEntry = db_studentQ.Get <SQLite_Tables.MyQueue>(i + 1); SQLite_Tables.MyQueue newEntry = new SQLite_Tables.MyQueue(); newEntry.id = i; newEntry.company = currentEntry.company; newEntry.position = currentEntry.position; db_studentQ.InsertOrReplace(newEntry); } db_studentQ.Delete <SQLite_Tables.MyQueue>(numStudentQs); int numStudents = db_myCompanyQ.Table <SQLite_Tables.Queue>().Count(); db_myCompanyQ.Delete <SQLite_Tables.Queue>(1); for (int i = 1; i <= numStudents - 1; i++) { SQLite_Tables.Queue newStudent = new SQLite_Tables.Queue(); newStudent.id = i; newStudent.studentid = db_myCompanyQ.Get <SQLite_Tables.Queue>(i + 1).studentid; db_myCompanyQ.InsertOrReplace(newStudent); } db_myCompanyQ.Delete <SQLite_Tables.Queue>(numStudents); Android.Support.V4.App.FragmentTransaction trans = FragmentManager.BeginTransaction(); trans.Replace(Resource.Id.qs_root_frame, new QsFragment()); trans.Commit(); }