Form_Publisher.cs
上传用户:chinapurv
上传日期:2014-03-12
资源大小:4870k
文件大小:18k
源码类别:

教育系统应用

开发平台:

C#

  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. namespace 图书管理系统
  7. {
  8. /// <summary>
  9. /// Form_Publisher 的摘要说明。
  10. /// </summary>
  11. public class Form_Publisher : System.Windows.Forms.Form
  12. {
  13. private System.Windows.Forms.Label label1;
  14. private System.Windows.Forms.Label label2;
  15. private System.Windows.Forms.Label label3;
  16. private System.Windows.Forms.Label label4;
  17. private System.Windows.Forms.TextBox pressname;
  18. private System.Windows.Forms.TextBox presslinkman;
  19. private System.Windows.Forms.TextBox pressaddress;
  20. private System.Windows.Forms.TextBox presstelephone;
  21. private System.Windows.Forms.Button butPrev;
  22. private System.Windows.Forms.Button butNext;
  23. private System.Windows.Forms.Button butLast;
  24. private System.Windows.Forms.Button butFirst;
  25. private System.Windows.Forms.Button butShowAll;
  26. private System.Windows.Forms.Label label5;
  27. private System.Windows.Forms.ComboBox comboBox1;
  28. private System.Windows.Forms.ComboBox comboBox2;
  29. private System.Windows.Forms.Button butSearch;
  30. private System.Windows.Forms.Button butDelete;
  31. private System.Windows.Forms.Button butAdd;
  32. private System.Windows.Forms.Button butAlter;
  33. private System.Windows.Forms.Button butBookManagement;
  34. private System.Windows.Forms.TextBox textForSearch;
  35. /// <summary>
  36. /// 必需的设计器变量。
  37. /// </summary>
  38. private System.ComponentModel.Container components = null;
  39. public Form_Publisher()
  40. {
  41. //
  42. // Windows 窗体设计器支持所必需的
  43. //
  44. InitializeComponent();
  45. //
  46. // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
  47. //
  48. }
  49. /// <summary>
  50. /// 清理所有正在使用的资源。
  51. /// </summary>
  52. protected override void Dispose( bool disposing )
  53. {
  54. if( disposing )
  55. {
  56. if(components != null)
  57. {
  58. components.Dispose();
  59. }
  60. }
  61. base.Dispose( disposing );
  62. }
  63. #region Windows 窗体设计器生成的代码
  64. /// <summary>
  65. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  66. /// 此方法的内容。
  67. /// </summary>
  68. private void InitializeComponent()
  69. {
  70. System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form_Publisher));
  71. this.label1 = new System.Windows.Forms.Label();
  72. this.label2 = new System.Windows.Forms.Label();
  73. this.label3 = new System.Windows.Forms.Label();
  74. this.label4 = new System.Windows.Forms.Label();
  75. this.pressname = new System.Windows.Forms.TextBox();
  76. this.presslinkman = new System.Windows.Forms.TextBox();
  77. this.pressaddress = new System.Windows.Forms.TextBox();
  78. this.presstelephone = new System.Windows.Forms.TextBox();
  79. this.butBookManagement = new System.Windows.Forms.Button();
  80. this.butPrev = new System.Windows.Forms.Button();
  81. this.butNext = new System.Windows.Forms.Button();
  82. this.butLast = new System.Windows.Forms.Button();
  83. this.butFirst = new System.Windows.Forms.Button();
  84. this.butShowAll = new System.Windows.Forms.Button();
  85. this.label5 = new System.Windows.Forms.Label();
  86. this.comboBox1 = new System.Windows.Forms.ComboBox();
  87. this.butSearch = new System.Windows.Forms.Button();
  88. this.textForSearch = new System.Windows.Forms.TextBox();
  89. this.comboBox2 = new System.Windows.Forms.ComboBox();
  90. this.butDelete = new System.Windows.Forms.Button();
  91. this.butAdd = new System.Windows.Forms.Button();
  92. this.butAlter = new System.Windows.Forms.Button();
  93. this.SuspendLayout();
  94. // 
  95. // label1
  96. // 
  97. this.label1.BackColor = System.Drawing.Color.Transparent;
  98. this.label1.Location = new System.Drawing.Point(72, 48);
  99. this.label1.Name = "label1";
  100. this.label1.Size = new System.Drawing.Size(112, 24);
  101. this.label1.TabIndex = 0;
  102. this.label1.Text = "出版社名称";
  103. // 
  104. // label2
  105. // 
  106. this.label2.BackColor = System.Drawing.Color.Transparent;
  107. this.label2.Location = new System.Drawing.Point(72, 96);
  108. this.label2.Name = "label2";
  109. this.label2.Size = new System.Drawing.Size(112, 24);
  110. this.label2.TabIndex = 1;
  111. this.label2.Text = "联系人姓名";
  112. // 
  113. // label3
  114. // 
  115. this.label3.BackColor = System.Drawing.Color.Transparent;
  116. this.label3.Location = new System.Drawing.Point(72, 144);
  117. this.label3.Name = "label3";
  118. this.label3.Size = new System.Drawing.Size(112, 24);
  119. this.label3.TabIndex = 2;
  120. this.label3.Text = "出版社地址";
  121. // 
  122. // label4
  123. // 
  124. this.label4.BackColor = System.Drawing.Color.Transparent;
  125. this.label4.Location = new System.Drawing.Point(72, 192);
  126. this.label4.Name = "label4";
  127. this.label4.Size = new System.Drawing.Size(112, 24);
  128. this.label4.TabIndex = 3;
  129. this.label4.Text = "联系电话";
  130. // 
  131. // pressname
  132. // 
  133. this.pressname.Location = new System.Drawing.Point(200, 48);
  134. this.pressname.Name = "pressname";
  135. this.pressname.ReadOnly = true;
  136. this.pressname.Size = new System.Drawing.Size(200, 21);
  137. this.pressname.TabIndex = 4;
  138. this.pressname.Text = "pressname";
  139. // 
  140. // presslinkman
  141. // 
  142. this.presslinkman.Location = new System.Drawing.Point(200, 96);
  143. this.presslinkman.Name = "presslinkman";
  144. this.presslinkman.ReadOnly = true;
  145. this.presslinkman.Size = new System.Drawing.Size(200, 21);
  146. this.presslinkman.TabIndex = 5;
  147. this.presslinkman.Text = "presslinkman";
  148. // 
  149. // pressaddress
  150. // 
  151. this.pressaddress.Location = new System.Drawing.Point(200, 136);
  152. this.pressaddress.Name = "pressaddress";
  153. this.pressaddress.ReadOnly = true;
  154. this.pressaddress.Size = new System.Drawing.Size(200, 21);
  155. this.pressaddress.TabIndex = 6;
  156. this.pressaddress.Text = "pressaddress";
  157. // 
  158. // presstelephone
  159. // 
  160. this.presstelephone.Location = new System.Drawing.Point(200, 192);
  161. this.presstelephone.Name = "presstelephone";
  162. this.presstelephone.ReadOnly = true;
  163. this.presstelephone.Size = new System.Drawing.Size(200, 21);
  164. this.presstelephone.TabIndex = 7;
  165. this.presstelephone.Text = "presstelephone";
  166. // 
  167. // butBookManagement
  168. // 
  169. this.butBookManagement.BackColor = System.Drawing.Color.Transparent;
  170. this.butBookManagement.Location = new System.Drawing.Point(312, 256);
  171. this.butBookManagement.Name = "butBookManagement";
  172. this.butBookManagement.Size = new System.Drawing.Size(104, 24);
  173. this.butBookManagement.TabIndex = 8;
  174. this.butBookManagement.Text = "书目信息管理";
  175. this.butBookManagement.Click += new System.EventHandler(this.butBookManagement_Click);
  176. // 
  177. // butPrev
  178. // 
  179. this.butPrev.BackColor = System.Drawing.Color.Transparent;
  180. this.butPrev.Location = new System.Drawing.Point(180, 344);
  181. this.butPrev.Name = "butPrev";
  182. this.butPrev.Size = new System.Drawing.Size(56, 24);
  183. this.butPrev.TabIndex = 9;
  184. this.butPrev.Text = "<";
  185. this.butPrev.Click += new System.EventHandler(this.butPrev_Click);
  186. // 
  187. // butNext
  188. // 
  189. this.butNext.BackColor = System.Drawing.Color.Transparent;
  190. this.butNext.Location = new System.Drawing.Point(236, 344);
  191. this.butNext.Name = "butNext";
  192. this.butNext.Size = new System.Drawing.Size(56, 24);
  193. this.butNext.TabIndex = 10;
  194. this.butNext.Text = ">";
  195. this.butNext.Click += new System.EventHandler(this.butNext_Click);
  196. // 
  197. // butLast
  198. // 
  199. this.butLast.BackColor = System.Drawing.Color.Transparent;
  200. this.butLast.Location = new System.Drawing.Point(292, 344);
  201. this.butLast.Name = "butLast";
  202. this.butLast.Size = new System.Drawing.Size(56, 24);
  203. this.butLast.TabIndex = 12;
  204. this.butLast.Text = ">|";
  205. this.butLast.Click += new System.EventHandler(this.butLast_Click);
  206. // 
  207. // butFirst
  208. // 
  209. this.butFirst.BackColor = System.Drawing.Color.Transparent;
  210. this.butFirst.Location = new System.Drawing.Point(124, 344);
  211. this.butFirst.Name = "butFirst";
  212. this.butFirst.Size = new System.Drawing.Size(56, 24);
  213. this.butFirst.TabIndex = 11;
  214. this.butFirst.Text = "|<";
  215. this.butFirst.Click += new System.EventHandler(this.butFirst_Click);
  216. // 
  217. // butShowAll
  218. // 
  219. this.butShowAll.BackColor = System.Drawing.Color.Transparent;
  220. this.butShowAll.Location = new System.Drawing.Point(224, 256);
  221. this.butShowAll.Name = "butShowAll";
  222. this.butShowAll.Size = new System.Drawing.Size(88, 24);
  223. this.butShowAll.TabIndex = 13;
  224. this.butShowAll.Text = "查看全部";
  225. this.butShowAll.Click += new System.EventHandler(this.butShowAll_Click);
  226. // 
  227. // label5
  228. // 
  229. this.label5.BackColor = System.Drawing.Color.Transparent;
  230. this.label5.Location = new System.Drawing.Point(36, 304);
  231. this.label5.Name = "label5";
  232. this.label5.Size = new System.Drawing.Size(56, 16);
  233. this.label5.TabIndex = 14;
  234. this.label5.Text = "查找方式";
  235. // 
  236. // comboBox1
  237. // 
  238. this.comboBox1.Items.AddRange(new object[] {
  239.    "出版社名称",
  240.    "联系电话"});
  241. this.comboBox1.Location = new System.Drawing.Point(108, 304);
  242. this.comboBox1.MaxDropDownItems = 2;
  243. this.comboBox1.Name = "comboBox1";
  244. this.comboBox1.Size = new System.Drawing.Size(88, 20);
  245. this.comboBox1.TabIndex = 15;
  246. this.comboBox1.Text = "出版社名称";
  247. // 
  248. // butSearch
  249. // 
  250. this.butSearch.BackColor = System.Drawing.Color.Transparent;
  251. this.butSearch.Location = new System.Drawing.Point(372, 304);
  252. this.butSearch.Name = "butSearch";
  253. this.butSearch.Size = new System.Drawing.Size(64, 24);
  254. this.butSearch.TabIndex = 16;
  255. this.butSearch.Text = "查找";
  256. this.butSearch.Click += new System.EventHandler(this.butSearch_Click);
  257. // 
  258. // textForSearch
  259. // 
  260. this.textForSearch.Location = new System.Drawing.Point(268, 304);
  261. this.textForSearch.Name = "textForSearch";
  262. this.textForSearch.Size = new System.Drawing.Size(96, 21);
  263. this.textForSearch.TabIndex = 17;
  264. this.textForSearch.Text = "";
  265. // 
  266. // comboBox2
  267. // 
  268. this.comboBox2.Items.AddRange(new object[] {
  269.    "模糊",
  270.    "精确"});
  271. this.comboBox2.Location = new System.Drawing.Point(212, 304);
  272. this.comboBox2.MaxDropDownItems = 2;
  273. this.comboBox2.Name = "comboBox2";
  274. this.comboBox2.Size = new System.Drawing.Size(48, 20);
  275. this.comboBox2.TabIndex = 18;
  276. this.comboBox2.Text = "模糊";
  277. // 
  278. // butDelete
  279. // 
  280. this.butDelete.BackColor = System.Drawing.Color.Transparent;
  281. this.butDelete.Location = new System.Drawing.Point(168, 256);
  282. this.butDelete.Name = "butDelete";
  283. this.butDelete.Size = new System.Drawing.Size(56, 24);
  284. this.butDelete.TabIndex = 48;
  285. this.butDelete.Text = "删除";
  286. this.butDelete.Click += new System.EventHandler(this.butDelete_Click);
  287. // 
  288. // butAdd
  289. // 
  290. this.butAdd.BackColor = System.Drawing.Color.Transparent;
  291. this.butAdd.Location = new System.Drawing.Point(112, 256);
  292. this.butAdd.Name = "butAdd";
  293. this.butAdd.Size = new System.Drawing.Size(56, 24);
  294. this.butAdd.TabIndex = 47;
  295. this.butAdd.Text = "添加";
  296. this.butAdd.Click += new System.EventHandler(this.butAdd_Click);
  297. // 
  298. // butAlter
  299. // 
  300. this.butAlter.BackColor = System.Drawing.Color.Transparent;
  301. this.butAlter.Location = new System.Drawing.Point(56, 256);
  302. this.butAlter.Name = "butAlter";
  303. this.butAlter.Size = new System.Drawing.Size(56, 24);
  304. this.butAlter.TabIndex = 46;
  305. this.butAlter.Text = "修改";
  306. this.butAlter.Click += new System.EventHandler(this.butAlter_Click);
  307. // 
  308. // Form_Publisher
  309. // 
  310. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  311. this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
  312. this.ClientSize = new System.Drawing.Size(472, 382);
  313. this.ControlBox = false;
  314. this.Controls.Add(this.butDelete);
  315. this.Controls.Add(this.butAdd);
  316. this.Controls.Add(this.butAlter);
  317. this.Controls.Add(this.comboBox2);
  318. this.Controls.Add(this.textForSearch);
  319. this.Controls.Add(this.presstelephone);
  320. this.Controls.Add(this.pressaddress);
  321. this.Controls.Add(this.presslinkman);
  322. this.Controls.Add(this.pressname);
  323. this.Controls.Add(this.butSearch);
  324. this.Controls.Add(this.comboBox1);
  325. this.Controls.Add(this.label5);
  326. this.Controls.Add(this.butShowAll);
  327. this.Controls.Add(this.butLast);
  328. this.Controls.Add(this.butFirst);
  329. this.Controls.Add(this.butNext);
  330. this.Controls.Add(this.butPrev);
  331. this.Controls.Add(this.butBookManagement);
  332. this.Controls.Add(this.label4);
  333. this.Controls.Add(this.label3);
  334. this.Controls.Add(this.label2);
  335. this.Controls.Add(this.label1);
  336. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
  337. this.Name = "Form_Publisher";
  338. this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
  339. this.Text = "Form_Publisher";
  340. this.Load += new System.EventHandler(this.Form_Publisher_Load);
  341. this.ResumeLayout(false);
  342. }
  343. #endregion
  344. private void butBookManagement_Click(object sender, System.EventArgs e)
  345. {
  346. if(Pressname!="")
  347. {
  348. Form_Publisher_BookManagement child=new Form_Publisher_BookManagement();
  349. child.ShowDialog();
  350. }
  351. else
  352. {
  353. MessageBox.Show("还没有选择出版社!","提示");
  354. }
  355. }
  356. SQL sql;
  357. public static string Pressname;
  358. private void Form_Publisher_Load(object sender, System.EventArgs e)
  359. {
  360. sql=new SQL("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=图书管理系统数据库.mdb");
  361. sql.ExecuteSQL("select * from 出版社信息表 order by pressname");
  362. show();
  363. }
  364. public void show()
  365. {
  366. if(sql.rows.GetLength(0)!=0)
  367. {
  368. pressname.Text=sql.rows[sql.getPos(),0].ToString();
  369. presslinkman.Text=sql.rows[sql.getPos(),1].ToString();
  370. pressaddress.Text=sql.rows[sql.getPos(),2].ToString();
  371. presstelephone.Text=sql.rows[sql.getPos(),3].ToString();
  372. }
  373. else
  374. {
  375. pressname.Text="";
  376. presslinkman.Text="";
  377. pressaddress.Text="";
  378. presstelephone.Text="";
  379. MessageBox.Show("无符合查询条件的结果!","提示");
  380. }
  381. Pressname=pressname.Text;
  382. }
  383. private void butPrev_Click(object sender, System.EventArgs e)
  384. {
  385. sql.pointToPrev();
  386. show();
  387. }
  388. private void butNext_Click(object sender, System.EventArgs e)
  389. {
  390. sql.pointToNext();
  391. show();
  392. }
  393. private void butFirst_Click(object sender, System.EventArgs e)
  394. {
  395. sql.pointToFirst();
  396. show();
  397. }
  398. private void butLast_Click(object sender, System.EventArgs e)
  399. {
  400. sql.pointToLast();
  401. show();
  402. }
  403. string oldpressname;
  404. private void butAlter_Click(object sender, System.EventArgs e)
  405. {
  406. if(butAlter.Text=="修改")
  407. {
  408. butAlter.Text="更新";
  409. oldpressname=pressname.Text;
  410. pressname.ReadOnly =false;
  411. presslinkman.ReadOnly  =false;
  412. pressaddress.ReadOnly  =false;
  413. presstelephone.ReadOnly  =false;
  414. butAdd.Enabled=false;
  415. butDelete.Enabled=false;
  416. butFirst.Enabled=false;
  417. butPrev.Enabled=false;
  418. butNext.Enabled=false;
  419. butLast.Enabled=false;
  420. butShowAll.Enabled=false;
  421. butSearch.Enabled=false;
  422. butBookManagement.Enabled=false;
  423. }
  424. else
  425. {
  426. if(sql.ExecuteSQL("update 出版社信息表 set pressname='"+pressname.Text+"',presslinkman='"+presslinkman.Text+"',pressaddress='"+pressaddress.Text+"',presstelephone='"+presstelephone.Text+"' where pressname='"+oldpressname+"'")
  427. ==false)
  428. {
  429. show();
  430. }
  431. else
  432. {
  433. Pressname=pressname.Text;
  434. sql.ExecuteSQL("update 出版社图书信息表 set pressname='"+pressname.Text+"' where pressname='"+oldpressname+"'");
  435. }
  436. pressname.ReadOnly  =true;
  437. presslinkman.ReadOnly  =true;
  438. pressaddress.ReadOnly  =true;
  439. presstelephone.ReadOnly =true;
  440. butAlter.Text="修改";
  441. butAdd.Enabled=true;
  442. butDelete.Enabled=true;
  443. butFirst.Enabled=true;
  444. butPrev.Enabled=true;
  445. butNext.Enabled=true;
  446. butLast.Enabled=true;
  447. butShowAll.Enabled=true;
  448. butSearch.Enabled=true;
  449. butBookManagement.Enabled=true;
  450. }
  451. }
  452. private void butAdd_Click(object sender, System.EventArgs e)
  453. {
  454. if(butAdd.Text=="添加")
  455. {
  456. butAdd.Text="提交";
  457. pressname.Text="";
  458. presslinkman.Text="";
  459. pressaddress.Text="";
  460. presstelephone.Text="";
  461. pressname.ReadOnly =false;
  462. presslinkman.ReadOnly  =false;
  463. pressaddress.ReadOnly  =false;
  464. presstelephone.ReadOnly  =false;
  465. butAlter.Enabled=false;
  466. butDelete.Enabled=false;
  467. butFirst.Enabled=false;
  468. butPrev.Enabled=false;
  469. butNext.Enabled=false;
  470. butLast.Enabled=false;
  471. butShowAll.Enabled=false;
  472. butSearch.Enabled=false;
  473. butBookManagement.Enabled=false;
  474. }
  475. else
  476. {
  477. if(sql.ExecuteSQL("insert into 出版社信息表 values('"+pressname.Text+"','"+presslinkman.Text+"','"+pressaddress.Text+"','"+presstelephone.Text+"')")
  478. ==false)
  479. {
  480. show();
  481. }
  482. else
  483. {
  484. Pressname=pressname.Text;
  485. }
  486. pressname.ReadOnly  =true;
  487. presslinkman.ReadOnly  =true;
  488. pressaddress.ReadOnly  =true;
  489. presstelephone.ReadOnly =true;
  490. butAdd.Text="添加";
  491. butAlter.Enabled=true;
  492. butDelete.Enabled=true;
  493. butFirst.Enabled=true;
  494. butPrev.Enabled=true;
  495. butNext.Enabled=true;
  496. butLast.Enabled=true;
  497. butShowAll.Enabled=true;
  498. butSearch.Enabled=true;
  499. butBookManagement.Enabled=true;
  500. }
  501. }
  502. private void butDelete_Click(object sender, System.EventArgs e)
  503. {
  504. sql.ExecuteSQL("delete from 出版社信息表 where pressname='"+pressname.Text+"'");
  505. sql.ExecuteSQL("delete from 出版社图书信息表 where pressname='"+pressname.Text+"'");
  506. sql.pointToFirst();
  507. show();
  508. }
  509. private void butSearch_Click(object sender, System.EventArgs e)
  510. {
  511. if(comboBox1.Text=="出版社名称")
  512. {
  513. if(comboBox2.Text=="精确")
  514. {
  515. sql.ExecuteSQL("select * from 出版社信息表 where pressname='"+textForSearch.Text+"'");
  516. show();
  517. }
  518. else
  519. {
  520. sql.ExecuteSQL("select * from 出版社信息表 where pressname like '%"+textForSearch.Text+"%'");
  521. show();
  522. }
  523. }
  524. else
  525. {
  526. if(comboBox2.Text=="精确")
  527. {
  528. sql.ExecuteSQL("select * from 出版社信息表 where presstelephone='"+textForSearch.Text+"'");
  529. show();
  530. }
  531. else
  532. {
  533. sql.ExecuteSQL("select * from 出版社信息表 where presstelephone like '%"+textForSearch.Text+"%'");
  534. show();
  535. }
  536. }
  537. }
  538. private void butShowAll_Click(object sender, System.EventArgs e)
  539. {
  540. sql.ExecuteSQL("select * from 出版社信息表 order by pressname");
  541. show();
  542. }
  543. }
  544. }