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

酒店行业

开发平台:

C#

  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. using System.Data ; using System.Data .SqlClient ;
  7. namespace RoomManage
  8. {
  9. /// <summary>
  10. /// dwinfo 的摘要说明。
  11. /// </summary>
  12. public class dwinfo : System.Windows.Forms.Form
  13. {
  14. private System.Windows.Forms.Label label1;
  15. private System.Windows.Forms.Label label2;
  16. private System.Windows.Forms.Label label3;
  17. private System.Windows.Forms.Label label5;
  18. private System.Windows.Forms.Label label6;
  19. private System.Windows.Forms.Label label7;
  20. private System.Windows.Forms.Label label8;
  21. private System.Windows.Forms.Label label9;
  22. private System.Windows.Forms.TextBox textBox1;
  23. private System.Windows.Forms.TextBox textBox2;
  24. private System.Windows.Forms.TextBox textBox3;
  25. private System.Windows.Forms.Label label4;
  26. private System.Windows.Forms.TextBox textBox4;
  27. private System.Windows.Forms.TextBox textBox5;
  28. private System.Windows.Forms.TextBox textBox6;
  29. private System.Windows.Forms.TextBox textBox7;
  30. private System.Windows.Forms.TextBox textBox8;
  31. private System.Windows.Forms.GroupBox groupBox1;
  32. private System.Windows.Forms.Button button1;
  33. private System.Windows.Forms.Button button2;
  34. private System.Windows.Forms.Button button3;
  35. /// <summary>
  36. /// 必需的设计器变量。
  37. /// </summary>
  38. private System.ComponentModel.Container components = null;
  39. string opername;//传递操作员姓名
  40. string[] chushi={"","","","","","","",""};
  41. DataConn dc=new DataConn ();
  42. public dwinfo(string s)
  43. {
  44. //
  45. // Windows 窗体设计器支持所必需的
  46. //
  47. InitializeComponent();
  48. this.opername =s;
  49. //
  50. // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
  51. //
  52. }
  53. /// <summary>
  54. /// 清理所有正在使用的资源。
  55. /// </summary>
  56. protected override void Dispose( bool disposing )
  57. {
  58. if( disposing )
  59. {
  60. if(components != null)
  61. {
  62. components.Dispose();
  63. }
  64. }
  65. base.Dispose( disposing );
  66. }
  67. #region Windows 窗体设计器生成的代码
  68. /// <summary>
  69. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  70. /// 此方法的内容。
  71. /// </summary>
  72. private void InitializeComponent()
  73. {
  74. this.label1 = new System.Windows.Forms.Label();
  75. this.label2 = new System.Windows.Forms.Label();
  76. this.label3 = new System.Windows.Forms.Label();
  77. this.label5 = new System.Windows.Forms.Label();
  78. this.label6 = new System.Windows.Forms.Label();
  79. this.label7 = new System.Windows.Forms.Label();
  80. this.label8 = new System.Windows.Forms.Label();
  81. this.label9 = new System.Windows.Forms.Label();
  82. this.textBox1 = new System.Windows.Forms.TextBox();
  83. this.textBox2 = new System.Windows.Forms.TextBox();
  84. this.textBox3 = new System.Windows.Forms.TextBox();
  85. this.label4 = new System.Windows.Forms.Label();
  86. this.textBox4 = new System.Windows.Forms.TextBox();
  87. this.textBox5 = new System.Windows.Forms.TextBox();
  88. this.textBox6 = new System.Windows.Forms.TextBox();
  89. this.textBox7 = new System.Windows.Forms.TextBox();
  90. this.textBox8 = new System.Windows.Forms.TextBox();
  91. this.groupBox1 = new System.Windows.Forms.GroupBox();
  92. this.button1 = new System.Windows.Forms.Button();
  93. this.button2 = new System.Windows.Forms.Button();
  94. this.button3 = new System.Windows.Forms.Button();
  95. this.SuspendLayout();
  96. // 
  97. // label1
  98. // 
  99. this.label1.Location = new System.Drawing.Point(8, 8);
  100. this.label1.Name = "label1";
  101. this.label1.Size = new System.Drawing.Size(72, 23);
  102. this.label1.TabIndex = 0;
  103. this.label1.Text = "单位名称:";
  104. this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  105. // 
  106. // label2
  107. // 
  108. this.label2.Location = new System.Drawing.Point(8, 32);
  109. this.label2.Name = "label2";
  110. this.label2.Size = new System.Drawing.Size(72, 23);
  111. this.label2.TabIndex = 0;
  112. this.label2.Text = "地  址:";
  113. this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  114. // 
  115. // label3
  116. // 
  117. this.label3.Location = new System.Drawing.Point(8, 56);
  118. this.label3.Name = "label3";
  119. this.label3.Size = new System.Drawing.Size(72, 23);
  120. this.label3.TabIndex = 0;
  121. this.label3.Text = "邮政编码:";
  122. this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  123. // 
  124. // label5
  125. // 
  126. this.label5.Location = new System.Drawing.Point(8, 80);
  127. this.label5.Name = "label5";
  128. this.label5.Size = new System.Drawing.Size(72, 23);
  129. this.label5.TabIndex = 0;
  130. this.label5.Text = "传  真:";
  131. this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  132. // 
  133. // label6
  134. // 
  135. this.label6.Location = new System.Drawing.Point(192, 104);
  136. this.label6.Name = "label6";
  137. this.label6.Size = new System.Drawing.Size(72, 23);
  138. this.label6.TabIndex = 0;
  139. this.label6.Text = "网  址:";
  140. this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  141. // 
  142. // label7
  143. // 
  144. this.label7.Location = new System.Drawing.Point(8, 104);
  145. this.label7.Name = "label7";
  146. this.label7.Size = new System.Drawing.Size(72, 23);
  147. this.label7.TabIndex = 0;
  148. this.label7.Text = "电子邮件:";
  149. this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  150. // 
  151. // label8
  152. // 
  153. this.label8.Location = new System.Drawing.Point(192, 80);
  154. this.label8.Name = "label8";
  155. this.label8.Size = new System.Drawing.Size(72, 23);
  156. this.label8.TabIndex = 0;
  157. this.label8.Text = "财务主管:";
  158. this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  159. // 
  160. // label9
  161. // 
  162. this.label9.Location = new System.Drawing.Point(192, 144);
  163. this.label9.Name = "label9";
  164. this.label9.Size = new System.Drawing.Size(72, 23);
  165. this.label9.TabIndex = 0;
  166. this.label9.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  167. // 
  168. // textBox1
  169. // 
  170. this.textBox1.Location = new System.Drawing.Point(80, 9);
  171. this.textBox1.Name = "textBox1";
  172. this.textBox1.Size = new System.Drawing.Size(288, 21);
  173. this.textBox1.TabIndex = 1;
  174. this.textBox1.Text = "";
  175. // 
  176. // textBox2
  177. // 
  178. this.textBox2.Location = new System.Drawing.Point(80, 33);
  179. this.textBox2.Name = "textBox2";
  180. this.textBox2.Size = new System.Drawing.Size(288, 21);
  181. this.textBox2.TabIndex = 1;
  182. this.textBox2.Text = "";
  183. // 
  184. // textBox3
  185. // 
  186. this.textBox3.Location = new System.Drawing.Point(264, 57);
  187. this.textBox3.Name = "textBox3";
  188. this.textBox3.TabIndex = 1;
  189. this.textBox3.Text = "";
  190. // 
  191. // label4
  192. // 
  193. this.label4.Location = new System.Drawing.Point(192, 56);
  194. this.label4.Name = "label4";
  195. this.label4.Size = new System.Drawing.Size(72, 23);
  196. this.label4.TabIndex = 0;
  197. this.label4.Text = "电  话:";
  198. this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  199. // 
  200. // textBox4
  201. // 
  202. this.textBox4.Location = new System.Drawing.Point(80, 105);
  203. this.textBox4.Name = "textBox4";
  204. this.textBox4.TabIndex = 1;
  205. this.textBox4.Text = "";
  206. // 
  207. // textBox5
  208. // 
  209. this.textBox5.Location = new System.Drawing.Point(80, 81);
  210. this.textBox5.Name = "textBox5";
  211. this.textBox5.TabIndex = 1;
  212. this.textBox5.Text = "";
  213. // 
  214. // textBox6
  215. // 
  216. this.textBox6.Location = new System.Drawing.Point(80, 57);
  217. this.textBox6.Name = "textBox6";
  218. this.textBox6.TabIndex = 1;
  219. this.textBox6.Text = "";
  220. // 
  221. // textBox7
  222. // 
  223. this.textBox7.Location = new System.Drawing.Point(264, 81);
  224. this.textBox7.Name = "textBox7";
  225. this.textBox7.TabIndex = 1;
  226. this.textBox7.Text = "";
  227. // 
  228. // textBox8
  229. // 
  230. this.textBox8.Location = new System.Drawing.Point(264, 105);
  231. this.textBox8.Name = "textBox8";
  232. this.textBox8.TabIndex = 1;
  233. this.textBox8.Text = "";
  234. // 
  235. // groupBox1
  236. // 
  237. this.groupBox1.Location = new System.Drawing.Point(0, 136);
  238. this.groupBox1.Name = "groupBox1";
  239. this.groupBox1.Size = new System.Drawing.Size(384, 3);
  240. this.groupBox1.TabIndex = 2;
  241. this.groupBox1.TabStop = false;
  242. // 
  243. // button1
  244. // 
  245. this.button1.Location = new System.Drawing.Point(8, 144);
  246. this.button1.Name = "button1";
  247. this.button1.Size = new System.Drawing.Size(48, 23);
  248. this.button1.TabIndex = 0;
  249. this.button1.Text = "保存";
  250. this.button1.Click += new System.EventHandler(this.button1_Click);
  251. // 
  252. // button2
  253. // 
  254. this.button2.Location = new System.Drawing.Point(64, 144);
  255. this.button2.Name = "button2";
  256. this.button2.Size = new System.Drawing.Size(48, 23);
  257. this.button2.TabIndex = 1;
  258. this.button2.Text = "还原";
  259. this.button2.Click += new System.EventHandler(this.button2_Click);
  260. // 
  261. // button3
  262. // 
  263. this.button3.Location = new System.Drawing.Point(120, 144);
  264. this.button3.Name = "button3";
  265. this.button3.Size = new System.Drawing.Size(48, 23);
  266. this.button3.TabIndex = 2;
  267. this.button3.Text = "退出";
  268. this.button3.Click += new System.EventHandler(this.button3_Click);
  269. // 
  270. // dwinfo
  271. // 
  272. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  273. this.ClientSize = new System.Drawing.Size(376, 173);
  274. this.ControlBox = false;
  275. this.Controls.Add(this.button1);
  276. this.Controls.Add(this.groupBox1);
  277. this.Controls.Add(this.textBox1);
  278. this.Controls.Add(this.label1);
  279. this.Controls.Add(this.label2);
  280. this.Controls.Add(this.label3);
  281. this.Controls.Add(this.label5);
  282. this.Controls.Add(this.label6);
  283. this.Controls.Add(this.label7);
  284. this.Controls.Add(this.label8);
  285. this.Controls.Add(this.label9);
  286. this.Controls.Add(this.textBox2);
  287. this.Controls.Add(this.textBox3);
  288. this.Controls.Add(this.label4);
  289. this.Controls.Add(this.textBox4);
  290. this.Controls.Add(this.textBox5);
  291. this.Controls.Add(this.textBox6);
  292. this.Controls.Add(this.textBox7);
  293. this.Controls.Add(this.textBox8);
  294. this.Controls.Add(this.button2);
  295. this.Controls.Add(this.button3);
  296. this.MaximizeBox = false;
  297. this.MaximumSize = new System.Drawing.Size(384, 200);
  298. this.MinimizeBox = false;
  299. this.MinimumSize = new System.Drawing.Size(384, 200);
  300. this.Name = "dwinfo";
  301. this.ShowInTaskbar = false;
  302. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
  303. this.Text = "本单位信息维护";
  304. this.TopMost = true;
  305. this.Load += new System.EventHandler(this.dwinfo_Load);
  306. this.ResumeLayout(false);
  307. }
  308. #endregion
  309. private void dwinfo_Load(object sender, System.EventArgs e)
  310. {
  311. this.AcceptButton =this.button1 ;
  312. this.label9 .Text ="操作员:"+this.opername ;
  313. string str=dc.connstr ;
  314. SqlConnection conn=new SqlConnection (str);
  315. string sql="select * from tabbdwdy";
  316. SqlDataAdapter adapter=new SqlDataAdapter (sql,conn);
  317. DataSet dataset=new DataSet ();
  318. adapter.Fill (dataset,"tab");
  319. this.textBox1 .DataBindings.Add (new Binding ("Text",dataset,"tab.单位名称"));
  320. this.textBox2 .DataBindings.Add (new Binding ("Text",dataset,"tab.地址"));
  321. this.textBox3 .DataBindings.Add (new Binding ("Text",dataset,"tab.电话"));
  322. this.textBox4 .DataBindings.Add (new Binding ("Text",dataset,"tab.电子邮件"));
  323. this.textBox5 .DataBindings.Add (new Binding ("Text",dataset,"tab.传真"));
  324. this.textBox6 .DataBindings.Add (new Binding ("Text",dataset,"tab.邮政编码"));
  325. this.textBox7 .DataBindings.Add (new Binding ("Text",dataset,"tab.财务主管"));
  326. this.textBox8 .DataBindings.Add (new Binding ("Text",dataset,"tab.网址"));
  327. //释放所有绑定
  328. this.textBox1 .DataBindings .Clear ();
  329. this.textBox2 .DataBindings .Clear ();
  330. this.textBox3 .DataBindings .Clear ();
  331. this.textBox4 .DataBindings .Clear ();
  332. this.textBox5 .DataBindings .Clear ();
  333. this.textBox6 .DataBindings .Clear ();
  334. this.textBox7 .DataBindings .Clear ();
  335. this.textBox8 .DataBindings .Clear ();
  336. chushi[0]=textBox1.Text ;
  337. chushi[1]=textBox2.Text ;
  338. chushi[2]=textBox3.Text ;
  339. chushi[3]=textBox4.Text ;
  340. chushi[4]=textBox5.Text ;
  341. chushi[5]=textBox6.Text ;
  342. chushi[6]=textBox7.Text ;
  343. chushi[7]=textBox8.Text ;
  344. conn.Dispose ();
  345. adapter.Dispose ();
  346. dataset.Dispose ();
  347. }
  348. private void button1_Click(object sender, System.EventArgs e)
  349. {
  350. string str=dc.connstr ;
  351. SqlConnection conn=new SqlConnection (str);
  352. string sql="update tabbdwdy set 单位名称='"+this.textBox1 .Text +"',地址='"+this.textBox2 .Text +"',邮政编码='"+this.textBox6.Text +"',电话='"+this.textBox3 .Text +"',传真='"+this.textBox5.Text +"',财务主管='"+this.textBox7.Text +"',电子邮件='"+this.textBox4.Text +"',网址='"+this.textBox8.Text +"'";
  353. SqlCommand cmd=new SqlCommand (sql,conn);
  354. conn.Open ();
  355. try
  356. {
  357. cmd.ExecuteNonQuery ();
  358. MessageBox.Show("保存成功。","恭喜");
  359. }
  360. catch(Exception err)
  361. {
  362. MessageBox.Show(err.Message,"保存信息出错!",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
  363. }
  364. finally
  365. {
  366. conn.Close ();
  367. cmd.Dispose ();
  368. }
  369. private void button3_Click(object sender, System.EventArgs e)
  370. {
  371. if(MessageBox.Show("真的要退出吗?","注意",MessageBoxButtons.OKCancel,MessageBoxIcon.Question)==DialogResult.OK)
  372. this.Close ();
  373. }
  374. private void button2_Click(object sender, System.EventArgs e)
  375. {
  376. textBox1.Text =chushi[0];
  377. textBox2.Text =chushi[1];
  378. textBox3.Text =chushi[2];
  379. textBox4.Text =chushi[3];
  380. textBox5.Text =chushi[4];
  381. textBox6.Text =chushi[5];
  382. textBox7.Text =chushi[6];
  383. textBox8.Text =chushi[7];
  384. }
  385. }
  386. }