Esempio n. 1
0
        public void queryMembershipNumber()
        {
            // Create a connection to the Sql Database
            SqlConnection connection = new SqlConnection();

            connection.ConnectionString = "Server=cis1.actx.edu;Database=Project1;User Id=db1;Password=db10;";
            connection.Open();

            // Instantiate the garage app
            Reservation_App_V2 reserve = new Reservation_App_V2();

            // Create a variable that holds the data from the Reservation App text box
            string membershipNumber = reserve.txtMemberID.Text;

            // Reads the information from the database
            using (SqlCommand queryInfoByNumber = connection.CreateCommand())
            {
                queryInfoByNumber.CommandText = "select * from dbo.Reservations where MemID = '" + membershipNumber + "'";

                using (SqlDataReader reader = queryInfoByNumber.ExecuteReader())
                {
                    string rec = "";
                    while (reader.Read())
                    {
                        // Write the information out to the end-user
                        rec  = "Membership ID: ";
                        rec += reader.GetInt32(0) + "\n";
                        rec += "License Plate: " + reader.GetString(1) + "\n";
                        rec += "Time In: " + reader.GetTimeSpan(2) + "\n";
                        rec += "Time Out: " + reader.GetTimeSpan(3) + "\n";
                        rec += "Spot ID: " + reader.GetString(4) + "\n";
                        rec += "Reservation Date: " + reader.GetDateTime(5) + "\n";
                        rec += "Reservation ID: " + reader.GetInt32(6);
                        Console.WriteLine(rec);
                        Console.ReadKey();
                    }
                }
            }
        }
Esempio n. 2
0
        private void button3_Click(object sender, EventArgs e)
        {
            Reservation_App_V2 res = new Reservation_App_V2();

            res.Show();
        }