Exemplo n.º 1
0
        public static string getPassenger()
        {
            string pstr;

            string   firstname, midname, lastname, age, gender, birthdate;
            DateTime birth;

            tempID = PassengerContainer.accessPassenger();

            DataSet dsPassenger = new DataSet();

            SQLConnection.Instance.OpenConnection();

            MySqlCommand     passData = new MySqlCommand();
            MySqlDataAdapter daPass   = new MySqlDataAdapter("select * from Passenger where PassengerID = '" + tempID + "';", SQLConnection.Instance.GetConnection());

            daPass.Fill(dsPassenger);

            SQLConnection.Instance.CloseConnection();

            DataRow dataRow = dsPassenger.Tables[0].Rows[0];

            firstname = (string)dataRow[1];
            midname   = (string)dataRow[2];
            lastname  = (string)dataRow[3];
            age       = (string)dataRow[4];
            gender    = (string)dataRow[5];
            birth     = (DateTime)dataRow[6];

            PassengerContainer.removePassengers();

            string date = birth.ToString("d");

            birthdate = DateTime.Parse(date).ToString("MM-dd-yyyy");

            if (string.IsNullOrEmpty(midname))
            {
                midname = " ";
            }
            else
            {
                midname = " " + midname + " ";
            }

            age = getAge(age);

            pstr = firstname + midname + lastname + "\nAge: " + age + " Gender: " + gender + " Birthdate: " + birthdate;

            return(pstr);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets passsenger first and last name to display in the label of the form.
        /// </summary>
        private void getPassenger()
        {
            PassengerContainer.setPassengerID(PassengerContainer.accessPassenger());

            string FirstName, LastName;

            SQLConnection.Instance.OpenConnection();

            MySqlCommand findFirst = new MySqlCommand("select FirstName from Passenger where PassengerID = '" + PassengerContainer.getPassengerID() + "';", SQLConnection.Instance.GetConnection());

            FirstName = (string)findFirst.ExecuteScalar();

            MySqlCommand findLast = new MySqlCommand("select LastName from Passenger where PassengerID = '" + PassengerContainer.getPassengerID() + "';", SQLConnection.Instance.GetConnection());

            LastName = (string)findLast.ExecuteScalar();

            pass_info_label.Text = "Passenger: " + FirstName + " " + LastName;

            SQLConnection.Instance.CloseConnection();
        }