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

📄 clinicreg.cs

📁 医院门诊收费系统
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.txt1.TabIndex = 36;
			this.txt1.Text = "";
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(576, 64);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(32, 24);
			this.label4.TabIndex = 35;
			this.label4.Text = "民族";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(400, 64);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(32, 24);
			this.label3.TabIndex = 34;
			this.label3.Text = "年龄";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(208, 64);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(32, 24);
			this.label2.TabIndex = 33;
			this.label2.Text = "性别";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(8, 64);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(32, 24);
			this.label1.TabIndex = 32;
			this.label1.Text = "姓名";
			// 
			// imageList1
			// 
			this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
			this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
			this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// ClinicReg
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(824, 352);
			this.Controls.Add(this.textBox6);
			this.Controls.Add(this.textBox5);
			this.Controls.Add(this.txt4);
			this.Controls.Add(this.txt3);
			this.Controls.Add(this.txt2);
			this.Controls.Add(this.txt1);
			this.Controls.Add(this.label10);
			this.Controls.Add(this.cmb4);
			this.Controls.Add(this.cmb6);
			this.Controls.Add(this.cmb5);
			this.Controls.Add(this.cmb3);
			this.Controls.Add(this.label9);
			this.Controls.Add(this.label8);
			this.Controls.Add(this.label7);
			this.Controls.Add(this.label6);
			this.Controls.Add(this.label5);
			this.Controls.Add(this.cmb2);
			this.Controls.Add(this.cmb1);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.toolBar1);
			this.Name = "ClinicReg";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "ClinicReg";
			this.Load += new System.EventHandler(this.ClinicReg_Load);
			this.ResumeLayout(false);

		}
		#endregion

	   private void ClinicReg_Load(object sender, System.EventArgs e)
		{
			
			string strConn="workstation id=localhost;Integrated Security=SSPI;database=hospitalms;";
			SqlConnection cn=new SqlConnection(strConn);
			cn.Open();
			SqlCommand cmb=cn.CreateCommand();
			cmb.CommandText="select distinct 名称 from 科室资料";
			SqlDataReader dr=cmb.ExecuteReader();
			cmb5.Items.Clear();
			while(dr.Read())
			{
				cmb5.Items.Add(dr.GetValue(0).ToString().Trim());
			}
			dr.Close();
		}
   
		private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
		{
			if(e.Button.ToolTipText=="新增")
			{
				this.SetDefaultValue();
				this.regID=this.CreateNewID("select max(编号) 最大编号 from 门诊挂号");
				this.infoID=this.CreateNewID("select max(编号) 最大编号 from 病人信息库");				
			}
			if(e.Button.ToolTipText=="保存")
			{
				if(this.CheckNotNull()==false)
				{
					return;
				}
				this.SaveReg();
				this.clearInfo();

			}
			if(e.Button.ToolTipText=="取消")
			{
				this.clearInfo();
				
			}
			if(e.Button.ToolTipText=="退出")
			{
				this.Close();
			}
		}
      
		private void cmb6_DropDown(object sender, System.EventArgs e)
		{
			
			cmb6.Items.Clear();
			if(cmb5.Text.Trim()=="")
			{
				return;
			}
			string strConn="workstation id=localhost;Integrated Security=SSPI;database=hospitalms;";
			SqlConnection cn=new SqlConnection(strConn);
			cn.Open();
			SqlCommand cmb=cn.CreateCommand();
			cmb.CommandText="select distinct 姓名 from 医生资料 where 科室='"+cmb5.Text.Trim()+"'";
			SqlDataReader dr=cmb.ExecuteReader();			
			while(dr.Read())
			{
				cmb6.Items.Add(dr.GetValue(0).ToString().Trim());
			}
			dr.Close();	
		}
		
		private void clearInfo()
		{
			txt1.Clear();
			txt2.Clear();
			txt3.Clear();
			txt4.Clear();
			cmb1.Text="";
			cmb2.Text="";
			cmb3.Text="";
			cmb4.Text="";
			cmb5.Text="";
			cmb6.Text="";
		}
	
		private void SetDefaultValue()
		{
			cmb1.SelectedText="男";
			cmb2.SelectedText="汉族";
			cmb3.SelectedText="自费";
			cmb4.SelectedText="普通";
			cmb5.SelectedText="内科";
			txt3.Text="1";
			txt4.Text=System.DateTime.Now.ToString();
		}
	  
		private void cmb4_SelectionChangeCommitted(object sender, System.EventArgs e)
		{
			if(cmb4.SelectedIndex==0)
			{
				txt3.Text="1";
			}
			if(cmb4.SelectedIndex==1)
			{
				txt3.Text="5";
			}
			if(cmb4.SelectedIndex==2)
			{
				txt3.Text="20";
			}
		}
		
		private bool CheckNotNull()
		{
			if(txt1.Text.Trim()=="")
			{
				MessageBox.Show("病人姓名不能为空,请输入姓名","提示",MessageBoxButtons.OK,MessageBoxIcon.Stop);
				return(false);
			}
			if(cmb3.Text.Trim()=="")
			{
				MessageBox.Show("费用类型不能为空,请选择费用类型","提示",MessageBoxButtons.OK,MessageBoxIcon.Stop);
				return(false);
			}
			if(cmb5.Text.Trim()=="")
			{
				MessageBox.Show("挂号科室不能为空,请选择挂号科室","提示",MessageBoxButtons.OK,MessageBoxIcon.Stop);
				return(false);
			}
			if(cmb6.Text.Trim()=="")
			{
				MessageBox.Show("未选择医生或您选择的挂号科室没有医生","提示",MessageBoxButtons.OK,MessageBoxIcon.Stop);
				return(false);
			}
			return(true);
		}
	
		private void SaveReg()
		{
			string strConn="workstation id=localhost;Integrated Security=SSPI;database=hospitalms;";
			SqlConnection cn=new SqlConnection(strConn);
			cn.Open();
			SqlCommand cmb=cn.CreateCommand();
			
			string insertStr="insert into 病人信息库([编号], [姓名], [性别], [年龄], [民族], [费用类型]) "
				+"values('"+infoID+"','"+txt1.Text.Trim()+"','"+cmb1.Text.Trim()+"','"+txt2.Text.Trim()
				+"','"+cmb2.Text.Trim()+"','"+cmb3.Text.Trim()+"')";			
			cmb.CommandText=insertStr;
			try
			{
				cmb.ExecuteNonQuery();
			}
			catch(Exception express)
			{
				MessageBox.Show(express.ToString(),"新增病人信息错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
				return;
			}
			insertStr="insert into 门诊挂号([编号], [病人编号], [姓名], [性别], [挂号科室], [费用类型],"
				+"[挂号类型], [挂号费用], [医生], [时间], [是否已划价]) "
				+"values('"+regID+"','"+infoID+"','"+txt1.Text.Trim()+"','"+cmb1.Text.Trim()+"','"
				+cmb5.Text.Trim()+"','"+cmb3.Text.Trim()+"','"+cmb4.Text.Trim()+"',CAST('"+txt3.Text
				+"' as decimal),'"+cmb6.Text.Trim()+"','"+txt4.Text+"','否')";
			cmb.CommandText=insertStr;
			try
			{
				cmb.ExecuteNonQuery();
			}
			catch(Exception express)
			{
				MessageBox.Show(express.ToString(),"新增门诊挂号错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
				return;
			}


		}
	
		private string CreateNewID(string sql)
		{
			string strConn="workstation id=localhost;Integrated Security=SSPI;database=hospitalms;";
			SqlConnection cn=new SqlConnection(strConn);
			cn.Open();
			SqlCommand cmb=cn.CreateCommand();
			cmb.CommandText=sql;
			string result;
			if(cmb.ExecuteScalar()!=System.DBNull.Value)
			{
				result=cmb.ExecuteScalar().ToString().Trim();
			}
			else
			{
				return(System.DateTime.Now.Year.ToString()+"0000001");
			}
			result=result.Substring(4,7);
			int newID=Convert.ToInt32(result)+1;
			int length=newID.ToString().Length;
			string returnStr=System.DateTime.Now.Year.ToString();
			switch(length)
			{
				case 1:
					returnStr+="000000"+newID.ToString();					
					break;
				case 2:
					returnStr+="00000"+newID.ToString();					
					break;
				case 3:
					returnStr+="0000"+newID.ToString();					
					break;
				case 4:
					returnStr+="000"+newID.ToString();					
					break;
				case 5:
					returnStr+="00"+newID.ToString();					
					break;
				case 6:
					returnStr+="0"+newID.ToString();					
					break;
				case 7:
					returnStr+=newID.ToString();					
					break;
			}
			return(returnStr);
		}
    }
}

⌨️ 快捷键说明

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