Exemplo n.º 1
0
        // Name: profileAddButton_Click
        //
        // Description:
        //      Handles the Add button click event.
        //      Extracts the values from the forms fields and creates a
        //      data set into which a new row will be inserted.
        //      If a new row is inserted the profile panel fields are updated.
        //
        // Inputs:
        //      sender      Control object
        //      e           Event arguments
        //
        // Outputs:
        //      None.
        //
        // Returns:
        //      None.
        //
        // History:
        //      02-Oct-2006 ([email protected])
        //          Created.
        private void profileAddButton_Click(object sender, EventArgs e)
        {
            // Add button click event.
            // Take the values from the profile forms and insert them into
            // the user_profile table.

            DialogResult result;

            if ((result = ProfileCheckItems()) == DialogResult.OK)
            {
                ProfileDataSet profileDataSet = new ProfileDataSet();

                String email;
                String lastName;
                String firstName;
                String airport;
                String photoPath;

                email = (profileEmailComboBox.Items.Count > 0) ?
                        profileEmailComboBox.SelectedValue.ToString() :
                        profileEmailComboBox.Text;
                airport = (profileAirportComboBox.Items.Count > 0) ?
                          profileAirportComboBox.SelectedValue.ToString() :
                          profileAirportComboBox.Text;

                lastName  = profileLastNameTextBox.Text;
                firstName = profileFirstNameTextBox.Text;
                photoPath = profilePhotoTextBox.Text;

                LoadProfile(profileDataSet.Tables["user_profile"], email);

                if (ProfileAdd(profileDataSet,
                               lastName,
                               firstName,
                               email,
                               airport,
                               photoPath) > 0)
                {
                    ShowButtons(profileButtons,
                                new Button[] {
                        profileModifyButton,
                        profileNewButton,
                        profileRemoveButton,
                        profileChangeButton
                    });
                    if (profileDefaultCheckBox.Checked == true)
                    {
                        profileEmail = email;
                        WriteConfiguration(appConfigFile);
                    }
                    SetProfileInfo(email);
                    ShowPanel(infoPanels, profilePanel);
                }
            }
            else if (result == DialogResult.Cancel)
            {
                Exception ex = new Exception("Add aborted");
                throw ex;
            }
        }
