Esempio n. 1
0
        /******************************************************************** LISTAR INGREDIENTE - FORMULACAO ********************************************************************/
        public List <Formulacao> DetalhesIngrediente(String ID, Object CodigoFormulacao)
        {
            //SqlConnection Conexao = new SqlConnection(ConfigurationManager.ConnectionStrings["BancoEstoque"].ConnectionString);
            SqlConnection Conexao = new SqlConnection("Server = DESKTOP-PHTQI5U\\SQLEXPRESS; Database = DRLTCC; Trusted_Connection = True;");

            Conexao.Open();
            SqlCommand Comando = new SqlCommand();

            Comando.Connection = Conexao;

            Comando.CommandText = "SELECT P.Porcentagem, I.NomeIngrediente FROM Formu_Ingrediente P JOIN Ingrediente I on CodigoIngrediente = FK_CodigoIngrediente WHERE FK_CodigoIngrediente = @FK_CodigoIngrediente AND FK_CodigoFormulacao = @FK_CodigoFormulacao;";
            Comando.Parameters.AddWithValue("@FK_CodigoIngrediente", ID);
            Comando.Parameters.AddWithValue("@FK_CodigoFormulacao", CodigoFormulacao);

            SqlDataReader Leitor = Comando.ExecuteReader();

            List <Formulacao> DetalheIngrediente = new List <Formulacao>();

            while (Leitor.Read())
            {
                Formulacao F = new Formulacao();
                F.NomeIngrediente = Leitor["NomeIngrediente"].ToString();
                F.Porcentagem     = Convert.ToDouble(Leitor["Porcentagem"].ToString());
                DetalheIngrediente.Add(F);
            }
            return(DetalheIngrediente);
        }
Esempio n. 2
0
        /******************************************************************** LISTAR FORMULAÇÕES ********************************************************************/
        public List <Formulacao> ListarFormulacoes()
        {
            //SqlConnection Conexao = new SqlConnection(ConfigurationManager.ConnectionStrings["BancoEstoque"].ConnectionString);
            SqlConnection Conexao = new SqlConnection("Server = DESKTOP-PHTQI5U\\SQLEXPRESS; Database = DRLTCC; Trusted_Connection = True;");

            Conexao.Open();
            SqlCommand Comando = new SqlCommand();

            Comando.Connection = Conexao;

            Comando.CommandText = "SELECT * FROM  Formulacao;";

            SqlDataReader     Leitor      = Comando.ExecuteReader();
            List <Formulacao> Formulacoes = new List <Formulacao>();

            while (Leitor.Read())
            {
                Formulacao F = new Formulacao();
                F.CodigoFormulacao = Convert.ToInt32(Leitor["CodigoFormulacao"].ToString());
                F.NomeFormulacao   = Leitor["NomeFormulacao"].ToString();

                Formulacoes.Add(F);
            }
            Conexao.Close();
            return(Formulacoes);
        }