Ejemplo n.º 1
0
        // BaseData class will be parent of this class
        public void InsertParkingSpace(ParkingSpace parkingSpace)
        {
            SqlConnection connection = ManageDatabaseConnection("Open");

            try
            {
                using (SqlCommand sqlCommand = new SqlCommand("insert_newParkingSpace", connection))
                {

                    sqlCommand.CommandType = CommandType.StoredProcedure;
                    sqlCommand.Parameters.Add("@SpaceNumber", SqlDbType.VarChar).Value = parkingSpace.SpaceNumber;
                    sqlCommand.Parameters.Add("@IdParkingLot", SqlDbType.Int).Value = parkingSpace.IdParkingLot;

                    sqlCommand.ExecuteNonQuery();
                    connection = ManageDatabaseConnection("Close");
                }
            }
            catch (SqlException sqlException)
            {

                throw sqlException;
            }
        }
Ejemplo n.º 2
0
 public void InsertNewParkingSpace(ParkingSpace parkingSpace)
 {
     parkingSpaceData.InsertParkingSpace(parkingSpace);
 }
Ejemplo n.º 3
0
        void insertSpaceInDB()
        {
            ParkingSpace newSpace = new ParkingSpace(TextBoxSpaceIdentifier.Text, 1);
                ParkingSpaceTransaction newSpaceTransaction = new ParkingSpaceTransaction();
                newSpaceTransaction.InsertNewParkingSpace(newSpace);

                ParkingSpaceTransaction transaction = new ParkingSpaceTransaction();
                List<string> existingSpaces = transaction.PrintExistingSpaces(1);
                printInScreen(existingSpaces);
        }