Exemplo n.º 2
0
        // Name: profileModifyButton_Click
        //
        // Description:
        //      Handles the Modify button click event.
        //      Activates all fields and populates the Email combo box list.
        //
        // Inputs:
        //      sender      Control object
        //      e           Event arguments
        //
        // Outputs:
        //      None.
        //
        // Returns:
        //      None.
        //
        // History:
        //      02-Oct-2006 ([email protected])
        //          Created.
        private void profileModifyButton_Click(object sender, EventArgs e)
        {
            // Modfy button click event.
            // Populate the email combo box list and convert from a text box.

            ProfileDataSet profileDataSet       = new ProfileDataSet();
            BindingSource  profileBindingSource = new BindingSource();
            String         email;

            email = profileEmailComboBox.Text;
            profileBindingSource.DataSource = profileDataSet;
            profileBindingSource.DataMember = "profileList";
            profileEmailComboBox.DataSource = profileBindingSource;

            profileEmailComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
            profilePhotoTextBox.Clear();
            GetProfileList(profileDataSet.Tables["profileList"]);
            // Check that we have entries in the data set that populates
            // combo box.
            if (profileDataSet.Tables["profileList"].Rows.Count > 0)
            {
                // Temporaily remove the event handler for the
                // SelectedIndexChanged event.  Stops it from triggering while
                // combo box is updated.
                profileEmailComboBox.SelectedIndexChanged -=
                    profileEmailComboBox_SelectedIndexChanged;
                profileEmailComboBox.SelectedIndex =
                    profileEmailComboBox.FindString(email);
                // Reinstate the event handler for the
                // SelectedIndexChanged event.
                profileEmailComboBox.SelectedIndexChanged +=
                    profileEmailComboBox_SelectedIndexChanged;
                ShowGroupBoxes(profileGroupBoxes, new GroupBox[] {
                    profilePersonalGroupBox,
                    profilePreferenceGroupBox,
                    profileAirportGroupBox
                });
                profileDefaultCheckBox.Enabled = true;
                ShowButtons(profileButtons, new Button[] { profileNewButton,
                                                           profileModifyButton, profileRemoveButton,
                                                           profileChangeButton });
            }
            else
            {
                // Alert for no results.
                DialogResult result = MessageBox.Show(rm.GetString("EmptyProfileList"),
                                                      rm.GetString("EmptyResultsCaption"),
                                                      MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 3
0
        // Name: profileRemoveButton_Click
        //
        // Description:
        //      Handles the Remove button click event.
        //      Extracts the selected email value and deletes the row identified
        //      by it.
        //
        // Inputs:
        //      sender      Control object
        //      e           Event arguments
        //
        // Outputs:
        //      None.
        //
        // Returns:
        //      None.
        //
        // History:
        //      02-Oct-2006 ([email protected])
        //          Created.
        private void profileRemoveButton_Click(object sender, EventArgs e)
        {
            // Remove button click event.
            // Take the email address and delete the row identified.

            String         email;
            ProfileDataSet profileDataSet = new ProfileDataSet();

            email = (profileEmailComboBox.Items.Count > 0) ?
                    profileEmailComboBox.SelectedValue.ToString() :
                    profileEmailComboBox.Text;

            if (email != null)
            {
                if (ProfileRemove(profileDataSet, email) > 0)
                {
                    if (profileEmail == email)
                    {
                        profileEmail = null;
                        profileDefaultCheckBox.Checked = false;
                    }
                    // Check each combo box in the list of combo boxes.
                    // Determine the type of the data source and clear the result
                    // set.
                    ComboBox[] comboBoxes = new ComboBox[] {
                        profileEmailComboBox,
                        profileRegionComboBox,
                        profileAirportComboBox
                    };

                    ClearComboBoxes(comboBoxes);

                    profileLastNameTextBox.Clear();
                    profileFirstNameTextBox.Clear();
                    if (profileCountryComboBox.Items.Count > 0)
                    {
                        profileCountryComboBox.SelectedIndex = 0;
                    }
                    SetProfileControls();
                }
            }
        }
Exemplo n.º 4
0
        // Name: ProfileChange - Update the specified profile
        //
        // Description:
        //      Updated the profile identified by the email.
        //
        // Inputs:
        //      dataSet     Data set containing rows to update.
        //      lastName    Last name value.
        //      firstName   First name value.
        //      email       Identifying email address.
        //      airport     Airport preference value.
        //      photoFile   Path to new or updated graphics image.
        //
        // Outputs:
        //      profileDataSet  Updated result set.
        //
        // Returns:
        //      rowsDeleted     Number of rows affected by the query.
        //
        // History:
        //      02-Oct-2006 ([email protected])
        //          Created.
        //      11-Oct-2006 ([email protected])
        //          Corrected typos.
        private int ProfileChange(ProfileDataSet dataSet, String lastName,
            String firstName, String email, String airport, String photoFile)
        {
            int resAffected = 0;
            try
            {
                // Clear the command parameter list
                ingresDataAdapter6.UpdateCommand.Parameters.Clear();

                // Associate the data row columns with the data set columns.
                ingresDataAdapter6.UpdateCommand.Parameters.Add("@up_last",
                    Ingres.Client.IngresType.NVarChar, "up_last");
                ingresDataAdapter6.UpdateCommand.Parameters.Add("@up_first",
                    Ingres.Client.IngresType.NVarChar, "up_first");
                ingresDataAdapter6.UpdateCommand.Parameters.Add("@up_email",
                    Ingres.Client.IngresType.NVarChar, "up_email");
                ingresDataAdapter6.UpdateCommand.Parameters.Add("@up_airport",
                    Ingres.Client.IngresType.NChar, "up_airport");

                // If a path to an image is specified convert it into a Byte
                // array value and assign it to the up_image column.
                // If there is no path do not specify up_image as a parameter.
                if (photoFile.Length > 0)
                {
                    MemoryStream stream = new MemoryStream();
                    Image photo = System.Drawing.Image.FromFile(photoFile);
                    photo.Save(stream, photo.RawFormat);
                    ingresDataAdapter6.UpdateCommand.Parameters.Add("@up_image",
                        Ingres.Client.IngresType.LongVarBinary, "up_image");
                    dataSet.Tables["user_profile"].Rows[0]["up_image"] = stream.ToArray();
                    stream.Close();
                    ingresDataAdapter6.UpdateCommand.CommandText =
                        String.Format(rm.GetString("ProfileUpdateQuery"),
                            rm.GetString("ImageAttribute"));
                }
                else
                {
                    ingresDataAdapter6.UpdateCommand.CommandText =
                        String.Format(rm.GetString("ProfileUpdateQuery"), "");
                }
                // Specify the previous value of email for the row as the
                // identity of the row for update in the WHERE clause.
                ingresDataAdapter6.UpdateCommand.Parameters.Add("@up_email",
                    IngresType.NChar, "up_email").SourceVersion =
                    DataRowVersion.Original;

                // Assign the values into the data set table.
                dataSet.Tables["user_profile"].Rows[0]["up_last"] = lastName;
                dataSet.Tables["user_profile"].Rows[0]["up_first"] = firstName;
                dataSet.Tables["user_profile"].Rows[0]["up_email"] = email;
                dataSet.Tables["user_profile"].Rows[0]["up_airport"] = airport;

                // Perform the update.
                resAffected = ingresDataAdapter6.Update(dataSet);
            }
            catch (IngresException ex)
            {
                DialogResult result = DisplayError(ex);
            }
            return (resAffected);
        }
Exemplo n.º 5
0
        // Name: ProfileAdd
        //
        // Description:
        //      Insert a new profile
        //
        // Inputs:
        //      porfileDataSet  Data set containing rows to update.
        //      lastName        Last name value.
        //      firstName       First name value.
        //      email           Identifying email address.
        //      airport         Airport preference value.
        //      photoFile       Path to graphics image.
        //
        // Outputs:
        //      profileDataSet  Updated with new row.
        //
        // Returns:
        //      resAffected     Number of rows affected.
        //
        // History:
        //      02-Oct-2006 ([email protected])
        //          Created.
        private int ProfileAdd(ProfileDataSet profileDataSet, String lastName,
            String firstName, String email, String airport, String photoFile)
        {
            int resAffected = 0;
            try
            {
                // Make a new row can use clone or just invoke NewRow method
                // for the table.
                DataTable dataTable = profileDataSet.Tables["user_profile"].Clone();
                DataRow dataRow = dataTable.NewRow();

                // Populate the columns with new values.
                dataRow["up_last"] = lastName;
                dataRow["up_first"] = firstName;
                dataRow["up_email"] = email;
                dataRow["up_airport"] = airport;

                // If a path to an image is specfied convert it into a Byte
                // array value and assign it tp the up_image column.
                // If there is no path a default null value will be used.
                if (photoFile.Length > 0)
                {
                    MemoryStream stream = new MemoryStream();
                    Image photo = System.Drawing.Image.FromFile(photoFile);
                    photo.Save(stream, photo.RawFormat);
                    dataRow["up_image"] = stream.ToArray();
                    stream.Close();
                }
                // Add the row into the table.
                dataTable.Rows.Add(dataRow);

                // Clear the command parameter list.
                ingresDataAdapter6.InsertCommand.Parameters.Clear();

                // Associate the data row columns with the data set columns.
                ingresDataAdapter6.InsertCommand.Parameters.Add("@up_last",
                    Ingres.Client.IngresType.NVarChar, "up_last");
                ingresDataAdapter6.InsertCommand.Parameters.Add("@up_first",
                    Ingres.Client.IngresType.NVarChar, "up_first");
                ingresDataAdapter6.InsertCommand.Parameters.Add("@up_email",
                    Ingres.Client.IngresType.NVarChar, "up_email");
                ingresDataAdapter6.InsertCommand.Parameters.Add("@up_airport",
                    Ingres.Client.IngresType.NChar, "up_airport");
                ingresDataAdapter6.InsertCommand.Parameters.Add("@up_image",
                    Ingres.Client.IngresType.LongVarBinary, "up_image");

                // Perform the insert.
                resAffected = ingresDataAdapter6.Update(dataTable);
            }
            catch (IngresException ex)
            {
                DialogResult result = DisplayError(ex);
            }
            return (resAffected);
        }
Exemplo n.º 6
0
        // Name: SetProfileInfo
        //
        // Description:
        //      Sets the profile controls specified by the email address.
        //      The email address is defined as a key and should only return
        //      one row.
        //
        //      The prefered departure airport is used to set the default
        //      departing airport controls and the profile airport controls.
        //
        // Inputs:
        //      None.
        //
        // Outputs:
        //      None.
        //
        // Returns:
        //      None.
        //
        // History:
        //      02-Oct-2006 ([email protected])
        //          Created.
        private void SetProfileInfo(String email)
        {
            if ((email != null) && (email.Length > 0))
            {
                ProfileDataSet profileDataSet = new ProfileDataSet();

                // Set the check box if the specified email is the same as
                // the default email address.
                profileDefaultCheckBox.Checked =
                    (email.CompareTo(profileEmail) == 0) ? true : false;
                // Retrieve the data for the specified profile.
                LoadProfile(profileDataSet.Tables["user_profile"], email);

                if (profileDataSet.Tables["user_profile"].Rows.Count > 0)
                {
                    DataRow resultRow;
                    String lastName;
                    String firstName;
                    String IATAcode;
                    Image photo;

                    MemoryStream memoryStream;

                    // Take the first row to be the result row.
                    // There should only be one row.
                    resultRow = profileDataSet.Tables["user_profile"].Rows[0];
                    lastName = (string)
                        resultRow[resultRow.Table.Columns["up_last"].Ordinal];
                    firstName = (string)
                        resultRow[resultRow.Table.Columns["up_first"].Ordinal];
                    IATAcode = (string)
                        resultRow[resultRow.Table.Columns["up_airport"].Ordinal];

                    // Convert the BLOB into a memory stream object.
                    // If the column contains a null value don't try to load
                    // it into the PictureBox.
                    if (resultRow[resultRow.Table.Columns["up_image"].Ordinal]
                        != System.DBNull.Value)
                    {
                        memoryStream =
                            new MemoryStream(
                                (Byte[])resultRow.ItemArray[resultRow.Table.Columns["up_image"].Ordinal]
                                );

                        // Read the BLOB stream into an image object.
                        photo = Image.FromStream(memoryStream);

                        // Set the image into an image box.
                        profilePictureBox.Image = photo;
                    }
                    else
                    {
                        profilePictureBox.Image = profilePictureBox.ErrorImage;
                    }

                    // Set the combo box selected item or the text.
                    if (profileEmailComboBox.Items.Count > 0)
                    {
                        profileEmailComboBox.SelectedIndex =
                            profileEmailComboBox.FindString(email);
                    }
                    else
                    {
                        profileEmailComboBox.Text = email;
                    }

                    profileLastNameTextBox.Text = lastName;
                    profileFirstNameTextBox.Text = firstName;
                    welcomeLabel.Text = String.Format(
                        rm.GetString("ProfileWelcome"), firstName);
                    emailAddressLabel.Text = email;
                    airportPreferenceLabel.Text = IATAcode;
                    SetAirportControls(
                        new ComboBox[] { profileCountryComboBox, profileRegionComboBox, profileAirportComboBox },
                        IATAcode);

                    SetAirportControls(
                        new ComboBox[] { departCountryComboBox, departRegionComboBox, departAirportComboBox },
                        IATAcode);
                }
            }
        }
Exemplo n.º 7
0
        // Name: profileRemoveButton_Click
        //
        // Description:
        //      Handles the Remove button click event.
        //      Extracts the selected email value and deletes the row identified
        //      by it.
        //
        // Inputs:
        //      sender      Control object
        //      e           Event arguments
        //
        // Outputs:
        //      None.
        //
        // Returns:
        //      None.
        //
        // History:
        //      02-Oct-2006 ([email protected])
        //          Created.
        private void profileRemoveButton_Click(object sender, EventArgs e)
        {
            // Remove button click event.
            // Take the email address and delete the row identified.

            String email;
            ProfileDataSet profileDataSet = new ProfileDataSet();

            email = (profileEmailComboBox.Items.Count > 0) ?
                profileEmailComboBox.SelectedValue.ToString() :
                profileEmailComboBox.Text;

            if (email != null)
            {
                if (ProfileRemove(profileDataSet, email) > 0)
                {
                    if (profileEmail == email)
                    {
                        profileEmail = null;
                        profileDefaultCheckBox.Checked = false;
                    }
                    // Check each combo box in the list of combo boxes.
                    // Determine the type of the data source and clear the result
                    // set.
                    ComboBox[] comboBoxes = new ComboBox[] {
                    profileEmailComboBox,
                    profileRegionComboBox,
                    profileAirportComboBox };

                    ClearComboBoxes(comboBoxes);

                    profileLastNameTextBox.Clear();
                    profileFirstNameTextBox.Clear();
                    if (profileCountryComboBox.Items.Count > 0)
                    {
                        profileCountryComboBox.SelectedIndex = 0;
                    }
                    SetProfileControls();
                }
            }
        }
Exemplo n.º 8
0
        // Name: profileModifyButton_Click
        //
        // Description:
        //      Handles the Modify button click event.
        //      Activates all fields and populates the Email combo box list.
        //
        // Inputs:
        //      sender      Control object
        //      e           Event arguments
        //
        // Outputs:
        //      None.
        //
        // Returns:
        //      None.
        //
        // History:
        //      02-Oct-2006 ([email protected])
        //          Created.
        private void profileModifyButton_Click(object sender, EventArgs e)
        {
            // Modfy button click event.
            // Populate the email combo box list and convert from a text box.

            ProfileDataSet profileDataSet = new ProfileDataSet();
            BindingSource profileBindingSource = new BindingSource();
            String email;

            email = profileEmailComboBox.Text;
            profileBindingSource.DataSource = profileDataSet;
            profileBindingSource.DataMember = "profileList";
            profileEmailComboBox.DataSource = profileBindingSource;

            profileEmailComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
            profilePhotoTextBox.Clear();
            GetProfileList(profileDataSet.Tables["profileList"]);
            // Check that we have entries in the data set that populates
            // combo box.
            if (profileDataSet.Tables["profileList"].Rows.Count > 0)
            {
                // Temporaily remove the event handler for the
                // SelectedIndexChanged event.  Stops it from triggering while
                // combo box is updated.
                profileEmailComboBox.SelectedIndexChanged -=
                    profileEmailComboBox_SelectedIndexChanged;
                profileEmailComboBox.SelectedIndex =
                    profileEmailComboBox.FindString(email);
                // Reinstate the event handler for the
                // SelectedIndexChanged event.
                profileEmailComboBox.SelectedIndexChanged +=
                    profileEmailComboBox_SelectedIndexChanged;
                ShowGroupBoxes(profileGroupBoxes, new GroupBox[] {
                profilePersonalGroupBox,
                profilePreferenceGroupBox,
                profileAirportGroupBox});
                profileDefaultCheckBox.Enabled = true;
                ShowButtons(profileButtons, new Button[] { profileNewButton,
                profileModifyButton, profileRemoveButton,
                profileChangeButton });
            }
            else
            {
                // Alert for no results.
                DialogResult result = MessageBox.Show(rm.GetString("EmptyProfileList"),
                    rm.GetString("EmptyResultsCaption"),
                    MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 9
0
        // Name: profileEmailComboBox_SelectedIndexChanged
        //
        // Description:
        //      Handles a changed email selection.
        //      Retrieves information for the specified email selection.
        //      Updates all forms fields.
        //
        // Inputs:
        //      sender      Control object
        //      e           Event arguments
        //
        // Outputs:
        //      None.
        //
        // Returns:
        //      None.
        //
        // History:
        //      02-Oct-2006 ([email protected])
        //          Created.
        private void profileEmailComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Email combo box selected index changed event.
            // Set the profile form controls according to the specified email
            // address.
            ComboBox comboBox = (ComboBox)sender;
            ProfileDataSet profileDataSet = new ProfileDataSet();

            if (comboBox.SelectedValue != null)
            {
                String email = comboBox.SelectedValue.ToString();

                // Set the default check box if the default profile email
                // address is the same as the selected email address.
                profileDefaultCheckBox.Checked =
                    (email.CompareTo(profileEmail) == 0) ? true : false;

                LoadProfile(profileDataSet.Tables["user_profile"], email);
                if (profileDataSet.Tables["user_profile"].Rows.Count > 0)
                {
                    DataRow resultRow;
                    String lastName;
                    String firstName;
                    String IATAcode;
                    Image photo;

                    MemoryStream memoryStream;

                    // Take the first row to be the result row.
                    // There should only be one row.
                    resultRow = profileDataSet.Tables["user_profile"].Rows[0];
                    lastName = (string)
                        resultRow[resultRow.Table.Columns["up_last"].Ordinal];
                    firstName = (string)
                        resultRow[resultRow.Table.Columns["up_first"].Ordinal];
                    IATAcode = (string)
                        resultRow[resultRow.Table.Columns["up_airport"].Ordinal];
                    // If the column contains a null value don't try to load
                    // it into the PictureBox.
                    if (resultRow[resultRow.Table.Columns["up_image"].Ordinal]
                        != System.DBNull.Value)
                    {
                        memoryStream =
                            new MemoryStream(
                                (byte[])resultRow[resultRow.Table.Columns["up_image"].Ordinal]
                                );
                        photo = Image.FromStream(memoryStream);
                        profilePictureBox.Image = photo;
                    }
                    else
                    {
                        profilePictureBox.Image = profilePictureBox.ErrorImage;
                    }
                    // Check the items in the combo box list and set its value
                    // if there are entries in it.
                    if (profileEmailComboBox.Items.Count > 0)
                    {
                        profileEmailComboBox.SelectedIndex =
                            profileEmailComboBox.FindString(email);
                    }
                    else
                    {
                        profileEmailComboBox.Text = email;
                    }

                    profileLastNameTextBox.Text = lastName;
                    profileFirstNameTextBox.Text = firstName;
                    welcomeLabel.Text = String.Format(
                        rm.GetString("ProfileWelcome"), firstName);
                    emailAddressLabel.Text = email;
                    airportPreferenceLabel.Text = IATAcode;
                    SetAirportControls(
                        new ComboBox[] { profileCountryComboBox, profileRegionComboBox, profileAirportComboBox },
                        IATAcode);
                    ShowPanel(infoPanels, profilePanel);
                }
            }
        }
Exemplo n.º 10
0
        // Name: profileChangeButton_Click
        //
        // Description:
        //      Handles the Change button click event.
        //      Updates the row identified by the email address with the
        //      values from the form.
        //      All values, except the photo, are updated even if unchanged.
        //
        // Inputs:
        //      sender      Control object
        //      e           Event arguments
        //
        // Outputs:
        //      None.
        //
        // Returns:
        //      None.
        //
        // History:
        //      02-Oct-2006 ([email protected])
        //          Created.
        private void profileChangeButton_Click(object sender, EventArgs e)
        {
            // Change button click event.
            // Update the values in the table for the specified email
            // address.
            DialogResult result;

            if ((result = ProfileCheckItems()) == DialogResult.OK)
            {
                ProfileDataSet profileDataSet = new ProfileDataSet();

                String email;
                String lastName;
                String firstName;
                String airport;
                String photoPath;

                email = (profileEmailComboBox.Items.Count > 0) ?
                    profileEmailComboBox.SelectedValue.ToString() :
                    profileEmailComboBox.Text;
                airport = (profileAirportComboBox.Items.Count > 0) ?
                    profileAirportComboBox.SelectedValue.ToString() :
                    profileAirportComboBox.Text;

                lastName = profileLastNameTextBox.Text;
                firstName = profileFirstNameTextBox.Text;
                photoPath = profilePhotoTextBox.Text;

                LoadProfile(profileDataSet.Tables["user_profile"], email);

                if (ProfileChange(profileDataSet,
                    lastName,
                    firstName,
                    email,
                    airport,
                    photoPath) > 0)
                {
                    ShowButtons(profileButtons,
                        new Button[] {
                            profileModifyButton,
                            profileNewButton,
                            profileRemoveButton,
                            profileChangeButton });
                    if (profileDefaultCheckBox.Checked == true)
                    {
                        profileEmail = email;
                        WriteConfiguration(appConfigFile);
                    }
                    SetProfileInfo(email);
                    ShowPanel(infoPanels, profilePanel);
                }
            }
            else if (result == DialogResult.Cancel)
            {
                Exception ex = new Exception("Change aborted");
                throw ex;
            }
        }
Exemplo n.º 11
0
        // Name: profileEmailComboBox_SelectedIndexChanged
        //
        // Description:
        //      Handles a changed email selection.
        //      Retrieves information for the specified email selection.
        //      Updates all forms fields.
        //
        // Inputs:
        //      sender      Control object
        //      e           Event arguments
        //
        // Outputs:
        //      None.
        //
        // Returns:
        //      None.
        //
        // History:
        //      02-Oct-2006 ([email protected])
        //          Created.
        private void profileEmailComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Email combo box selected index changed event.
            // Set the profile form controls according to the specified email
            // address.
            ComboBox       comboBox       = (ComboBox)sender;
            ProfileDataSet profileDataSet = new ProfileDataSet();

            if (comboBox.SelectedValue != null)
            {
                String email = comboBox.SelectedValue.ToString();

                // Set the default check box if the default profile email
                // address is the same as the selected email address.
                profileDefaultCheckBox.Checked =
                    (email.CompareTo(profileEmail) == 0) ? true : false;

                LoadProfile(profileDataSet.Tables["user_profile"], email);
                if (profileDataSet.Tables["user_profile"].Rows.Count > 0)
                {
                    DataRow resultRow;
                    String  lastName;
                    String  firstName;
                    String  IATAcode;
                    Image   photo;

                    MemoryStream memoryStream;

                    // Take the first row to be the result row.
                    // There should only be one row.
                    resultRow = profileDataSet.Tables["user_profile"].Rows[0];
                    lastName  = (string)
                                resultRow[resultRow.Table.Columns["up_last"].Ordinal];
                    firstName = (string)
                                resultRow[resultRow.Table.Columns["up_first"].Ordinal];
                    IATAcode = (string)
                               resultRow[resultRow.Table.Columns["up_airport"].Ordinal];
                    // If the column contains a null value don't try to load
                    // it into the PictureBox.
                    if (resultRow[resultRow.Table.Columns["up_image"].Ordinal]
                        != System.DBNull.Value)
                    {
                        memoryStream =
                            new MemoryStream(
                                (byte[])resultRow[resultRow.Table.Columns["up_image"].Ordinal]
                                );
                        photo = Image.FromStream(memoryStream);
                        profilePictureBox.Image = photo;
                    }
                    else
                    {
                        profilePictureBox.Image = profilePictureBox.ErrorImage;
                    }
                    // Check the items in the combo box list and set its value
                    // if there are entries in it.
                    if (profileEmailComboBox.Items.Count > 0)
                    {
                        profileEmailComboBox.SelectedIndex =
                            profileEmailComboBox.FindString(email);
                    }
                    else
                    {
                        profileEmailComboBox.Text = email;
                    }

                    profileLastNameTextBox.Text  = lastName;
                    profileFirstNameTextBox.Text = firstName;
                    welcomeLabel.Text            = String.Format(
                        rm.GetString("ProfileWelcome"), firstName);
                    emailAddressLabel.Text      = email;
                    airportPreferenceLabel.Text = IATAcode;
                    SetAirportControls(
                        new ComboBox[] { profileCountryComboBox, profileRegionComboBox, profileAirportComboBox },
                        IATAcode);
                    ShowPanel(infoPanels, profilePanel);
                }
            }
        }
Exemplo n.º 12
0
        // Name: SetProfileInfo
        //
        // Description:
        //      Sets the profile controls specified by the email address.
        //      The email address is defined as a key and should only return
        //      one row.
        //
        //      The prefered departure airport is used to set the default
        //      departing airport controls and the profile airport controls.
        //
        // Inputs:
        //      None.
        //
        // Outputs:
        //      None.
        //
        // Returns:
        //      None.
        //
        // History:
        //      02-Oct-2006 ([email protected])
        //          Created.
        private void SetProfileInfo(String email)
        {
            if ((email != null) && (email.Length > 0))
            {
                ProfileDataSet profileDataSet = new ProfileDataSet();

                // Set the check box if the specified email is the same as
                // the default email address.
                profileDefaultCheckBox.Checked =
                    (email.CompareTo(profileEmail) == 0) ? true : false;
                // Retrieve the data for the specified profile.
                LoadProfile(profileDataSet.Tables["user_profile"], email);

                if (profileDataSet.Tables["user_profile"].Rows.Count > 0)
                {
                    DataRow resultRow;
                    String  lastName;
                    String  firstName;
                    String  IATAcode;
                    Image   photo;

                    MemoryStream memoryStream;

                    // Take the first row to be the result row.
                    // There should only be one row.
                    resultRow = profileDataSet.Tables["user_profile"].Rows[0];
                    lastName  = (string)
                                resultRow[resultRow.Table.Columns["up_last"].Ordinal];
                    firstName = (string)
                                resultRow[resultRow.Table.Columns["up_first"].Ordinal];
                    IATAcode = (string)
                               resultRow[resultRow.Table.Columns["up_airport"].Ordinal];

                    // Convert the BLOB into a memory stream object.
                    // If the column contains a null value don't try to load
                    // it into the PictureBox.
                    if (resultRow[resultRow.Table.Columns["up_image"].Ordinal]
                        != System.DBNull.Value)
                    {
                        memoryStream =
                            new MemoryStream(
                                (Byte[])resultRow.ItemArray[resultRow.Table.Columns["up_image"].Ordinal]
                                );

                        // Read the BLOB stream into an image object.
                        photo = Image.FromStream(memoryStream);

                        // Set the image into an image box.
                        profilePictureBox.Image = photo;
                    }
                    else
                    {
                        profilePictureBox.Image = profilePictureBox.ErrorImage;
                    }

                    // Set the combo box selected item or the text.
                    if (profileEmailComboBox.Items.Count > 0)
                    {
                        profileEmailComboBox.SelectedIndex =
                            profileEmailComboBox.FindString(email);
                    }
                    else
                    {
                        profileEmailComboBox.Text = email;
                    }

                    profileLastNameTextBox.Text  = lastName;
                    profileFirstNameTextBox.Text = firstName;
                    welcomeLabel.Text            = String.Format(
                        rm.GetString("ProfileWelcome"), firstName);
                    emailAddressLabel.Text      = email;
                    airportPreferenceLabel.Text = IATAcode;
                    SetAirportControls(
                        new ComboBox[] { profileCountryComboBox, profileRegionComboBox, profileAirportComboBox },
                        IATAcode);

                    SetAirportControls(
                        new ComboBox[] { departCountryComboBox, departRegionComboBox, departAirportComboBox },
                        IATAcode);
                }
            }
        }