Example #1
0
        public Boolean publicar(publicar_dto dto)
        {
            /*
             *        @stock = 1,
             *  @descripcion = N'des',
             *  @estado = 1,
             *  @idvisibilidad = 1,
             *  @fecha_inicio = N'//',
             *  @fecha_vencimiento = N'//',
             *  @permitir_preguntas = 1,
             *  @precio = 1.1,
             *  @costo = 1.1,
             *  @tipo_publicacion = N'Directa',
             *  @idrubro = 1,
             *  @idusuario = 1
             */
            //DataTable resultadoConsulta;
            try
            {
                //conectar();

                using (var command = new SqlCommand("DALE_SA.pr_publicar")
                {
                    CommandType = CommandType.StoredProcedure
                })
                {
                    //var dt = new DataTable(); //create your own data table
                    command.Parameters.AddWithValue("@stock", dto.getstock());
                    command.Parameters.AddWithValue("@descripcion", dto.getdescripcion());
                    command.Parameters.AddWithValue("@estado", dto.getestado());
                    command.Parameters.AddWithValue("@idvisibilidad", dto.getidvisibilidad());
                    command.Parameters.AddWithValue("@fecha_inicio", dto.getfecha_inicio());
                    command.Parameters.AddWithValue("@fecha_vencimiento", dto.getfecha_vencimiento());
                    command.Parameters.AddWithValue("@permitir_preguntas", dto.getpermitir_preguntas());
                    command.Parameters.AddWithValue("@permitir_envio", dto.getenvio());
                    command.Parameters.AddWithValue("@precio", dto.getprecio());
                    command.Parameters.AddWithValue("@costo", dto.getcosto());
                    command.Parameters.AddWithValue("@tipo_publicacion", dto.gettipo_publicacion());
                    command.Parameters.AddWithValue("@idrubro", dto.getidrubro());
                    command.Parameters.AddWithValue("@idusuario", dto.getidusuario());
                    command.Connection = cnn;

                    conectar();
                    command.ExecuteNonQuery();
                }
                System.Console.WriteLine("CONSULTA SQL OK");
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("Hubo un problema con la peticion");
                return(false);
            }
            finally //si tiro error o si todo bien, cierra la sesion.
            {
                desconectar();
            }
            return(true);
        }
Example #2
0
        public Boolean comprar(publicar_dto dto)
        {
            /*
             *  DECLARE @RC int
             *  DECLARE @cantidad numeric(18,0)
             *  DECLARE @idusuario numeric(18,0)
             *  DECLARE @idpublicacion numeric(18,0)
             *  DECLARE @fecha nvarchar(255)
             *  DECLARE @idvisibilidad numeric(18,0)
             *  DECLARE @envio bit
             *  DECLARE @precio numeric(18,2)
             * EXECUTE @RC = [DALE_SA].[pr_comprar]
             * @cantidad
             * ,@idusuario
             * ,@idpublicacion
             * ,@fecha
             * ,@idvisibilidad
             * ,@envio
             * ,@precio
             */
            try
            {
                //conectar();

                using (var command = new SqlCommand("DALE_SA.pr_comprar")
                {
                    CommandType = CommandType.StoredProcedure
                })
                {
                    //var dt = new DataTable(); //create your own data table
                    command.Parameters.AddWithValue("@cantidad", dto.getstock());
                    command.Parameters.AddWithValue("@idusuario", dto.getidusuario());
                    command.Parameters.AddWithValue("@idpublicacion", dto.getidpubliacion());
                    command.Parameters.AddWithValue("@fecha", dto.getfechasys());
                    command.Parameters.AddWithValue("@envio", dto.getenvio());
                    command.Parameters.AddWithValue("@precio", dto.getprecio());
                    System.Console.WriteLine("SARARARAR: " + command.ToString());

                    command.Connection = cnn;

                    conectar();
                    command.ExecuteNonQuery();
                }
                System.Console.WriteLine("CONSULTA SQL OK");
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("Hubo un problema con la peticion");
                System.Console.WriteLine("Execpcion decimal compra: " + ex.ToString());
                return(false);
            }
            finally //si tiro error o si todo bien, cierra la sesion.
            {
                desconectar();
            }
            return(true);
        }