Exemple #1
0
        /// <summary>
        /// Consigue la información del modelo que corresponde al mueble recibido desde la base de datos
        /// </summary>
        /// <param name="m">mueble del cual queremos información</param>
        /// <returns></returns>
        public static string GetDetalleMueble(Mueble m)
        {
            StringBuilder sb = new StringBuilder();

            command.CommandText = $"SELECT Descripcion,Alto,Ancho,Profundidad FROM Modelo where Modelo.Identificador = @id";
            command.Parameters.Clear();
            command.Parameters.AddWithValue("@id", m.IDModelo);
            try
            {
                conexion.Open();
                SqlDataReader oDr = command.ExecuteReader();

                while (oDr.Read())
                {
                    sb.AppendLine(oDr["Descripcion"].ToString());
                    sb.AppendLine($"Alto: {oDr["Alto"].ToString()}cm");
                    sb.AppendLine($"Ancho: {oDr["Ancho"].ToString()}cm");
                    sb.AppendLine($"Profundidad: {oDr["Profundidad"].ToString()}cm");
                }
                return(sb.ToString());
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                if (conexion.State != System.Data.ConnectionState.Closed)
                {
                    conexion.Close();
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// Inserta un mueble en la base de datos
 /// </summary>
 /// <param name="m">mueble a insertar</param>
 public static void Insert(Mueble m)
 {
     command.CommandText = "INSERT INTO Mueble" +
                           "(Guid,IdModelo,FechaDeFabricacion,FechaDeEnvio,Color) " +
                           "VALUES(@Guid, @IdModelo, @FechaDeFabricacion,GETDATE(),@Color)";
     command.Parameters.AddWithValue("@Guid", m.CodigoGuid.ToString());
     command.Parameters.AddWithValue("@IdModelo", m.IDModelo);
     command.Parameters.AddWithValue("@FechaDeFabricacion", m.FechaDeFabricacion);
     command.Parameters.AddWithValue("@Color", m.ColorString);
     Ejecutar();
 }