Ejemplo n.º 1
0
        private void AddRoomButton_Click(object sender, EventArgs e)
        {
            string roomGUID     = Guid.NewGuid().ToString().ToUpper();
            string floorGUID_fk = FloorListBox2.SelectedValue.ToString();
            string roomTypeGUID = RoomTypeListBox2.SelectedValue.ToString();
            string roomNumber   = Convert.ToString(RoomNumberTextBox.Text);

            SqlConnection mySqlConnection = new SqlConnection(connectionString);

            mySqlConnection.Open();

            SqlCommand mySqlCommand = mySqlConnection.CreateCommand();

            mySqlCommand.CommandText = "INSERT INTO Rooms(roomGUID,floorGUID_fk,roomTypeGUID_fk,roomNumber) VALUES('" +
                                       roomGUID + "','" +
                                       floorGUID_fk + "','" +
                                       roomTypeGUID + "','" +
                                       roomNumber + "')";

            mySqlCommand.ExecuteNonQuery();
            mySqlConnection.Close();

            PopulateRoomListBox();

            RoomNumberTextBox.Text = "";
            RoomNumberTextBox.Focus();
        }