public void CrearBotones() { consultaSQL = " SELECT count(ID_MENU) FROM MENU "; datos = con.EjecutarNSQL(consultaSQL); for (int i = 1; i <= datos; i++) { consultaSQL = null; consultaSQL = " Select ID_MENU from MENU where ID_MENU= " + i; idmenuBase[i] = con.EjecutarNSQL(consultaSQL); } int x = 5, y = 5; for (int i = 1; i <= datos; i++) { Button btn = new Button(); btn.Height = 200; btn.Width = 200; btn.Location = new Point(x, y); //Posicion y = y + 150; //Acomodado de botones if (y > 700) //Si hay 3 botones en la misma linea aumentamos la posicion X para crear otra linea al lado y no salirnos de la pantalla { y = 10; x = x + 150; } btn.Name = "c" + i.ToString(); btn.Text = idmenuBase[i].ToString(); SqlCommand consultaSQL = new SqlCommand("SELECT FOTO FROM MENU WHERE ID_MENU = " + i + ";", con.conexion()); SqlDataAdapter dp = new SqlDataAdapter(consultaSQL); DataSet ds = new DataSet("foto"); byte[] bytes = new byte[0]; dp.Fill(ds, "foto"); DataRow myRiw = ds.Tables["foto"].Rows[0]; bytes = (byte[])myRiw["foto"]; MemoryStream ms = new MemoryStream(bytes); //Para hacer stretch la imagen del boton btn.BackgroundImageLayout = ImageLayout.Stretch; btn.BackgroundImage = Image.FromStream(ms); //btn.Image = Image.FromStream(ms); btn.Click += new EventHandler(button_Click); flowLayoutPanel1.Controls.Add(btn); } }
public void mostrarImagen() { SqlCommand consultaSQL = new SqlCommand("SELECT FOTO FROM MENU WHERE ID_MENU = " + ClaseCompartida.idMenu + ";", con.conexion()); SqlDataAdapter dp = new SqlDataAdapter(consultaSQL); DataSet ds = new DataSet("foto"); byte[] bytes = new byte[0]; dp.Fill(ds, "foto"); DataRow myRiw = ds.Tables["foto"].Rows[0]; bytes = (byte[])myRiw["foto"]; MemoryStream ms = new MemoryStream(bytes); pbPlatillo.Image = Image.FromStream(ms); }
public void mostrarImagen() { SqlCommand consultaSQL = new SqlCommand("SELECT FOTO FROM MENU WHERE ID_MENU = " + dgvPedidos.Rows[dgvPedidos.CurrentRow.Index].Cells["ID_MENU"].Value.ToString(), con.conexion()); SqlDataAdapter dp = new SqlDataAdapter(consultaSQL); DataSet ds = new DataSet("foto"); byte[] bytes = new byte[0]; dp.Fill(ds, "foto"); DataRow myRiw = ds.Tables["foto"].Rows[0]; bytes = (byte[])myRiw["foto"]; MemoryStream ms = new MemoryStream(bytes); pictureBox1.Image = Image.FromStream(ms); }