예제 #1
0
        /*
         * Pre:  There must exist a contact with the input contact id
         * Post: The informatin of the contact with the input contact id is loaded to the page
         * @param contactId is the contact id of the contact to load
         */
        private void loadContact(int contactId)
        {
            Contact contact = new Contact(contactId);

            if (contact.id != -1)
            {
                Session[contactVar] = contact;

                //load contact data to form
                lblId.Text = contact.id.ToString();
                txtFirstNameSearch.Text = contact.firstName;
                txtLastNameSearch.Text  = contact.lastName;
                lblName.Text            = contact.firstName + " " + contact.middleInitial + " " + contact.lastName;
                lblDistrict.Text        = DbInterfaceStudent.GetStudentDistrict(contact.districtId);
                lblContactType.Text     = contact.contactTypeId;

                string mtnaId = DbInterfaceContact.GetMtnaId(contact.id);

                if (!mtnaId.Equals(""))
                {
                    txtMtnaId.Text    = mtnaId;
                    txtMtnaId.Enabled = false;
                }
            }
            else
            {
                lblContactSearchError.Text    = "An error occurred during the search";
                lblContactSearchError.Visible = true;
            }
        }
예제 #2
0
        /*
         * Pre:
         * Post: Update the list of available teachers
         */
        private void updateTeacherDropdown()
        {
            ddlTeacher.DataSource = null;
            ddlTeacher.DataBind();
            ddlTeacher.Items.Clear();

            if (ddlDistrictSearch.SelectedIndex > 0)
            {
                int year       = Convert.ToInt32(ddlYear.SelectedValue);
                int districtId = Convert.ToInt32(ddlDistrictSearch.SelectedValue);

                DataTable table = DbInterfaceContact.GetTeachersForEvent(districtId, year);

                if (table != null)
                {
                    //add empty item
                    ddlTeacher.Items.Add(new ListItem("", ""));

                    //add teachers from district
                    ddlTeacher.DataSource = table;

                    ddlTeacher.DataTextField  = "ComboName";
                    ddlTeacher.DataValueField = "ContactId";

                    ddlTeacher.DataBind();
                }
                else
                {
                    showErrorMessage("Error: The teachers for the selected event could not be retrieved.");
                }
            }
        }
예제 #3
0
파일: Contact.cs 프로젝트: slam900/WMTASite
    /*
     * Constructor for loading the data of an existing contact
     */
    public Contact(int id, bool needInfo) : base(id)
    {
        Contact temp = null;

        if (needInfo)
        {
            temp = DbInterfaceContact.GetContact(id);
        }

        if (temp != null)
        {
            this.id       = id;
            firstName     = temp.firstName;
            middleInitial = temp.middleInitial;
            lastName      = temp.lastName;
            contactTypeId = temp.contactTypeId;
            phone         = temp.phone;
            email         = temp.email;
            setAddress(temp.street, temp.city, temp.state, temp.zip);
            districtId = temp.districtId;
        }
        else if (needInfo)
        {
            this.id = -1;
        }
        else if (!needInfo)
        {
            this.id = id;
        }
    }
예제 #4
0
        /*
         * Pre:
         * Post: If the current user is a teacher, the teacher dropdown
         *       should only show the current user
         */
        private void loadTeacherDropdown()
        {
            if (HighestPermissionTeacher())
            {
                User    user    = (User)Session[Utility.userRole];
                Contact contact = DbInterfaceContact.GetContact(user.contactId);

                if (contact != null)
                {
                    ddlTeacher.Items.Add(new ListItem(contact.lastName + ", " + contact.firstName, user.contactId.ToString()));
                }
            }
        }
