public CatalogData Get() { int imageSize; byte[] image; CatalogData cd = new CatalogData(); cd.ColNames = new String[] { "Название продукции", "Единицы измерения", CatalogData.IMAGE_MARKER + "Изображение" }; MySqlCommand cmd = new MySqlCommand("SELECT p_id,p_name,p_unit,p_image,p_image,p_imgsize FROM products ORDER BY p_id ASC;", sql); MySqlDataReader rd = cmd.ExecuteReader(); List <CatalogData.Row> rws = new List <CatalogData.Row>(); while (rd.Read()) { CatalogData.Row rw = new CatalogData.Row(); rw.key = rd.GetInt32(0); //rw.imageSize = rd.GetInt32("p_imgsize"); imageSize = rd.GetInt32("p_imgsize"); image = new byte[imageSize]; if (imageSize != 0) { rd.GetBytes(rd.GetOrdinal("p_image"), 0, image, 0, imageSize); } rw.data = new String[] { rd.GetString("p_name"), rd.GetString("p_unit"), Convert.ToBase64String(image) }; rws.Add(rw); } rd.Close(); cd.Rows = rws.ToArray(); return(cd); }
public CatalogData Get() { CatalogData cd = new CatalogData(); cd.ColNames = new String[] { "порода", "сокращение", CatalogData.COLOR_MARKER + "Цвет" }; MySqlCommand cmd = new MySqlCommand("SELECT b_id,b_name,b_short_name,b_color FROM breeds ORDER BY b_id;", sql); MySqlDataReader rd = cmd.ExecuteReader(); List <CatalogData.Row> rws = new List <CatalogData.Row>(); while (rd.Read()) { CatalogData.Row rw = new CatalogData.Row(); rw.key = rd.GetInt32(0); rw.data = new String[] { rd.GetString(1), rd.GetString(2), rd.GetString(3) }; rws.Add(rw); } rd.Close(); cd.Rows = rws.ToArray(); return(cd); }
public CatalogData Get() { CatalogData cd = new CatalogData(); cd.ColNames = new String[] { "Причина" }; MySqlCommand cmd = new MySqlCommand("SELECT d_id,d_name FROM deadreasons WHERE d_id>2 ORDER BY d_id;", sql); MySqlDataReader rd = cmd.ExecuteReader(); List <CatalogData.Row> rws = new List <CatalogData.Row>(); while (rd.Read()) { CatalogData.Row rw = new CatalogData.Row(); rw.key = rd.GetInt32(0); rw.data = new String[] { rd.GetString(1) }; rws.Add(rw); } rd.Close(); cd.Rows = rws.ToArray(); return(cd); }
public CatalogData Get() { CatalogData cd = new CatalogData(); cd.ColNames = new String[] { "ген", "зона", "сокращение" }; MySqlCommand cmd = new MySqlCommand("SELECT z_id,z_name,z_short_name FROM zones ORDER BY z_name;", sql); MySqlDataReader rd = cmd.ExecuteReader(); List <CatalogData.Row> rws = new List <CatalogData.Row>(); while (rd.Read()) { CatalogData.Row rw = new CatalogData.Row(); rw.key = rd.GetInt32(0); rw.data = new String[] { rd.GetString(0), rd.GetString(1), rd.GetString(2) }; rws.Add(rw); } rd.Close(); cd.Rows = rws.ToArray(); return(cd); }