public void InsertPieceOfFurniture(PieceOfFurniture pieceoffurniture)
        {
            using (SqlConnection connection = CreateConnection())
            {
                try
                {
                    SqlCommand command = new SqlCommand("appSchema.usp_NyMöbel", connection);
                    command.CommandType = CommandType.StoredProcedure;

                    command.Parameters.Add("@Beskrivning", SqlDbType.VarChar, 50).Value = pieceoffurniture.Description;
                    command.Parameters.Add("@Pris", SqlDbType.Decimal, 6).Value         = pieceoffurniture.Price;
                    command.Parameters.Add("@Inköpspris", SqlDbType.Decimal, 6).Value   = pieceoffurniture.BuyingPrice;
                    command.Parameters.Add("@Antal", SqlDbType.Int, 4).Value            = pieceoffurniture.Quantity;

                    command.Parameters.Add("@MöbelID", SqlDbType.Int, 4).Direction = ParameterDirection.Output;

                    connection.Open();
                    command.ExecuteNonQuery();
                    pieceoffurniture.PieceOfFurnitureID = (int)command.Parameters["@MöbelID"].Value;
                }
                catch
                {
                    throw new ApplicationException("Ett fel uppstod i dataåtkomstlagret.");
                }
            }
        }
 public void FurnitureListView_InsertItem(PieceOfFurniture pieceoffurniture)
 {
     if (ModelState.IsValid)
     {
         try
         {
             Service.SavePieceOfFurniture(pieceoffurniture);
             Label1.Visible = true;
         }
         catch (Exception)
         {
             ModelState.AddModelError(String.Empty, "Ett oväntat fel inträffade då möbeluppgift skulle läggas till.");
         }
     }
 }