예제 #5
0
        /*
         * Pre:  id must be an integer or the empty string
         * Post:  The input parameters are used to search for existing contacts.  Matching contact
         *        information is displayed in the input gridview.
         * @param gridView is the gridView in which the search results will be displayed
         * @param id is the id being searched for - must be an integer or the empty string
         * @param firstName is all or part of the first name being searched for
         * @param lastName is all or part of the last name being searched for
         * @param districtId is the district of contacts that should be searched
         * @returns true if results were found and false otherwise
         */
        private bool searchContacts(GridView gridView, string id, string firstName, string lastName, string session, int districtId)
        {
            bool result = true;

            try
            {
                DataTable table = DbInterfaceContact.GetContactSearchResults(id, firstName, lastName, districtId);

                //If there are results in the table, display them.  Otherwise clear current
                //results and return false
                if (table != null && table.Rows.Count > 0)
                {
                    gridView.DataSource = table;
                    gridView.DataBind();

                    //save the data for quick re-binding upon paging
                    Session[session] = table;
                }
                else if (table != null && table.Rows.Count == 0)
                {
                    clearGridView(gridView);
                    result = false;
                }
                else if (table == null)
                {
                    lblContactSearchError.Text    = "An error occurred.  Please make sure all entered data is valid.";
                    lblContactSearchError.Visible = true;
                }
            }
            catch (Exception e)
            {
                lblContactSearchError.Text    = "An error occurred.  Please make sure all entered data is valid.";
                lblContactSearchError.Visible = true;

                //log issue in database
                Utility.LogError("Register Contacts", "searchContacts", gridView.ID + ", " + id + ", " + firstName + ", " + lastName + ", " + session, "Message: " + e.Message + "   Stack Trace: " + e.StackTrace, -1);
            }

            return(result);
        }
예제 #6
0
        /*
         * Pre:  id must be an integer or the empty string
         * Post:  The input parameters are used to search for existing contacts.  Matching contact
         *        information is displayed in the input gridview.
         * @param gridView is the gridView in which the search results will be displayed
         * @param id is the id being searched for - must be an integer or the empty string
         * @param firstName is all or part of the first name being searched for
         * @param lastName is all or part of the last name being searched for
         * @returns true if results were found and false otherwise
         */
        private bool searchTeachers(GridView gridView, string id, string firstName, string lastName, string session)
        {
            DataTable table;
            bool      result = true;

            try
            {
                table = DbInterfaceContact.TeacherSearch(id, firstName, lastName);

                //If there are results in the table, display them.  Otherwise clear current
                //results and return false
                if (table != null && table.Rows.Count > 0)
                {
                    gridView.DataSource = table;
                    gridView.DataBind();
                    gridView.HeaderRow.BackColor = Color.Black;

                    //save the data for quick re-binding upon paging
                    Session[session] = table;
                }
                else if (table != null && table.Rows.Count == 0)
                {
                    clearGridView(gridView);
                    result = false;
                }
                else if (table == null)
                {
                    showErrorMessage("Error: An error occurred during the search. Please make sure all entered data is valid.");
                }
            }
            catch (Exception e)
            {
                showErrorMessage("Error: An error occurred during the search. Please make sure all entered data is valid.");

                //log issue in database
                Utility.LogError("Transfer Students", "searchTeachers", gridView.ID + ", " + id + ", " + firstName + ", " + lastName + ", " + session, "Message: " + e.Message + "   Stack Trace: " + e.StackTrace, -1);
            }

            return(result);
        }
예제 #7
0
        /*
         * Pre:
         * Post: If the user has entered valid information, the new contact information is added
         *       to the database.
         *       If the add is successful, the new contacts's id number will be displayed to the user,
         *       otherwise an error message will take its place.
         */
        private void Register()
        {
            try
            {
                //if the entered information is valid, add the new contact
                if (verifyInformation())
                {
                    int    contactId, year;
                    string mtnaId;

                    //get input information
                    contactId = Convert.ToInt32(lblId.Text);
                    year      = Convert.ToInt32(ddlYear.SelectedValue);
                    mtnaId    = txtMtnaId.Text;

                    if (DbInterfaceContact.RegisterContact(contactId, year, mtnaId)) //show success message
                    {
                        showSuccessMessage("The contact was successfully registered.");

                        pnlButtons.Visible       = false;
                        pnlFullPage.Visible      = false;
                        pnlContactSearch.Visible = true;

                        clearData();
                        clearContactSearch();
                    }
                    else //show error message
                    {
                        showErrorMessage("Error: There was an error registering the contact.");
                    }
                }
            }
            catch (Exception e)
            {
                showErrorMessage("Error: There was an error registering the contact.");

                Utility.LogError("Register Contact", "Register", "", "Message: " + e.Message + "   Stack Trace: " + e.StackTrace, -1);
            }
        }
