tscx.cs
上传用户:toshiba_01
上传日期:2007-06-08
资源大小:306k
文件大小:10k
源码类别:

酒店行业

开发平台:

C#

  1. 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));
  2. this.button2 = new System.Windows.Forms.Button();
  3. this.groupBox4 = new System.Windows.Forms.GroupBox();
  4. this.label1 = new System.Windows.Forms.Label();
  5. this.label2 = new System.Windows.Forms.Label();
  6. this.groupBox6 = new System.Windows.Forms.GroupBox();
  7. this.label3 = new System.Windows.Forms.Label();
  8. this.comboBox1 = new System.Windows.Forms.ComboBox();
  9. this.tb = new System.Windows.Forms.TextBox();
  10. this.dt = new System.Windows.Forms.DateTimePicker();
  11. this.dg = new System.Windows.Forms.DataGrid();
  12. this.groupBox2.SuspendLayout();
  13. this.groupBox3.SuspendLayout();
  14. ((System.ComponentModel.ISupportInitialize)(this.dg)).BeginInit();
  15. // 
  16. // button1
  17. // 
  18. this.button1.Location = new System.Drawing.Point(8, 80);
  19. this.button1.Name = "button1";
  20. this.button1.TabIndex = 1;
  21. // 
  22. // groupBox1
  23. // 
  24. this.groupBox1.Name = "groupBox1";
  25. // 
  26. // groupBox2
  27. // 
  28. this.groupBox2.Controls.Add(this.button2);
  29. this.groupBox2.Name = "groupBox2";
  30. this.groupBox2.Controls.SetChildIndex(this.button1, 0);
  31. this.groupBox2.Controls.SetChildIndex(this.button2, 0);
  32. // 
  33. // pictureBox1
  34. // 
  35. this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
  36. this.pictureBox1.Name = "pictureBox1";
  37. // 
  38. // groupBox3
  39. // 
  40. this.groupBox3.Controls.Add(this.dg);
  41. this.groupBox3.Controls.Add(this.dt);
  42. this.groupBox3.Controls.Add(this.tb);
  43. this.groupBox3.Controls.Add(this.label3);
  44. this.groupBox3.Controls.Add(this.comboBox1);
  45. this.groupBox3.Controls.Add(this.groupBox6);
  46. this.groupBox3.Controls.Add(this.label2);
  47. this.groupBox3.Controls.Add(this.label1);
  48. this.groupBox3.Controls.Add(this.groupBox4);
  49. this.groupBox3.Name = "groupBox3";
  50. // 
  51. // button2
  52. // 
  53. this.button2.Location = new System.Drawing.Point(8, 32);
  54. this.button2.Name = "button2";
  55. this.button2.Size = new System.Drawing.Size(48, 23);
  56. this.button2.TabIndex = 0;
  57. this.button2.Text = "查询";
  58. this.button2.Click += new System.EventHandler(this.button2_Click);
  59. // 
  60. // groupBox4
  61. // 
  62. this.groupBox4.Location = new System.Drawing.Point(0, 240);
  63. this.groupBox4.Name = "groupBox4";
  64. this.groupBox4.Size = new System.Drawing.Size(384, 3);
  65. this.groupBox4.TabIndex = 1;
  66. this.groupBox4.TabStop = false;
  67. this.groupBox4.Text = "groupBox4";
  68. // 
  69. // label1
  70. // 
  71. this.label1.Location = new System.Drawing.Point(16, 248);
  72. this.label1.Name = "label1";
  73. this.label1.TabIndex = 2;
  74. this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  75. // 
  76. // label2
  77. // 
  78. this.label2.Location = new System.Drawing.Point(200, 248);
  79. this.label2.Name = "label2";
  80. this.label2.Size = new System.Drawing.Size(144, 23);
  81. this.label2.TabIndex = 3;
  82. this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  83. // 
  84. // groupBox6
  85. // 
  86. this.groupBox6.Location = new System.Drawing.Point(0, 48);
  87. this.groupBox6.Name = "groupBox6";
  88. this.groupBox6.Size = new System.Drawing.Size(384, 3);
  89. this.groupBox6.TabIndex = 19;
  90. this.groupBox6.TabStop = false;
  91. // 
  92. // label3
  93. // 
  94. this.label3.Location = new System.Drawing.Point(8, 19);
  95. this.label3.Name = "label3";
  96. this.label3.Size = new System.Drawing.Size(72, 23);
  97. this.label3.TabIndex = 21;
  98. this.label3.Text = "查 询 项:";
  99. this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  100. // 
  101. // comboBox1
  102. // 
  103. this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  104. this.comboBox1.Items.AddRange(new object[] {
  105.    "姓名",
  106.    "证件号码",
  107.    "退房日期",
  108.    "全部"});
  109. this.comboBox1.Location = new System.Drawing.Point(80, 20);
  110. this.comboBox1.Name = "comboBox1";
  111. this.comboBox1.Size = new System.Drawing.Size(128, 20);
  112. this.comboBox1.TabIndex = 20;
  113. this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  114. // 
  115. // tb
  116. // 
  117. this.tb.Location = new System.Drawing.Point(216, 20);
  118. this.tb.Name = "tb";
  119. this.tb.Size = new System.Drawing.Size(120, 21);
  120. this.tb.TabIndex = 25;
  121. this.tb.Text = "";
  122. // 
  123. // dt
  124. // 
  125. this.dt.Format = System.Windows.Forms.DateTimePickerFormat.Short;
  126. this.dt.Location = new System.Drawing.Point(216, 20);
  127. this.dt.Name = "dt";
  128. this.dt.Size = new System.Drawing.Size(120, 21);
  129. this.dt.TabIndex = 23;
  130. // 
  131. // dg
  132. // 
  133. this.dg.AlternatingBackColor = System.Drawing.Color.GhostWhite;
  134. this.dg.BackColor = System.Drawing.Color.GhostWhite;
  135. this.dg.BackgroundColor = System.Drawing.Color.Lavender;
  136. this.dg.BorderStyle = System.Windows.Forms.BorderStyle.None;
  137. this.dg.CaptionBackColor = System.Drawing.Color.RoyalBlue;
  138. this.dg.CaptionForeColor = System.Drawing.Color.White;
  139. this.dg.CaptionText = "查询结果";
  140. this.dg.DataMember = "";
  141. this.dg.FlatMode = true;
  142. this.dg.Font = new System.Drawing.Font("Tahoma", 8F);
  143. this.dg.ForeColor = System.Drawing.Color.MidnightBlue;
  144. this.dg.GridLineColor = System.Drawing.Color.RoyalBlue;
  145. this.dg.HeaderBackColor = System.Drawing.Color.MidnightBlue;
  146. this.dg.HeaderFont = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Bold);
  147. this.dg.HeaderForeColor = System.Drawing.Color.Lavender;
  148. this.dg.LinkColor = System.Drawing.Color.Teal;
  149. this.dg.Location = new System.Drawing.Point(8, 56);
  150. this.dg.Name = "dg";
  151. this.dg.ParentRowsBackColor = System.Drawing.Color.Lavender;
  152. this.dg.ParentRowsForeColor = System.Drawing.Color.MidnightBlue;
  153. this.dg.ReadOnly = true;
  154. this.dg.SelectionBackColor = System.Drawing.Color.Teal;
  155. this.dg.SelectionForeColor = System.Drawing.Color.PaleGreen;
  156. this.dg.Size = new System.Drawing.Size(368, 184);
  157. this.dg.TabIndex = 26;
  158. // 
  159. // tscx
  160. // 
  161. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  162. this.ClientSize = new System.Drawing.Size(480, 283);
  163. this.Name = "tscx";
  164. this.Text = "退宿查询";
  165. this.Load += new System.EventHandler(this.tscx_Load);
  166. this.groupBox2.ResumeLayout(false);
  167. this.groupBox3.ResumeLayout(false);
  168. ((System.ComponentModel.ISupportInitialize)(this.dg)).EndInit();
  169. } #endregion
  170. private System.Windows.Forms.Button button2;
  171. private System.Windows.Forms.GroupBox groupBox4;
  172. private System.Windows.Forms.Label label1;
  173. private System.Windows.Forms.Label label2;
  174. private System.Windows.Forms.GroupBox groupBox6;
  175. private System.Windows.Forms.Label label3;
  176. private System.Windows.Forms.ComboBox comboBox1;
  177. private System.Windows.Forms.TextBox tb;
  178. private System.Windows.Forms.DateTimePicker dt;
  179. private System.Windows.Forms.DataGrid dg;//传递操作员姓名
  180. DataConn dc=new DataConn ();
  181. string opername;
  182. private void tscx_Load(object sender, System.EventArgs e)
  183. {
  184. this.AcceptButton =this.button2 ;
  185. this.label1 .Text ="操 作 员:"+this.opername ;
  186. this.label2 .Text ="查询日期:"+System.DateTime .Today.Date.ToShortDateString();
  187. this.dt.Visible =false;
  188. this.tb.Visible =false;
  189. }
  190. private void button2_Click(object sender, System.EventArgs e)
  191. {
  192. string str=dc.connstr ;
  193. SqlConnection conn=new SqlConnection (str);
  194. DataSet dataset=new DataSet ();
  195. if(this.comboBox1.SelectedIndex==0)
  196. {
  197. string sql1="select * from tabtfd where 姓名='"+this.tb .Text +"'";
  198. SqlDataAdapter a1=new SqlDataAdapter (sql1,conn);
  199. a1.Fill (dataset,"t1");
  200. dg.DataSource =dataset.Tables ["t1"];
  201. a1.Dispose ();
  202. }
  203. if(this.comboBox1.SelectedIndex==1)
  204. {
  205. string sql2="select * from tabtfd where 证件号码='"+this.tb .Text +"'";
  206. SqlDataAdapter a2=new SqlDataAdapter (sql2,conn);
  207. a2.Fill (dataset,"t2");
  208. dg.DataSource =dataset.Tables ["t2"];
  209. a2.Dispose ();
  210. }
  211. if(this.comboBox1.SelectedIndex==2)
  212. {
  213. string sql3="select * from tabtfd where 退房日期='"+this.dt .Value .ToShortDateString ()+"'";
  214. SqlDataAdapter a3=new SqlDataAdapter (sql3,conn);
  215. a3.Fill (dataset,"t3");
  216. dg.DataSource =dataset.Tables ["t3"];
  217. a3.Dispose ();
  218. }
  219. if(this.comboBox1.SelectedIndex==3)
  220. {
  221. string sql4="select * from tabtfd";
  222. SqlDataAdapter a4=new SqlDataAdapter (sql4,conn);
  223. a4.Fill (dataset,"t4");
  224. dg.DataSource =dataset.Tables ["t4"];
  225. a4.Dispose ();
  226. }
  227. dataset.Dispose ();
  228. conn.Dispose ();
  229. }
  230. private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
  231. {
  232. if(this.comboBox1.SelectedIndex==2)
  233. {
  234. this.dt.Visible =true;
  235. this.tb.Visible =false;
  236. }
  237. if(this.comboBox1.SelectedIndex==0|this.comboBox1.SelectedIndex==0)
  238. {
  239. this.dt.Visible =false;
  240. this.tb.Visible =true;
  241. }
  242. if(this.comboBox1.SelectedIndex==3)
  243. {
  244. this.dt.Visible =false;
  245. this.tb.Visible =false;
  246. }
  247. } } }