示例#1
0
        private void Perfil_Load(object sender, EventArgs e)
        {
            AcessoSQL ata = new AcessoSQL();

            //preenchendo o txtnomfun conforme do cracha informado
            SqlConnection con  = new SqlConnection(@"Data Source = SERVER151; Initial Catalog = Teste190; User ID = sa; Password = Admin2018@");
            SqlCommand    comm = new SqlCommand("select * from Usuarios where Email ='" + Login.usuarioConectado + "'", con);

            //* Aqui no CommandType tem que definir se vai utilizar uma Stored Procedure ou uma query */
            comm.CommandType = CommandType.Text; /* Quando usa Query */

            //* Aqui tem que preencher e adicionar os parametros*/
            comm.Parameters.Add(new SqlParameter("@Nome", "Nome"));

            con.Open();
            SqlDataReader dr = comm.ExecuteReader();

            while (dr.Read())
            {
                //* No dr["Nome do Campo da query que quer associar a Textbox */
                lblBemVindo2.Text = "Olá " + dr["Nome"].ToString() + ".";
                if (dr["Sexo"].ToString() == "Masculino")
                {
                    pic1.Image = Image.FromFile(@"C:\CloudTech\Imagens\man.png");
                    picL.Image = Image.FromFile(@"C:\CloudTech\Imagens\man.png");
                }
                else
                {
                    pic1.Image = Image.FromFile(@"C:\CloudTech\Imagens\girl.png");
                    picL.Image = Image.FromFile(@"C:\CloudTech\Imagens\girl.png");
                }
            }
            con.Close();

            //SqlCommand comm1 = new SqlCommand("select * from produtos WHERE ID_Produto = (SELECT MAX(ID_Produto) FROM Produtos)", con);
            SqlCommand comm1 = new SqlCommand("SELECT * FROM  Pedidos where Email = '" + Login.usuarioConectado + "'", con);

            //* Aqui no CommandType tem que definir se vai utilizar uma Stored Procedure ou uma query */

            //* Aqui no CommandType tem que definir se vai utilizar uma Stored Procedure ou uma query */
            comm1.CommandType = CommandType.Text; /* Quando usa Query */

            //* Aqui tem que preencher e adicionar os parametros*/
            //comm1.Parameters.Add(new SqlParameter("@ID_Produto", "ID_Produto"));

            con.Open();
            //SqlDataAdapter sqlAdapter = new SqlDataAdapter(comm1);
            //DataTable dtRetorno = new DataTable();
            //sqlAdapter.Fill(dtRetorno);
            SqlDataReader dr1 = comm1.ExecuteReader();
            int           i   = 1;

            while (dr1.Read())
            {
                if (i == 0)
                {
                    painel.Size = new Size(1051, 450);
                    lblAviso.BringToFront();
                }

                if (i == 1)
                {
                    lblAviso.SendToBack();
                    painel1.BringToFront();
                    lblNomeProd1.Text = dr1["Nome"].ToString();
                    qtd1.Text         = (dr1["Qtd"].ToString());
                    txtParc1.Text     = dr1["Parcela"].ToString();
                    picProduto1.Image = Image.FromFile(dr1["Imagem"].ToString());
                    lblPreco1.Text    = dr1["Preco"].ToString();
                    lblTotal1.Text    = dr1["Precototal"].ToString();
                }
                else
                {
                }
                if (i == 2)
                {
                    painel2.BringToFront();
                    lblNomeProd2.Text = dr1["Nome"].ToString();
                    qtd2.Text         = (dr1["Qtd"].ToString());
                    txtParc2.Text     = dr1["Parcela"].ToString();
                    picProduto2.Image = Image.FromFile(dr1["Imagem"].ToString());
                    lblPreco2.Text    = dr1["Preco"].ToString();
                    lblTotal2.Text    = dr1["Precototal"].ToString();
                }
                else
                {
                }
                if (i == 3)
                {
                    painel.Size = new Size(1051, 831);
                    painel3.BringToFront();
                    lblNomeProd3.Text = dr1["Nome"].ToString();
                    qtd3.Text         = (dr1["Qtd"].ToString());
                    txtParc3.Text     = dr1["Parcela"].ToString();
                    picProduto3.Image = Image.FromFile(dr1["Imagem"].ToString());
                    lblPreco3.Text    = dr1["Preco"].ToString();
                    lblTotal3.Text    = dr1["Precototal"].ToString();
                }
                else
                {
                }
                if (i == 4)
                {
                    painel.Size = new Size(1051, 1080);
                    painel4.BringToFront();
                    lblNomeProd4.Text = dr1["Nome"].ToString();
                    qtd4.Text         = (dr1["Qtd"].ToString());
                    txtParc4.Text     = dr1["Parcela"].ToString();
                    picProduto4.Image = Image.FromFile(dr1["Imagem"].ToString());
                    lblPreco4.Text    = dr1["Preco"].ToString();
                    lblTotal4.Text    = dr1["Precototal"].ToString();
                }

                if (i == 5)
                {
                    painel.Size = new Size(1051, 1327);
                    painel5.BringToFront();
                    lblNomeProd5.Text = dr1["Nome"].ToString();
                    qtd5.Text         = (dr1["Qtd"].ToString());
                    txtParc5.Text     = dr1["Parcela"].ToString();
                    picProduto5.Image = Image.FromFile(dr1["Imagem"].ToString());
                    lblPreco5.Text    = dr1["Preco"].ToString();
                    lblTotal5.Text    = dr1["Precototal"].ToString();
                }

                if (i == 6)
                {
                    painel.Size = new Size(1051, 1590);
                    painel6.BringToFront();
                    lblNomeProd6.Text = dr1["Nome"].ToString();
                    qtd6.Text         = (dr1["Qtd"].ToString());
                    txtParc6.Text     = dr1["Parcela"].ToString();
                    picProduto6.Image = Image.FromFile(dr1["Imagem"].ToString());
                    lblPreco6.Text    = dr1["Preco"].ToString();
                    lblTotal6.Text    = dr1["Precototal"].ToString();
                }
                i++;
            }
            con.Close();
        }