コード例 #1
0
ファイル: Program_Bd.cs プロジェクト: esuchecki/GDD_DALE_SA
        public Boolean ofertar(publicar_dto dto)
        {
            /*
             *         USE [GD1C2016]
             * GO
             *
             * DECLARE @RC int
             * DECLARE @idusuario numeric(18,0)
             * DECLARE @idpublicacion numeric(18,0)
             * DECLARE @fecha nvarchar(255)
             * DECLARE @envio bit
             * DECLARE @monto numeric(18,2)
             *
             * -- TODO: Establezca los valores de los parámetros aquí.
             *
             * EXECUTE @RC = [DALE_SA].[pr_ofertar]
             * @idusuario
             * ,@idpublicacion
             * ,@fecha
             * ,@envio
             * ,@monto
             * GO
             */
            try
            {
                //conectar();

                using (var command = new SqlCommand("DALE_SA.pr_ofertar")
                {
                    CommandType = CommandType.StoredProcedure
                })
                {
                    //var dt = new DataTable(); //create your own data table
                    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("@monto", dto.getprecio());


                    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);
        }
コード例 #2
0
ファイル: Program_Bd.cs プロジェクト: esuchecki/GDD_DALE_SA
        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);
        }
コード例 #3
0
ファイル: Program_Bd.cs プロジェクト: esuchecki/GDD_DALE_SA
        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);
        }
コード例 #4
0
ファイル: Program_Bd.cs プロジェクト: esuchecki/GDD_DALE_SA
        public int AMBvisibilidad(publicar_dto dto)
        {
            int retorno = -1;

            try
            {
                /*
                 * @idvisibilidad AS Numeric(18,0),
                 * @descripcion AS Nvarchar(255),
                 * @porcentaje_venta  AS numeric(18,2),
                 * @precio_publicacion AS numeric(18,2),
                 * @precio_envio AS numeric(18,2),
                 * @codigo AS numeric(18),
                 * @estado AS bit,
                 * @accion AS numeric(1))
                 */

                using (var command = new SqlCommand("DALE_SA.ABMvisibilidad")
                {
                    CommandType = CommandType.StoredProcedure
                })
                {
                    //var dt = new DataTable(); //create your own data table


                    /*  MessageBox.Show("idv"+dto.getidvisibilidad());
                     *
                     * MessageBox.Show("D"+dto.getdescripcion());
                     *
                     * MessageBox.Show("C"+dto.getidrubro());
                     *
                     * MessageBox.Show("P"+dto.getporc());
                     *
                     * MessageBox.Show("E"+dto.getcosto());
                     *
                     * MessageBox.Show("Preci"+dto.getprecio());
                     *
                     * MessageBox.Show("ACCION" + dto.gettipo_publicacion());*/



                    command.Parameters.AddWithValue("@idvisibilidad", dto.getidvisibilidad());
                    command.Parameters.AddWithValue("@descripcion", dto.getdescripcion());
                    command.Parameters.AddWithValue("@porcentaje_venta", dto.getporc());
                    command.Parameters.AddWithValue("@precio_publicacion", dto.getprecio());
                    command.Parameters.AddWithValue("@precio_envio", dto.getcosto());
                    command.Parameters.AddWithValue("@codigo", dto.getidrubro());
                    command.Parameters.AddWithValue("@estado", dto.getestado());
                    command.Parameters.AddWithValue("@accion", dto.gettipo_publicacion());

                    SqlParameter retval = command.Parameters.Add("@b", SqlDbType.Int);
                    retval.Direction = ParameterDirection.ReturnValue;



                    command.Connection = cnn;

                    conectar();



                    command.ExecuteNonQuery();
                    retorno = (int)command.Parameters["@b"].Value;
                }
                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());
                //MessageBox.Show(ex.ToString());
                System.Console.WriteLine("-1");
                return(-1);
            }
            finally //si tiro error o si todo bien, cierra la sesion.
            {
                desconectar();
            }
            System.Console.WriteLine("CONSULTA SQL OK33333");
            return(retorno);
        }