Exemplo n.º 1
0
        private void addCommit(TutorMaster.Commitment commit)
        {
            TutorMasterDBEntities4 db = new TutorMasterDBEntities4();                                  //add a commitment

            db.Commitments.AddObject(commit);
            db.SaveChanges();
        }
Exemplo n.º 2
0
        private void setTuteeLocations()
        {
            TutorMasterDBEntities4 db = new TutorMasterDBEntities4();                                          //Connect to the database
            string loc = txtLoc.Text;                                                                          //grab the text of the location the tutor typed in

            for (int i = 0; i < info.Count(); i++)                                                             //for every time chosen
            {
                DateTime startDate = DateTimeMethods.getStartTime(info[i]);                                    //get the startTime
                DateTime endDate   = DateTimeMethods.getEndTime(info[i]);                                      //get the endTime

                int partnerID = Convert.ToInt32(info[i].Split(',')[2]);

                List <Commitment> tuteeCmtList = (from stucmt in db.StudentCommitments                          //get the tutee's commitments
                                                  where stucmt.ID == partnerID
                                                  join cmt in db.Commitments on stucmt.CmtID equals cmt.CmtID
                                                  select cmt).ToList();
                //if a commitment is in the time slot
                for (int m = 0; m < tuteeCmtList.Count(); m++)                                                 //go through the tutee commitments
                {
                    if (DateTimeMethods.inTheTimeSlot(startDate, endDate, tuteeCmtList[m]))
                    {
                        tuteeCmtList[m].Class = tuteeCmtList[m].Class + "!";                                   //add an exclamation point to the tutee class so that the system knows this is a new commitment
                        if (!admin)
                        {
                            tuteeCmtList[m].Location = loc + "?";                                                  //change the location to the string the user typed in + a question mark
                        }
                        else
                        {
                            tuteeCmtList[m].Location = loc;
                        }
                        db.SaveChanges();                                                                      //save to database
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void loadClassTutorList()
        {
            //1. pull all of the students that are available as tutors into a list
            TutorMasterDBEntities4 db = new TutorMasterDBEntities4();

            //Get classcode of selected class
            string className = combFirstChoice.Items[combFirstChoice.SelectedIndex].ToString();
            string classCode = (from row in db.Classes where row.ClassName == className select row.ClassCode).First();

            //1.1 Identify all the tutors and put them in a list
            List <User> tutors = (from userCla in db.StudentClasses
                                  where userCla.ClassCode == classCode
                                  join u in db.Users on userCla.ID equals u.ID
                                  select u).ToList();

            //2. set them up in the combo box
            foreach (User u in tutors)
            {
                if (u.ID != ACCID)
                {
                    tutorIDs.Insert(0, u.ID);
                    combSecondChoice.Items.Add(u.FirstName + " " + u.LastName);
                }
            }
        }
Exemplo n.º 4
0
        private void setTutorLocations()
        {
            TutorMasterDBEntities4 db      = new TutorMasterDBEntities4();                                           //Connect to the database
            string            loc          = txtLoc.Text;                                                            //grab the text of the location the tutor typed in
            List <Commitment> tutorCmtList = (from stucmt in db.StudentCommitments                                   //get the tutor's commitments
                                              where stucmt.ID == id
                                              join cmt in db.Commitments on stucmt.CmtID equals cmt.CmtID
                                              select cmt).ToList();

            for (int i = 0; i < info.Count(); i++)                                                                   //for every time chosen
            {
                DateTime startDate = DateTimeMethods.getStartTime(info[i]);                                          //get the startTime
                DateTime endDate   = DateTimeMethods.getEndTime(info[i]);                                            //get the endTime
                for (int c = 0; c < tutorCmtList.Count(); c++)                                                       //go through the tutor commitments
                {
                    if (DateTimeMethods.inTheTimeSlot(startDate, endDate, tutorCmtList[c]))                          //if a commitment is in the time slot
                    {
                        if (!admin)
                        {
                            tutorCmtList[c].Location = loc + "?";                                                        //change the location to the string the user typed in + a question mark
                        }
                        else
                        {
                            tutorCmtList[c].Location = loc;                                                          //change the location to the string the user typed in
                        }
                        db.SaveChanges();                                                                            //save to database
                    }
                }
            }
        }
Exemplo n.º 5
0
        private void btnAccept_Click(object sender, EventArgs e)
        {
            //This will need to change each student account selected and then remove the pending requests from the DB
            TutorMasterDBEntities4 db = new TutorMasterDBEntities4();            //side note, we should carefully control the life cycle of object contexts like these   //open the db

            int reqNum = lvPendingRequests.CheckedItems.Count;                   //identify how many requests have been checked

            for (int i = 0; i < reqNum; i++)                                     //iterate for how many requests have been clicked
            {
                string CC  = lvPendingRequests.CheckedItems[i].SubItems[1].Text; //pull the classcode from the request in question
                string Id  = lvPendingRequests.CheckedItems[i].SubItems[2].Text;
                int    Id2 = Int32.Parse(Id);                                    //Change the string into an int, this is really fragile if a bad id number is put in the system somehow. typechecking for those ids should prevent it

                StudentClass newClass = new StudentClass();
                newClass.Key       = getNextRequestKey();
                newClass.ClassCode = CC;
                newClass.ID        = Id2;
                db.StudentClasses.AddObject(newClass);

                Student tutor = (from row in db.Students where row.ID == Id2 select row).First();
                tutor.Tutor = true;
                TutorRequest delU = (from row in db.TutorRequests where ((row.ClassCode == CC) && (row.ID == Id2)) select row).First(); //find the request that has the right ID and class code

                if (delU != null)
                {
                    db.TutorRequests.DeleteObject(delU);                                                                //delete the object in the db
                    db.SaveChanges();                                                                                   //save the cahnges to the db
                }
            }

            db.SaveChanges();
            MessageBox.Show("The selected tutor requests have been accepted and the tutors have been approved to tutor the selected courses");
            lvPendingRequests.Clear(); //clean out the box
            SetupPendingRequests(id);  //Set up the box again
        }
Exemplo n.º 6
0
        private void btnReject_Click(object sender, EventArgs e)                                                    //This Button now works fully! addition functionality would be eror checking for parse function and sending message to students and administrators once we set that up.
        {
            //This will need to remove all the requests from the DB and leave all acounts unchanged. Eventually, it will send a message to the admin account
            TutorMasterDBEntities4 db = new TutorMasterDBEntities4();            //side note, we should carefully control the life cycle of object contexts like these                                           //open the db

            int reqNum = lvPendingRequests.CheckedItems.Count;                   //identify how many requests have been checked

            for (int i = 0; i < reqNum; i++)                                     //iterate for how many requests have been clicked
            {
                string CC  = lvPendingRequests.CheckedItems[i].SubItems[1].Text; //pull the classcode from the request in question
                string Id  = lvPendingRequests.CheckedItems[i].SubItems[2].Text;
                int    Id2 = Int32.Parse(Id);                                    //Change the string into an int


                //This line creates text objects that look like 'FIRST LAST CLASS-123 ID' you may want to split the string to get the class code, but you also need the student ID

                TutorRequest delU = (from row in db.TutorRequests where ((row.ClassCode == CC) && (row.ID == Id2)) select row).First(); //find the request that has the right ID and class code

                if (delU != null)
                {
                    db.TutorRequests.DeleteObject(delU);                                                                //delete the object in the db
                    db.SaveChanges();                                                                                   //save the cahnges to the db
                }
            }

            MessageBox.Show("The selected requests have been rejected and the selected tutors have not been approved for the requests courses.");
            lvPendingRequests.Clear(); //clean out the box
            SetupPendingRequests(id);  //Set up the box again
        }
        //constructor for editting an appointment
        public AdminCreateAppointmentForm(int accID, string info)
        {
            InitializeComponent();
            id   = accID;                                                   //get the student's id
            edit = true;                                                    //remember that we are editting an appointment
            populateListview();                                             //load the listview features
            rememberStudIDs.Add(Convert.ToInt16(info.Split(',')[8]));       //throw the partner id in the remember list
            loadAppointmentInformation(info);                               //load the appointment information

            TutorMasterDBEntities4 db = new TutorMasterDBEntities4();       //open the database
            string class1;

            if (info.Split(',')[2].Contains('!'))                           //if its a new commitment, ignore the !
            {
                class1 = info.Split(',')[2].Substring(0, info.Split(',')[2].Length - 1);
            }
            else                                                            //if its not, then just get the classcode
            {
                class1 = info.Split(',')[2];
            }
            btnCancel.Hide();                                                                                                     //hide the cancel button
            cbWeekly.Enabled = false;
            Class course = (from row in db.StudentClasses.AsEnumerable() where row.ClassCode == class1 select row.Class).First(); //get the class based on the course number

            cbxClasses.Text  = course.ClassName.ToString();                                                                       //set this dropdown text to the courses classname
            cbxStudents.Text = info.Split(',')[7];                                                                                //set the student text to the name of the partner
            loadMinutesAndHours(info);                                                                                            //set the minutes and hour dropdowns
            pickCurrent(info);                                                                                                    //have the current timeslot of the appointment be checked in the listview
        }
        private bool loadTuteeStudentCheckBox()
        {
            cbxStudents.Items.Clear();
            rememberStudIDs.Clear();
            bool tutorsExist = false;

            TutorMasterDBEntities4 db = new TutorMasterDBEntities4();

            string chosenClass = cbxClasses.Text.ToString();                                                                    //get the class that has been chosen

            var approvedTutors = (from Classname in db.Classes                                                                  //find all of its tutors that have requested to tutor it
                                  where chosenClass == Classname.ClassName
                                  join stuClass in db.StudentClasses on Classname.ClassCode equals stuClass.ClassCode
                                  select stuClass.ID).ToList();

            if (approvedTutors.Count == 0)
            {
                MessageBox.Show("There are currently no tutors approved for this course, please try again later or choose another course.");
            }
            else
            {
                for (int i = 0; i < approvedTutors.Count; i++)
                {
                    User tutor = (from row in db.Users.AsEnumerable() where row.ID == approvedTutors[i] select row).First();
                    if (!tutor.Username.ToString().Contains('?'))                                                               //see if any of them are approved
                    {
                        cbxStudents.Items.Add(tutor.FirstName + " " + tutor.LastName);                                          //put their names in the dropdown boxes
                        rememberStudIDs.Add(tutor.ID);                                                                          //remember their ids
                        tutorsExist = true;                                                                                     //say we have approved tutors for this course
                    }
                }
            }
            return(tutorsExist);
        }
        private void removeInvalidCourses()
        //remove the courses the student is approved to tutor
        {
            TutorMasterDBEntities4 db = new TutorMasterDBEntities4();
            bool thisStudentATutor    = (bool)(from row in db.Students where row.ID == id select row.Tutor).First();

            if (thisStudentATutor)                                                                                              //check if the student is a tutor
            {
                List <string> removeClasses = (from stuClass in db.StudentClasses.AsEnumerable()                                //if they are, get all the courses that tutor from the database
                                               where stuClass.ID == id
                                               join course in db.Classes.AsEnumerable() on stuClass.ClassCode equals course.ClassCode
                                               select course.ClassName).ToList();

                for (int i = 0; i < cbxClasses.Items.Count; i++)                                                                //go through the courses in the dropdown
                {
                    for (int j = 0; j < removeClasses.Count; j++)                                                               //go through the courses the student can tutor
                    {
                        if (removeClasses[j].ToString() == cbxClasses.Items[i].ToString())                                      //if you get a match, remove the class from the dropdown
                        {
                            cbxClasses.Items.Remove(cbxClasses.Items[i]);
                        }
                    }
                }
            }
        }
Exemplo n.º 10
0
        private void addStudentCommit(TutorMaster.StudentCommitment studentCommit)                      //add a student commitment
        {
            TutorMasterDBEntities4 db = new TutorMasterDBEntities4();

            db.StudentCommitments.AddObject(studentCommit);
            db.SaveChanges();
        }
Exemplo n.º 11
0
        //this function gets all of the classes in the database and the department names and loads them into a tree view
        private void setupClasses()
        {
            tvClasses.CheckBoxes = true;                                                         //have the treeview have checkboxes

            TutorMasterDBEntities4 db = new TutorMasterDBEntities4();                            //connect to database
            var          classes      = from c in db.Classes select c;                           //get the classes from the class table
            List <Class> cls          = new List <Class>();

            cls = classes.ToList();                                                              //convert them into a list of classes

            foreach (Class cl in cls)                                                            //for each class in the list of classes
            {
                if (tvClasses.Nodes.ContainsKey(cl.Department))                                  //if it is contained in a department
                {
                    tvClasses.Nodes[cl.Department].Nodes.Add(new TreeNode(cl.ClassName));        //put it in its department as a node
                }
                else
                {
                    TreeNode nNode = new TreeNode(cl.Department);                                //add the department nodes
                    nNode.Name = cl.Department;
                    nNode.Nodes.Add(cl.ClassName);
                    tvClasses.Nodes.Add(nNode);
                }
            }
            tvClasses.Sort();                                                                    //sort the treeview
        }
Exemplo n.º 12
0
        private void btnChangePassword_Click(object sender, EventArgs e)
        {
            TutorMasterDBEntities4 db = new TutorMasterDBEntities4();                                                                        //open the database
            User   user         = (from row in db.Users.AsEnumerable() where row.ID == id select row).First();                               //get the user account
            string accountType  = user.AccountType;                                                                                          //get the accountType of the user
            string oldPassword  = user.Password;                                                                                             //get the password of the user
            string inputOld     = txtOldPass.Text;                                                                                           //get the password they put in the old password textbox
            string inputNew     = txtNewPass.Text;                                                                                           //get the new password they put in the new password textbox
            string inputConfirm = txtConfirm.Text;                                                                                           //get the confirmation of the password they put in the confirmation textbox

            if (string.IsNullOrWhiteSpace(oldPassword) || string.IsNullOrWhiteSpace(inputNew) || string.IsNullOrWhiteSpace(inputConfirm))    //check if they put something in each text box
            {
                MessageBox.Show("Please enter your old password, new password, and confirm your new password.");
            }
            else if (oldPassword != inputOld)                                                                                                //check if the old password matches what they put in
            {
                MessageBox.Show("Your old password and the password you put in as your old password do not match.");
            }
            else if (inputNew != inputConfirm)                                                                                               //check if the new password they put in and the confirmation as the same
            {
                MessageBox.Show("The new password you typed in and its confirmation do not match.");
            }
            else
            {
                user.Password = inputNew;                                                                                                    //update the database
                db.SaveChanges();
                backToMain(accountType);                                                                                                     //go back to the right main form
            }
        }
Exemplo n.º 13
0
        private void addRequest(TutorMaster.TutorRequest request)
        //add tutor request to the datbase
        {
            TutorMasterDBEntities4 db = new TutorMasterDBEntities4();

            db.TutorRequests.AddObject(request);
            db.SaveChanges();
        }
Exemplo n.º 14
0
        private string getAccType(string username)
        {
            TutorMasterDBEntities4 db = new TutorMasterDBEntities4();                                               //This creates a reference to an entity so we can point and look through things (I think)

            string accType = (from row in db.Users where row.Username == username select row.AccountType).Single(); //Same kind of idea, check all the entries in User to find which user we're talking about. Then pull out the single attribute accountType

            return(accType);
        }
Exemplo n.º 15
0
        private void btnCancel_Click(object sender, EventArgs e)
        {
            TutorMasterDBEntities4 db = new TutorMasterDBEntities4();                                                                        //open the database
            User   user        = (from row in db.Users.AsEnumerable() where row.ID == id select row).First();                                //get the user account
            string accountType = user.AccountType;                                                                                           //get the accountType of the user

            backToMain(accountType);                                                                                                         //send the user back to main without having changed anything
        }
Exemplo n.º 16
0
        private int getID(string username)
        {
            TutorMasterDBEntities4 db = new TutorMasterDBEntities4();                                //This creates a reference to an entity so we can point and look through things (I think)

            int accID = (from row in db.Users where row.Username == username select row.ID).First(); //Same as accountType but with a different attribute

            return(accID);
        }
Exemplo n.º 17
0
        private int getNextID()
        //get unused id for a new user
        {
            TutorMasterDBEntities4 db = new TutorMasterDBEntities4();
            int rowNum = db.Users.Count();

            var lastRow = db.Users.OrderByDescending(u => u.ID).Select(r => r.ID).First();

            return(lastRow + 1);
        }
Exemplo n.º 18
0
        private void setPreviousWeekliesToFalse()
        {
            TutorMasterDBEntities4 db = new TutorMasterDBEntities4();                                         //connect to the database

            List <Commitment> cmtList = (from stucmt in db.StudentCommitments                                 //get the commit list of the signed in student
                                         where stucmt.ID == id
                                         join cmt in db.Commitments on stucmt.CmtID equals cmt.CmtID
                                         select cmt).ToList();

            List <DateTime> searchList = new List <DateTime>();                                                 //initialize search list

            SortsAndSearches.QuickSort(ref cmtList, cmtList.Count());

            searchList = getStartTimes();                                                                     //get the startTimes from the listview

            for (int i = 0; i < cmtList.Count(); i++)                                                         //for each commitment in the commit list
            {
                if (DateTimeMethods.weeklyAndFound(cmtList[i], searchList))                                   //if the commitment is in the search list and weekly
                {
                    DateTime startSemes = new DateTime(2017, 1, 1, 0, 0, 0);
                    DateTime weekBack   = Convert.ToDateTime(cmtList[i].StartTime).AddDays(-7);               //go a week back in time
                    while (DateTime.Compare(startSemes, weekBack) <= 0)                                       //perform a binary search here
                    {
                        bool found = false;
                        int  first = 0;
                        int  last  = cmtList.Count() - 1;
                        while (first <= last && !found)
                        {
                            int midpoint = (first + last) / 2;
                            if (DateTimeMethods.sameTime(cmtList[midpoint], weekBack))                        //if you find the weekBack date time
                            {
                                if (cmtList[midpoint].Open == true)                                           //if the commitment is open
                                {
                                    cmtList[midpoint].Weekly = false;                                         //set its weekly to false
                                    db.SaveChanges();                                                         //save the changes to the database
                                }
                                found = true;
                            }
                            else
                            {
                                if (DateTimeMethods.weekBackEarlier(weekBack, cmtList[midpoint]))                                    //if weekback is earlier, search first half of list
                                {
                                    last = midpoint - 1;
                                }
                                else                                                                          //else, search the second half of the list
                                {
                                    first = midpoint + 1;
                                }
                            }
                        }
                        weekBack = weekBack.AddDays(-7);                                                      //go a week back in time
                    }
                }
            }
        }
Exemplo n.º 19
0
        private void saveClasses()
        {
            TutorMasterDBEntities4 db = new TutorMasterDBEntities4();
            //var numReq = db.TutorRequests.Count(x => x.ID == accID);
            var requestClasses = (from stucla in db.TutorRequests
                                  where stucla.ID == accID
                                  join cla in db.Classes on stucla.ClassCode equals cla.ClassCode
                                  select cla).ToList();
            var acceptedClasses = (from stucla in db.StudentClasses
                                   where stucla.ID == accID
                                   join cla in db.Classes on stucla.ClassCode equals cla.ClassCode
                                   select cla).ToList();

            int numDepartments = tvClasses.Nodes.Count;

            for (int i = 0; i < numDepartments; i++)
            {
                int numNodes = tvClasses.Nodes[i].Nodes.Count;
                for (int j = 0; j < numNodes; j++)                          //loop through each class in each department and check whether the node is checked
                {
                    TreeNode tn = tvClasses.Nodes[i].Nodes[j];
                    if (!tn.Checked)
                    {
                        //if already approved but not checked, delete from approved
                        if (acceptedClasses.Exists(x => x.ClassName.Equals(tn.Text)))
                        {
                            string classCode = acceptedClasses.Find(x => x.ClassName.Equals(tn.Text)).ClassCode;
                            db.StudentClasses.DeleteObject((from row in db.StudentClasses where row.ClassCode == classCode select row).First());
                        }
                        //if requested and unchecked, delete from requests
                        if (requestClasses.Exists(x => x.ClassName.Equals(tn.Text)))
                        {
                            string classCode = requestClasses.Find(x => x.ClassName.Equals(tn.Text)).ClassCode;
                            db.TutorRequests.DeleteObject((from row in db.TutorRequests where row.ClassCode == classCode select row).First());
                        }
                    }
                    //if not approved or requested but checked, submit a request
                    else
                    {
                        if (!(acceptedClasses.Exists(x => x.ClassName.Equals(tn.Text))) && !(requestClasses.Exists(x => x.ClassName.Equals(tn.Text))))
                        {
                            TutorMaster.TutorRequest request = new TutorMaster.TutorRequest();
                            request.Key = getNextRequestKey();
                            request.ID  = accID;
                            string classCode = (from row in db.Classes where row.ClassName == tn.Text select row.ClassCode).First();
                            request.ClassCode = classCode;
                            addRequest(request);
                        }
                    }
                }
            }

            db.SaveChanges();
        }
Exemplo n.º 20
0
        private void saveNewTutorTutee(bool tutor, bool tutee, int id)
        {
            TutorMasterDBEntities4 db = new TutorMasterDBEntities4();                          //connect to database
            Student newStudent        = new Student();                                         //make new student object

            newStudent.Tutee = tutee;                                                          //load up the information
            newStudent.Tutor = tutor;
            newStudent.ID    = id;

            db.Students.AddObject(newStudent);                                                 //add the tutor/tutee to the database
            db.SaveChanges();                                                                  //save the changes
        }
Exemplo n.º 21
0
        private void SetUpClassName()
        {
            TutorMasterDBEntities4 db = new TutorMasterDBEntities4();

            foreach (Class c in db.Classes)
            {
                combCourseName.Items.Add(c.ClassName); //add all the class names to this list
            }

            removeInvalidCourses();                    //remove the courses that the student is an approved tutor for
            combHours.Text = "0";
            combMins.Text  = "00";
        }
        //load the tutee classes checkbox
        private void loadTuteeClassesCheckBox()
        {
            TutorMasterDBEntities4 db = new TutorMasterDBEntities4();                                                           //open the database

            List <string> classes = (from offeredClass in db.Classes.AsEnumerable() select offeredClass.ClassName).ToList();    //get all the class names

            for (int i = 0; i < classes.Count(); i++)                                                                           //go thru the list of class names
            {
                cbxClasses.Items.Add(classes[i]);                                                                               //add the classes to the drop down
            }

            removeInvalidCourses();                                                                                             //remove the courses the student can tutor
        }
        private void loadTutorClassesCheckBox()
        {
            TutorMasterDBEntities4 db = new TutorMasterDBEntities4();                                                           //open the database

            List <string> approvedClasses = (from stuClass in db.StudentClasses                                                 //get the course names the student is allowed to tutor from the databse
                                             where stuClass.ID == id
                                             join appClass in db.Classes on stuClass.ClassCode equals appClass.ClassCode
                                             select appClass.ClassName).ToList();

            for (int i = 0; i < approvedClasses.Count; i++)                                                                     //go thru the list of class names
            {
                cbxClasses.Items.Add(approvedClasses[i]);                                                                       //add approved classes to the dropdown
            }
        }
Exemplo n.º 24
0
        private void setupClassList()
        {
            TutorMasterDBEntities4 db = new TutorMasterDBEntities4();

            List <string> userClasses = (from row in db.StudentClasses where row.ID == ACCID select row.ClassCode).ToList();

            foreach (Class c in db.Classes)
            {
                if (!userClasses.Contains(c.ClassCode))
                {
                    combFirstChoice.Items.Add(c.ClassName);
                }
            }
        }
Exemplo n.º 25
0
        //load second choice options based on what the first choice was
        private void loadTutorClassList()
        {
            TutorMasterDBEntities4 db = new TutorMasterDBEntities4();

            int           id          = tutorIDs[combFirstChoice.SelectedIndex];
            List <Class>  classes     = (from row in db.StudentClasses where row.ID == id select row.Class).ToList();
            List <string> userClasses = (from row in db.StudentClasses where row.ID == ACCID select row.ClassCode).ToList();

            foreach (Class SC in classes)
            {
                if (!userClasses.Contains(SC.ClassCode))
                {
                    combSecondChoice.Items.Add(SC.ClassName);
                }
            }
        }
Exemplo n.º 26
0
        private int getNextStdCmtKey()                                                                 //go into database and get the last student commitment ID
        {
            TutorMasterDBEntities4 db = new TutorMasterDBEntities4();
            int rowNum = db.StudentCommitments.Count();
            int lastRow;

            if (rowNum > 0)
            {
                lastRow = db.StudentCommitments.OrderByDescending(u => u.Key).Select(r => r.Key).First();
            }
            else
            {
                lastRow = 0;
            }
            return(lastRow + 1);
        }
        private void setInformation()
        {
            TutorMasterDBEntities4 db = new TutorMasterDBEntities4();

            User    u = (from row in db.Users where row.ID == accID select row).First();            //get user and student object from database
            Student s = (from row in db.Students where row.ID == accID select row).First();

            lblFirstName.Text  = u.FirstName;                   //load and set the student information
            lblLastName.Text   = u.LastName;
            lblUsername.Text   = u.Username;
            lblPhone.Text      = u.PhoneNumber;
            lblEmail.Text      = u.Email;
            lblTutorTutee.Text = "";

            if ((bool)s.Tutee)                          //set the tutor and tutee information
            {
                lblTutorTutee.Text += "Tutee\n";
            }
            if ((bool)s.Tutor)
            {
                lblTutorTutee.Text += "Tutor";

                this.Width      += 280;                                                             //if they're a tutor expand the window and move the logo
                imgLogo.Location = new Point(imgLogo.Location.X + 280, imgLogo.Location.Y);

                List <StudentClass> classes = (from row in db.StudentClasses where row.ID == accID select row).ToList();     //get the classes they can tutor and load them into a listview
                foreach (StudentClass c in classes)
                {
                    lvClasses.Items.Add(c.ClassCode);
                }

                List <TutorRequest> requests = (from row in db.TutorRequests where row.ID == accID select row).ToList();     //get the classes they're requested to tutor and load them into a listview
                foreach (TutorRequest r in requests)
                {
                    lvRequests.Items.Add(r.ClassCode);
                }
            }
            else                         //if they aren't a tutor, hide the labels and boxes for the class lists
            {
                lblClasses.Hide();
                lblRequests.Hide();

                lvClasses.Hide();
                lvRequests.Hide();
            }
        }
Exemplo n.º 28
0
        private int getNextRequestKey()
        //get unused id for a new tutor request
        {
            TutorMasterDBEntities4 db = new TutorMasterDBEntities4();
            int rowNum = db.TutorRequests.Count();
            int lastRow;

            if (rowNum > 0)
            {
                lastRow = db.TutorRequests.OrderByDescending(u => u.Key).Select(r => r.Key).First();
            }
            else
            {
                lastRow = 0;
            }
            return(lastRow + 1);
        }
Exemplo n.º 29
0
        private void saveNewUser(string fname, string lname, string username, string password, string email, string phone, string accounttype, int id)
        {
            TutorMasterDBEntities4 db = new TutorMasterDBEntities4();                          //connection to new database
            User newUser = new User();                                                         //create a new user and load him up with the information

            newUser.ID          = id;
            newUser.FirstName   = fname;
            newUser.LastName    = lname;
            newUser.Username    = username;
            newUser.Password    = password;
            newUser.Email       = email;
            newUser.AccountType = accounttype;
            newUser.PhoneNumber = phone;

            db.Users.AddObject(newUser);                                                       //add them to the users table in the database
            db.SaveChanges();                                                                  //save the changes to the database
        }
Exemplo n.º 30
0
        private int getNextRequestKey()
        //gets unused key from database
        {
            TutorMasterDBEntities4 db = new TutorMasterDBEntities4();
            int rowNum = db.StudentClasses.Count();
            int lastRow;

            if (rowNum > 0)
            {
                lastRow = db.StudentClasses.OrderByDescending(u => u.Key).Select(r => r.Key).First();
            }
            else
            {
                lastRow = 0;
            }
            return(lastRow + 1);
        }