⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hosedit.cs

📁 实施医院管理系统
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using DataAccess;
using comman;

namespace main
{
	/// <summary>
	/// HosEdit 的摘要说明。
	/// </summary>
	public class HosEdit : System.Windows.Forms.Form
	{
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		private System.Windows.Forms.TextBox textBox1;
		private System.Windows.Forms.ComboBox comboBox1;
		private System.Windows.Forms.TextBox textBox2;
		private System.Windows.Forms.TextBox textBox3;
		private System.Windows.Forms.ComboBox comboBox2;
		private System.Windows.Forms.ComboBox comboBox3;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.GroupBox groupBox1;

		private HosptialAccess hosAccess = new HosptialAccess();
		private DictonaryAccess dicAccess = new DictonaryAccess();
		private CityAccess cityAccess = new CityAccess();
		private Hospital _hospital = new Hospital();

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

			this.Text = "新增医院";
			Dictionary[] dic = dicAccess.GetDetailByCate("医院级别");
			for(int i =0;i<dic.Length;i++)
			{
				this.comboBox1.Items.Add(dic[i]);
			}
			Dictionary[] dic1 = dicAccess.GetDetailByCate("所在省份");
			for(int i =0;i<dic1.Length;i++)
			{
				this.comboBox2.Items.Add(dic1[i]);
			}
			
			

				 //
				 // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
				 //
			 }
		
		public HosEdit(string HosName,string HosGrade,string ProvinceName,string City,string Traffic,string Address)
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			this.Text = "医院信息修改";
			Dictionary[] dic = dicAccess.GetDetailByCate("医院级别");
			for(int i =0;i<dic.Length;i++)
			{
				this.comboBox1.Items.Add(dic[i]);
			}
			Dictionary[] dic1 = dicAccess.GetDetailByCate("所在省份");
			for(int i =0;i<dic1.Length;i++)
			{
				this.comboBox2.Items.Add(dic1[i]);
			}

			this.textBox1.Text = HosName;
			this.textBox2.Text = Traffic;
			this.textBox3.Text = Address;
			this.comboBox1.Text = HosGrade;
			this.comboBox2.Text = ProvinceName;
			this.comboBox3.Text = City;
			
			