예제 #8
0
        /*
         * Pre:
         * Post:  If the current user is a teacher they can only add/edit their own students.
         *        If the current user is a district administrator they can only add/edit students
         *        in their district
         */
        private void filterDistrictsAndTeachers()
        {
            //filter available districts and teachers based on user role
            User user = (User)Session[Utility.userRole];

            //if the user is a teacher, only allow students to be added to their district and assigned to themselves
            if (user.permissionLevel.Contains('T') && !(user.permissionLevel.Contains('A') || user.permissionLevel.Contains('S') ||
                                                        user.permissionLevel.Contains('D')))
            {
                //only show current teacher's district
                cboDistrict.DataBind();
                ListItem item = cboDistrict.Items.FindByValue(user.districtId.ToString());
                cboDistrict.Items.Clear();
                cboDistrict.Items.Add(item);

                //only show current teacher in teacher dropdown
                cboCurrTeacher.DataBind();
                item = cboCurrTeacher.Items.FindByValue(user.contactId.ToString());
                cboCurrTeacher.Items.Clear();
                cboCurrTeacher.Items.Add(item);
            }
            //if the user is a district admin, allow them to add students to their district to and assign them to a teacher in their district
            else if (user.permissionLevel.Contains('D') && !(user.permissionLevel.Contains('A') || user.permissionLevel.Contains('S')))
            {
                //only show current user's district
                cboDistrict.DataBind();
                ListItem item = cboDistrict.Items.FindByValue(user.districtId.ToString());
                cboDistrict.Items.Clear();
                cboDistrict.Items.Add(item);

                //only show teachers in the current user's district
                DataTable table = DbInterfaceContact.GetTeachersFromDistrict(user.districtId);
                cboCurrTeacher.DataSourceID = null;
                cboCurrTeacher.DataSource   = table;
                cboCurrTeacher.DataBind();
            }
        }
예제 #9
0
 /*
  * Pre:
  * Post: The permission information is retrieved for the user with
  *       the current first initial, last name, and MTNA Id
  */
 private void login()
 {
     DbInterfaceContact.ContactLogin(this);
 }
예제 #10
0
파일: Contact.cs 프로젝트: slam900/WMTASite
 /*
  * Pre:
  * Post: Determines whether or not the contact is associated with
  *       any students
  * @returns true if there are associated students and false otherwise
  */
 public bool hasStudents()
 {
     return(DbInterfaceContact.ContactHasStudents(id));
 }
예제 #11
0
파일: Contact.cs 프로젝트: slam900/WMTASite
 /*
  * Pre:
  * Post: The contact and all associated information is deleted
  *       from the database
  * @returns true if the contact was deleted and false otherwise
  */
 public bool deleteInDatabase()
 {
     return(DbInterfaceContact.DeleteContact(id));
 }
예제 #12
0
파일: Contact.cs 프로젝트: slam900/WMTASite
 /*
  * Pre:  The contact information must have been previously entered
  *       into the database, meaning that there is a unique id
  * Post: The contact's information is updated
  */
 public void updateInDatabase()
 {
     DbInterfaceContact.UpdateContact(this);
 }
예제 #13
0
파일: Contact.cs 프로젝트: slam900/WMTASite
 /*
  * Pre:  The contact must have a first and last name, contact type, phone
  *       number, and email address
  * Post: The new contact is added to the database
  */
 public void addToDatabase()
 {
     id = DbInterfaceContact.CreateContact(this);
 }
예제 #14
0
 /*
  * Pre:  The currTeacherId must exist in the system.
  * Post: The name of the teacher with a teacher id of
  *       currTeacherId is returned.
  */
 public string getCurrTeacher()
 {
     return(DbInterfaceContact.GetContactName(currTeacherId));
 }