public void PrintProduct(string quirt) { try { Product.Controls.Clear(); OleDbCommand command = new OleDbCommand(quirt, connection); connection.Open(); OleDbDataReader reader = command.ExecuteReader(); while (reader.Read()) { ElProduct Item = new ElProduct(); byte[] Photo = (byte[])(reader[6]); MemoryStream memoryStream = new MemoryStream(Photo); Item.gunaPictureBox2.Image = Image.FromStream(memoryStream); Item.gunaLabel2.Text = $"{reader[2]}"; Item.ID.Text = $"{reader[0]}"; Product.Controls.Add(Item); } reader.Close(); connection.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); connection.Close(); } }
private void gunaLabel1_Click(object sender, EventArgs e) { try { Form2.Instance.Product.Controls.Clear(); OleDbCommand command = new OleDbCommand("SELECT IDтовар, Товар.Название, Photo " + "FROM Раздел " + "INNER JOIN Товар ON Раздел.IDраздел = Товар.IDраздел " + $"WHERE Раздел.Название = '{gunaLabel1.Text}'", connection); connection.Open(); OleDbDataReader reader = command.ExecuteReader(); while (reader.Read()) { ElProduct Item = new ElProduct(); byte[] Photo = (byte[])(reader[2]); MemoryStream memoryStream = new MemoryStream(Photo); Item.gunaPictureBox2.Image = Image.FromStream(memoryStream); Item.gunaLabel2.Text = $"{reader[1]}"; Item.ID.Text = $"{reader[0]}"; Form2.Instance.Product.Controls.Add(Item); } reader.Close(); connection.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); connection.Close(); } }