			//
			// 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()
		{
			this.textBox1 = new System.Windows.Forms.TextBox();
			this.comboBox1 = new System.Windows.Forms.ComboBox();
			this.comboBox2 = new System.Windows.Forms.ComboBox();
			this.comboBox3 = new System.Windows.Forms.ComboBox();
			this.textBox2 = new System.Windows.Forms.TextBox();
			this.textBox3 = new System.Windows.Forms.TextBox();
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.label6 = new System.Windows.Forms.Label();
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.label4 = new System.Windows.Forms.Label();
			this.label5 = new System.Windows.Forms.Label();
			this.button1 = new System.Windows.Forms.Button();
			this.button2 = new System.Windows.Forms.Button();
			this.groupBox1.SuspendLayout();
			this.SuspendLayout();
			// 
			// textBox1
			// 
			this.textBox1.Location = new System.Drawing.Point(8, 32);
			this.textBox1.Name = "textBox1";
			this.textBox1.Size = new System.Drawing.Size(120, 21);
			this.textBox1.TabIndex = 0;
			this.textBox1.Text = "";
			// 
			// comboBox1
			// 
			this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.comboBox1.Location = new System.Drawing.Point(144, 32);
			this.comboBox1.Name = "comboBox1";
			this.comboBox1.Size = new System.Drawing.Size(121, 20);
			this.comboBox1.TabIndex = 1;
			// 
			// comboBox2
			// 
			this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.comboBox2.Location = new System.Drawing.Point(8, 80);
			this.comboBox2.Name = "comboBox2";
			this.comboBox2.Size = new System.Drawing.Size(121, 20);
			this.comboBox2.TabIndex = 1;
			this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged);
			// 
			// comboBox3
			// 
			this.comboBox3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.comboBox3.Location = new System.Drawing.Point(144, 80);
			this.comboBox3.Name = "comboBox3";
			this.comboBox3.Size = new System.Drawing.Size(121, 20);
			this.comboBox3.TabIndex = 1;
			// 
			// textBox2
			// 
			this.textBox2.Location = new System.Drawing.Point(8, 16);
			this.textBox2.Multiline = true;
			this.textBox2.Name = "textBox2";
			this.textBox2.Size = new System.Drawing.Size(256, 168);
			this.textBox2.TabIndex = 2;
			this.textBox2.Text = "";
			// 
			// textBox3
			// 
			this.textBox3.Location = new System.Drawing.Point(8, 208);
			this.textBox3.Multiline = true;
			this.textBox3.Name = "textBox3";
			this.textBox3.Size = new System.Drawing.Size(256, 72);
			this.textBox3.TabIndex = 2;
			this.textBox3.Text = "";
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this.textBox2);
			this.groupBox1.Controls.Add(this.textBox3);
			this.groupBox1.Controls.Add(this.label6);
			this.groupBox1.Location = new System.Drawing.Point(0, 104);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(280, 288);
			this.groupBox1.TabIndex = 3;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "交通情况";
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(8, 184);
			this.label6.Name = "label6";
			this.label6.TabIndex = 4;
			this.label6.Text = "详细地址";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(8, 8);
			this.label1.Name = "label1";
			this.label1.TabIndex = 4;
			this.label1.Text = "医院名称";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(144, 8);
			this.label2.Name = "label2";
			this.label2.TabIndex = 4;
			this.label2.Text = "医院级别";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(8, 56);
			this.label3.Name = "label3";
			this.label3.TabIndex = 4;
			this.label3.Text = "所在省";
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(144, 88);
			this.label4.Name = "label4";
			this.label4.TabIndex = 4;
			this.label4.Text = "label1";
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(144, 56);
			this.label5.Name = "label5";
			this.label5.TabIndex = 4;
			this.label5.Text = "所在市";
			// 
			// button1
			// 
			this.button1.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.button1.Location = new System.Drawing.Point(48, 400);
			this.button1.Name = "button1";
			this.button1.TabIndex = 5;
			this.button1.Text = "确定";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// button2
			// 
			this.button2.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.button2.Location = new System.Drawing.Point(160, 400);
			this.button2.Name = "button2";
			this.button2.TabIndex = 5;
			this.button2.Text = "取消";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// HosEdit
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(280, 430);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.groupBox1);
			this.Controls.Add(this.comboBox1);
			this.Controls.Add(this.textBox1);
			this.Controls.Add(this.comboBox2);
			this.Controls.Add(this.comboBox3);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.label5);
			this.Controls.Add(this.button2);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
			this.MaximizeBox = false;
			this.Name = "HosEdit";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "HosEdit";
			this.groupBox1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void comboBox2_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			this.comboBox3.Items.Clear();
			City[] city = cityAccess.GetNameByProID(((Dictionary)this.comboBox2.SelectedItem).ID);

			for(int i=0;i<city.Length;i++)
			{
				this.comboBox3.Items.Add(city[i]);

			}
			this.comboBox3.Text = "";
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			if(this.textBox1.Text != "" && this.comboBox1.Text != "")
			{
				if(this.comboBox3.SelectedIndex != -1)
				{
					_hospital.Name = this.textBox1.Text;
					_hospital.GradeID = Convert.ToInt32(((Dictionary)this.comboBox1.SelectedItem).ID);
					_hospital.ProvinceID = Convert.ToInt32(((Dictionary)this.comboBox2.SelectedItem).ID);
					_hospital.CityID = Convert.ToInt32(((City)this.comboBox3.SelectedItem).CityID);
					_hospital.Traffic = this.textBox2.Text;
					_hospital.Address = this.textBox3.Text;
					this.DialogResult = DialogResult.OK;
				}	
				else
					MessageBox.Show("请选择所在城市!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
			}
			else
				MessageBox.Show("医院名称,级别不能为空!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);

			
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			this.Close();
			this.DialogResult = DialogResult.Cancel;
		}
	
		public  Hospital Hospital
			{
				 get
				{
					return _hospital;
				}
			}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -