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

酒店行业

开发平台:

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 kfyd : RoomManage.pub {
  2. private System.Windows.Forms.Button button2;
  3. private System.Windows.Forms.Button button3;
  4. private System.Windows.Forms.Button button4;
  5. private System.Windows.Forms.PictureBox pictureBox2;
  6. private System.Windows.Forms.Button button5;
  7. private System.Windows.Forms.Label label1;
  8. private System.Windows.Forms.Label label2;
  9. private System.Windows.Forms.Label label3;
  10. private System.Windows.Forms.Label label4;
  11. private System.Windows.Forms.Label label6;
  12. private System.Windows.Forms.Label label7;
  13. private System.Windows.Forms.Label label8;
  14. private System.Windows.Forms.Label label9;
  15. private System.Windows.Forms.Label label10;
  16. private System.Windows.Forms.Label label11;
  17. private System.Windows.Forms.Label label13;
  18. private System.Windows.Forms.TextBox textBox1;
  19. private System.Windows.Forms.ComboBox comboBox1;
  20. private System.Windows.Forms.TextBox textBox2;
  21. private System.Windows.Forms.TextBox textBox3;
  22. private System.Windows.Forms.TextBox textBox5;
  23. private System.Windows.Forms.ComboBox comboBox2;
  24. private System.Windows.Forms.TextBox textBox6;
  25. private System.Windows.Forms.TextBox textBox7;
  26. private System.Windows.Forms.TextBox textBox8;
  27. private System.Windows.Forms.TextBox textBox9;
  28. private System.Windows.Forms.TextBox textBox10;
  29. private System.Windows.Forms.Button button6; private System.ComponentModel.IContainer components = null;
  30. private System.Windows.Forms.Label label12;
  31. private System.Windows.Forms.GroupBox groupBox4; string opername; public kfyd(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(kfyd));
  32. this.button2 = new System.Windows.Forms.Button();
  33. this.button3 = new System.Windows.Forms.Button();
  34. this.button4 = new System.Windows.Forms.Button();
  35. this.pictureBox2 = new System.Windows.Forms.PictureBox();
  36. this.button5 = new System.Windows.Forms.Button();
  37. this.label1 = new System.Windows.Forms.Label();
  38. this.label2 = new System.Windows.Forms.Label();
  39. this.label3 = new System.Windows.Forms.Label();
  40. this.label4 = new System.Windows.Forms.Label();
  41. this.label6 = new System.Windows.Forms.Label();
  42. this.label7 = new System.Windows.Forms.Label();
  43. this.label8 = new System.Windows.Forms.Label();
  44. this.label9 = new System.Windows.Forms.Label();
  45. this.label10 = new System.Windows.Forms.Label();
  46. this.label11 = new System.Windows.Forms.Label();
  47. this.label13 = new System.Windows.Forms.Label();
  48. this.textBox1 = new System.Windows.Forms.TextBox();
  49. this.comboBox1 = new System.Windows.Forms.ComboBox();
  50. this.textBox2 = new System.Windows.Forms.TextBox();
  51. this.textBox3 = new System.Windows.Forms.TextBox();
  52. this.textBox5 = new System.Windows.Forms.TextBox();
  53. this.comboBox2 = new System.Windows.Forms.ComboBox();
  54. this.textBox6 = new System.Windows.Forms.TextBox();
  55. this.textBox7 = new System.Windows.Forms.TextBox();
  56. this.textBox8 = new System.Windows.Forms.TextBox();
  57. this.textBox9 = new System.Windows.Forms.TextBox();
  58. this.textBox10 = new System.Windows.Forms.TextBox();
  59. this.button6 = new System.Windows.Forms.Button();
  60. this.label12 = new System.Windows.Forms.Label();
  61. this.groupBox4 = new System.Windows.Forms.GroupBox();
  62. this.groupBox2.SuspendLayout();
  63. this.groupBox3.SuspendLayout();
  64. // 
  65. // button1
  66. // 
  67. this.button1.Name = "button1";
  68. this.button1.TabIndex = 13;
  69. // 
  70. // groupBox1
  71. // 
  72. this.groupBox1.Name = "groupBox1";
  73. // 
  74. // groupBox2
  75. // 
  76. this.groupBox2.Controls.Add(this.button6);
  77. this.groupBox2.Controls.Add(this.button5);
  78. this.groupBox2.Name = "groupBox2";
  79. this.groupBox2.Controls.SetChildIndex(this.button1, 0);
  80. this.groupBox2.Controls.SetChildIndex(this.button5, 0);
  81. this.groupBox2.Controls.SetChildIndex(this.button6, 0);
  82. // 
  83. // pictureBox1
  84. // 
  85. this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
  86. this.pictureBox1.Name = "pictureBox1";
  87. // 
  88. // groupBox3
  89. // 
  90. this.groupBox3.Controls.Add(this.groupBox4);
  91. this.groupBox3.Controls.Add(this.textBox10);
  92. this.groupBox3.Controls.Add(this.textBox9);
  93. this.groupBox3.Controls.Add(this.textBox8);
  94. this.groupBox3.Controls.Add(this.textBox7);
  95. this.groupBox3.Controls.Add(this.textBox6);
  96. this.groupBox3.Controls.Add(this.textBox5);
  97. this.groupBox3.Controls.Add(this.textBox3);
  98. this.groupBox3.Controls.Add(this.textBox2);
  99. this.groupBox3.Controls.Add(this.textBox1);
  100. this.groupBox3.Controls.Add(this.comboBox2);
  101. this.groupBox3.Controls.Add(this.comboBox1);
  102. this.groupBox3.Controls.Add(this.label13);
  103. this.groupBox3.Controls.Add(this.label12);
  104. this.groupBox3.Controls.Add(this.label11);
  105. this.groupBox3.Controls.Add(this.label10);
  106. this.groupBox3.Controls.Add(this.label9);
  107. this.groupBox3.Controls.Add(this.label8);
  108. this.groupBox3.Controls.Add(this.label7);
  109. this.groupBox3.Controls.Add(this.label6);
  110. this.groupBox3.Controls.Add(this.label4);
  111. this.groupBox3.Controls.Add(this.label3);
  112. this.groupBox3.Controls.Add(this.label2);
  113. this.groupBox3.Controls.Add(this.label1);
  114. this.groupBox3.Name = "groupBox3";
  115. // 
  116. // button2
  117. // 
  118. this.button2.Location = new System.Drawing.Point(32, 136);
  119. this.button2.Name = "button2";
  120. this.button2.TabIndex = 1;
  121. this.button2.Text = "button2";
  122. // 
  123. // button3
  124. // 
  125. this.button3.Location = new System.Drawing.Point(0, 192);
  126. this.button3.Name = "button3";
  127. this.button3.TabIndex = 2;
  128. this.button3.Text = "button3";
  129. // 
  130. // button4
  131. // 
  132. this.button4.Location = new System.Drawing.Point(16, 136);
  133. this.button4.Name = "button4";
  134. this.button4.TabIndex = 3;
  135. this.button4.Text = "button4";
  136. // 
  137. // pictureBox2
  138. // 
  139. this.pictureBox2.Location = new System.Drawing.Point(16, 72);
  140. this.pictureBox2.Name = "pictureBox2";
  141. this.pictureBox2.TabIndex = 4;
  142. this.pictureBox2.TabStop = false;
  143. // 
  144. // button5
  145. // 
  146. this.button5.Location = new System.Drawing.Point(8, 16);
  147. this.button5.Name = "button5";
  148. this.button5.Size = new System.Drawing.Size(48, 23);
  149. this.button5.TabIndex = 11;
  150. this.button5.Text = "登记";
  151. this.button5.Click += new System.EventHandler(this.button5_Click);
  152. // 
  153. // label1
  154. // 
  155. this.label1.Location = new System.Drawing.Point(16, 24);
  156. this.label1.Name = "label1";
  157. this.label1.Size = new System.Drawing.Size(72, 23);
  158. this.label1.TabIndex = 0;
  159. this.label1.Text = "姓  名:";
  160. // 
  161. // label2
  162. // 
  163. this.label2.Location = new System.Drawing.Point(200, 24);
  164. this.label2.Name = "label2";
  165. this.label2.Size = new System.Drawing.Size(72, 23);
  166. this.label2.TabIndex = 1;
  167. this.label2.Text = "证件名称:";
  168. // 
  169. // label3
  170. // 
  171. this.label3.Location = new System.Drawing.Point(16, 59);
  172. this.label3.Name = "label3";
  173. this.label3.Size = new System.Drawing.Size(72, 23);
  174. this.label3.TabIndex = 2;
  175. this.label3.Text = "证件号码:";
  176. // 
  177. // label4
  178. // 
  179. this.label4.Location = new System.Drawing.Point(200, 59);
  180. this.label4.Name = "label4";
  181. this.label4.Size = new System.Drawing.Size(72, 23);
  182. this.label4.TabIndex = 3;
  183. this.label4.Text = "联系电话:";
  184. // 
  185. // label6
  186. // 
  187. this.label6.Location = new System.Drawing.Point(16, 94);
  188. this.label6.Name = "label6";
  189. this.label6.Size = new System.Drawing.Size(72, 23);
  190. this.label6.TabIndex = 5;
  191. this.label6.Text = "详细地址:";
  192. // 
  193. // label7
  194. // 
  195. this.label7.Location = new System.Drawing.Point(16, 129);
  196. this.label7.Name = "label7";
  197. this.label7.Size = new System.Drawing.Size(72, 23);
  198. this.label7.TabIndex = 6;
  199. this.label7.Text = "客房类型:";
  200. // 
  201. // label8
  202. // 
  203. this.label8.Location = new System.Drawing.Point(200, 129);
  204. this.label8.Name = "label8";
  205. this.label8.Size = new System.Drawing.Size(72, 23);
  206. this.label8.TabIndex = 7;
  207. this.label8.Text = "房间价格:";
  208. // 
  209. // label9
  210. // 
  211. this.label9.Location = new System.Drawing.Point(200, 164);
  212. this.label9.Name = "label9";
  213. this.label9.Size = new System.Drawing.Size(72, 23);
  214. this.label9.TabIndex = 8;
  215. this.label9.Text = "预付金额:";
  216. // 
  217. // label10
  218. // 
  219. this.label10.Location = new System.Drawing.Point(16, 248);
  220. this.label10.Name = "label10";
  221. this.label10.Size = new System.Drawing.Size(144, 24);
  222. this.label10.TabIndex = 9;
  223. this.label10.Text = "预住日期:";
  224. // 
  225. // label11
  226. // 
  227. this.label11.Location = new System.Drawing.Point(16, 164);
  228. this.label11.Name = "label11";
  229. this.label11.Size = new System.Drawing.Size(72, 23);
  230. this.label11.TabIndex = 10;
  231. this.label11.Text = "预住天数:";
  232. // 
  233. // label13
  234. // 
  235. this.label13.Location = new System.Drawing.Point(16, 199);
  236. this.label13.Name = "label13";
  237. this.label13.Size = new System.Drawing.Size(72, 23);
  238. this.label13.TabIndex = 12;
  239. this.label13.Text = "备  注:";
  240. // 
  241. // textBox1
  242. // 
  243. this.textBox1.Location = new System.Drawing.Point(80, 21);
  244. this.textBox1.Name = "textBox1";
  245. this.textBox1.TabIndex = 0;
  246. this.textBox1.Text = "";
  247. // 
  248. // comboBox1
  249. // 
  250. this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  251. this.comboBox1.Items.AddRange(new object[] {
  252.    "身份证",
  253.    "学生证",
  254.    "其 它"});
  255. this.comboBox1.Location = new System.Drawing.Point(264, 21);
  256. this.comboBox1.Name = "comboBox1";
  257. this.comboBox1.Size = new System.Drawing.Size(96, 20);
  258. this.comboBox1.TabIndex = 1;
  259. // 
  260. // textBox2
  261. // 
  262. this.textBox2.Location = new System.Drawing.Point(80, 55);
  263. this.textBox2.Name = "textBox2";
  264. this.textBox2.TabIndex = 2;
  265. this.textBox2.Text = "";
  266. // 
  267. // textBox3
  268. // 
  269. this.textBox3.Location = new System.Drawing.Point(264, 55);
  270. this.textBox3.Name = "textBox3";
  271. this.textBox3.Size = new System.Drawing.Size(96, 21);
  272. this.textBox3.TabIndex = 3;
  273. this.textBox3.Text = "";
  274. // 
  275. // textBox5
  276. // 
  277. this.textBox5.Location = new System.Drawing.Point(80, 91);
  278. this.textBox5.Name = "textBox5";
  279. this.textBox5.Size = new System.Drawing.Size(280, 21);
  280. this.textBox5.TabIndex = 4;
  281. this.textBox5.Text = "";
  282. // 
  283. // comboBox2
  284. // 
  285. this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  286. this.comboBox2.Items.AddRange(new object[] {
  287.    "普房",
  288.    "标房",
  289.    "套房",
  290.    "双人间",
  291.    "总统套房"});
  292. this.comboBox2.Location = new System.Drawing.Point(80, 126);
  293. this.comboBox2.Name = "comboBox2";
  294. this.comboBox2.Size = new System.Drawing.Size(104, 20);
  295. this.comboBox2.TabIndex = 5;
  296. this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged);
  297. // 
  298. // textBox6
  299. // 
  300. this.textBox6.Location = new System.Drawing.Point(264, 126);
  301. this.textBox6.Name = "textBox6";
  302. this.textBox6.ReadOnly = true;
  303. this.textBox6.Size = new System.Drawing.Size(96, 21);
  304. this.textBox6.TabIndex = 6;
  305. this.textBox6.Text = "";
  306. // 
  307. // textBox7
  308. // 
  309. this.textBox7.Location = new System.Drawing.Point(80, 161);
  310. this.textBox7.Name = "textBox7";
  311. this.textBox7.TabIndex = 7;
  312. this.textBox7.Text = "";
  313. this.textBox7.TextChanged += new System.EventHandler(this.textBox7_TextChanged);
  314. // 
  315. // textBox8
  316. // 
  317. this.textBox8.Location = new System.Drawing.Point(264, 161);
  318. this.textBox8.Name = "textBox8";
  319. this.textBox8.Size = new System.Drawing.Size(96, 21);
  320. this.textBox8.TabIndex = 8;
  321. this.textBox8.Text = "";
  322. this.textBox8.TextChanged += new System.EventHandler(this.textBox8_TextChanged);
  323. // 
  324. // textBox9
  325. // 
  326. this.textBox9.Location = new System.Drawing.Point(80, 196);
  327. this.textBox9.Name = "textBox9";
  328. this.textBox9.Size = new System.Drawing.Size(280, 21);
  329. this.textBox9.TabIndex = 9;
  330. this.textBox9.Text = "";
  331. // 
  332. // textBox10
  333. // 
  334. this.textBox10.Location = new System.Drawing.Point(80, 244);
  335. this.textBox10.Name = "textBox10";
  336. this.textBox10.ReadOnly = true;
  337. this.textBox10.TabIndex = 24;
  338. this.textBox10.Text = "";
  339. // 
  340. // button6
  341. // 
  342. this.button6.Location = new System.Drawing.Point(8, 56);
  343. this.button6.Name = "button6";
  344. this.button6.Size = new System.Drawing.Size(48, 23);
  345. this.button6.TabIndex = 12;
  346. this.button6.Text = "重填";
  347. this.button6.Click += new System.EventHandler(this.button6_Click);
  348. // 
  349. // label12
  350. // 
  351. this.label12.Location = new System.Drawing.Point(200, 248);
  352. this.label12.Name = "label12";
  353. this.label12.Size = new System.Drawing.Size(144, 24);
  354. this.label12.TabIndex = 11;
  355. // 
  356. // groupBox4
  357. // 
  358. this.groupBox4.Location = new System.Drawing.Point(0, 232);
  359. this.groupBox4.Name = "groupBox4";
  360. this.groupBox4.Size = new System.Drawing.Size(384, 3);
  361. this.groupBox4.TabIndex = 25;
  362. this.groupBox4.TabStop = false;
  363. // 
  364. // kfyd
  365. // 
  366. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  367. this.ClientSize = new System.Drawing.Size(480, 283);
  368. this.Name = "kfyd";
  369. this.Text = "客房预定";
  370. this.Load += new System.EventHandler(this.kfyd_Load);
  371. this.groupBox2.ResumeLayout(false);
  372. this.groupBox3.ResumeLayout(false);
  373. } #endregion
  374. DataConn dc=new DataConn ();
  375. private void kfyd_Load(object sender, System.EventArgs e)
  376. {
  377. this.label12 .Text ="操作员:"+this.opername ;
  378. this.AcceptButton =this.button5 ;
  379. this.textBox10.Text =System.DateTime .Today.Date.ToShortDateString();
  380. this.comboBox2 .Text="";
  381. this.textBox6 .Text ="";
  382. }
  383. //检查输入是否有误
  384. private bool checkinput()
  385. {
  386. bool passed=true;
  387. if(this.textBox1.Text .Length==0|this.textBox2 .Text .Length ==0|this.textBox3 .Text .Length ==0|this.textBox5 .Text .Length ==0|this.textBox6 .Text .Length ==0|this.textBox7 .Text .Length ==0|this.textBox8 .Text .Length ==0)
  388. passed=false;
  389. return passed;
  390. }
  391. //清空
  392. private void chushi()
  393. {
  394. textBox1.Text ="";
  395. comboBox1.SelectedIndex =-1;
  396. comboBox2.SelectedIndex =-1;
  397. textBox2.Text ="";
  398. textBox3.Text ="";
  399. textBox5.Text ="";
  400. textBox6.Text ="";
  401. textBox7.Text ="";
  402. textBox8.Text ="";
  403. textBox9.Text ="";
  404. }
  405. private void button5_Click(object sender, System.EventArgs e)
  406. {
  407. string str=dc.connstr ;
  408. SqlConnection conn=new SqlConnection (str);
  409. string sql="insert into tabkfyd values(";
  410. sql=sql+"'"+this.textBox1 .Text +"',";
  411. sql=sql+"'"+this.comboBox1.Text +"',";
  412. sql=sql+"'"+this.textBox2 .Text +"',";
  413. sql=sql+"'"+this.textBox3 .Text +"',";
  414. sql=sql+"'"+this.textBox5 .Text +"',";
  415. sql=sql+"'"+this.comboBox2.Text +"',";
  416. sql=sql+""+this.textBox6 .Text +",";
  417. sql=sql+"'"+this.textBox10 .Text +"',";
  418. sql=sql+""+this.textBox7 .Text +",";
  419. sql=sql+""+this.textBox8 .Text +",";
  420. sql=sql+"'"+this.opername +"',";
  421. sql=sql+"'"+this.textBox9 .Text +"')";
  422. SqlCommand cmd=new SqlCommand (sql,conn);
  423. conn.Open ();
  424. try
  425. {
  426. if(this.checkinput ()==true)
  427. {
  428. cmd.ExecuteNonQuery ();
  429. MessageBox.Show ("您已预定成功!","恭喜",MessageBoxButtons.OK ,MessageBoxIcon.Information);
  430. chushi ();//清空
  431. }
  432. else
  433. MessageBox.Show ("对不起,您的输入有误,请仔细检查,重新输入!","注意",MessageBoxButtons.OK ,MessageBoxIcon.Error );
  434. }
  435. catch
  436. {
  437. MessageBox.Show ("对不起,您的输入有误,请仔细检查,重新输入!","注意",MessageBoxButtons.OK ,MessageBoxIcon.Error );
  438. }
  439. finally
  440. {
  441. conn.Close ();
  442. cmd.Dispose ();
  443. }
  444. }
  445. private void button6_Click(object sender, System.EventArgs e)
  446. {
  447. this.textBox1 .Text ="";
  448. this.textBox2 .Text ="";
  449. this.textBox3 .Text ="";
  450. this.textBox5 .Text ="";
  451. this.textBox6 .Text ="";
  452. this.textBox7 .Text ="";
  453. this.textBox8 .Text ="";
  454. this.textBox9 .Text ="";
  455. this.comboBox1 .Text ="";
  456. this.comboBox2 .Text ="";
  457. }
  458. private void comboBox2_SelectedIndexChanged(object sender, System.EventArgs e)
  459. {
  460. this.textBox6 .DataBindings .Clear ();
  461. string str=dc.connstr ;
  462. SqlConnection conn=new SqlConnection (str);
  463. string sql="select * from tabkflx where 客房类型='"+this.comboBox2.Text+"'";
  464. SqlDataAdapter adapter=new SqlDataAdapter (sql,conn);
  465. DataSet dataset=new DataSet ();
  466. adapter.Fill (dataset,"tabkflx");
  467. this.textBox6 .DataBindings.Add (new Binding ("Text",dataset,"tabkflx.价格"));;
  468. conn.Close ();
  469. adapter.Dispose ();
  470. dataset.Dispose ();
  471. }
  472. private void textBox7_TextChanged(object sender, System.EventArgs e)
  473. {
  474. string str=this.textBox7.Text ;
  475. int f=1;
  476. for(int i=0;i<str.Length ;i++)
  477. {
  478. if(str[i]<'0'|str[i]>'9')
  479. f=0;
  480. break;
  481. }
  482. if(f==0)
  483. {
  484. // MessageBox.Show ("对不起,您的输入有误!","注意",MessageBoxButtons.OK ,MessageBoxIcon.Error );
  485. this.textBox7 .Text ="";
  486. }
  487. }
  488. private void textBox8_TextChanged(object sender, System.EventArgs e)
  489. {
  490. string str=this.textBox8.Text ;
  491. int f=1;
  492. for(int i=0;i<str.Length ;i++)
  493. {
  494. if(str[i]<'0'|str[i]>'9')
  495. f=0;
  496. break;
  497. }
  498. if(f==0)
  499. {
  500. // MessageBox.Show ("对不起,您的输入有误!","注意",MessageBoxButtons.OK ,MessageBoxIcon.Error );
  501. this.textBox8 .Text ="";
  502. }
  503. } } }