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

酒店行业

开发平台:

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 zscx : RoomManage.pub {
  2. private System.Windows.Forms.Button button2;
  3. private System.Windows.Forms.GroupBox groupBox4;
  4. private System.Windows.Forms.GroupBox groupBox5;
  5. private System.Windows.Forms.Label label1;
  6. private System.Windows.Forms.Label label2;
  7. private System.Windows.Forms.ComboBox comboBox1;
  8. private System.Windows.Forms.DateTimePicker dt;
  9. private System.Windows.Forms.TextBox tb;
  10. private System.Windows.Forms.GroupBox groupBox6;
  11. private System.Windows.Forms.Label label3;
  12. private System.Windows.Forms.DataGrid dg;
  13. private System.Windows.Forms.RadioButton rb1;
  14. private System.Windows.Forms.RadioButton rb2;
  15. 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));
  16. this.button2 = new System.Windows.Forms.Button();
  17. this.groupBox4 = new System.Windows.Forms.GroupBox();
  18. this.groupBox5 = new System.Windows.Forms.GroupBox();
  19. this.label1 = new System.Windows.Forms.Label();
  20. this.label2 = new System.Windows.Forms.Label();
  21. this.rb1 = new System.Windows.Forms.RadioButton();
  22. this.rb2 = new System.Windows.Forms.RadioButton();
  23. this.rb3 = new System.Windows.Forms.RadioButton();
  24. this.comboBox1 = new System.Windows.Forms.ComboBox();
  25. this.dt = new System.Windows.Forms.DateTimePicker();
  26. this.tb = new System.Windows.Forms.TextBox();
  27. this.groupBox6 = new System.Windows.Forms.GroupBox();
  28. this.label3 = new System.Windows.Forms.Label();
  29. this.dg = new System.Windows.Forms.DataGrid();
  30. this.groupBox2.SuspendLayout();
  31. this.groupBox3.SuspendLayout();
  32. ((System.ComponentModel.ISupportInitialize)(this.dg)).BeginInit();
  33. // 
  34. // button1
  35. // 
  36. this.button1.Location = new System.Drawing.Point(8, 80);
  37. this.button1.Name = "button1";
  38. this.button1.TabIndex = 1;
  39. // 
  40. // groupBox1
  41. // 
  42. this.groupBox1.Name = "groupBox1";
  43. // 
  44. // groupBox2
  45. // 
  46. this.groupBox2.Controls.Add(this.button2);
  47. this.groupBox2.Name = "groupBox2";
  48. this.groupBox2.Controls.SetChildIndex(this.button2, 0);
  49. this.groupBox2.Controls.SetChildIndex(this.button1, 0);
  50. // 
  51. // pictureBox1
  52. // 
  53. this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
  54. this.pictureBox1.Name = "pictureBox1";
  55. // 
  56. // groupBox3
  57. // 
  58. this.groupBox3.Controls.Add(this.dg);
  59. this.groupBox3.Controls.Add(this.label3);
  60. this.groupBox3.Controls.Add(this.groupBox6);
  61. this.groupBox3.Controls.Add(this.tb);
  62. this.groupBox3.Controls.Add(this.dt);
  63. this.groupBox3.Controls.Add(this.comboBox1);
  64. this.groupBox3.Controls.Add(this.rb3);
  65. this.groupBox3.Controls.Add(this.rb2);
  66. this.groupBox3.Controls.Add(this.rb1);
  67. this.groupBox3.Controls.Add(this.label2);
  68. this.groupBox3.Controls.Add(this.label1);
  69. this.groupBox3.Controls.Add(this.groupBox5);
  70. this.groupBox3.Controls.Add(this.groupBox4);
  71. this.groupBox3.Name = "groupBox3";
  72. // 
  73. // button2
  74. // 
  75. this.button2.Location = new System.Drawing.Point(8, 32);
  76. this.button2.Name = "button2";
  77. this.button2.Size = new System.Drawing.Size(48, 23);
  78. this.button2.TabIndex = 0;
  79. this.button2.Text = "查询";
  80. this.button2.Click += new System.EventHandler(this.button2_Click);
  81. // 
  82. // groupBox4
  83. // 
  84. this.groupBox4.Location = new System.Drawing.Point(0, 240);
  85. this.groupBox4.Name = "groupBox4";
  86. this.groupBox4.Size = new System.Drawing.Size(384, 3);
  87. this.groupBox4.TabIndex = 0;
  88. this.groupBox4.TabStop = false;
  89. this.groupBox4.Text = "groupBox4";
  90. // 
  91. // groupBox5
  92. // 
  93. this.groupBox5.Location = new System.Drawing.Point(0, 72);
  94. this.groupBox5.Name = "groupBox5";
  95. this.groupBox5.Size = new System.Drawing.Size(384, 3);
  96. this.groupBox5.TabIndex = 1;
  97. this.groupBox5.TabStop = false;
  98. // 
  99. // label1
  100. // 
  101. this.label1.Location = new System.Drawing.Point(8, 256);
  102. this.label1.Name = "label1";
  103. this.label1.Size = new System.Drawing.Size(104, 16);
  104. this.label1.TabIndex = 3;
  105. this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  106. // 
  107. // label2
  108. // 
  109. this.label2.Location = new System.Drawing.Point(240, 256);
  110. this.label2.Name = "label2";
  111. this.label2.Size = new System.Drawing.Size(128, 16);
  112. this.label2.TabIndex = 5;
  113. this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  114. // 
  115. // rb1
  116. // 
  117. this.rb1.Location = new System.Drawing.Point(16, 13);
  118. this.rb1.Name = "rb1";
  119. this.rb1.Size = new System.Drawing.Size(64, 24);
  120. this.rb1.TabIndex = 6;
  121. this.rb1.Text = "已结帐";
  122. this.rb1.Click += new System.EventHandler(this.rb1_Click);
  123. // 
  124. // rb2
  125. // 
  126. this.rb2.Location = new System.Drawing.Point(160, 13);
  127. this.rb2.Name = "rb2";
  128. this.rb2.Size = new System.Drawing.Size(64, 24);
  129. this.rb2.TabIndex = 7;
  130. this.rb2.Text = "未结帐";
  131. this.rb2.Click += new System.EventHandler(this.rb2_Click);
  132. // 
  133. // rb3
  134. // 
  135. this.rb3.Location = new System.Drawing.Point(304, 13);
  136. this.rb3.Name = "rb3";
  137. this.rb3.Size = new System.Drawing.Size(64, 24);
  138. this.rb3.TabIndex = 8;
  139. this.rb3.Text = "全 部";
  140. this.rb3.Click += new System.EventHandler(this.rb3_Click);
  141. // 
  142. // comboBox1
  143. // 
  144. this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  145. this.comboBox1.Items.AddRange(new object[] {
  146.    "姓名",
  147.    "证件号码",
  148.    "住宿日期",
  149.    "无"});
  150. this.comboBox1.Location = new System.Drawing.Point(88, 47);
  151. this.comboBox1.Name = "comboBox1";
  152. this.comboBox1.Size = new System.Drawing.Size(128, 20);
  153. this.comboBox1.TabIndex = 11;
  154. this.comboBox1.KeyUp += new System.Windows.Forms.KeyEventHandler(this.comboBox1_KeyUp);
  155. this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  156. // 
  157. // dt
  158. // 
  159. this.dt.Format = System.Windows.Forms.DateTimePickerFormat.Short;
  160. this.dt.Location = new System.Drawing.Point(224, 47);
  161. this.dt.Name = "dt";
  162. this.dt.Size = new System.Drawing.Size(128, 21);
  163. this.dt.TabIndex = 16;
  164. // 
  165. // tb
  166. // 
  167. this.tb.Location = new System.Drawing.Point(224, 48);
  168. this.tb.Name = "tb";
  169. this.tb.Size = new System.Drawing.Size(128, 21);
  170. this.tb.TabIndex = 17;
  171. this.tb.Text = "";
  172. // 
  173. // groupBox6
  174. // 
  175. this.groupBox6.Location = new System.Drawing.Point(0, 37);
  176. this.groupBox6.Name = "groupBox6";
  177. this.groupBox6.Size = new System.Drawing.Size(384, 3);
  178. this.groupBox6.TabIndex = 18;
  179. this.groupBox6.TabStop = false;
  180. // 
  181. // label3
  182. // 
  183. this.label3.Location = new System.Drawing.Point(16, 46);
  184. this.label3.Name = "label3";
  185. this.label3.Size = new System.Drawing.Size(72, 23);
  186. this.label3.TabIndex = 19;
  187. this.label3.Text = "查 询 项:";
  188. this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  189. // 
  190. // dg
  191. // 
  192. this.dg.AlternatingBackColor = System.Drawing.Color.GhostWhite;
  193. this.dg.BackColor = System.Drawing.Color.GhostWhite;
  194. this.dg.BackgroundColor = System.Drawing.Color.Lavender;
  195. this.dg.BorderStyle = System.Windows.Forms.BorderStyle.None;
  196. this.dg.CaptionBackColor = System.Drawing.Color.RoyalBlue;
  197. this.dg.CaptionForeColor = System.Drawing.Color.White;
  198. this.dg.CaptionText = "查询结果";
  199. this.dg.DataMember = "";
  200. this.dg.FlatMode = true;
  201. this.dg.Font = new System.Drawing.Font("Tahoma", 8F);
  202. this.dg.ForeColor = System.Drawing.Color.MidnightBlue;
  203. this.dg.GridLineColor = System.Drawing.Color.RoyalBlue;
  204. this.dg.HeaderBackColor = System.Drawing.Color.MidnightBlue;
  205. this.dg.HeaderFont = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Bold);
  206. this.dg.HeaderForeColor = System.Drawing.Color.Lavender;
  207. this.dg.LinkColor = System.Drawing.Color.Teal;
  208. this.dg.Location = new System.Drawing.Point(8, 80);
  209. this.dg.Name = "dg";
  210. this.dg.ParentRowsBackColor = System.Drawing.Color.Lavender;
  211. this.dg.ParentRowsForeColor = System.Drawing.Color.MidnightBlue;
  212. this.dg.ReadOnly = true;
  213. this.dg.SelectionBackColor = System.Drawing.Color.Teal;
  214. this.dg.SelectionForeColor = System.Drawing.Color.PaleGreen;
  215. this.dg.Size = new System.Drawing.Size(368, 160);
  216. this.dg.TabIndex = 20;
  217. // 
  218. // zscx
  219. // 
  220. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  221. this.ClientSize = new System.Drawing.Size(480, 283);
  222. this.Name = "zscx";
  223. this.Text = "住宿查询";
  224. this.Load += new System.EventHandler(this.zscx_Load);
  225. this.groupBox2.ResumeLayout(false);
  226. this.groupBox3.ResumeLayout(false);
  227. ((System.ComponentModel.ISupportInitialize)(this.dg)).EndInit();
  228. } #endregion
  229. DataConn dc=new DataConn ();
  230. string opername;//传递操作员姓名
  231. int order=0;//指示查询类型
  232. private void zscx_Load(object sender, System.EventArgs e)
  233. {
  234. this.AcceptButton =this.button2 ;
  235. this.label2 .Text ="查询日期:"+System.DateTime .Today.Date.ToShortDateString();
  236. this.label1 .Text ="操 作 员:"+this.opername ;
  237. this.tb .Visible =false;
  238. this.dt.Visible =false;
  239. }
  240. private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
  241. {
  242. if(this.comboBox1.SelectedIndex==2)
  243. {
  244. this.dt.Visible =true;
  245. this.tb.Visible =false;
  246. }
  247. if(this.comboBox1.SelectedIndex==0|this.comboBox1.SelectedIndex==1)
  248. {
  249. this.dt.Visible =false;
  250. this.tb.Visible =true;
  251. }
  252. if(this.comboBox1 .SelectedIndex ==3)
  253. {
  254. this.dt.Visible =false;
  255. this.tb.Visible =false;
  256. }
  257. }
  258. private void comboBox1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
  259. {
  260. this.comboBox1 .Text ="";
  261. }
  262. private void button2_Click(object sender, System.EventArgs e)
  263. {
  264. string str=dc.connstr ;
  265. SqlConnection conn=new SqlConnection (str);
  266. DataSet dataset=new DataSet ();
  267. int order1=0;
  268. //查询已结帐的所有记录
  269. if((order==1&this.comboBox1 .Text =="")|(this.rb1 .Checked ==true&(this.comboBox1 .SelectedIndex ==3)))
  270. {
  271. order1=1;
  272. string sql1="select * from tabdjb where 是否结帐='1'";
  273. SqlDataAdapter a1=new SqlDataAdapter (sql1,conn);
  274. a1.Fill (dataset,"t1");
  275. }
  276. //查询未结帐的所有记录
  277. if((order==2&this.comboBox1 .Text =="")|(this.rb2 .Checked ==true&(this.comboBox1 .SelectedIndex ==3)))
  278. {
  279. order1=2;
  280. string sql2="select * from tabdjb where 是否结帐='0'";
  281. SqlDataAdapter a2=new SqlDataAdapter (sql2,conn);
  282. a2.Fill (dataset,"t2");
  283. }
  284. //查询所有记录
  285. if((order==3&this.comboBox1 .Text =="")|(this.rb3 .Checked ==true&(this.comboBox1 .SelectedIndex ==3)))
  286. {
  287. order1=3;
  288. string sql3="select * from tabdjb";
  289. SqlDataAdapter a3=new SqlDataAdapter (sql3,conn);
  290. a3.Fill (dataset,"t3");
  291. }
  292. //按姓名查询已结帐记录
  293. if(order==1&this.comboBox1.SelectedIndex==0)
  294. {
  295. order1=4;
  296. string sql4="select * from tabdjb where 是否结帐='1'and 姓名='"+this.tb .Text +"'";
  297. SqlDataAdapter a4=new SqlDataAdapter (sql4,conn);
  298. a4.Fill (dataset,"t4");
  299. }
  300. //按姓名查询未结帐记录
  301. if(order==2&this.comboBox1.SelectedIndex==0)
  302. {
  303. order1=5;
  304. string sql5="select * from tabdjb where 是否结帐='0'and 姓名='"+this.tb .Text +"'";
  305. SqlDataAdapter a5=new SqlDataAdapter (sql5,conn);
  306. a5.Fill (dataset,"t5");
  307. }
  308. //按姓名查询所有记录
  309. if(order==3&this.comboBox1.SelectedIndex==0)
  310. {
  311. order1=6;
  312. string sql6="select * from tabdjb where 姓名='"+this.tb .Text +"'";
  313. SqlDataAdapter a6=new SqlDataAdapter (sql6,conn);
  314. a6.Fill (dataset,"t6");
  315. }
  316. //按证件号码查询已结帐记录
  317. if(order==1&this.comboBox1.SelectedIndex==1)
  318. {
  319. order1=7;
  320. string sql7="select * from tabdjb where 是否结帐='1'and 证件号码='"+this.tb .Text +"'";
  321. SqlDataAdapter a7=new SqlDataAdapter (sql7,conn);
  322. a7.Fill (dataset,"t7");
  323. }
  324. //按证件号码查询未结帐记录
  325. if(order==2&this.comboBox1.SelectedIndex==1)
  326. {
  327. order1=8;
  328. string sql8="select * from tabdjb where 是否结帐='0'and 证件号码='"+this.tb .Text +"'";
  329. SqlDataAdapter a8=new SqlDataAdapter (sql8,conn);
  330. a8.Fill (dataset,"t8");
  331. }
  332. //按证件号码查询所有记录
  333. if(order==3&this.comboBox1.SelectedIndex==1)
  334. {
  335. order1=9;
  336. string sql9="select * from tabdjb where 证件号码='"+this.tb .Text +"'";
  337. SqlDataAdapter a9=new SqlDataAdapter (sql9,conn);
  338. a9.Fill (dataset,"t9");
  339. }
  340. //按住宿日期查询已结帐记录
  341. if(order==1&this.comboBox1.SelectedIndex==2)
  342. {
  343. order1=10;
  344. string sql10="select * from tabdjb where 是否结帐='1'and 住宿日期='"+this.dt.Value .ToShortDateString ()+"'";
  345. SqlDataAdapter a10=new SqlDataAdapter (sql10,conn);
  346. a10.Fill (dataset,"t10");
  347. }
  348. //按住宿日期查询未结帐记录
  349. if(order==2&this.comboBox1.SelectedIndex==2)
  350. {
  351. order1=11;
  352. string sql11="select * from tabdjb where 是否结帐='0'and 住宿日期='"+this.dt.Value .ToShortDateString ()+"'";
  353. SqlDataAdapter a11=new SqlDataAdapter (sql11,conn);
  354. a11.Fill (dataset,"t11");
  355. }
  356. //按住宿日期查询所有记录
  357. if(order==3&this.comboBox1.SelectedIndex==2)
  358. {
  359. order1=12;
  360. string sql12="select * from tabdjb where 住宿日期='"+this.dt.Value .ToShortDateString ()+"'";
  361. SqlDataAdapter a12=new SqlDataAdapter (sql12,conn);
  362. a12.Fill (dataset,"t12");
  363. }
  364. switch(order1)
  365. {
  366. case 1:
  367. dg.DataSource =dataset.Tables ["t1"];
  368. break;
  369. case 2:
  370. dg.DataSource =dataset.Tables ["t2"];
  371. break;
  372. case 3:
  373. dg.DataSource =dataset.Tables ["t3"];
  374. break;
  375. case 4:
  376. dg.DataSource =dataset.Tables ["t4"];
  377. break;
  378. case 5:
  379. dg.DataSource =dataset.Tables ["t5"];
  380. break;
  381. case 6:
  382. dg.DataSource =dataset.Tables ["t6"];
  383. break;
  384. case 7:
  385. dg.DataSource =dataset.Tables ["t7"];
  386. break;
  387. case 8:
  388. dg.DataSource =dataset.Tables ["t8"];
  389. break;
  390. case 9:
  391. dg.DataSource =dataset.Tables ["t9"];
  392. break;
  393. case 10:
  394. dg.DataSource =dataset.Tables ["t10"];
  395. break;
  396. case 11:
  397. dg.DataSource =dataset.Tables ["t11"];
  398. break;
  399. case 12:
  400. dg.DataSource =dataset.Tables ["t12"];
  401. break;
  402. }
  403. dataset.Dispose ();
  404. conn.Dispose ();
  405. }
  406. private void rb1_Click(object sender, System.EventArgs e)
  407. {
  408. order=1;
  409. }
  410. private void rb2_Click(object sender, System.EventArgs e)
  411. {
  412. order=2;
  413. }
  414. private void rb3_Click(object sender, System.EventArgs e)
  415. {
  416. order=3;
  417. }
  418. } }