Exemplo n.º 1
0
        public string Login(string username, string password)
        {
            string[] valores = new string[2];
            bool     isFill  = false;

            try
            {
                Connection c = new Connection();
                // En base de este documento: https://www.c-sharpcorner.com/article/calling-oracle-stored-procedures-from-microsoft-net/
                // Otro: https://stackoverflow.com/questions/3940587/calling-oracle-stored-procedure-from-c
                OracleDataAdapter adapter = new OracleDataAdapter();
                OracleCommand     comm    = new OracleCommand();
                comm.Connection = c.Conn;
                // retorna usuario y perfil
                comm.CommandText = "pkg_usuariosv2.login_usuario";
                comm.CommandType = System.Data.CommandType.StoredProcedure;
                comm.Parameters.Add("in_username", OracleDbType.Varchar2, 30, "username").Value = username;
                comm.Parameters.Add("in_password", OracleDbType.Varchar2, 20, "password").Value = password;
                comm.Parameters.Add("t_cursor", OracleDbType.RefCursor).Direction = System.Data.ParameterDirection.Output;
                using (OracleDataReader reader = comm.ExecuteReader())
                {
                    string usuario = string.Empty;
                    string perfil  = string.Empty;
                    while (reader.Read())
                    {
                        usuario    = reader[0].ToString();
                        perfil     = reader[1].ToString();
                        valores[0] = usuario;
                        valores[1] = perfil;
                        isFill     = true;
                    }
                    c.Close();
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
            }

            return(isFill ? isFill.ToString() : f.Return("Usuario y/o contraseño no válidos"));
        }
        public string UpdateProducto(int id, string nombre, string descripcion, int id_tipoproducto)
        {
            string r = string.Empty;

            try
            {
                Connection        c       = new Connection();
                OracleDataAdapter adapter = new OracleDataAdapter();
                OracleCommand     comm    = new OracleCommand();
                comm.Connection = c.Conn;
                // retorna usuario y perfil
                comm.CommandText = "pkg_productos.update_productos";
                comm.CommandType = System.Data.CommandType.StoredProcedure;
                comm.Parameters.Add("in_id_producto", OracleDbType.Int32, 38, "id_producto").Value         = id;
                comm.Parameters.Add("in_nombre", OracleDbType.Varchar2, 50, "nombre").Value                = nombre;
                comm.Parameters.Add("in_descripcion", OracleDbType.Varchar2, 200, "descripcion").Value     = descripcion;
                comm.Parameters.Add("in_id_tipoproducto", OracleDbType.Int32, 38, "id_tipoproducto").Value = id_tipoproducto;
                OracleParameter param = comm.Parameters.Add("response", OracleDbType.Int32, ParameterDirection.Output);

                comm.ExecuteNonQuery();
                var responseQuery = param.Value.ToString();
                if (responseQuery == "1")
                {
                    r = "El producto ha sido actualizada";
                }
                else
                {
                    r = "No se ha actualizado ningún producto";
                }

                c.Close();
            }
            catch (Exception e)
            {
                r = "Ha ocurrido un error";
                Debug.WriteLine(e.ToString());
            }
            return(f.Return(r));
        }
Exemplo n.º 3
0
        public string InsertVenta(int fk_usuario, DateTime fecha, int fk_tipoVenta)
        {
            string r = string.Empty;

            try
            {
                Connection        c       = new Connection();
                OracleDataAdapter adapter = new OracleDataAdapter();
                OracleCommand     comm    = new OracleCommand();
                comm.Connection = c.Conn;
                // retorna usuario y perfil
                comm.CommandText = "pkg_ventas.insert_ventas";
                comm.CommandType = System.Data.CommandType.StoredProcedure;
                comm.Parameters.Add("in_id_usuario", OracleDbType.Int32, 38, "id_usuario").Value     = fk_usuario;
                comm.Parameters.Add("in_fecha", OracleDbType.Date, 30, "fecha").Value                = fecha;
                comm.Parameters.Add("in_id_tipoventa", OracleDbType.Int32, 38, "id_tipoventa").Value = fk_tipoVenta;
                OracleParameter param = comm.Parameters.Add("response", OracleDbType.Int32, ParameterDirection.Output);

                comm.ExecuteNonQuery();
                var responseQuery = param.Value.ToString();
                if (responseQuery == "1")
                {
                    r = "Venta Ingresada.";
                }
                else
                {
                    r = "Venta no ha sido ingresada. Consulte con el equipo técnico.";
                }

                c.Close();
            }
            catch (Exception e)
            {
                r = "Ha ocurrido un error.";
                Debug.WriteLine(e.ToString());
            }
            return(f.Return(r));
        }
Exemplo n.º 4
0
        public string UpdateVenta(int id, DateTime fecha_inicio, DateTime fecha_termino)
        {
            string r = string.Empty;

            try
            {
                Connection        c       = new Connection();
                OracleDataAdapter adapter = new OracleDataAdapter();
                OracleCommand     comm    = new OracleCommand();
                comm.Connection = c.Conn;
                // retorna usuario y perfil
                comm.CommandText = "pkg_contratos.update_contratos";
                comm.CommandType = System.Data.CommandType.StoredProcedure;
                comm.Parameters.Add("in_id", OracleDbType.Int32, 38, "id").Value = id;
                comm.Parameters.Add("in_fecha_inicio", OracleDbType.Date, 30, "fecha_inicio").Value   = fecha_inicio;
                comm.Parameters.Add("in_fecha_termino", OracleDbType.Date, 30, "fecha_termino").Value = fecha_termino;
                OracleParameter param = comm.Parameters.Add("response", OracleDbType.Int32, ParameterDirection.Output);

                comm.ExecuteNonQuery();
                var responseQuery = param.Value.ToString();
                if (responseQuery == "1")
                {
                    r = "El contrato ha sido actualizado";
                }
                else
                {
                    r = "No se ha actualizado ningún contrato";
                }

                c.Close();
            }
            catch (Exception e)
            {
                r = "Ha ocurrido un error";
                Debug.WriteLine(e.ToString());
            }
            return(f.Return(r));
        }
Exemplo n.º 5
0
        public string InsertDetalleVenta(int id_producto, int id_venta, int cantidad)
        {
            string r = string.Empty;

            try
            {
                Connection        c       = new Connection();
                OracleDataAdapter adapter = new OracleDataAdapter();
                OracleCommand     comm    = new OracleCommand();
                comm.Connection = c.Conn;
                // retorna usuario y perfil
                comm.CommandText = "pkg_detalle_venta.insert_detalle_venta";
                comm.CommandType = System.Data.CommandType.StoredProcedure;
                comm.Parameters.Add("in_id_producto", OracleDbType.Int32, 38, "id_usuario").Value = id_producto;
                comm.Parameters.Add("in_id_venta", OracleDbType.Int32, 38, "id_venta").Value      = id_venta;
                comm.Parameters.Add("in_cantidad", OracleDbType.Int32, 38, "cantidad").Value      = cantidad;
                OracleParameter param = comm.Parameters.Add("response", OracleDbType.Int32, ParameterDirection.Output);
                comm.ExecuteNonQuery();
                var responseQuery = param.Value.ToString();
                if (responseQuery == "1")
                {
                    r = "Detalle de venta ingresado.";
                }
                else
                {
                    r = "Detalle de venta no ha sido ingresada. Consulte con el equipo técnico.";
                }

                c.Close();
            }
            catch (Exception e)
            {
                r = "Ha ocurrido un error.";
                Debug.WriteLine(e.ToString());
            }
            return(f.Return(r));
        }
Exemplo n.º 6
0
        public string UpdateOfertaGanadora(int id_oferta)
        {
            string r = string.Empty;

            try
            {
                Connection        c       = new Connection();
                OracleDataAdapter adapter = new OracleDataAdapter();
                OracleCommand     comm    = new OracleCommand();
                comm.Connection = c.Conn;
                // retorna usuario y perfil
                comm.CommandText = "PKG_OFERTAS.update_oferta_ganadora";
                comm.CommandType = System.Data.CommandType.StoredProcedure;
                comm.Parameters.Add("in_id_oferta", OracleDbType.Int32, 38, "id_oferta").Value = id_oferta;
                OracleParameter param = comm.Parameters.Add("response", OracleDbType.Int32, ParameterDirection.Output);

                comm.ExecuteNonQuery();
                var responseQuery = param.Value.ToString();
                if (responseQuery == "1")
                {
                    r = "La oferta ha sido actualizada";
                }
                else
                {
                    r = "No se ha actualizado ninguna oferta";
                }

                c.Close();
            }
            catch (Exception e)
            {
                r = "Ha ocurrido un error";
                Debug.WriteLine(e.ToString());
            }
            return(f.Return(r));
        }