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

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

namespace HISClinic
{
	/// <summary>
	/// frmRegistrationNew 的摘要说明。
	/// </summary>
	public class frmRegistrationNew : System.Windows.Forms.Form
	{
		//用于绑定数据到控件的数据视图
		private DataView _dvDepartments;
		private DataView _dvRegistrationTypes;
		private DataView _dvDoctors;
		private System.Windows.Forms.Button btnCancel;
		private System.Windows.Forms.Button btnSave;
		private System.Windows.Forms.ComboBox cboRegistrationType;
		private System.Windows.Forms.DataGrid grdDepartment;
		private HISClinic.Controls.PatientInfo patientInfo;
		private System.Windows.Forms.GroupBox grpPatientInfo;
		private System.Windows.Forms.GroupBox grpDepartment;
		private System.Windows.Forms.GroupBox grpRegistrationType;
		private System.Windows.Forms.GroupBox grpDoctor;
		private System.Windows.Forms.DataGrid grdDoctor;
		private System.Windows.Forms.PictureBox pictureBox2;
		private System.Windows.Forms.PictureBox pictureBox1;
		private System.Windows.Forms.PictureBox pictureBox8;
		private System.Windows.Forms.PictureBox pictureBox3;
		private System.Windows.Forms.PictureBox pictureBox4;
		private System.Windows.Forms.PictureBox pictureBox6;
		private System.Windows.Forms.PictureBox pictureBox9;
		private System.Windows.Forms.PictureBox pictureBox12;
		private System.Windows.Forms.PictureBox pictureBox13;
		private System.Windows.Forms.PictureBox pictureBox7;
		private System.Windows.Forms.PictureBox pictureBox10;
		private System.Windows.Forms.PictureBox pictureBox5;
		private System.Windows.Forms.PictureBox pictureBox11;
		private System.Windows.Forms.Panel panel1;
		private System.Windows.Forms.Panel panel2;
		private System.Windows.Forms.Panel panel3;
		private System.Windows.Forms.Panel panel4;
		
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmRegistrationNew()
		{
			//
			// 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(frmRegistrationNew));
			this.grpPatientInfo = new System.Windows.Forms.GroupBox();
			this.pictureBox8 = 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.grpDepartment = new System.Windows.Forms.GroupBox();
			this.pictureBox10 = new System.Windows.Forms.PictureBox();
			this.pictureBox4 = new System.Windows.Forms.PictureBox();
			this.pictureBox3 = new System.Windows.Forms.PictureBox();
			this.grdDepartment = new System.Windows.Forms.DataGrid();
			this.cboRegistrationType = new System.Windows.Forms.ComboBox();
			this.btnCancel = new System.Windows.Forms.Button();
			this.btnSave = new System.Windows.Forms.Button();
			this.grpRegistrationType = new System.Windows.Forms.GroupBox();
			this.pictureBox5 = new System.Windows.Forms.PictureBox();
			this.pictureBox13 = new System.Windows.Forms.PictureBox();
			this.pictureBox12 = new System.Windows.Forms.PictureBox();
			this.pictureBox11 = new System.Windows.Forms.PictureBox();
			this.grpDoctor = new System.Windows.Forms.GroupBox();
			this.pictureBox7 = new System.Windows.Forms.PictureBox();
			this.pictureBox9 = new System.Windows.Forms.PictureBox();
			this.pictureBox6 = new System.Windows.Forms.PictureBox();
			this.grdDoctor = new System.Windows.Forms.DataGrid();
			this.panel1 = new System.Windows.Forms.Panel();
			this.panel2 = new System.Windows.Forms.Panel();
			this.panel3 = new System.Windows.Forms.Panel();
			this.panel4 = new System.Windows.Forms.Panel();
			this.grpPatientInfo.SuspendLayout();
			this.grpDepartment.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.grdDepartment)).BeginInit();
			this.grpRegistrationType.SuspendLayout();
			this.grpDoctor.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.grdDoctor)).BeginInit();
			this.panel1.SuspendLayout();
			this.panel2.SuspendLayout();
			this.panel3.SuspendLayout();
			this.panel4.SuspendLayout();
			this.SuspendLayout();
			// 
			// grpPatientInfo
			// 
			this.grpPatientInfo.Controls.Add(this.panel1);
			this.grpPatientInfo.Controls.Add(this.pictureBox8);
			this.grpPatientInfo.Controls.Add(this.patientInfo);
			this.grpPatientInfo.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.grpPatientInfo.Location = new System.Drawing.Point(8, 5);
			this.grpPatientInfo.Name = "grpPatientInfo";
			this.grpPatientInfo.Size = new System.Drawing.Size(660, 90);
			this.grpPatientInfo.TabIndex = 0;
			this.grpPatientInfo.TabStop = false;
			this.grpPatientInfo.Text = "病人信息";
			// 
			// 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(660, 6);
			this.pictureBox8.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
			this.pictureBox8.TabIndex = 10;
			this.pictureBox8.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(540, 0);
			this.pictureBox2.Name = "pictureBox2";
			this.pictureBox2.Size = new System.Drawing.Size(120, 25);
			this.pictureBox2.TabIndex = 7;
			this.pictureBox2.TabStop = false;
			this.pictureBox2.Click += new System.EventHandler(this.pictureBox2_Click);
			// 
			// pictureBox1
			// 
			this.pictureBox1.BackColor = System.Drawing.SystemColors.ControlLightLight;
			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(544, 25);
			this.pictureBox1.TabIndex = 6;
			this.pictureBox1.TabStop = false;
			// 
			// patientInfo
			// 
			this.patientInfo.BackColor = System.Drawing.Color.AliceBlue;
			this.patientInfo.Location = new System.Drawing.Point(0, 32);
			this.patientInfo.Name = "patientInfo";
			this.patientInfo.Size = new System.Drawing.Size(660, 55);
			this.patientInfo.TabIndex = 0;
			this.patientInfo.GetPatientInfoFailed += new HISClinic.Controls.OnGetPatientInfoFailed(this.patientInfo_GetPatientInfoFailed);
			this.patientInfo.GetPatientInfoCompleted += new HISClinic.Controls.OnGetPatientInfoCompleted(this.patientInfo_GetPatientInfoCompleted);
			// 
			// grpDepartment
			// 
			this.grpDepartment.BackColor = System.Drawing.Color.AliceBlue;
			this.grpDepartment.Controls.Add(this.panel2);
			this.grpDepartment.Controls.Add(this.pictureBox10);
			this.grpDepartment.Controls.Add(this.grdDepartment);
			this.grpDepartment.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.grpDepartment.Location = new System.Drawing.Point(8, 100);
			this.grpDepartment.Name = "grpDepartment";
			this.grpDepartment.Size = new System.Drawing.Size(260, 240);
			this.grpDepartment.TabIndex = 1;
			this.grpDepartment.TabStop = false;
			this.grpDepartment.Text = "门诊科室";
			// 
			// pictureBox10
			// 
			this.pictureBox10.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox10.Image")));
			this.pictureBox10.Location = new System.Drawing.Point(0, 25);
			this.pictureBox10.Name = "pictureBox10";
			this.pictureBox10.Size = new System.Drawing.Size(260, 6);
			this.pictureBox10.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
			this.pictureBox10.TabIndex = 13;
			this.pictureBox10.TabStop = false;
			// 
			// pictureBox4
			// 
			this.pictureBox4.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureBox4.BackgroundImage")));
			this.pictureBox4.Dock = System.Windows.Forms.DockStyle.Right;
			this.pictureBox4.Location = new System.Drawing.Point(140, 0);
			this.pictureBox4.Name = "pictureBox4";
			this.pictureBox4.Size = new System.Drawing.Size(120, 25);
			this.pictureBox4.TabIndex = 8;
			this.pictureBox4.TabStop = false;
			// 
			// pictureBox3
			// 
			this.pictureBox3.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureBox3.BackgroundImage")));
			this.pictureBox3.Dock = System.Windows.Forms.DockStyle.Left;
			this.pictureBox3.Location = new System.Drawing.Point(0, 0);
			this.pictureBox3.Name = "pictureBox3";
			this.pictureBox3.Size = new System.Drawing.Size(144, 25);
			this.pictureBox3.TabIndex = 7;
			this.pictureBox3.TabStop = false;
			// 
			// grdDepartment
			// 
			this.grdDepartment.BackgroundColor = System.Drawing.Color.FromArgb(((System.Byte)(241)), ((System.Byte)(241)), ((System.Byte)(241)));
			this.grdDepartment.CaptionVisible = false;
			this.grdDepartment.DataMember = "";
			this.grdDepartment.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.grdDepartment.Location = new System.Drawing.Point(1, 40);
			this.grdDepartment.Name = "grdDepartment";
			this.grdDepartment.Size = new System.Drawing.Size(256, 199);
			this.grdDepartment.TabIndex = 0;
			this.grdDepartment.CurrentCellChanged += new System.EventHandler(this.grdDepartment_CurrentCellChanged);
			// 
			// cboRegistrationType
			// 
			this.cboRegistrationType.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(241)), ((System.Byte)(241)), ((System.Byte)(241)));
			this.cboRegistrationType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cboRegistrationType.Location = new System.Drawing.Point(8, 38);
			this.cboRegistrationType.Name = "cboRegistrationType";
			this.cboRegistrationType.Size = new System.Drawing.Size(244, 20);
			this.cboRegistrationType.TabIndex = 1;
			this.cboRegistrationType.SelectedIndexChanged += new System.EventHandler(this.cboRegistrationType_SelectedIndexChanged);
			// 
			// btnCancel
			// 
			this.btnCancel.BackColor = System.Drawing.SystemColors.InactiveBorder;
			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(576, 406);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.Size = new System.Drawing.Size(64, 23);
			this.btnCancel.TabIndex = 3;
			this.btnCancel.Text = "取 消";
			this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
			// 
			// btnSave
			// 
			this.btnSave.BackColor = System.Drawing.SystemColors.InactiveBorder;
			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(496, 406);
			this.btnSave.Name = "btnSave";
			this.btnSave.Size = new System.Drawing.Size(64, 23);
			this.btnSave.TabIndex = 2;
			this.btnSave.Text = "挂 号";
			this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
			// 
			// grpRegistrationType
			// 
			this.grpRegistrationType.BackColor = System.Drawing.Color.AliceBlue;
			this.grpRegistrationType.Controls.Add(this.panel4);
			this.grpRegistrationType.Controls.Add(this.pictureBox5);
			this.grpRegistrationType.Controls.Add(this.cboRegistrationType);
			this.grpRegistrationType.Controls.Add(this.pictureBox11);
			this.grpRegistrationType.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.grpRegistrationType.Location = new System.Drawing.Point(8, 345);
			this.grpRegistrationType.Name = "grpRegistrationType";
			this.grpRegistrationType.Size = new System.Drawing.Size(260, 60);
			this.grpRegistrationType.TabIndex = 4;
			this.grpRegistrationType.TabStop = false;
			this.grpRegistrationType.Text = "门诊类型";
			// 
			// pictureBox5
			// 
			this.pictureBox5.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox5.Image")));
			this.pictureBox5.Location = new System.Drawing.Point(0, 25);
			this.pictureBox5.Name = "pictureBox5";
			this.pictureBox5.Size = new System.Drawing.Size(260, 6);
			this.pictureBox5.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
			this.pictureBox5.TabIndex = 14;
			this.pictureBox5.TabStop = false;
			// 
			// pictureBox13
			// 
			this.pictureBox13.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureBox13.BackgroundImage")));
			this.pictureBox13.Dock = System.Windows.Forms.DockStyle.Right;
			this.pictureBox13.Location = new System.Drawing.Point(140, 0);
			this.pictureBox13.Name = "pictureBox13";
			this.pictureBox13.Size = new System.Drawing.Size(120, 25);
			this.pictureBox13.TabIndex = 10;
			this.pictureBox13.TabStop = false;
			// 
			// pictureBox12
			// 
			this.pictureBox12.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureBox12.BackgroundImage")));
			this.pictureBox12.Dock = System.Windows.Forms.DockStyle.Left;
			this.pictureBox12.Location = new System.Drawing.Point(0, 0);
			this.pictureBox12.Name = "pictureBox12";
			this.pictureBox12.Size = new System.Drawing.Size(144, 25);
			this.pictureBox12.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
			this.pictureBox12.TabIndex = 9;
			this.pictureBox12.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, 37);
			this.pictureBox11.Name = "pictureBox11";
			this.pictureBox11.Size = new System.Drawing.Size(260, 23);
			this.pictureBox11.TabIndex = 15;
			this.pictureBox11.TabStop = false;
			// 
			// grpDoctor
			// 
			this.grpDoctor.BackColor = System.Drawing.Color.AliceBlue;
			this.grpDoctor.Controls.Add(this.panel3);
			this.grpDoctor.Controls.Add(this.pictureBox7);
			this.grpDoctor.Controls.Add(this.grdDoctor);
			this.grpDoctor.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.grpDoctor.Location = new System.Drawing.Point(274, 100);
			this.grpDoctor.Name = "grpDoctor";
			this.grpDoctor.Size = new System.Drawing.Size(395, 304);
			this.grpDoctor.TabIndex = 5;
			this.grpDoctor.TabStop = false;
			this.grpDoctor.Text = "门诊医生";
			// 
			// pictureBox7
			// 
			this.pictureBox7.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox7.Image")));
			this.pictureBox7.Location = new System.Drawing.Point(0, 25);
			this.pictureBox7.Name = "pictureBox7";
			this.pictureBox7.Size = new System.Drawing.Size(395, 6);
			this.pictureBox7.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
			this.pictureBox7.TabIndex = 12;
			this.pictureBox7.TabStop = false;
			// 
			// pictureBox9
			// 
			this.pictureBox9.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureBox9.BackgroundImage")));
			this.pictureBox9.Dock = System.Windows.Forms.DockStyle.Right;
			this.pictureBox9.Location = new System.Drawing.Point(275, 0);
			this.pictureBox9.Name = "pictureBox9";
			this.pictureBox9.Size = new System.Drawing.Size(120, 25);
			this.pictureBox9.TabIndex = 9;
			this.pictureBox9.TabStop = false;
			// 
			// pictureBox6
			// 
			this.pictureBox6.BackColor = System.Drawing.SystemColors.ControlLightLight;
			this.pictureBox6.Dock = System.Windows.Forms.DockStyle.Left;
			this.pictureBox6.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox6.Image")));
			this.pictureBox6.Location = new System.Drawing.Point(0, 0);
			this.pictureBox6.Name = "pictureBox6";
			this.pictureBox6.Size = new System.Drawing.Size(280, 25);
			this.pictureBox6.TabIndex = 8;
			this.pictureBox6.TabStop = false;
			// 
			// grdDoctor
			// 
			this.grdDoctor.BackgroundColor = System.Drawing.Color.FromArgb(((System.Byte)(241)), ((System.Byte)(241)), ((System.Byte)(241)));
			this.grdDoctor.CaptionVisible = false;
			this.grdDoctor.DataMember = "";
			this.grdDoctor.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.grdDoctor.Location = new System.Drawing.Point(1, 40);
			this.grdDoctor.Name = "grdDoctor";
			this.grdDoctor.Size = new System.Drawing.Size(391, 262);
			this.grdDoctor.TabIndex = 1;
			// 
			// 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(660, 25);
			this.panel1.TabIndex = 11;
			// 
			// panel2
			// 
			this.panel2.Controls.Add(this.pictureBox3);
			this.panel2.Controls.Add(this.pictureBox4);
			this.panel2.Location = new System.Drawing.Point(0, 0);
			this.panel2.Name = "panel2";
			this.panel2.Size = new System.Drawing.Size(260, 25);
			this.panel2.TabIndex = 14;
			// 
			// panel3
			// 
			this.panel3.Controls.Add(this.pictureBox6);
			this.panel3.Controls.Add(this.pictureBox9);
			this.panel3.Location = new System.Drawing.Point(0, 0);
			this.panel3.Name = "panel3";
			this.panel3.Size = new System.Drawing.Size(395, 25);
			this.panel3.TabIndex = 13;
			// 
			// panel4
			// 
			this.panel4.Controls.Add(this.pictureBox12);
			this.panel4.Controls.Add(this.pictureBox13);
			this.panel4.Location = new System.Drawing.Point(0, 0);
			this.panel4.Name = "panel4";
			this.panel4.Size = new System.Drawing.Size(260, 25);
			this.panel4.TabIndex = 16;
			// 
			// frmRegistrationNew
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackColor = System.Drawing.SystemColors.InactiveCaptionText;
			this.ClientSize = new System.Drawing.Size(674, 432);
			this.Controls.Add(this.grpRegistrationType);
			this.Controls.Add(this.btnSave);
			this.Controls.Add(this.btnCancel);
			this.Controls.Add(this.grpDepartment);
			this.Controls.Add(this.grpPatientInfo);
			this.Controls.Add(this.grpDoctor);
			this.ForeColor = System.Drawing.SystemColors.Desktop;
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "frmRegistrationNew";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "病人挂号";
			this.Load += new System.EventHandler(this.frmRegistrationNew_Load);
			this.grpPatientInfo.ResumeLayout(false);
			this.grpDepartment.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.grdDepartment)).EndInit();
			this.grpRegistrationType.ResumeLayout(false);
			this.grpDoctor.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.grdDoctor)).EndInit();
			this.panel1.ResumeLayout(false);
			this.panel2.ResumeLayout(false);
			this.panel3.ResumeLayout(false);
			this.panel4.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void frmRegistrationNew_Load(object sender, System.EventArgs e)
		{
			try
			{
				//设置DataGrid的风格
				SetgrdDepartmentStyle();
				SetgrdDoctorStyle();

				//获取门诊科室
				DepartmentsEx departmentsEx=(new Department()).GetDepartment();
				_dvDepartments=new DataView(departmentsEx.t_Department,"",DepartmentsEx.t_DepartmentDataTableEx.FIELD_DepartmentID,DataViewRowState.CurrentRows);
				grdDepartment.SetDataBinding(_dvDepartments,string.Empty);

				//获取门诊类型
				RegistrationTypesEx registrationTypesEx=(new RegistrationType()).GetRegistrationType();
				_dvRegistrationTypes=new DataView(registrationTypesEx.t_RegistrationType,"",RegistrationTypesEx.t_RegistrationTypeDataTableEx.FIELD_RegistrationTypeID,DataViewRowState.CurrentRows);
				cboRegistrationType.DataSource=_dvRegistrationTypes;
				cboRegistrationType.ValueMember=RegistrationTypesEx.t_RegistrationTypeDataTableEx.FIELD_RegistrationTypeID;
				cboRegistrationType.DisplayMember=RegistrationTypesEx.t_RegistrationTypeDataTableEx.FIELD_Name;

				//获取门诊医生
				DoctorsEx doctorsEx=(new User.Doctor()).GetDoctor();
				_dvDoctors=new DataView(doctorsEx.t_Doctor,"",DoctorsEx.t_DoctorDataTableEx.FIELD_DoctorID,DataViewRowState.CurrentRows);
				grdDoctor.SetDataBinding(_dvDoctors,string.Empty);

				FilterDoctor();
			}
			catch(Exception ex)
			{
				MessageProcess.ShowError(ex.Message);
			}
		}
		
		/// <summary>
		/// 通过DepartmentID和RegistrationTypeID过滤医生记录
		/// </summary>

		private void FilterDoctor()
		{
			if(_dvDepartments!=null && _dvRegistrationTypes!=null)
			{  
				if(_dvDepartments.Count == 0 || _dvRegistrationTypes.Count == 0)return;
				if(_dvDoctors!=null)
				{			
					_dvDoctors.RowFilter=DoctorsEx.t_DoctorDataTableEx.FIELD_DepartmentID  + "=" + _dvDepartments[grdDepartment.CurrentRowIndex][DepartmentsEx.t_DepartmentDataTableEx.FIELD_DepartmentID].ToString() +
						" AND " +
						DoctorsEx.t_DoctorDataTableEx.FIELD_RegistrationTypeID + "=" + _dvRegistrationTypes[cboRegistrationType.SelectedIndex][RegistrationTypesEx.t_RegistrationTypeDataTableEx.FIELD_RegistrationTypeID].ToString();
					
					btnSave.Enabled=(_dvDoctors.Count>0) && (patientInfo.PatientRow!=null);
				}
			}
		}

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

		private void btnSave_Click(object sender, System.EventArgs e)
		{
			try
			{
				RegistrationsEx registrationsEx=new  RegistrationsEx();
				RegistrationsEx.t_RegistrationRow registrationRow=registrationsEx.t_Registration.Newt_RegistrationRow();
				Patients.t_PatientRow patientRow=patientInfo.PatientRow;

				registrationRow.PatientID=patientRow.PatientID;
				registrationRow.RegistrationTypeID=Convert.ToInt16(_dvRegistrationTypes[cboRegistrationType.SelectedIndex][RegistrationTypesEx.t_RegistrationTypeDataTableEx.FIELD_RegistrationTypeID]);
				registrationRow.DeparptmentID=Convert.ToInt16(_dvDepartments[grdDepartment.CurrentRowIndex][DepartmentsEx.t_DepartmentDataTableEx.FIELD_DepartmentID]);
				registrationRow.RegistrarID=((Users.t_UserRow)((Users)CacheDataManager.GetCacheData(UsersEx.t_UserDataTableEx.TableName_User)).t_User.Rows[0]).UserID;
				registrationRow.DoctorID=Convert.ToInt16(_dvDoctors[grdDoctor.CurrentRowIndex][DoctorsEx.t_DoctorDataTableEx.FIELD_DoctorID]);;
				registrationRow.Status=Convert.ToByte(RegistrationsEx.RegistrationStatus.Available);
				
				registrationsEx.t_Registration.Rows.Add(registrationRow);

				//保存挂号信息
				(new Registration()).AddRegistration(registrationRow);

				MessageProcess.ShowInformation("保存挂号信息成功!");
				patientInfo.WaitForFindNextPatient();
				FilterDoctor();
			}
			catch(Exception ex)
			{
				MessageProcess.ShowError(ex.Message);
			}
		}

		/// <summary>
		/// 设置Department DataGried的显示风格
		/// </summary>
		private void SetgrdDepartmentStyle()
		{
			DataGridTableStyle tableStyle=new DataGridTableStyle();
            
			//增加一列用于显示门诊科室
			DataGridColumnStyle columnStyleName=new DataGridTextBoxColumnEx();
			columnStyleName.HeaderText="科室名";
			columnStyleName.MappingName=DepartmentsEx.t_DepartmentDataTableEx.FIELD_Name;
			columnStyleName.Width=grdDepartment.Width-4;						
			tableStyle.GridColumnStyles.Add(columnStyleName);	

			tableStyle.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			tableStyle.MappingName = DepartmentsEx.t_DepartmentDataTableEx.TableName_Department;
			tableStyle.RowHeadersVisible = false;
			tableStyle.AlternatingBackColor = System.Drawing.Color.LightGray;
			tableStyle.AllowSorting=false;		
			
			grdDepartment.TableStyles.Add(tableStyle);			
			grdDepartment.ReadOnly=true;			
		}

		/// <summary>
		/// 设置Doctor DataGried的显示风格
		/// </summary>
		private void SetgrdDoctorStyle()
		{
			DataGridTableStyle tableStyle=new DataGridTableStyle();

			//增加一列用于显示门诊医生
			DataGridColumnStyle columnStyleName=new DataGridTextBoxColumnEx();
			columnStyleName.HeaderText="姓名";
			columnStyleName.MappingName=DoctorsEx.t_DoctorDataTableEx.FIELD_Name;
			columnStyleName.Width=150;						
			tableStyle.GridColumnStyles.Add(columnStyleName);	

			//增加一列用于显示性别
			DataGridBoolColumnEx columnStyleSex=new DataGridBoolColumnEx();
			
			columnStyleSex.HeaderText="性别";
			columnStyleSex.MappingName=DoctorsEx.t_DoctorDataTableEx.FIELD_Sex;
			columnStyleSex.Translation.Add(true,"男");
			columnStyleSex.Translation.Add(false,"女");
			columnStyleSex.Alignment=HorizontalAlignment.Center;
			columnStyleSex.Width=75;				
			tableStyle.GridColumnStyles.Add(columnStyleSex);

			//增加一列用于显示性别
			DataGridTextBoxColumnEx columnStyleAge=new DataGridTextBoxColumnEx();
			
			columnStyleAge.HeaderText="年龄";
			columnStyleAge.MappingName=DoctorsEx.t_DoctorDataTableEx.FIELD_Age;
			columnStyleAge.Alignment=HorizontalAlignment.Center;
			columnStyleAge.Width=grdDoctor.Width - columnStyleName.Width - columnStyleSex.Width-4;	
			tableStyle.GridColumnStyles.Add(columnStyleAge);

			tableStyle.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			tableStyle.MappingName = DoctorsEx.t_DoctorDataTableEx.TableName_Doctor;
			tableStyle.RowHeadersVisible = false;						

			tableStyle.AlternatingBackColor = System.Drawing.Color.LightGray;
			tableStyle.AllowSorting=false;		
			
			grdDoctor.TableStyles.Add(tableStyle);	
			grdDoctor.ReadOnly=true;
		}

		private void grdDepartment_CurrentCellChanged(object sender, System.EventArgs e)
		{
			FilterDoctor();
		}

		private void cboRegistrationType_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			FilterDoctor();
		}

		private void patientInfo_GetPatientInfoCompleted()
		{
			FilterDoctor();
		}

		private void patientInfo_GetPatientInfoFailed()
		{
			btnSave.Enabled=false;
		}

		private void pictureBox2_Click(object sender, System.EventArgs e)
		{
		
		}
	}
}
