?? regquery.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 + -