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

📄 regquery.cs

📁 用于医院的病人管理
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace 医院管理系统
{
	/// <summary>
	/// RegQuery 的摘要说明。
	/// </summary>
	public class RegQuery : System.Windows.Forms.Form
	{
		private System.Data.SqlClient.SqlDataAdapter da1;
		private 医院管理系统.DataSet3 dataSet31;
		private System.Windows.Forms.DataGrid dataGrid1;
		private System.Windows.Forms.Label label8;
		private System.Windows.Forms.Button btnSearch;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.Label label7;
		private System.Windows.Forms.TextBox txt2;
		private System.Windows.Forms.TextBox txt1;
		private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
		private System.Data.SqlClient.SqlConnection sqlConnection1;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public RegQuery()
		{
			//
			// 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(RegQuery));
			this.da1 = new System.Data.SqlClient.SqlDataAdapter();
			this.dataSet31 = new 医院管理系统.DataSet3();
			this.dataGrid1 = new System.Windows.Forms.DataGrid();
			this.label8 = new System.Windows.Forms.Label();
			this.btnSearch = new System.Windows.Forms.Button();
			this.txt2 = new System.Windows.Forms.TextBox();
			this.txt1 = new System.Windows.Forms.TextBox();
			this.label6 = new System.Windows.Forms.Label();
			this.label7 = new System.Windows.Forms.Label();
			this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
			this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
			((System.ComponentModel.ISupportInitialize)(this.dataSet31)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
			this.SuspendLayout();
			// 
			// da1
			// 
			this.da1.SelectCommand = this.sqlSelectCommand1;
			this.da1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
																						  new System.Data.Common.DataTableMapping("Table", "门诊挂号", new System.Data.Common.DataColumnMapping[] {
																																																  new System.Data.Common.DataColumnMapping("挂号科室", "挂号科室"),
																																																  new System.Data.Common.DataColumnMapping("人数", "人数"),
																																																  new System.Data.Common.DataColumnMapping("挂号金额", "挂号金额")})});
			// 
			// dataSet31
			// 
			this.dataSet31.DataSetName = "DataSet3";
			this.dataSet31.Locale = new System.Globalization.CultureInfo("zh-CN");
			// 
			// dataGrid1
			// 
			this.dataGrid1.CaptionVisible = false;
			this.dataGrid1.DataMember = "门诊挂号";
			this.dataGrid1.DataSource = this.dataSet31;
			this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGrid1.Location = new System.Drawing.Point(0, 112);
			this.dataGrid1.Name = "dataGrid1";
			this.dataGrid1.ReadOnly = true;
			this.dataGrid1.Size = new System.Drawing.Size(416, 304);
			this.dataGrid1.TabIndex = 0;
			// 
			// label8
			// 
			this.label8.Location = new System.Drawing.Point(88, 24);
			this.label8.Name = "label8";
			this.label8.Size = new System.Drawing.Size(144, 16);
			this.label8.TabIndex = 9;
			this.label8.Text = "格式如\'2004-1-1\'";
			// 
			// btnSearch
			// 
			this.btnSearch.Image = ((System.Drawing.Image)(resources.GetObject("btnSearch.Image")));
			this.btnSearch.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.btnSearch.Location = new System.Drawing.Point(264, 56);
			this.btnSearch.Name = "btnSearch";
			this.btnSearch.Size = new System.Drawing.Size(80, 24);
			this.btnSearch.TabIndex = 6;
			this.btnSearch.Text = "搜索";
			this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
			// 
			// txt2
			// 
			this.txt2.Location = new System.Drawing.Point(88, 72);
			this.txt2.Name = "txt2";
			this.txt2.Size = new System.Drawing.Size(144, 21);
			this.txt2.TabIndex = 4;
			this.txt2.Text = "";
			// 
			// txt1
			// 
			this.txt1.Location = new System.Drawing.Point(88, 40);
			this.txt1.Name = "txt1";
			this.txt1.Size = new System.Drawing.Size(144, 21);
			this.txt1.TabIndex = 5;
			this.txt1.Text = "";
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(32, 45);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(56, 16);
			this.label6.TabIndex = 7;
			this.label6.Text = "开始时间";
			// 
			// label7
			// 
			this.label7.Location = new System.Drawing.Point(32, 77);
			this.label7.Name = "label7";
			this.label7.Size = new System.Drawing.Size(56, 16);
			this.label7.TabIndex = 8;
			this.label7.Text = "结束时间";
			// 
			// sqlSelectCommand1
			// 
			this.sqlSelectCommand1.CommandText = "SELECT 挂号科室, COUNT(编号) AS 人数, SUM(挂号费用) AS 挂号金额 FROM 门诊挂号 WHERE (时间 > @Param3) AN" +
				"D (时间 < @Param4) GROUP BY 挂号科室";
			this.sqlSelectCommand1.Connection = this.sqlConnection1;
			this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param3", System.Data.SqlDbType.DateTime, 8, "时间"));
			this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param4", System.Data.SqlDbType.DateTime, 8, "时间"));
			// 
			// sqlConnection1
			// 
			this.sqlConnection1.ConnectionString = "workstation id=localhost;packet size=4096;integrated security=SSPI;data source=\"." +
				"\";persist security info=False;initial catalog=hisbook";
			// 
			// RegQuery
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(416, 413);
			this.Controls.Add(this.label8);
			this.Controls.Add(this.btnSearch);
			this.Controls.Add(this.txt2);
			this.Controls.Add(this.txt1);
			this.Controls.Add(this.label6);
			this.Controls.Add(this.label7);
			this.Controls.Add(this.dataGrid1);
			this.Name = "RegQuery";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "【科室挂号量】";
			this.Load += new System.EventHandler(this.RegQuery_Load);
			((System.ComponentModel.ISupportInitialize)(this.dataSet31)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		//-------------初始化窗体,读入数据-----------
		private void RegQuery_Load(object sender, System.EventArgs e)
		{
			da1.SelectCommand.Parameters[0].Value="1990-1-1";//默认时间范围
			da1.SelectCommand.Parameters[1].Value="2010-12-31";
			da1.Fill(dataSet31);
		}

		//-------------根据时间范围查询数据--------------
		private void btnSearch_Click(object sender, System.EventArgs e)
		{
			da1.SelectCommand.Parameters[0].Value="1990-1-1";
			da1.SelectCommand.Parameters[1].Value="2010-12-31";
			if(txt1.Text.Trim()!="")
			{
				da1.SelectCommand.Parameters[0].Value=txt1.Text;
			}
			if(txt2.Text.Trim()!="")
			{
				da1.SelectCommand.Parameters[1].Value=txt2.Text;
			}
			dataSet31.Clear();
			da1.Fill(dataSet31);		
		}
	}
}

⌨️ 快捷键说明

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