示例#1
0
        private void Confirmq_Click(object sender, EventArgs e)
        {
            MyAttributes myAttributes = db_attributes.Get <MyAttributes>(1);
            Companies    thisCompany  = db_myCF.Get <Companies>(companyInt);

            string           fileName_Q = "qs_" + myAttributes.cfid.ToString() + "_" + thisCompany.name + ".db3";
            string           dbPath_Q   = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), fileName_Q);
            SQLiteConnection db_Q       = new SQLiteConnection(dbPath_Q);

            string           fileName_myQs = "myqs_" + myAttributes.cfid.ToString() + "_" + myAttributes.loginid + ".db3";
            string           dbPath_myQs   = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), fileName_myQs);
            SQLiteConnection db_myQs       = new SQLiteConnection(dbPath_myQs);

            db_myQs.CreateTable <SQLite_Tables.MyQueue>();

            try
            {
                var queryResults = db_Q.Query <SQLite_Tables.Queue>("SELECT * FROM Queue WHERE studentid = ?", myAttributes.typeid);
                if (queryResults.Count != 0)
                {
                    Toast.MakeText(this.Activity, "You are already onQ with this company", ToastLength.Short).Show();
                }
                else
                {
                    int numQs = db_Q.Table <SQLite_Tables.Queue>().Count();

                    SQLite_Tables.Queue newQ = new SQLite_Tables.Queue();
                    newQ.id        = numQs + 1;
                    newQ.studentid = myAttributes.typeid;

                    db_Q.Insert(newQ);

                    SQLite_Tables.MyQueue myQ = new SQLite_Tables.MyQueue();
                    int numMyQs = db_myQs.Table <SQLite_Tables.MyQueue>().Count();
                    myQ.id       = numMyQs + 1;
                    myQ.company  = thisCompany.name;
                    myQ.position = newQ.id;

                    db_myQs.Insert(myQ);

                    Toast.MakeText(this.Activity, "You are onQ in Position " + (numQs + 1).ToString() + "!", ToastLength.Short).Show();

                    Android.Support.V4.App.FragmentTransaction trans = FragmentManager.BeginTransaction();
                    trans.Replace(Resource.Id.companies_root_frame, new CompaniesFragment());
                    trans.Commit();

                    Android.Support.V4.App.FragmentTransaction trans2 = FragmentManager.BeginTransaction();
                    trans.Replace(Resource.Id.qs_root_frame, new QsFragment());
                    trans2.Commit();

                    viewPager.SetCurrentItem(1, true);
                }
            }
            catch
            {
                Toast.MakeText(this.Activity, "No Recruiters have checked in with this company yet...", ToastLength.Short).Show();
                //this.Activity.DeleteDatabase(dbPath_Q);
            }
        }
        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();
        }