using System;
using System.Data;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

using HISClinic.DataModel;
using HISClinic.BLL;
using HISClinic.UIProcess;
using HISClinic.UIProcess.ColumnStyles;

namespace HISClinic
{
	/// <summary>
	/// frmPrescriptionNew 的摘要说明。
	/// </summary>
	public class frmPrescriptionNew : System.Windows.Forms.Form
	{
		private PrescriptionsEx _prescriptionsEx;
		private PrescriptionsEx.t_PrescriptionMasterRow _prescriptionMasterRow;
		private DataView _dvPrescriptionDetail=null;
		private RegistrationsEx.t_RegistrationRow _RegistrationRow;

		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.Button btnSave;
		private System.Windows.Forms.Button btnCancel;
		private System.Windows.Forms.GroupBox groupBox2;
		private System.Windows.Forms.Label lblPrescribeType;
		private System.Windows.Forms.Label lblDiagnosis1;
		private System.Windows.Forms.Label lblDiagnosis2;
		private System.Windows.Forms.TextBox txtDiagnosis1;
		private System.Windows.Forms.TextBox txtDiagnosis2;
		private System.Windows.Forms.DataGrid grdPrescriptionDetail;		
		private System.Windows.Forms.GroupBox groupBox3;
		private System.Windows.Forms.RadioButton rdoFirstVisit;
		private System.Windows.Forms.RadioButton rdoFurtherVisit;
		private System.Windows.Forms.Button btnAdd;
		private System.Windows.Forms.Button btnEdit;
		private System.Windows.Forms.Button btnDelete;
		private System.Windows.Forms.Label lblSumTotal;
		private System.Windows.Forms.Label lblSumTotalValue;
		private System.Windows.Forms.Button btnSelectDisease2;
		private System.Windows.Forms.Button btnSelectDisease1;
		private HISClinic.Controls.PatientInfo patientInfo;
		private System.Windows.Forms.PictureBox pictureBox1;
		private System.Windows.Forms.PictureBox pictureBox2;
		private System.Windows.Forms.PictureBox pictureBox3;
		private System.Windows.Forms.PictureBox pictureBox4;
		private System.Windows.Forms.PictureBox pictureBox5;
		private System.Windows.Forms.PictureBox pictureBox8;
		private System.Windows.Forms.PictureBox pictureBox10;
		private System.Windows.Forms.PictureBox pictureBox12;
		private System.Windows.Forms.PictureBox pictureBox6;
		private System.Windows.Forms.PictureBox pictureBox7;
		private System.Windows.Forms.PictureBox pictureBox11;
		private System.Windows.Forms.Panel panel1;
		private System.Windows.Forms.Panel panel2;
		private System.Windows.Forms.Panel panel3;
		
		
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmPrescriptionNew()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmPrescriptionNew));
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.pictureBox3 = new System.Windows.Forms.PictureBox();
			this.pictureBox2 = new System.Windows.Forms.PictureBox();
			this.pictureBox1 = new System.Windows.Forms.PictureBox();
			this.patientInfo = new HISClinic.Controls.PatientInfo();
			this.btnSave = new System.Windows.Forms.Button();
			this.btnCancel = new System.Windows.Forms.Button();
			this.groupBox2 = new System.Windows.Forms.GroupBox();
			this.pictureBox8 = new System.Windows.Forms.PictureBox();
			this.pictureBox5 = new System.Windows.Forms.PictureBox();
			this.pictureBox4 = new System.Windows.Forms.PictureBox();
			this.lblSumTotalValue = new System.Windows.Forms.Label();
			this.lblSumTotal = new System.Windows.Forms.Label();
			this.btnAdd = new System.Windows.Forms.Button();
			this.btnEdit = new System.Windows.Forms.Button();
			this.btnDelete = new System.Windows.Forms.Button();
			this.grdPrescriptionDetail = new System.Windows.Forms.DataGrid();
			this.pictureBox7 = new System.Windows.Forms.PictureBox();
			this.txtDiagnosis2 = new System.Windows.Forms.TextBox();
			this.txtDiagnosis1 = new System.Windows.Forms.TextBox();
			this.lblDiagnosis2 = new System.Windows.Forms.Label();
			this.lblDiagnosis1 = new System.Windows.Forms.Label();
			this.lblPrescribeType = new System.Windows.Forms.Label();
			this.groupBox3 = new System.Windows.Forms.GroupBox();
			this.pictureBox12 = new System.Windows.Forms.PictureBox();
			this.pictureBox10 = new System.Windows.Forms.PictureBox();
			this.btnSelectDisease2 = new System.Windows.Forms.Button();
			this.btnSelectDisease1 = new System.Windows.Forms.Button();
			this.rdoFurtherVisit = new System.Windows.Forms.RadioButton();
			this.rdoFirstVisit = new System.Windows.Forms.RadioButton();
			this.pictureBox6 = new System.Windows.Forms.PictureBox();
			this.pictureBox11 = new System.Windows.Forms.PictureBox();
			this.panel1 = new System.Windows.Forms.Panel();
			this.panel2 = new System.Windows.Forms.Panel();
			this.panel3 = new System.Windows.Forms.Panel();
			this.groupBox1.SuspendLayout();
			this.groupBox2.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.grdPrescriptionDetail)).BeginInit();
			this.groupBox3.SuspendLayout();
			this.panel1.SuspendLayout();
			this.panel2.SuspendLayout();
			this.panel3.SuspendLayout();
			this.SuspendLayout();
			// 
			// groupBox1
			// 
			this.groupBox1.BackColor = System.Drawing.SystemColors.ControlLightLight;
			this.groupBox1.Controls.Add(this.panel1);
			this.groupBox1.Controls.Add(this.pictureBox3);
			this.groupBox1.Controls.Add(this.patientInfo);
			this.groupBox1.Location = new System.Drawing.Point(8, 8);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(655, 90);
			this.groupBox1.TabIndex = 0;
			this.groupBox1.TabStop = false;
			// 
			// pictureBox3
			// 
			this.pictureBox3.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox3.Image")));
			this.pictureBox3.Location = new System.Drawing.Point(0, 25);
			this.pictureBox3.Name = "pictureBox3";
			this.pictureBox3.Size = new System.Drawing.Size(656, 6);
			this.pictureBox3.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
			this.pictureBox3.TabIndex = 4;
			this.pictureBox3.TabStop = false;
			// 
			// pictureBox2
			// 
			this.pictureBox2.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureBox2.BackgroundImage")));
			this.pictureBox2.Dock = System.Windows.Forms.DockStyle.Right;
			this.pictureBox2.Location = new System.Drawing.Point(536, 0);
			this.pictureBox2.Name = "pictureBox2";
			this.pictureBox2.Size = new System.Drawing.Size(120, 25);
			this.pictureBox2.TabIndex = 3;
			this.pictureBox2.TabStop = false;
			// 
			// pictureBox1
			// 
			this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Left;
			this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
			this.pictureBox1.Location = new System.Drawing.Point(0, 0);
			this.pictureBox1.Name = "pictureBox1";
			this.pictureBox1.Size = new System.Drawing.Size(536, 25);
			this.pictureBox1.TabIndex = 2;
			this.pictureBox1.TabStop = false;
			// 
			// patientInfo
			// 
			this.patientInfo.BackColor = System.Drawing.Color.AliceBlue;
			this.patientInfo.Location = new System.Drawing.Point(0, 30);
			this.patientInfo.Name = "patientInfo";
			this.patientInfo.Size = new System.Drawing.Size(655, 61);
			this.patientInfo.TabIndex = 1;
			this.patientInfo.GetPatientInfoCompleted += new HISClinic.Controls.OnGetPatientInfoCompleted(this.patientInfo_GetPatientInfoCompleted);
			// 
			// btnSave
			// 
			this.btnSave.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnSave.BackgroundImage")));
			this.btnSave.Enabled = false;
			this.btnSave.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.btnSave.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.btnSave.Location = new System.Drawing.Point(515, 438);
			this.btnSave.Name = "btnSave";
			this.btnSave.Size = new System.Drawing.Size(64, 23);
			this.btnSave.TabIndex = 3;
			this.btnSave.Text = "开处方";
			this.btnSave.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
			this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
			// 
			// btnCancel
			// 
			this.btnCancel.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnCancel.BackgroundImage")));
			this.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.btnCancel.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.btnCancel.Location = new System.Drawing.Point(595, 438);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.Size = new System.Drawing.Size(64, 23);
			this.btnCancel.TabIndex = 4;
			this.btnCancel.Text = "取 消";
			this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
			// 
			// groupBox2
			// 
			this.groupBox2.BackColor = System.Drawing.Color.AliceBlue;
			this.groupBox2.Controls.Add(this.panel2);
			this.groupBox2.Controls.Add(this.pictureBox8);
			this.groupBox2.Controls.Add(this.lblSumTotalValue);
			this.groupBox2.Controls.Add(this.lblSumTotal);
			this.groupBox2.Controls.Add(this.btnAdd);
			this.groupBox2.Controls.Add(this.btnEdit);
			this.groupBox2.Controls.Add(this.btnDelete);
			this.groupBox2.Controls.Add(this.grdPrescriptionDetail);
			this.groupBox2.Controls.Add(this.pictureBox7);
			this.groupBox2.Location = new System.Drawing.Point(8, 104);
			this.groupBox2.Name = "groupBox2";
			this.groupBox2.Size = new System.Drawing.Size(656, 256);
			this.groupBox2.TabIndex = 1;
			this.groupBox2.TabStop = false;
			// 
			// pictureBox8
			// 
			this.pictureBox8.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox8.Image")));
			this.pictureBox8.Location = new System.Drawing.Point(0, 25);
			this.pictureBox8.Name = "pictureBox8";
			this.pictureBox8.Size = new System.Drawing.Size(656, 6);
			this.pictureBox8.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
			this.pictureBox8.TabIndex = 9;
			this.pictureBox8.TabStop = false;
			// 
			// pictureBox5
			// 
			this.pictureBox5.Dock = System.Windows.Forms.DockStyle.Right;
			this.pictureBox5.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox5.Image")));
			this.pictureBox5.Location = new System.Drawing.Point(536, 0);
			this.pictureBox5.Name = "pictureBox5";
			this.pictureBox5.Size = new System.Drawing.Size(120, 25);
			this.pictureBox5.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
			this.pictureBox5.TabIndex = 7;
			this.pictureBox5.TabStop = false;
			// 
			// pictureBox4
			// 
			this.pictureBox4.BackColor = System.Drawing.SystemColors.ControlLightLight;
			this.pictureBox4.Dock = System.Windows.Forms.DockStyle.Left;
			this.pictureBox4.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox4.Image")));
			this.pictureBox4.Location = new System.Drawing.Point(0, 0);
			this.pictureBox4.Name = "pictureBox4";
			this.pictureBox4.Size = new System.Drawing.Size(536, 25);
			this.pictureBox4.TabIndex = 6;
			this.pictureBox4.TabStop = false;
			// 
			// lblSumTotalValue
			// 
			this.lblSumTotalValue.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(186)), ((System.Byte)(209)), ((System.Byte)(247)));
			this.lblSumTotalValue.Location = new System.Drawing.Point(512, 238);
			this.lblSumTotalValue.Name = "lblSumTotalValue";
			this.lblSumTotalValue.Size = new System.Drawing.Size(112, 16);
			this.lblSumTotalValue.TabIndex = 5;
			this.lblSumTotalValue.Text = "0.00";
			this.lblSumTotalValue.TextAlign = System.Drawing.ContentAlignment.TopRight;
			// 
			// lblSumTotal
			// 
			this.lblSumTotal.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(186)), ((System.Byte)(209)), ((System.Byte)(247)));
			this.lblSumTotal.Location = new System.Drawing.Point(464, 238);
			this.lblSumTotal.Name = "lblSumTotal";
			this.lblSumTotal.Size = new System.Drawing.Size(48, 16);
			this.lblSumTotal.TabIndex = 4;
			this.lblSumTotal.Text = "合计：";
			// 
			// btnAdd
			// 
			this.btnAdd.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnAdd.BackgroundImage")));
			this.btnAdd.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.btnAdd.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.btnAdd.Location = new System.Drawing.Point(0, 233);
			this.btnAdd.Name = "btnAdd";
			this.btnAdd.Size = new System.Drawing.Size(56, 23);
			this.btnAdd.TabIndex = 1;
			this.btnAdd.Text = "增 加";
			this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
			// 
			// btnEdit
			// 
			this.btnEdit.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnEdit.BackgroundImage")));
			this.btnEdit.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.btnEdit.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.btnEdit.Location = new System.Drawing.Point(72, 233);
			this.btnEdit.Name = "btnEdit";
			this.btnEdit.Size = new System.Drawing.Size(56, 23);
			this.btnEdit.TabIndex = 2;
			this.btnEdit.Text = "修 改";
			this.btnEdit.Click += new System.EventHandler(this.btnEdit_Click);
			// 
			// btnDelete
			// 
			this.btnDelete.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnDelete.BackgroundImage")));
			this.btnDelete.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.btnDelete.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.btnDelete.Location = new System.Drawing.Point(144, 233);
			this.btnDelete.Name = "btnDelete";
			this.btnDelete.Size = new System.Drawing.Size(56, 23);
			this.btnDelete.TabIndex = 3;
			this.btnDelete.Text = "删 除";
			this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click);
			// 
			// grdPrescriptionDetail
			// 
			this.grdPrescriptionDetail.BackgroundColor = System.Drawing.SystemColors.ActiveCaptionText;
			this.grdPrescriptionDetail.CaptionVisible = false;
			this.grdPrescriptionDetail.DataMember = "";
			this.grdPrescriptionDetail.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.grdPrescriptionDetail.Location = new System.Drawing.Point(2, 40);
			this.grdPrescriptionDetail.Name = "grdPrescriptionDetail";
			this.grdPrescriptionDetail.ReadOnly = true;
			this.grdPrescriptionDetail.Size = new System.Drawing.Size(650, 192);
			this.grdPrescriptionDetail.TabIndex = 0;
			this.grdPrescriptionDetail.TabStop = false;
			// 
			// pictureBox7
			// 
			this.pictureBox7.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureBox7.BackgroundImage")));
			this.pictureBox7.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.pictureBox7.Location = new System.Drawing.Point(0, 233);
			this.pictureBox7.Name = "pictureBox7";
			this.pictureBox7.Size = new System.Drawing.Size(656, 23);
			this.pictureBox7.TabIndex = 10;
			this.pictureBox7.TabStop = false;
			// 
			// txtDiagnosis2
			// 
			this.txtDiagnosis2.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(241)), ((System.Byte)(241)), ((System.Byte)(241)));
			this.txtDiagnosis2.Location = new System.Drawing.Point(484, 44);
			this.txtDiagnosis2.Name = "txtDiagnosis2";
			this.txtDiagnosis2.ReadOnly = true;
			this.txtDiagnosis2.Size = new System.Drawing.Size(140, 21);
			this.txtDiagnosis2.TabIndex = 6;
			this.txtDiagnosis2.TabStop = false;
			this.txtDiagnosis2.Text = "";
			this.txtDiagnosis2.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtDiagnosis2_KeyDown);
			// 
			// txtDiagnosis1
			// 
			this.txtDiagnosis1.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(241)), ((System.Byte)(241)), ((System.Byte)(241)));
			this.txtDiagnosis1.Location = new System.Drawing.Point(244, 44);
			this.txtDiagnosis1.Name = "txtDiagnosis1";
			this.txtDiagnosis1.ReadOnly = true;
			this.txtDiagnosis1.Size = new System.Drawing.Size(140, 21);
			this.txtDiagnosis1.TabIndex = 3;
			this.txtDiagnosis1.TabStop = false;
			this.txtDiagnosis1.Text = "";
			this.txtDiagnosis1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtDiagnosis1_KeyDown);
			// 
			// lblDiagnosis2
			// 
			this.lblDiagnosis2.AutoSize = true;
			this.lblDiagnosis2.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(186)), ((System.Byte)(209)), ((System.Byte)(247)));
			this.lblDiagnosis2.Location = new System.Drawing.Point(424, 47);
			this.lblDiagnosis2.Name = "lblDiagnosis2";
			this.lblDiagnosis2.Size = new System.Drawing.Size(54, 17);
			this.lblDiagnosis2.TabIndex = 7;
			this.lblDiagnosis2.Text = "诊断二：";
			// 
			// lblDiagnosis1
			// 
			this.lblDiagnosis1.AutoSize = true;
			this.lblDiagnosis1.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(186)), ((System.Byte)(209)), ((System.Byte)(247)));
			this.lblDiagnosis1.Location = new System.Drawing.Point(184, 47);
			this.lblDiagnosis1.Name = "lblDiagnosis1";
			this.lblDiagnosis1.Size = new System.Drawing.Size(54, 17);
			this.lblDiagnosis1.TabIndex = 5;
			this.lblDiagnosis1.Text = "诊断一：";
			// 
			// lblPrescribeType
			// 
			this.lblPrescribeType.AutoSize = true;
			this.lblPrescribeType.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(186)), ((System.Byte)(209)), ((System.Byte)(247)));
			this.lblPrescribeType.Location = new System.Drawing.Point(16, 47);
			this.lblPrescribeType.Name = "lblPrescribeType";
			this.lblPrescribeType.Size = new System.Drawing.Size(42, 17);
			this.lblPrescribeType.TabIndex = 3;
			this.lblPrescribeType.Text = "诊别：";
			// 
			// groupBox3
			// 
			this.groupBox3.BackColor = System.Drawing.Color.AliceBlue;
			this.groupBox3.Controls.Add(this.panel3);
			this.groupBox3.Controls.Add(this.btnSelectDisease2);
			this.groupBox3.Controls.Add(this.btnSelectDisease1);
			this.groupBox3.Controls.Add(this.rdoFurtherVisit);
			this.groupBox3.Controls.Add(this.txtDiagnosis2);
			this.groupBox3.Controls.Add(this.txtDiagnosis1);
			this.groupBox3.Controls.Add(this.rdoFirstVisit);
			this.groupBox3.Controls.Add(this.lblDiagnosis2);
			this.groupBox3.Controls.Add(this.lblDiagnosis1);
			this.groupBox3.Controls.Add(this.lblPrescribeType);
			this.groupBox3.Controls.Add(this.pictureBox6);
			this.groupBox3.Controls.Add(this.pictureBox11);
			this.groupBox3.Location = new System.Drawing.Point(8, 364);
			this.groupBox3.Name = "groupBox3";
			this.groupBox3.Size = new System.Drawing.Size(656, 68);
			this.groupBox3.TabIndex = 2;
			this.groupBox3.TabStop = false;
			this.groupBox3.Text = "就诊内容";
			// 
			// pictureBox12
			// 
			this.pictureBox12.Dock = System.Windows.Forms.DockStyle.Right;
			this.pictureBox12.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox12.Image")));
			this.pictureBox12.Location = new System.Drawing.Point(536, 0);
			this.pictureBox12.Name = "pictureBox12";
			this.pictureBox12.Size = new System.Drawing.Size(120, 25);
			this.pictureBox12.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
			this.pictureBox12.TabIndex = 12;
			this.pictureBox12.TabStop = false;
			// 
			// pictureBox10
			// 
			this.pictureBox10.BackColor = System.Drawing.SystemColors.ControlLightLight;
			this.pictureBox10.Dock = System.Windows.Forms.DockStyle.Left;
			this.pictureBox10.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox10.Image")));
			this.pictureBox10.Location = new System.Drawing.Point(0, 0);
			this.pictureBox10.Name = "pictureBox10";
			this.pictureBox10.Size = new System.Drawing.Size(536, 25);
			this.pictureBox10.TabIndex = 10;
			this.pictureBox10.TabStop = false;
			// 
			// btnSelectDisease2
			// 
			this.btnSelectDisease2.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnSelectDisease2.BackgroundImage")));
			this.btnSelectDisease2.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.btnSelectDisease2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.btnSelectDisease2.Location = new System.Drawing.Point(624, 43);
			this.btnSelectDisease2.Name = "btnSelectDisease2";
			this.btnSelectDisease2.Size = new System.Drawing.Size(32, 23);
			this.btnSelectDisease2.TabIndex = 9;
			this.btnSelectDisease2.Text = "...";
			this.btnSelectDisease2.Click += new System.EventHandler(this.btnSelectDisease2_Click);
			// 
			// btnSelectDisease1
			// 
			this.btnSelectDisease1.BackColor = System.Drawing.SystemColors.InactiveCaptionText;
			this.btnSelectDisease1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnSelectDisease1.BackgroundImage")));
			this.btnSelectDisease1.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.btnSelectDisease1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.btnSelectDisease1.Location = new System.Drawing.Point(384, 43);
			this.btnSelectDisease1.Name = "btnSelectDisease1";
			this.btnSelectDisease1.Size = new System.Drawing.Size(32, 23);
			this.btnSelectDisease1.TabIndex = 4;
			this.btnSelectDisease1.Text = "...";
			this.btnSelectDisease1.Click += new System.EventHandler(this.btnSelectDisease1_Click);
			// 
			// rdoFurtherVisit
			// 
			this.rdoFurtherVisit.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(186)), ((System.Byte)(209)), ((System.Byte)(247)));
			this.rdoFurtherVisit.Checked = true;
			this.rdoFurtherVisit.Location = new System.Drawing.Point(104, 47);
			this.rdoFurtherVisit.Name = "rdoFurtherVisit";
			this.rdoFurtherVisit.Size = new System.Drawing.Size(48, 17);
			this.rdoFurtherVisit.TabIndex = 2;
			this.rdoFurtherVisit.TabStop = true;
			this.rdoFurtherVisit.Text = "复诊";
			this.rdoFurtherVisit.TextAlign = System.Drawing.ContentAlignment.TopCenter;
			// 
			// rdoFirstVisit
			// 
			this.rdoFirstVisit.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(186)), ((System.Byte)(209)), ((System.Byte)(247)));
			this.rdoFirstVisit.Location = new System.Drawing.Point(56, 47);
			this.rdoFirstVisit.Name = "rdoFirstVisit";
			this.rdoFirstVisit.Size = new System.Drawing.Size(48, 17);
			this.rdoFirstVisit.TabIndex = 1;
			this.rdoFirstVisit.Text = "初诊";
			this.rdoFirstVisit.TextAlign = System.Drawing.ContentAlignment.TopCenter;
			this.rdoFirstVisit.CheckedChanged += new System.EventHandler(this.rdoFirstVisit_CheckedChanged);
			// 
			// pictureBox6
			// 
			this.pictureBox6.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox6.Image")));
			this.pictureBox6.Location = new System.Drawing.Point(0, 25);
			this.pictureBox6.Name = "pictureBox6";
			this.pictureBox6.Size = new System.Drawing.Size(656, 6);
			this.pictureBox6.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
			this.pictureBox6.TabIndex = 10;
			this.pictureBox6.TabStop = false;
			// 
			// pictureBox11
			// 
			this.pictureBox11.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureBox11.BackgroundImage")));
			this.pictureBox11.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.pictureBox11.Location = new System.Drawing.Point(0, 43);
			this.pictureBox11.Name = "pictureBox11";
			this.pictureBox11.Size = new System.Drawing.Size(656, 23);
			this.pictureBox11.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
			this.pictureBox11.TabIndex = 13;
			this.pictureBox11.TabStop = false;
			// 
			// panel1
			// 
			this.panel1.Controls.Add(this.pictureBox1);
			this.panel1.Controls.Add(this.pictureBox2);
			this.panel1.Location = new System.Drawing.Point(0, 0);
			this.panel1.Name = "panel1";
			this.panel1.Size = new System.Drawing.Size(656, 25);
			this.panel1.TabIndex = 5;
			// 
			// panel2
			// 
			this.panel2.Controls.Add(this.pictureBox4);
			this.panel2.Controls.Add(this.pictureBox5);
			this.panel2.Location = new System.Drawing.Point(0, 0);
			this.panel2.Name = "panel2";
			this.panel2.Size = new System.Drawing.Size(656, 25);
			this.panel2.TabIndex = 11;
			// 
			// panel3
			// 
			this.panel3.Controls.Add(this.pictureBox10);
			this.panel3.Controls.Add(this.pictureBox12);
			this.panel3.Location = new System.Drawing.Point(0, 0);
			this.panel3.Name = "panel3";
			this.panel3.Size = new System.Drawing.Size(656, 25);
			this.panel3.TabIndex = 14;
			// 
			// frmPrescriptionNew
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackColor = System.Drawing.SystemColors.InactiveCaptionText;
			this.ClientSize = new System.Drawing.Size(674, 468);
			this.Controls.Add(this.groupBox3);
			this.Controls.Add(this.groupBox2);
			this.Controls.Add(this.groupBox1);
			this.Controls.Add(this.btnCancel);
			this.Controls.Add(this.btnSave);
			this.ForeColor = System.Drawing.SystemColors.Desktop;
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "frmPrescriptionNew";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "就诊界面";
			this.Load += new System.EventHandler(this.frmPrescriptionNew_Load);
			this.groupBox1.ResumeLayout(false);
			this.groupBox2.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.grdPrescriptionDetail)).EndInit();
			this.groupBox3.ResumeLayout(false);
			this.panel1.ResumeLayout(false);
			this.panel2.ResumeLayout(false);
			this.panel3.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void btnCancel_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void frmPrescriptionNew_Load(object sender, System.EventArgs e)
		{
			try
			{
				SetgrdPrescriptionDetailStyle();
				this._prescriptionsEx=new PrescriptionsEx();
				this._dvPrescriptionDetail=new DataView(this._prescriptionsEx.t_PrescriptionDetail,"","RxID,LineNumber",DataViewRowState.CurrentRows);

				grdPrescriptionDetail.SetDataBinding(_dvPrescriptionDetail,string.Empty);
				SetButtonEnabled();
			}
			catch(Exception ex)
			{
				MessageProcess.ShowError(ex.Message);
			}
		}
        
		/// <summary>
		/// 设置grdPrescriptionDetail的显示风格
		/// </summary>
		private void SetgrdPrescriptionDetailStyle()
		{
			DataGridTableStyle tableStyle=new DataGridTableStyle();

			//增加一列用于显示LineNumber
			DataGridColumnStyle columnStyleLineNumber=new DataGridTextBoxColumnEx();
			columnStyleLineNumber.HeaderText="序";
			columnStyleLineNumber.Alignment=HorizontalAlignment.Center;
			columnStyleLineNumber.MappingName=PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_LineNumber;
			columnStyleLineNumber.Width=30;						
			tableStyle.GridColumnStyles.Add(columnStyleLineNumber);	

			//增加一列用于显示MedicineName
			DataGridTextBoxColumnEx columnStyleMedicineName=new DataGridTextBoxColumnEx();			
			columnStyleMedicineName.HeaderText="药品名";
			columnStyleMedicineName.MappingName=PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_MedicineName;			
			columnStyleMedicineName.Width=125;				
			tableStyle.GridColumnStyles.Add(columnStyleMedicineName);

			//增加一列用于显示MedicineSpec
			DataGridTextBoxColumnEx columnStyleMedicineSpec=new DataGridTextBoxColumnEx();			
			columnStyleMedicineSpec.HeaderText="规格";
			columnStyleMedicineSpec.MappingName=PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_MedicineSpec;			
			columnStyleMedicineSpec.Width=100;
			tableStyle.GridColumnStyles.Add(columnStyleMedicineSpec);

			//增加一列用于显示Quantity
			DataGridTextBoxColumnEx columnStyleQuantity=new DataGridTextBoxColumnEx();			
			columnStyleQuantity.HeaderText="数量";
			columnStyleQuantity.Alignment=HorizontalAlignment.Right;
			columnStyleQuantity.MappingName=PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_Quantity;			
			columnStyleQuantity.Width=40;
			tableStyle.GridColumnStyles.Add(columnStyleQuantity);

			//增加一列用于显示DailyTimes
			DataGridTextBoxColumnEx columnStyleDailyTimes=new DataGridTextBoxColumnEx();			
			columnStyleDailyTimes.HeaderText="次/日";
			columnStyleDailyTimes.MappingName=PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_DailyTimes;			
			columnStyleDailyTimes.Alignment=HorizontalAlignment.Right;
			columnStyleDailyTimes.Width=40;
			tableStyle.GridColumnStyles.Add(columnStyleDailyTimes);

			//增加一列用于显示DosageEverytime
			DataGridTextBoxColumnEx columnStyleDosageEverytime=new DataGridTextBoxColumnEx();			
			columnStyleDosageEverytime.HeaderText="用量/次";
			columnStyleDosageEverytime.Alignment=HorizontalAlignment.Right;
			columnStyleDosageEverytime.MappingName=PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_DosageEverytime;			
			columnStyleDosageEverytime.Width=50;
			tableStyle.GridColumnStyles.Add(columnStyleDosageEverytime);

			//增加一列用于显示UnitName
			DataGridTextBoxColumnEx columnStyleUnitName=new DataGridTextBoxColumnEx();			
			columnStyleUnitName.HeaderText="单位";
			columnStyleUnitName.Alignment=HorizontalAlignment.Center;
			columnStyleUnitName.MappingName=PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_UnitName;			
			columnStyleUnitName.Width=30;
			tableStyle.GridColumnStyles.Add(columnStyleUnitName); 

			//增加一列用于显示CommomUsage
			DataGridTextBoxColumnEx columnStyleCommomUsage=new DataGridTextBoxColumnEx();
			
			columnStyleCommomUsage.HeaderText="用法";
			columnStyleCommomUsage.MappingName=PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_CommomUsage;			
			columnStyleCommomUsage.Width=80;
			tableStyle.GridColumnStyles.Add(columnStyleCommomUsage);

			//增加一列用于显示UnitPrice
			DataGridDecimalColumn columnStyleUnitPrice=new DataGridDecimalColumn();
			
			columnStyleUnitPrice.HeaderText="单价";
			columnStyleUnitPrice.Alignment=HorizontalAlignment.Right;
			columnStyleUnitPrice.MappingName=PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_UnitPrice;			
			columnStyleUnitPrice.Width=55;
			tableStyle.GridColumnStyles.Add(columnStyleUnitPrice);

			//增加一列用于显示SubTotal
			DataGridDecimalColumn columnStyleSubTotal=new DataGridDecimalColumn();
			
			columnStyleSubTotal.HeaderText="小计";
			columnStyleSubTotal.Alignment=HorizontalAlignment.Right;
			columnStyleSubTotal.MappingName=PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_SubTotal;			
			columnStyleSubTotal.Width=65;
			tableStyle.GridColumnStyles.Add(columnStyleSubTotal);

			tableStyle.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			tableStyle.MappingName = PrescriptionsEx.t_PrescriptionDetailDataTableEx.TableName_PrescriptionDetail;
			tableStyle.RowHeadersVisible = false;			
			tableStyle.AllowSorting=false;	
        
			tableStyle.AlternatingBackColor = System.Drawing.Color.LightGray;
			
		
			grdPrescriptionDetail.TableStyles.Add(tableStyle);	
			grdPrescriptionDetail.ReadOnly=true;			
		}

		private void patientInfo_GetPatientInfoCompleted()
		{

			DoctorsEx doctorsEx=(DoctorsEx)CacheDataManager.GetCacheData(DoctorsEx.t_DoctorDataTableEx.TableName_Doctor);	
		
			RegistrationsEx registrationsEx=(new Registration()).FindRegistration(
				Convert.ToInt32(patientInfo.PatientRow[PatientsEx.t_PatientDataTableEx.FIELD_PatientID]),
				Convert.ToInt32(doctorsEx.t_Doctor.Rows[0][DoctorsEx.t_DoctorDataTableEx.FIELD_DoctorID])
				);

			if(registrationsEx ==null)
			{
				if(MessageProcess.ShowQuestion("该病人还未挂号，是否继续？") == DialogResult.No)
				{				
					_RegistrationRow=null;
					_prescriptionMasterRow=null;
					patientInfo.WaitForFindNextPatient();
					SetButtonEnabled();
					return;
				};
				_RegistrationRow=null;
			}
			else
			{
				_RegistrationRow=(RegistrationsEx.t_RegistrationRow) registrationsEx.t_Registration.Rows[0];
			}
			
			if(_prescriptionsEx.t_PrescriptionMaster.Rows.Count>0)
			{
				_prescriptionsEx.t_PrescriptionMaster.Rows.Clear();
			}			

			_prescriptionMasterRow=_prescriptionsEx.t_PrescriptionMaster.Newt_PrescriptionMasterRow();
			_prescriptionMasterRow.BeginEdit();

			_prescriptionMasterRow[PrescriptionsEx.t_PrescriptionMasterDataTableEx.FIELD_PatientID]=patientInfo.PatientRow[PatientsEx.t_PatientDataTableEx.FIELD_PatientID];
			_prescriptionMasterRow[PrescriptionsEx.t_PrescriptionMasterDataTableEx.FIELD_PatientName]=patientInfo.PatientRow[PatientsEx.t_PatientDataTableEx.FIELD_Name];	
			_prescriptionMasterRow[PrescriptionsEx.t_PrescriptionMasterDataTableEx.FIELD_FirstVisit]=rdoFirstVisit.Checked;
			_prescriptionMasterRow[PrescriptionsEx.t_PrescriptionMasterDataTableEx.FIELD_DepartmentID]=doctorsEx.t_Doctor[0][DoctorsEx.t_DoctorDataTableEx.FIELD_DepartmentID];
			_prescriptionMasterRow[PrescriptionsEx.t_PrescriptionMasterDataTableEx.FIELD_DepartmentName]=doctorsEx.t_Doctor[0][DoctorsEx.t_DoctorDataTableEx.FIELD_DepartmentName];;
			_prescriptionMasterRow[PrescriptionsEx.t_PrescriptionMasterDataTableEx.FIELD_PrescriberID]=doctorsEx.t_Doctor[0][DoctorsEx.t_DoctorDataTableEx.FIELD_DoctorID];
			_prescriptionMasterRow[PrescriptionsEx.t_PrescriptionMasterDataTableEx.FIELD_PrescriberName]=doctorsEx.t_Doctor[0][DoctorsEx.t_DoctorDataTableEx.FIELD_Name];
			_prescriptionMasterRow[PrescriptionsEx.t_PrescriptionMasterDataTableEx.FIELD_MakeDate]=DateTime.Now;
			_prescriptionMasterRow[PrescriptionsEx.t_PrescriptionMasterDataTableEx.FIELD_Status]=PrescriptionsEx.PrescriptionStatus.Maked;				
			_prescriptionMasterRow.EndEdit();
			_prescriptionsEx.t_PrescriptionMaster.Addt_PrescriptionMasterRow(_prescriptionMasterRow);
			
			SetButtonEnabled();
		}
		private void btnSave_Click(object sender, System.EventArgs e)
		{
			try
			{
				(new Prescription()).SavePrescriptions(_prescriptionsEx,_RegistrationRow==null?0:_RegistrationRow.RegistrationID);
				_prescriptionsEx.Clear();
				_RegistrationRow=null;
				_prescriptionMasterRow=null;
				patientInfo.WaitForFindNextPatient();
				MessageProcess.ShowInformation("保存处方信息成功!");
				SetButtonEnabled();
			}
			catch(Exception ex)
			{
				MessageProcess.ShowError("保存处方信息出错！\n原因："+ex.Message);
			}
		}

		private void InitControls()
		{
			
		}

		private void rdoFirstVisit_CheckedChanged(object sender, System.EventArgs e)
		{
			if(_prescriptionMasterRow != null)
			{
				_prescriptionMasterRow[PrescriptionsEx.t_PrescriptionMasterDataTableEx.FIELD_FirstVisit]=rdoFirstVisit.Checked;
			}
		}

		private void SetButtonEnabled()
		{
			bool status1=_prescriptionMasterRow != null;
			bool status2=_dvPrescriptionDetail.Count>0;

			btnAdd.Enabled=status1;
			btnEdit.Enabled=status1 && status2;
			btnDelete.Enabled=status1  && status2;

			btnSelectDisease1.Enabled=status1;
			btnSelectDisease2.Enabled=status1;

			btnSave.Enabled=status1 && status2;

			rdoFirstVisit.Enabled=status1;
			rdoFurtherVisit.Enabled=status1;
			txtDiagnosis1.Enabled=status1;
			txtDiagnosis2.Enabled=status1;
			btnSelectDisease1.Enabled=status1;
			btnSelectDisease2.Enabled=status1;
		}

		private void btnAdd_Click(object sender, System.EventArgs e)
		{
			frmSelectMedicine frmselectMedicine=new frmSelectMedicine();
			
			//增加药品信息
			if(frmselectMedicine.ShowDialog() == DialogResult.OK )
			{
				Prescriptions.t_PrescriptionDetailRow prescriptionDetailRow=frmselectMedicine.PrescriptionDetailRow;
				
				DataRowView drv=_dvPrescriptionDetail.AddNew();
				drv.BeginEdit();
				drv[PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_RxID]= this._prescriptionMasterRow[PrescriptionsEx.t_PrescriptionMasterDataTableEx.FIELD_RxID];
				drv[PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_LineNumber]=_dvPrescriptionDetail.Count;
				drv[PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_MedicineID]=prescriptionDetailRow[PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_MedicineID];
				drv[PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_MedicineName]=prescriptionDetailRow[PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_MedicineName];
				drv[PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_MedicineSpec]=prescriptionDetailRow[PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_MedicineSpec];
				drv[PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_DailyTimes]=prescriptionDetailRow[PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_DailyTimes];
				drv[PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_DosageEverytime]=prescriptionDetailRow[PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_DosageEverytime];
				drv[PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_CommomUsage]=prescriptionDetailRow[PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_CommomUsage];
				drv[PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_Quantity]=prescriptionDetailRow[PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_Quantity];
				drv[PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_UnitName]=prescriptionDetailRow[PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_UnitName];
				drv[PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_UnitPrice]=prescriptionDetailRow[PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_UnitPrice];
				drv[PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_SubTotal]=prescriptionDetailRow[PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_SubTotal];
				drv.EndEdit();  
			
				ShowSumTotal();
			}

			frmselectMedicine.Dispose();
			SetButtonEnabled();
		}

		private void btnEdit_Click(object sender, System.EventArgs e)
		{
			PrescriptionsEx.t_PrescriptionDetailRow prescriptionDetailRow= _prescriptionsEx.t_PrescriptionDetail.FindByRxIDLineNumber(
				Convert.ToInt64(_dvPrescriptionDetail[grdPrescriptionDetail.CurrentCell.RowNumber][PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_RxID]),
				Convert.ToInt16(_dvPrescriptionDetail[grdPrescriptionDetail.CurrentCell.RowNumber][PrescriptionsEx.t_PrescriptionDetailDataTableEx.FIELD_LineNumber])
				);
			if( prescriptionDetailRow != null )
			{
				frmSelectMedicine frmselectMedicine=new frmSelectMedicine();
				frmselectMedicine.PrescriptionDetailRow=prescriptionDetailRow;
			
				//增加药品信息
				if(frmselectMedicine.ShowDialog() == DialogResult.OK )
				{
					prescriptionDetailRow.EndEdit();
					
					ShowSumTotal();
				}
				frmselectMedicine.Dispose();
			}
		}

		private void btnDelete_Click(object sender, System.EventArgs e)
		{
			_dvPrescriptionDetail.Delete(grdPrescriptionDetail.CurrentCell.RowNumber);
			SetButtonEnabled();
			ShowSumTotal();
		}
		
		/// <summary>
		/// 显示药品价格总计
		/// </summary>
		private void ShowSumTotal()
		{
			decimal SumTotal=Prescription.CalculateSumTotal(_prescriptionsEx.t_PrescriptionDetail);
			_prescriptionMasterRow[PrescriptionsEx.t_PrescriptionMasterDataTableEx.FIELD_SumTotal]=SumTotal;
			lblSumTotalValue.Text=SumTotal.ToString("0.00");
		}

		private void btnSelectDisease1_Click(object sender, System.EventArgs e)
		{
			frmSelectDisease frmselectDisease=new frmSelectDisease();

			SetSelectDiseaseFormShowOnButtonLocation(btnSelectDisease1,frmselectDisease);
			if(frmselectDisease.ShowDialog() == DialogResult.OK )
			{
				DiseasesEx.t_DiseaseRow diseaseRow=frmselectDisease.DiseaseRow;
				_prescriptionMasterRow[PrescriptionsEx.t_PrescriptionMasterDataTableEx.FIELD_Diagnosis1ID]=diseaseRow[DiseasesEx.t_DiseaseDataTableEx.FIELD_DiseaseID];
				_prescriptionMasterRow[PrescriptionsEx.t_PrescriptionMasterDataTableEx.FIELD_Diagnosis1Name]=diseaseRow[DiseasesEx.t_DiseaseDataTableEx.FIELD_Name];

				txtDiagnosis1.Text=_prescriptionMasterRow[PrescriptionsEx.t_PrescriptionMasterDataTableEx.FIELD_Diagnosis1Name].ToString();
			}
			frmselectDisease.Dispose();
		}

		/// <summary>
		/// 设置选择疾病信息窗口显示按钮上方的位置
		/// </summary>
		/// <param name="button"></param>
		/// <param name="selectDiseaseForm"></param>
		private void SetSelectDiseaseFormShowOnButtonLocation(Button button,frmSelectDisease selectDiseaseForm)
		{
			Rectangle rect=button.ClientRectangle;			
			Point temp=button.RectangleToScreen(rect).Location;

			temp.X=temp.X-selectDiseaseForm.Width+button.Width;
			temp.Y=temp.Y-selectDiseaseForm.Height;
			
			selectDiseaseForm.Location=temp;
		}

		private void btnSelectDisease2_Click(object sender, System.EventArgs e)
		{
			frmSelectDisease frmselectDisease=new frmSelectDisease();

			SetSelectDiseaseFormShowOnButtonLocation(btnSelectDisease2,frmselectDisease);
			if(frmselectDisease.ShowDialog() == DialogResult.OK )
			{
				DiseasesEx.t_DiseaseRow diseaseRow=frmselectDisease.DiseaseRow;
				_prescriptionMasterRow[PrescriptionsEx.t_PrescriptionMasterDataTableEx.FIELD_Diagnosis2ID]=diseaseRow[DiseasesEx.t_DiseaseDataTableEx.FIELD_DiseaseID];
				_prescriptionMasterRow[PrescriptionsEx.t_PrescriptionMasterDataTableEx.FIELD_Diagnosis2Name]=diseaseRow[DiseasesEx.t_DiseaseDataTableEx.FIELD_Name];

				txtDiagnosis2.Text=_prescriptionMasterRow[PrescriptionsEx.t_PrescriptionMasterDataTableEx.FIELD_Diagnosis2Name].ToString();
			}
			frmselectDisease.Dispose();
		}

		private void txtDiagnosis1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{

			if(e.KeyCode==Keys.Delete || e.KeyCode==Keys.Back)
			{
				txtDiagnosis1.Text="";
				_prescriptionMasterRow[PrescriptionsEx.t_PrescriptionMasterDataTableEx.FIELD_Diagnosis1ID]=DBNull.Value;
				_prescriptionMasterRow[PrescriptionsEx.t_PrescriptionMasterDataTableEx.FIELD_Diagnosis1Name]=DBNull.Value;
			}
		}

		private void txtDiagnosis2_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if(e.KeyCode==Keys.Delete || e.KeyCode==Keys.Back)
			{
				txtDiagnosis2.Text="";
				_prescriptionMasterRow[PrescriptionsEx.t_PrescriptionMasterDataTableEx.FIELD_Diagnosis2ID]=DBNull.Value;
				_prescriptionMasterRow[PrescriptionsEx.t_PrescriptionMasterDataTableEx.FIELD_Diagnosis2Name]=DBNull.Value;
			}
		}
	}
}
