zscx.cs
上传用户:toshiba_01
上传日期:2007-06-08
资源大小:306k
文件大小:15k
- 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 zscx : RoomManage.pub
{
- private System.Windows.Forms.Button button2;
- private System.Windows.Forms.GroupBox groupBox4;
- private System.Windows.Forms.GroupBox groupBox5;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.ComboBox comboBox1;
- private System.Windows.Forms.DateTimePicker dt;
- private System.Windows.Forms.TextBox tb;
- private System.Windows.Forms.GroupBox groupBox6;
- private System.Windows.Forms.Label label3;
- private System.Windows.Forms.DataGrid dg;
- private System.Windows.Forms.RadioButton rb1;
- private System.Windows.Forms.RadioButton rb2;
- private System.Windows.Forms.RadioButton rb3;
private System.ComponentModel.IContainer components = null;
public zscx(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(zscx));
- this.button2 = new System.Windows.Forms.Button();
- this.groupBox4 = new System.Windows.Forms.GroupBox();
- this.groupBox5 = new System.Windows.Forms.GroupBox();
- this.label1 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.rb1 = new System.Windows.Forms.RadioButton();
- this.rb2 = new System.Windows.Forms.RadioButton();
- this.rb3 = new System.Windows.Forms.RadioButton();
- this.comboBox1 = new System.Windows.Forms.ComboBox();
- this.dt = new System.Windows.Forms.DateTimePicker();
- this.tb = new System.Windows.Forms.TextBox();
- this.groupBox6 = new System.Windows.Forms.GroupBox();
- this.label3 = new System.Windows.Forms.Label();
- 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.button2, 0);
- this.groupBox2.Controls.SetChildIndex(this.button1, 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.label3);
- this.groupBox3.Controls.Add(this.groupBox6);
- this.groupBox3.Controls.Add(this.tb);
- this.groupBox3.Controls.Add(this.dt);
- this.groupBox3.Controls.Add(this.comboBox1);
- this.groupBox3.Controls.Add(this.rb3);
- this.groupBox3.Controls.Add(this.rb2);
- this.groupBox3.Controls.Add(this.rb1);
- this.groupBox3.Controls.Add(this.label2);
- this.groupBox3.Controls.Add(this.label1);
- this.groupBox3.Controls.Add(this.groupBox5);
- 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 = 0;
- this.groupBox4.TabStop = false;
- this.groupBox4.Text = "groupBox4";
- //
- // groupBox5
- //
- this.groupBox5.Location = new System.Drawing.Point(0, 72);
- this.groupBox5.Name = "groupBox5";
- this.groupBox5.Size = new System.Drawing.Size(384, 3);
- this.groupBox5.TabIndex = 1;
- this.groupBox5.TabStop = false;
- //
- // label1
- //
- this.label1.Location = new System.Drawing.Point(8, 256);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(104, 16);
- this.label1.TabIndex = 3;
- this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // label2
- //
- this.label2.Location = new System.Drawing.Point(240, 256);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(128, 16);
- this.label2.TabIndex = 5;
- this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // rb1
- //
- this.rb1.Location = new System.Drawing.Point(16, 13);
- this.rb1.Name = "rb1";
- this.rb1.Size = new System.Drawing.Size(64, 24);
- this.rb1.TabIndex = 6;
- this.rb1.Text = "已结帐";
- this.rb1.Click += new System.EventHandler(this.rb1_Click);
- //
- // rb2
- //
- this.rb2.Location = new System.Drawing.Point(160, 13);
- this.rb2.Name = "rb2";
- this.rb2.Size = new System.Drawing.Size(64, 24);
- this.rb2.TabIndex = 7;
- this.rb2.Text = "未结帐";
- this.rb2.Click += new System.EventHandler(this.rb2_Click);
- //
- // rb3
- //
- this.rb3.Location = new System.Drawing.Point(304, 13);
- this.rb3.Name = "rb3";
- this.rb3.Size = new System.Drawing.Size(64, 24);
- this.rb3.TabIndex = 8;
- this.rb3.Text = "全 部";
- this.rb3.Click += new System.EventHandler(this.rb3_Click);
- //
- // comboBox1
- //
- this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- this.comboBox1.Items.AddRange(new object[] {
- "姓名",
- "证件号码",
- "住宿日期",
- "无"});
- this.comboBox1.Location = new System.Drawing.Point(88, 47);
- this.comboBox1.Name = "comboBox1";
- this.comboBox1.Size = new System.Drawing.Size(128, 20);
- this.comboBox1.TabIndex = 11;
- this.comboBox1.KeyUp += new System.Windows.Forms.KeyEventHandler(this.comboBox1_KeyUp);
- this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
- //
- // dt
- //
- this.dt.Format = System.Windows.Forms.DateTimePickerFormat.Short;
- this.dt.Location = new System.Drawing.Point(224, 47);
- this.dt.Name = "dt";
- this.dt.Size = new System.Drawing.Size(128, 21);
- this.dt.TabIndex = 16;
- //
- // tb
- //
- this.tb.Location = new System.Drawing.Point(224, 48);
- this.tb.Name = "tb";
- this.tb.Size = new System.Drawing.Size(128, 21);
- this.tb.TabIndex = 17;
- this.tb.Text = "";
- //
- // groupBox6
- //
- this.groupBox6.Location = new System.Drawing.Point(0, 37);
- this.groupBox6.Name = "groupBox6";
- this.groupBox6.Size = new System.Drawing.Size(384, 3);
- this.groupBox6.TabIndex = 18;
- this.groupBox6.TabStop = false;
- //
- // label3
- //
- this.label3.Location = new System.Drawing.Point(16, 46);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(72, 23);
- this.label3.TabIndex = 19;
- this.label3.Text = "查 询 项:";
- this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // 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, 80);
- 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, 160);
- this.dg.TabIndex = 20;
- //
- // zscx
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
- this.ClientSize = new System.Drawing.Size(480, 283);
- this.Name = "zscx";
- this.Text = "住宿查询";
- this.Load += new System.EventHandler(this.zscx_Load);
- this.groupBox2.ResumeLayout(false);
- this.groupBox3.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.dg)).EndInit();
- }
#endregion
- DataConn dc=new DataConn ();
- string opername;//传递操作员姓名
- int order=0;//指示查询类型
-
- private void zscx_Load(object sender, System.EventArgs e)
- {
- this.AcceptButton =this.button2 ;
- this.label2 .Text ="查询日期:"+System.DateTime .Today.Date.ToShortDateString();
- this.label1 .Text ="操 作 员:"+this.opername ;
- this.tb .Visible =false;
- this.dt.Visible =false;
- }
- 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==1)
- {
- this.dt.Visible =false;
- this.tb.Visible =true;
- }
- if(this.comboBox1 .SelectedIndex ==3)
- {
- this.dt.Visible =false;
- this.tb.Visible =false;
- }
- }
- private void comboBox1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
- {
- this.comboBox1 .Text ="";
- }
- private void button2_Click(object sender, System.EventArgs e)
- {
- string str=dc.connstr ;
- SqlConnection conn=new SqlConnection (str);
- DataSet dataset=new DataSet ();
- int order1=0;
- //查询已结帐的所有记录
- if((order==1&this.comboBox1 .Text =="")|(this.rb1 .Checked ==true&(this.comboBox1 .SelectedIndex ==3)))
- {
- order1=1;
- string sql1="select * from tabdjb where 是否结帐='1'";
- SqlDataAdapter a1=new SqlDataAdapter (sql1,conn);
- a1.Fill (dataset,"t1");
- }
- //查询未结帐的所有记录
- if((order==2&this.comboBox1 .Text =="")|(this.rb2 .Checked ==true&(this.comboBox1 .SelectedIndex ==3)))
- {
- order1=2;
- string sql2="select * from tabdjb where 是否结帐='0'";
- SqlDataAdapter a2=new SqlDataAdapter (sql2,conn);
- a2.Fill (dataset,"t2");
- }
- //查询所有记录
- if((order==3&this.comboBox1 .Text =="")|(this.rb3 .Checked ==true&(this.comboBox1 .SelectedIndex ==3)))
- {
- order1=3;
- string sql3="select * from tabdjb";
- SqlDataAdapter a3=new SqlDataAdapter (sql3,conn);
- a3.Fill (dataset,"t3");
- }
- //按姓名查询已结帐记录
- if(order==1&this.comboBox1.SelectedIndex==0)
- {
- order1=4;
- string sql4="select * from tabdjb where 是否结帐='1'and 姓名='"+this.tb .Text +"'";
- SqlDataAdapter a4=new SqlDataAdapter (sql4,conn);
- a4.Fill (dataset,"t4");
- }
- //按姓名查询未结帐记录
- if(order==2&this.comboBox1.SelectedIndex==0)
- {
- order1=5;
- string sql5="select * from tabdjb where 是否结帐='0'and 姓名='"+this.tb .Text +"'";
- SqlDataAdapter a5=new SqlDataAdapter (sql5,conn);
- a5.Fill (dataset,"t5");
- }
- //按姓名查询所有记录
- if(order==3&this.comboBox1.SelectedIndex==0)
- {
- order1=6;
- string sql6="select * from tabdjb where 姓名='"+this.tb .Text +"'";
- SqlDataAdapter a6=new SqlDataAdapter (sql6,conn);
- a6.Fill (dataset,"t6");
- }
- //按证件号码查询已结帐记录
- if(order==1&this.comboBox1.SelectedIndex==1)
- {
- order1=7;
- string sql7="select * from tabdjb where 是否结帐='1'and 证件号码='"+this.tb .Text +"'";
- SqlDataAdapter a7=new SqlDataAdapter (sql7,conn);
- a7.Fill (dataset,"t7");
- }
- //按证件号码查询未结帐记录
- if(order==2&this.comboBox1.SelectedIndex==1)
- {
- order1=8;
- string sql8="select * from tabdjb where 是否结帐='0'and 证件号码='"+this.tb .Text +"'";
- SqlDataAdapter a8=new SqlDataAdapter (sql8,conn);
- a8.Fill (dataset,"t8");
- }
- //按证件号码查询所有记录
- if(order==3&this.comboBox1.SelectedIndex==1)
- {
- order1=9;
- string sql9="select * from tabdjb where 证件号码='"+this.tb .Text +"'";
- SqlDataAdapter a9=new SqlDataAdapter (sql9,conn);
- a9.Fill (dataset,"t9");
- }
- //按住宿日期查询已结帐记录
- if(order==1&this.comboBox1.SelectedIndex==2)
- {
- order1=10;
- string sql10="select * from tabdjb where 是否结帐='1'and 住宿日期='"+this.dt.Value .ToShortDateString ()+"'";
- SqlDataAdapter a10=new SqlDataAdapter (sql10,conn);
- a10.Fill (dataset,"t10");
- }
- //按住宿日期查询未结帐记录
- if(order==2&this.comboBox1.SelectedIndex==2)
- {
- order1=11;
- string sql11="select * from tabdjb where 是否结帐='0'and 住宿日期='"+this.dt.Value .ToShortDateString ()+"'";
- SqlDataAdapter a11=new SqlDataAdapter (sql11,conn);
- a11.Fill (dataset,"t11");
- }
- //按住宿日期查询所有记录
- if(order==3&this.comboBox1.SelectedIndex==2)
- {
- order1=12;
- string sql12="select * from tabdjb where 住宿日期='"+this.dt.Value .ToShortDateString ()+"'";
- SqlDataAdapter a12=new SqlDataAdapter (sql12,conn);
- a12.Fill (dataset,"t12");
- }
- switch(order1)
- {
- case 1:
- dg.DataSource =dataset.Tables ["t1"];
- break;
- case 2:
- dg.DataSource =dataset.Tables ["t2"];
- break;
- case 3:
- dg.DataSource =dataset.Tables ["t3"];
- break;
- case 4:
- dg.DataSource =dataset.Tables ["t4"];
- break;
- case 5:
- dg.DataSource =dataset.Tables ["t5"];
- break;
- case 6:
- dg.DataSource =dataset.Tables ["t6"];
- break;
- case 7:
- dg.DataSource =dataset.Tables ["t7"];
- break;
- case 8:
- dg.DataSource =dataset.Tables ["t8"];
- break;
- case 9:
- dg.DataSource =dataset.Tables ["t9"];
- break;
- case 10:
- dg.DataSource =dataset.Tables ["t10"];
- break;
- case 11:
- dg.DataSource =dataset.Tables ["t11"];
- break;
- case 12:
- dg.DataSource =dataset.Tables ["t12"];
- break;
- }
- dataset.Dispose ();
- conn.Dispose ();
- }
- private void rb1_Click(object sender, System.EventArgs e)
- {
- order=1;
- }
- private void rb2_Click(object sender, System.EventArgs e)
- {
- order=2;
- }
- private void rb3_Click(object sender, System.EventArgs e)
- {
- order=3;
- }
-
}
}