//数据库操作 private void button1_Click_1(object sender, EventArgs e) { if (scientificname.Text.Length == 0) { MessageBox.Show("请先输入作物名称"); scientificname.Text = null; } else { MyDbRead myDbRead = new MyDbRead(); string searchCommand = "SELECT *FROM detail WHERE name='" + scientificname.Text.ToString() + "'"; try { myDbRead.mydbread(searchCommand); //数据处理显示 nigtemp.Text = myDbRead.Nt.ToString(); daytemp.Text = myDbRead.Dt.ToString(); nurhumi.Text = myDbRead.Nh.ToString(); mathumi.Text = myDbRead.Mh.ToString(); id = myDbRead.Id; detail.Text = myDbRead.Introduce; //照片读取 string startupPath = Application.StartupPath; startupPath += "\\cropImage\\" + myDbRead.Id.ToString() + ".jpg"; pictureBox1.Image = Image.FromFile(startupPath); pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; } catch { MessageBox.Show("无数据"); pictureBox1.Image = null; } } }
private void search_Click(object sender, EventArgs e) { string searchCommand = "SELECT *FROM detail WHERE name='" + strname.Text.ToString() + "'"; MyDbRead myDbRead = new MyDbRead(); try { myDbRead.mydbread(searchCommand); //数据处理显示 myDbRead.Nt.ToString(); myDbRead.Dt.ToString(); myDbRead.Nh.ToString(); myDbRead.Mh.ToString(); growId = myDbRead.Id; //MessageBox.Show(i.ToString()); growSelect(growId); dataStart.Enabled = true; } catch { MessageBox.Show("查询无数据"); } }