

界面设计 代码
namespace JACKTools.Tempreture
{
partial class frm_main
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frm_main));
this.dtinput = new System.Windows.Forms.DateTimePicker();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.cmbTmp = new System.Windows.Forms.ComboBox();
this.btn_save = new System.Windows.Forms.Button();
this.体温记录 = new System.Windows.Forms.GroupBox();
this.cmbmemo = new System.Windows.Forms.ComboBox();
this.label6 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.dt_end = new System.Windows.Forms.DateTimePicker();
this.listView1 = new System.Windows.Forms.ListView();
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
this.columnHeader3 = new System.Windows.Forms.ColumnHeader();
this.columnHeader4 = new System.Windows.Forms.ColumnHeader();
this.columnHeader5 = new System.Windows.Forms.ColumnHeader();
this.btn_print = new System.Windows.Forms.Button();
this.btnsearch = new System.Windows.Forms.Button();
this.label4 = new System.Windows.Forms.Label();
this.dt_start = new System.Windows.Forms.DateTimePicker();
this.pd = new System.Drawing.Printing.PrintDocument();
this.ppd = new System.Windows.Forms.PrintPreviewDialog();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
this.体温记录.SuspendLayout();
this.groupBox1.SuspendLayout();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
//
// dtinput
//
this.dtinput.CustomFormat = "yyyy-MM-dd";
this.dtinput.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.dtinput.Location = new System.Drawing.Point(75, 84);
this.dtinput.Name = "dtinput";
this.dtinput.Size = new System.Drawing.Size(101, 21);
this.dtinput.TabIndex = 0;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(20, 28);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(29, 12);
this.label1.TabIndex = 1;
this.label1.Text = "日期";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(182, 86);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(29, 12);
this.label2.TabIndex = 2;
this.label2.Text = "体温";
//
// cmbTmp
//
this.cmbTmp.FormattingEnabled = true;
this.cmbTmp.Items.AddRange(new object[] {
"35.5",
"35.6",
"35.7",
"35.8",
"35.9",
"36",
"36.1",
"36.2",
"36.3",
"36.4",
"36.5",
"36.6",
"36.7",
"36.8",
"36.9",
"37",
"37.1",
"37.2",
"37.3",
"37.4",
"37.5"});
this.cmbTmp.Location = new System.Drawing.Point(217, 84);
this.cmbTmp.Name = "cmbTmp";
this.cmbTmp.Size = new System.Drawing.Size(57, 20);
this.cmbTmp.TabIndex = 3;
//
// btn_save
//
this.btn_save.Location = new System.Drawing.Point(455, 82);
this.btn_save.Name = "btn_save";
this.btn_save.Size = new System.Drawing.Size(75, 23);
this.btn_save.TabIndex = 4;
this.btn_save.Text = "保存";
this.btn_save.UseVisualStyleBackColor = true;
this.btn_save.Click += new System.EventHandler(this.btn_save_Click);
//
// 体温记录
//
this.体温记录.Controls.Add(this.cmbmemo);
this.体温记录.Controls.Add(this.label6);
this.体温记录.Controls.Add(this.textBox1);
this.体温记录.Controls.Add(this.label5);
this.体温记录.Controls.Add(this.label3);
this.体温记录.Controls.Add(this.dtinput);
this.体温记录.Controls.Add(this.btn_save);
this.体温记录.Controls.Add(this.cmbTmp);
this.体温记录.Controls.Add(this.label2);
this.体温记录.Location = new System.Drawing.Point(12, 12);
this.体温记录.Name = "体温记录";
this.体温记录.Size = new System.Drawing.Size(539, 118);
this.体温记录.TabIndex = 5;
this.体温记录.TabStop = false;
this.体温记录.Text = "体温记录";
//
// cmbmemo
//
this.cmbmemo.FormattingEnabled = true;
this.cmbmemo.Items.AddRange(new object[] {
"|",
"☆|月经",
"¤|量少",
"★|同房",
"※|生病",
"↑|开始服药",
"↓|停止服药",
"▲|不明原因出血",
"♀|疑似排卵腹痛"});
this.cmbmemo.Location = new System.Drawing.Point(315, 84);
this.cmbmemo.Name = "cmbmemo";
this.cmbmemo.Size = new System.Drawing.Size(134, 20);
this.cmbmemo.TabIndex = 9;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(280, 89);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(29, 12);
this.label6.TabIndex = 8;
this.label6.Text = "备注";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(75, 28);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(127, 21);
this.textBox1.TabIndex = 7;
this.textBox1.Text = "苏小妹";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(40, 31);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(29, 12);
this.label5.TabIndex = 6;
this.label5.Text = "姓名";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(40, 90);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(29, 12);
this.label3.TabIndex = 5;
this.label3.Text = "日期";
//
// groupBox1
//
this.groupBox1.Controls.Add(this.dt_end);
this.groupBox1.Controls.Add(this.listView1);
this.groupBox1.Controls.Add(this.btn_print);
this.groupBox1.Controls.Add(this.btnsearch);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.dt_start);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Location = new System.Drawing.Point(12, 146);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(539, 267);
this.groupBox1.TabIndex = 6;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "体温数据查看";
//
// dt_end
//
this.dt_end.CustomFormat = "yyyy-MM-dd";
this.dt_end.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.dt_end.Location = new System.Drawing.Point(208, 22);
this.dt_end.Name = "dt_end";
this.dt_end.Size = new System.Drawing.Size(130, 21);
this.dt_end.TabIndex = 11;
//
// listView1
//
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2,
this.columnHeader3,
this.columnHeader4,
this.columnHeader5});
this.listView1.FullRowSelect = true;
this.listView1.Location = new System.Drawing.Point(6, 49);
this.listView1.MultiSelect = false;
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(524, 212);
this.listView1.TabIndex = 10;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
this.columnHeader1.Text = "";
this.columnHeader1.Width = 20;
//
// columnHeader2
//
this.columnHeader2.Text = "日期";
this.columnHeader2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader2.Width = 120;
//
// columnHeader3
//
this.columnHeader3.Text = "体温℃";
this.columnHeader3.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader3.Width = 80;
//
// columnHeader4
//
this.columnHeader4.Text = "录入日期";
this.columnHeader4.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.columnHeader4.Width = 120;
//
// columnHeader5
//
this.columnHeader5.Text = "备注";
this.columnHeader5.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader5.Width = 120;
//
// btn_print
//
this.btn_print.Location = new System.Drawing.Point(429, 22);
this.btn_print.Name = "btn_print";
this.btn_print.Size = new System.Drawing.Size(75, 23);
this.btn_print.TabIndex = 9;
this.btn_print.Text = "打印折线图";
this.btn_print.UseVisualStyleBackColor = true;
this.btn_print.Click += new System.EventHandler(this.btn_print_Click);
//
// btnsearch
//
this.btnsearch.Location = new System.Drawing.Point(348, 21);
this.btnsearch.Name = "btnsearch";
this.btnsearch.Size = new System.Drawing.Size(75, 23);
this.btnsearch.TabIndex = 6;
this.btnsearch.Text = "查询";
this.btnsearch.UseVisualStyleBackColor = true;
this.btnsearch.Click += new System.EventHandler(this.btnsearch_Click);
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(191, 26);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(11, 12);
this.label4.TabIndex = 8;
this.label4.Text = "~";
//
// dt_start
//
this.dt_start.CustomFormat = "yyyy-MM-dd";
this.dt_start.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.dt_start.Location = new System.Drawing.Point(55, 22);
this.dt_start.Name = "dt_start";
this.dt_start.Size = new System.Drawing.Size(130, 21);
this.dt_start.TabIndex = 6;
//
// pd
//
this.pd.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.pd_PrintPage);
//
// ppd
//
this.ppd.AutoScrollMargin = new System.Drawing.Size(0, 0);
this.ppd.AutoScrollMinSize = new System.Drawing.Size(0, 0);
this.ppd.ClientSize = new System.Drawing.Size(400, 300);
this.ppd.Enabled = true;
this.ppd.Icon = ((System.Drawing.Icon)(resources.GetObject("ppd.Icon")));
this.ppd.Name = "ppd";
this.ppd.Visible = false;
//
// statusStrip1
//
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabel1});
this.statusStrip1.Location = new System.Drawing.Point(0, 413);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(562, 22);
this.statusStrip1.TabIndex = 7;
this.statusStrip1.Text = "statusStrip1";
//
// toolStripStatusLabel1
//
this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
this.toolStripStatusLabel1.Size = new System.Drawing.Size(131, 17);
this.toolStripStatusLabel1.Text = "toolStripStatusLabel1";
//
// frm_main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(562, 435);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.体温记录);
this.Name = "frm_main";
this.Text = "frm_main";
this.体温记录.ResumeLayout(false);
this.体温记录.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.DateTimePicker dtinput;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.ComboBox cmbTmp;
private System.Windows.Forms.Button btn_save;
private System.Windows.Forms.GroupBox 体温记录;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button btnsearch;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.DateTimePicker dt_start;
private System.Windows.Forms.Button btn_print;
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.ColumnHeader columnHeader3;
private System.Windows.Forms.ColumnHeader columnHeader4;
private System.Windows.Forms.DateTimePicker dt_end;
private System.Drawing.Printing.PrintDocument pd;
private System.Windows.Forms.PrintPreviewDialog ppd;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.ComboBox cmbmemo;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.ColumnHeader columnHeader5;
private System.Windows.Forms.StatusStrip statusStrip1;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
}
}
逻辑代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Drawing;
namespace JACKTools.Tempreture
{
public class PointTmp
{
public PointTmp(PointF pf,String pflag)
{
this._PointF = pf;
this.Pointflag = pflag;
}
public PointF _PointF
{
get;
set;
}
public String Pointflag
{
get;
set;
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace JACKTools.Tempreture
{
public partial class frm_main : Form
{
String dbname = "femailtmp.db";
public frm_main()
{
InitializeComponent();
toolStripStatusLabel1.Text = "";
}
private void btn_save_Click(object sender, EventArgs e)
{
toolStripStatusLabel1.Text = "即将保存";
DBHelper.SQLiteHelper sqlitehelper = new DBHelper.SQLiteHelper(dbname);
String cmdselect = "select * from [temp] where monthday = '" + dtinput.Text.Trim() + "'";
DataTable dt = sqlitehelper.executeFind(cmdselect, dbname);
//已经录入过了
if (dt.Rows.Count > 0)
{
DialogResult dr = MessageBox.Show(dtinput.Text.Trim() + "的体温已经录入过了,确认使用现在录入的值" + cmbTmp.Text.Trim() + "?",
"提醒", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (dr == DialogResult.OK)
{
String cmddel = "delete from [temp] where monthday = '" + dtinput.Text.Trim() + "'";
sqlitehelper.execute(cmddel,dbname);
}
else return;
}
String cmd = "insert into [temp] values('" + dtinput.Text.Trim() + "'," + cmbTmp.Text.Trim() + ",'"
+ DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + cmbmemo.Text.Trim()+"')";
int tmp = sqlitehelper.execute(cmd,dbname);
if (tmp> 0)
toolStripStatusLabel1.Text = "保存成功!";
else toolStripStatusLabel1.Text = "数据异常!";
}
private void btnsearch_Click(object sender, EventArgs e)
{
DBHelper.SQLiteHelper sqlitehelper = new DBHelper.SQLiteHelper("femailtmp.db");
String cmd = "select * from temp where monthday between '" + dt_start.Text.Trim() + "' and '" +
dt_end.Text.Trim() + "'";
DataTable dt = sqlitehelper.executeFind(cmd,dbname);
listView1.Items.Clear();
for (int i = 0; i < dt.Rows.Count; i++)
{
String[] lsvitem;
lsvitem = new string[] { (i + 1) + "", dt.Rows[i]["monthday"].ToString().Substring(0,10).Replace("/","-"),
dt.Rows[i]["temp"].ToString(),
dt.Rows[i]["inserttime"].ToString().Replace("/","-") ,
dt.Rows[i]["memo"].ToString().Replace("/","-")
};
this.listView1.Items.Add(new ListViewItem(lsvitem));
}
}
private void btn_print_Click(object sender, EventArgs e)
{
pd.DefaultPageSettings.Landscape = true;
ppd.Document = pd;
ppd.ShowDialog();
}
private void pd_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
int lineh = 20;
int linez = 50;
int linetmp = 20;
Point sp = new Point(100, 220);
Font drawFont = new Font("Arial", 10);
SolidBrush drawBrush = new SolidBrush(Color.Red);
Pen p = new Pen(Color.Black);
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
List<PointTmp> lst = new List<PointTmp>();
DateTime dt = dt_start.Value;
e.Graphics.DrawString("女性基础体温表", new Font("Arial", 30), new SolidBrush(Color.Black), new PointF(400f, 80f));
e.Graphics.DrawString(textBox1.Text.Trim(),new Font("Arial", 15),new SolidBrush(Color.Black),new PointF(950f,130f));
//横线
for (int i = 0; i <= lineh; i++)
{
//横向刻度
e.Graphics.DrawString((37.5 - 0.1 * i) + "℃", new Font(drawFont, FontStyle.Bold), drawBrush, new Point(sp.X - 60, sp.Y + i * linetmp - linetmp/2));
if (i != 0 && i % 5 == 0 && i != lineh)
p = new Pen(Color.Red);
else p = new Pen(Color.Black);
e.Graphics.DrawLine(p, sp.X, sp.Y + i * linetmp, sp.X + linetmp * linez, sp.Y + i * linetmp);
}
//纵向线
for (int i = 0; i <= linez; i++)
{
//纵向刻度
DateTime dttmp = dt.AddDays(i);
if (dttmp.Day == dt_start.Value.Day)
{
e.Graphics.DrawString(dttmp.Year + "年", new Font(drawFont, FontStyle.Bold), drawBrush, new Point(sp.X + i * linetmp - linetmp / 2, sp.Y - 60));
e.Graphics.DrawString(dttmp.Month + "月", new Font(drawFont, FontStyle.Bold), drawBrush, new Point(sp.X + i * linetmp - linetmp / 2, sp.Y - 40));
}
if(dttmp <= dt_end.Value.AddDays(1))
lst.Add(getPointF(sp, new DateTime(dttmp.Year, dttmp.Month, dttmp.Day), sp.X + i * linetmp, linetmp));
e.Graphics.DrawString(dt.AddDays(i).Day + "", new Font(drawFont, FontStyle.Bold), drawBrush, new Point(sp.X + i * linetmp - linetmp / 2, sp.Y - 20));
if (i != 0 && i % 7 == 0 && i != linez)
p = new Pen(Color.Red);
else p = new Pen(Color.Black);
e.Graphics.DrawLine(p, sp.X + i * linetmp, sp.Y, sp.X + i * linetmp, sp.Y + lineh * linetmp);
}
int cnt = 0;
List<PointF> lstpf = new List<PointF>();
foreach (PointTmp pt in lst)
{
if (pt._PointF.Y != 0 && pt._PointF.X != 0)
{
lstpf.Add(pt._PointF);
e.Graphics.FillEllipse(drawBrush, pt._PointF.X - linetmp / 4, pt._PointF.Y - linetmp / 4, linetmp / 2, linetmp / 2);
if (pt.Pointflag != "")
{
SizeF sizeF = e.Graphics.MeasureString(pt.Pointflag, new Font("Arial", linetmp/2));
e.Graphics.DrawString(pt.Pointflag, new Font(new Font("Arial", linetmp / 2), FontStyle.Bold), drawBrush, pt._PointF.X - sizeF.Width / 2, sp.Y + lineh*linetmp);
}
}
}
if(lstpf.Count>1)
e.Graphics.DrawLines(p, lstpf.ToArray());
StringBuilder sb = new StringBuilder();
for (int i = 1; i < cmbmemo.Items.Count; i++)
sb.Append(cmbmemo.Items[i].ToString().Replace("|","") + " ");
e.Graphics.DrawString(sb.ToString(), new Font(new Font("Arial", linetmp / 2), FontStyle.Bold), drawBrush, sp.X + linetmp * (linez / 3 +5), sp.Y + (lineh + 2) * linetmp);
}
private PointTmp getPointF(Point sp, DateTime dt, int point_x, int linetmp)
{
DBHelper.SQLiteHelper sqlitehelper = new DBHelper.SQLiteHelper("femailtmp.db");
String cmdselect = "select * from [temp] where monthday = '" + dt.ToString("yyyy-MM-dd") + "'";
DataTable dttmp = sqlitehelper.executeFind(cmdselect,dbname);
if (dttmp.Rows.Count <= 0)
{
return new PointTmp(new PointF(0.0f, 0.0f),"");
}
else
{
float temp = float.Parse(dttmp.Rows[0][1].ToString());
String flag = dttmp.Rows[0][3].ToString();
flag = flag.Length > 1? flag.Substring(0, flag.IndexOf("|")):"";
return new PointTmp(new PointF(float.Parse(point_x.ToString()), float.Parse((sp.Y + (37.5 - temp) / 0.1 * linetmp).ToString())), flag);
}
}
}
}

被折叠的 条评论
为什么被折叠?



