日期:2014-05-18 浏览次数:20851 次
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form6 : Form { public Form6() { InitializeComponent(); Db db = new Db(); textBox1.Text = "1"; } private void Form1_Load(object sender, EventArgs e) { //pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox1_Paint); } private void pictureBox1_Paint(object sender, PaintEventArgs e) { Db db = new Db(); Graphics g = e.Graphics; Pen pen = new Pen(Color.Black, 2); SolidBrush sb = new SolidBrush(Color.Green); Point[] xpts = new Point[3]{ new Point(pictureBox1.Width-35,pictureBox1.Height-32), new Point(pictureBox1.Width-35,pictureBox1.Height-28), new Point(pictureBox1.Width-30,pictureBox1.Height-30) }; g.DrawLine(pen, 50, pictureBox1.Height - 30, pictureBox1.Width - 30, pictureBox1.Height - 30); g.DrawPolygon(pen, xpts); g.DrawString("时间", new Font("宋体", 9), sb, pictureBox1.Width - 30, pictureBox1.Height - 30); Point[] ypts = new Point[3]{ new Point(48,55), new Point(50,50), new Point(52,55) }; g.DrawLine(pen, 50, pictureBox1.Height - 30, 50, 50); g.DrawPolygon(pen, ypts); g.DrawString("/mmHg", new Font("宋体", 9), sb, 50, 50); g.DrawString("50", new Font("宋体", 9), sb, 30, pictureBox1.Height - 35); for (int j = 0; j < 9; j++) { g.DrawLine(pen, 50, pictureBox1.Height - 30 - (j + 1) * (pictureBox1.Height - 80) / 10, 55, pictureBox1.Height - 30 - (j + 1) * (pictureBox1.Height - 80) / 10); g.DrawString(((j + 1) * 13 + 50).ToString(), new Font("宋体", 9), sb, 30, pictureBox1.Height - 35 - (j + 1) * (pictureBox1.Height - 80) / 10); } string sql = "select sbp,dbp,time from bp where pnum='" + textBox1.Text + "'"; string[,] a = db.doSelect(sql); int n = 0; n = a.GetLength(0); //取出的数据的行数为n; int i = 0; for (i = 0; i < n - 1; i++) { g.DrawLine(new Pen(Color.Blue), 50 + (i + 1) * (pictureBox1.Width - 80) / (n + 1), pictureBox1.Height - 30 - (int.Parse(a[i, 0]) - 50) * (pictureBox1.Height - 80) / 130, 50 + (i + 2) * (pictureBox1.Width - 80) / (n + 1), pictureBox1.Height - 30 - (int.Parse(a[i + 1, 0]) - 50) * (pictureBox1.Height - 80) / 130); g.DrawLine(new Pen(Color.Red), 50 + (i + 1) * (pictureBox1.Width - 80) / (n + 1), pictureBox1.Height - 30 - (int.Parse(a[i, 1]) - 50) * (pictureBox1.Height - 80) / 130, 50 + (i + 2) * (pictureBox1.Width - 80) / (n + 1), pictureBox1.Height - 30 - (int.Parse(a[i + 1, 1]) - 50) * (pictureBox1.Height - 80) / 130); g.DrawLine(new Pen(Color.Black), 50 + (i + 1) * (pictureBox1.Width - 80) / (n + 1), pictureBox1.Height - 35, 50 + (i + 1) * (pictureBox1.Width - 80) / (n + 1), pictureBox1.Height - 30); g.DrawString(a[i, 2], new Font("宋体", 9), sb, 20 + (i + 1) * (pictureBox1.Width - 80) / (n + 1), pictureBox1.Height - 28); } g.DrawLine(new Pen(Color.Blue)