📄 tscx.cs
字号:
using System;using System.Collections;using System.ComponentModel;using System.Drawing;using System.Windows.Forms;using System.Data ;using System.Data .SqlClient ;namespace RoomManage{ public class tscx : RoomManage.pub { private System.ComponentModel.IContainer components = null; public tscx(string s) { // 该调用是 Windows 窗体设计器所必需的。 InitializeComponent(); this.opername =s; // TODO: 在 InitializeComponent 调用后添加任何初始化 } /// <summary> /// 清理所有正在使用的资源。 /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region 设计器生成的代码 /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(tscx));
this.button2 = new System.Windows.Forms.Button();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.groupBox6 = new System.Windows.Forms.GroupBox();
this.label3 = new System.Windows.Forms.Label();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.tb = new System.Windows.Forms.TextBox();
this.dt = new System.Windows.Forms.DateTimePicker();
this.dg = new System.Windows.Forms.DataGrid();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dg)).BeginInit();
//
// button1
//
this.button1.Location = new System.Drawing.Point(8, 80);
this.button1.Name = "button1";
this.button1.TabIndex = 1;
//
// groupBox1
//
this.groupBox1.Name = "groupBox1";
//
// groupBox2
//
this.groupBox2.Controls.Add(this.button2);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Controls.SetChildIndex(this.button1, 0);
this.groupBox2.Controls.SetChildIndex(this.button2, 0);
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Name = "pictureBox1";
//
// groupBox3
//
this.groupBox3.Controls.Add(this.dg);
this.groupBox3.Controls.Add(this.dt);
this.groupBox3.Controls.Add(this.tb);
this.groupBox3.Controls.Add(this.label3);
this.groupBox3.Controls.Add(this.comboBox1);
this.groupBox3.Controls.Add(this.groupBox6);
this.groupBox3.Controls.Add(this.label2);
this.groupBox3.Controls.Add(this.label1);
this.groupBox3.Controls.Add(this.groupBox4);
this.groupBox3.Name = "groupBox3";
//
// button2
//
this.button2.Location = new System.Drawing.Point(8, 32);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(48, 23);
this.button2.TabIndex = 0;
this.button2.Text = "查询";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// groupBox4
//
this.groupBox4.Location = new System.Drawing.Point(0, 240);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(384, 3);
this.groupBox4.TabIndex = 1;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "groupBox4";
//
// label1
//
this.label1.Location = new System.Drawing.Point(16, 248);
this.label1.Name = "label1";
this.label1.TabIndex = 2;
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label2
//
this.label2.Location = new System.Drawing.Point(200, 248);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(144, 23);
this.label2.TabIndex = 3;
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// groupBox6
//
this.groupBox6.Location = new System.Drawing.Point(0, 48);
this.groupBox6.Name = "groupBox6";
this.groupBox6.Size = new System.Drawing.Size(384, 3);
this.groupBox6.TabIndex = 19;
this.groupBox6.TabStop = false;
//
// label3
//
this.label3.Location = new System.Drawing.Point(8, 19);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(72, 23);
this.label3.TabIndex = 21;
this.label3.Text = "查 询 项:";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// comboBox1
//
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox1.Items.AddRange(new object[] {
"姓名",
"证件号码",
"退房日期",
"全部"});
this.comboBox1.Location = new System.Drawing.Point(80, 20);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(128, 20);
this.comboBox1.TabIndex = 20;
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
//
// tb
//
this.tb.Location = new System.Drawing.Point(216, 20);
this.tb.Name = "tb";
this.tb.Size = new System.Drawing.Size(120, 21);
this.tb.TabIndex = 25;
this.tb.Text = "";
//
// dt
//
this.dt.Format = System.Windows.Forms.DateTimePickerFormat.Short;
this.dt.Location = new System.Drawing.Point(216, 20);
this.dt.Name = "dt";
this.dt.Size = new System.Drawing.Size(120, 21);
this.dt.TabIndex = 23;
//
// dg
//
this.dg.AlternatingBackColor = System.Drawing.Color.GhostWhite;
this.dg.BackColor = System.Drawing.Color.GhostWhite;
this.dg.BackgroundColor = System.Drawing.Color.Lavender;
this.dg.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.dg.CaptionBackColor = System.Drawing.Color.RoyalBlue;
this.dg.CaptionForeColor = System.Drawing.Color.White;
this.dg.CaptionText = "查询结果";
this.dg.DataMember = "";
this.dg.FlatMode = true;
this.dg.Font = new System.Drawing.Font("Tahoma", 8F);
this.dg.ForeColor = System.Drawing.Color.MidnightBlue;
this.dg.GridLineColor = System.Drawing.Color.RoyalBlue;
this.dg.HeaderBackColor = System.Drawing.Color.MidnightBlue;
this.dg.HeaderFont = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Bold);
this.dg.HeaderForeColor = System.Drawing.Color.Lavender;
this.dg.LinkColor = System.Drawing.Color.Teal;
this.dg.Location = new System.Drawing.Point(8, 56);
this.dg.Name = "dg";
this.dg.ParentRowsBackColor = System.Drawing.Color.Lavender;
this.dg.ParentRowsForeColor = System.Drawing.Color.MidnightBlue;
this.dg.ReadOnly = true;
this.dg.SelectionBackColor = System.Drawing.Color.Teal;
this.dg.SelectionForeColor = System.Drawing.Color.PaleGreen;
this.dg.Size = new System.Drawing.Size(368, 184);
this.dg.TabIndex = 26;
//
// tscx
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(480, 283);
this.Name = "tscx";
this.Text = "退宿查询";
this.Load += new System.EventHandler(this.tscx_Load);
this.groupBox2.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dg)).EndInit();
} #endregion
private System.Windows.Forms.Button button2;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.GroupBox groupBox6;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.TextBox tb;
private System.Windows.Forms.DateTimePicker dt;
private System.Windows.Forms.DataGrid dg;//传递操作员姓名
DataConn dc=new DataConn ();
string opername;
private void tscx_Load(object sender, System.EventArgs e)
{
this.AcceptButton =this.button2 ;
this.label1 .Text ="操 作 员:"+this.opername ;
this.label2 .Text ="查询日期:"+System.DateTime .Today.Date.ToShortDateString();
this.dt.Visible =false;
this.tb.Visible =false;
}
private void button2_Click(object sender, System.EventArgs e)
{
string str=dc.connstr ;
SqlConnection conn=new SqlConnection (str);
DataSet dataset=new DataSet ();
if(this.comboBox1.SelectedIndex==0)
{
string sql1="select * from tabtfd where 姓名='"+this.tb .Text +"'";
SqlDataAdapter a1=new SqlDataAdapter (sql1,conn);
a1.Fill (dataset,"t1");
dg.DataSource =dataset.Tables ["t1"];
a1.Dispose ();
}
if(this.comboBox1.SelectedIndex==1)
{
string sql2="select * from tabtfd where 证件号码='"+this.tb .Text +"'";
SqlDataAdapter a2=new SqlDataAdapter (sql2,conn);
a2.Fill (dataset,"t2");
dg.DataSource =dataset.Tables ["t2"];
a2.Dispose ();
}
if(this.comboBox1.SelectedIndex==2)
{
string sql3="select * from tabtfd where 退房日期='"+this.dt .Value .ToShortDateString ()+"'";
SqlDataAdapter a3=new SqlDataAdapter (sql3,conn);
a3.Fill (dataset,"t3");
dg.DataSource =dataset.Tables ["t3"];
a3.Dispose ();
}
if(this.comboBox1.SelectedIndex==3)
{
string sql4="select * from tabtfd";
SqlDataAdapter a4=new SqlDataAdapter (sql4,conn);
a4.Fill (dataset,"t4");
dg.DataSource =dataset.Tables ["t4"];
a4.Dispose ();
}
dataset.Dispose ();
conn.Dispose ();
}
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
if(this.comboBox1.SelectedIndex==2)
{
this.dt.Visible =true;
this.tb.Visible =false;
}
if(this.comboBox1.SelectedIndex==0|this.comboBox1.SelectedIndex==0)
{
this.dt.Visible =false;
this.tb.Visible =true;
}
if(this.comboBox1.SelectedIndex==3)
{
this.dt.Visible =false;
this.tb.Visible =false;
}
} }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -