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

教育系统应用

开发平台:

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_Customer 的摘要说明。
  10. /// </summary>
  11. public class Form_Customer : System.Windows.Forms.Form
  12. {
  13. private System.Windows.Forms.TextBox customeremail;
  14. private System.Windows.Forms.TextBox customersex;
  15. private System.Windows.Forms.TextBox customertelephone;
  16. private System.Windows.Forms.TextBox customeraddress;
  17. private System.Windows.Forms.TextBox customerinfo;
  18. private System.Windows.Forms.Label label5;
  19. private System.Windows.Forms.Label label4;
  20. private System.Windows.Forms.Label label3;
  21. private System.Windows.Forms.Label label2;
  22. private System.Windows.Forms.Label label1;
  23. private System.Windows.Forms.TextBox customername;
  24. private System.Windows.Forms.TextBox customerID;
  25. private System.Windows.Forms.Label label7;
  26. private System.Windows.Forms.Label label8;
  27. private System.Windows.Forms.ComboBox comboBox2;
  28. private System.Windows.Forms.Button butSearch;
  29. private System.Windows.Forms.ComboBox comboBox1;
  30. private System.Windows.Forms.Label label6;
  31. private System.Windows.Forms.Button butLast;
  32. private System.Windows.Forms.Button butFirst;
  33. private System.Windows.Forms.Button butNext;
  34. private System.Windows.Forms.Button butPrev;
  35. private System.Windows.Forms.Button butDelete;
  36. private System.Windows.Forms.Button butAdd;
  37. private System.Windows.Forms.Button butAlter;
  38. private System.Windows.Forms.Button AddOrder;
  39. private System.Windows.Forms.Button butLookOverOrders;
  40. private System.Windows.Forms.TextBox textForSearch;
  41. private System.Windows.Forms.Button butShowAll;
  42. /// <summary>
  43. /// 必需的设计器变量。
  44. /// </summary>
  45. private System.ComponentModel.Container components = null;
  46. public Form_Customer()
  47. {
  48. //
  49. // Windows 窗体设计器支持所必需的
  50. //
  51. InitializeComponent();
  52. //
  53. // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
  54. //
  55. }
  56. /// <summary>
  57. /// 清理所有正在使用的资源。
  58. /// </summary>
  59. protected override void Dispose( bool disposing )
  60. {
  61. if( disposing )
  62. {
  63. if(components != null)
  64. {
  65. components.Dispose();
  66. }
  67. }
  68. base.Dispose( disposing );
  69. }
  70. #region Windows 窗体设计器生成的代码
  71. /// <summary>
  72. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  73. /// 此方法的内容。
  74. /// </summary>
  75. private void InitializeComponent()
  76. {
  77. System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form_Customer));
  78. this.customeremail = new System.Windows.Forms.TextBox();
  79. this.customersex = new System.Windows.Forms.TextBox();
  80. this.customertelephone = new System.Windows.Forms.TextBox();
  81. this.customeraddress = new System.Windows.Forms.TextBox();
  82. this.customerinfo = new System.Windows.Forms.TextBox();
  83. this.label5 = new System.Windows.Forms.Label();
  84. this.label4 = new System.Windows.Forms.Label();
  85. this.label3 = new System.Windows.Forms.Label();
  86. this.label2 = new System.Windows.Forms.Label();
  87. this.label1 = new System.Windows.Forms.Label();
  88. this.AddOrder = new System.Windows.Forms.Button();
  89. this.butLookOverOrders = new System.Windows.Forms.Button();
  90. this.customername = new System.Windows.Forms.TextBox();
  91. this.customerID = new System.Windows.Forms.TextBox();
  92. this.label7 = new System.Windows.Forms.Label();
  93. this.label8 = new System.Windows.Forms.Label();
  94. this.comboBox2 = new System.Windows.Forms.ComboBox();
  95. this.textForSearch = new System.Windows.Forms.TextBox();
  96. this.butSearch = new System.Windows.Forms.Button();
  97. this.comboBox1 = new System.Windows.Forms.ComboBox();
  98. this.label6 = new System.Windows.Forms.Label();
  99. this.butLast = new System.Windows.Forms.Button();
  100. this.butFirst = new System.Windows.Forms.Button();
  101. this.butNext = new System.Windows.Forms.Button();
  102. this.butPrev = new System.Windows.Forms.Button();
  103. this.butDelete = new System.Windows.Forms.Button();
  104. this.butAdd = new System.Windows.Forms.Button();
  105. this.butAlter = new System.Windows.Forms.Button();
  106. this.butShowAll = new System.Windows.Forms.Button();
  107. this.SuspendLayout();
  108. // 
  109. // customeremail
  110. // 
  111. this.customeremail.Location = new System.Drawing.Point(177, 216);
  112. this.customeremail.Name = "customeremail";
  113. this.customeremail.ReadOnly = true;
  114. this.customeremail.Size = new System.Drawing.Size(216, 21);
  115. this.customeremail.TabIndex = 23;
  116. this.customeremail.Text = "customere-mail";
  117. // 
  118. // customersex
  119. // 
  120. this.customersex.Location = new System.Drawing.Point(177, 184);
  121. this.customersex.Name = "customersex";
  122. this.customersex.ReadOnly = true;
  123. this.customersex.Size = new System.Drawing.Size(216, 21);
  124. this.customersex.TabIndex = 22;
  125. this.customersex.Text = "customersex";
  126. // 
  127. // customertelephone
  128. // 
  129. this.customertelephone.Location = new System.Drawing.Point(177, 152);
  130. this.customertelephone.Name = "customertelephone";
  131. this.customertelephone.ReadOnly = true;
  132. this.customertelephone.Size = new System.Drawing.Size(216, 21);
  133. this.customertelephone.TabIndex = 21;
  134. this.customertelephone.Text = "customertelephone";
  135. // 
  136. // customeraddress
  137. // 
  138. this.customeraddress.Location = new System.Drawing.Point(177, 120);
  139. this.customeraddress.Name = "customeraddress";
  140. this.customeraddress.ReadOnly = true;
  141. this.customeraddress.Size = new System.Drawing.Size(216, 21);
  142. this.customeraddress.TabIndex = 20;
  143. this.customeraddress.Text = "customeraddress";
  144. // 
  145. // customerinfo
  146. // 
  147. this.customerinfo.Location = new System.Drawing.Point(177, 88);
  148. this.customerinfo.Name = "customerinfo";
  149. this.customerinfo.ReadOnly = true;
  150. this.customerinfo.Size = new System.Drawing.Size(216, 21);
  151. this.customerinfo.TabIndex = 19;
  152. this.customerinfo.Text = "customerinfo";
  153. // 
  154. // label5
  155. // 
  156. this.label5.BackColor = System.Drawing.Color.Transparent;
  157. this.label5.Location = new System.Drawing.Point(80, 216);
  158. this.label5.Name = "label5";
  159. this.label5.Size = new System.Drawing.Size(65, 16);
  160. this.label5.TabIndex = 17;
  161. this.label5.Text = "E-mail";
  162. // 
  163. // label4
  164. // 
  165. this.label4.BackColor = System.Drawing.Color.Transparent;
  166. this.label4.Location = new System.Drawing.Point(80, 184);
  167. this.label4.Name = "label4";
  168. this.label4.Size = new System.Drawing.Size(65, 16);
  169. this.label4.TabIndex = 16;
  170. this.label4.Text = "客户性别";
  171. // 
  172. // label3
  173. // 
  174. this.label3.BackColor = System.Drawing.Color.Transparent;
  175. this.label3.Location = new System.Drawing.Point(80, 152);
  176. this.label3.Name = "label3";
  177. this.label3.Size = new System.Drawing.Size(65, 16);
  178. this.label3.TabIndex = 15;
  179. this.label3.Text = "联系电话";
  180. // 
  181. // label2
  182. // 
  183. this.label2.BackColor = System.Drawing.Color.Transparent;
  184. this.label2.Location = new System.Drawing.Point(80, 120);
  185. this.label2.Name = "label2";
  186. this.label2.Size = new System.Drawing.Size(65, 16);
  187. this.label2.TabIndex = 14;
  188. this.label2.Text = "客户地址";
  189. // 
  190. // label1
  191. // 
  192. this.label1.BackColor = System.Drawing.Color.Transparent;
  193. this.label1.Location = new System.Drawing.Point(80, 88);
  194. this.label1.Name = "label1";
  195. this.label1.Size = new System.Drawing.Size(65, 16);
  196. this.label1.TabIndex = 13;
  197. this.label1.Text = "客户信息";
  198. // 
  199. // AddOrder
  200. // 
  201. this.AddOrder.BackColor = System.Drawing.Color.Transparent;
  202. this.AddOrder.Location = new System.Drawing.Point(108, 272);
  203. this.AddOrder.Name = "AddOrder";
  204. this.AddOrder.Size = new System.Drawing.Size(64, 24);
  205. this.AddOrder.TabIndex = 26;
  206. this.AddOrder.Text = "添加订单";
  207. this.AddOrder.Click += new System.EventHandler(this.AddOrder_Click);
  208. // 
  209. // butLookOverOrders
  210. // 
  211. this.butLookOverOrders.BackColor = System.Drawing.Color.Transparent;
  212. this.butLookOverOrders.Location = new System.Drawing.Point(44, 272);
  213. this.butLookOverOrders.Name = "butLookOverOrders";
  214. this.butLookOverOrders.Size = new System.Drawing.Size(64, 24);
  215. this.butLookOverOrders.TabIndex = 25;
  216. this.butLookOverOrders.Text = "查看定单";
  217. this.butLookOverOrders.Click += new System.EventHandler(this.butLookOverOrders_Click);
  218. // 
  219. // customername
  220. // 
  221. this.customername.Location = new System.Drawing.Point(177, 56);
  222. this.customername.Name = "customername";
  223. this.customername.ReadOnly = true;
  224. this.customername.Size = new System.Drawing.Size(216, 21);
  225. this.customername.TabIndex = 33;
  226. this.customername.Text = "customername";
  227. // 
  228. // customerID
  229. // 
  230. this.customerID.Location = new System.Drawing.Point(177, 24);
  231. this.customerID.Name = "customerID";
  232. this.customerID.ReadOnly = true;
  233. this.customerID.Size = new System.Drawing.Size(216, 21);
  234. this.customerID.TabIndex = 32;
  235. this.customerID.Text = "customerID";
  236. // 
  237. // label7
  238. // 
  239. this.label7.BackColor = System.Drawing.Color.Transparent;
  240. this.label7.Location = new System.Drawing.Point(80, 56);
  241. this.label7.Name = "label7";
  242. this.label7.Size = new System.Drawing.Size(65, 16);
  243. this.label7.TabIndex = 31;
  244. this.label7.Text = "客户名称";
  245. // 
  246. // label8
  247. // 
  248. this.label8.BackColor = System.Drawing.Color.Transparent;
  249. this.label8.Location = new System.Drawing.Point(80, 24);
  250. this.label8.Name = "label8";
  251. this.label8.Size = new System.Drawing.Size(65, 16);
  252. this.label8.TabIndex = 30;
  253. this.label8.Text = "客户ID";
  254. // 
  255. // comboBox2
  256. // 
  257. this.comboBox2.Items.AddRange(new object[] {
  258.    "模糊",
  259.    "精确"});
  260. this.comboBox2.Location = new System.Drawing.Point(188, 312);
  261. this.comboBox2.MaxDropDownItems = 2;
  262. this.comboBox2.Name = "comboBox2";
  263. this.comboBox2.Size = new System.Drawing.Size(48, 20);
  264. this.comboBox2.TabIndex = 38;
  265. this.comboBox2.Text = "模糊";
  266. // 
  267. // textForSearch
  268. // 
  269. this.textForSearch.Location = new System.Drawing.Point(252, 312);
  270. this.textForSearch.Name = "textForSearch";
  271. this.textForSearch.Size = new System.Drawing.Size(96, 21);
  272. this.textForSearch.TabIndex = 37;
  273. this.textForSearch.Text = "";
  274. // 
  275. // butSearch
  276. // 
  277. this.butSearch.BackColor = System.Drawing.Color.Transparent;
  278. this.butSearch.Location = new System.Drawing.Point(364, 312);
  279. this.butSearch.Name = "butSearch";
  280. this.butSearch.Size = new System.Drawing.Size(64, 24);
  281. this.butSearch.TabIndex = 36;
  282. this.butSearch.Text = "查找客户";
  283. this.butSearch.Click += new System.EventHandler(this.butSearch_Click);
  284. // 
  285. // comboBox1
  286. // 
  287. this.comboBox1.Items.AddRange(new object[] {
  288.    "客户名称",
  289.    "E-mail"});
  290. this.comboBox1.Location = new System.Drawing.Point(100, 312);
  291. this.comboBox1.MaxDropDownItems = 2;
  292. this.comboBox1.Name = "comboBox1";
  293. this.comboBox1.Size = new System.Drawing.Size(80, 20);
  294. this.comboBox1.TabIndex = 35;
  295. this.comboBox1.Text = "客户名称";
  296. // 
  297. // label6
  298. // 
  299. this.label6.BackColor = System.Drawing.Color.Transparent;
  300. this.label6.Location = new System.Drawing.Point(44, 312);
  301. this.label6.Name = "label6";
  302. this.label6.Size = new System.Drawing.Size(56, 16);
  303. this.label6.TabIndex = 34;
  304. this.label6.Text = "查找方式";
  305. // 
  306. // butLast
  307. // 
  308. this.butLast.BackColor = System.Drawing.Color.Transparent;
  309. this.butLast.Location = new System.Drawing.Point(292, 344);
  310. this.butLast.Name = "butLast";
  311. this.butLast.Size = new System.Drawing.Size(56, 24);
  312. this.butLast.TabIndex = 42;
  313. this.butLast.Text = ">|";
  314. this.butLast.Click += new System.EventHandler(this.butLast_Click);
  315. // 
  316. // butFirst
  317. // 
  318. this.butFirst.BackColor = System.Drawing.Color.Transparent;
  319. this.butFirst.Location = new System.Drawing.Point(124, 344);
  320. this.butFirst.Name = "butFirst";
  321. this.butFirst.Size = new System.Drawing.Size(56, 24);
  322. this.butFirst.TabIndex = 41;
  323. this.butFirst.Text = "|<";
  324. this.butFirst.Click += new System.EventHandler(this.butFirst_Click);
  325. // 
  326. // butNext
  327. // 
  328. this.butNext.BackColor = System.Drawing.Color.Transparent;
  329. this.butNext.Location = new System.Drawing.Point(236, 344);
  330. this.butNext.Name = "butNext";
  331. this.butNext.Size = new System.Drawing.Size(56, 24);
  332. this.butNext.TabIndex = 40;
  333. this.butNext.Text = ">";
  334. this.butNext.Click += new System.EventHandler(this.butNext_Click);
  335. // 
  336. // butPrev
  337. // 
  338. this.butPrev.BackColor = System.Drawing.Color.Transparent;
  339. this.butPrev.Location = new System.Drawing.Point(180, 344);
  340. this.butPrev.Name = "butPrev";
  341. this.butPrev.Size = new System.Drawing.Size(56, 24);
  342. this.butPrev.TabIndex = 39;
  343. this.butPrev.Text = "<";
  344. this.butPrev.Click += new System.EventHandler(this.butPrev_Click);
  345. // 
  346. // butDelete
  347. // 
  348. this.butDelete.BackColor = System.Drawing.Color.Transparent;
  349. this.butDelete.Location = new System.Drawing.Point(300, 272);
  350. this.butDelete.Name = "butDelete";
  351. this.butDelete.Size = new System.Drawing.Size(64, 24);
  352. this.butDelete.TabIndex = 48;
  353. this.butDelete.Text = "删除";
  354. this.butDelete.Click += new System.EventHandler(this.butDelete_Click);
  355. // 
  356. // butAdd
  357. // 
  358. this.butAdd.BackColor = System.Drawing.Color.Transparent;
  359. this.butAdd.Location = new System.Drawing.Point(236, 272);
  360. this.butAdd.Name = "butAdd";
  361. this.butAdd.Size = new System.Drawing.Size(64, 24);
  362. this.butAdd.TabIndex = 47;
  363. this.butAdd.Text = "添加";
  364. this.butAdd.Click += new System.EventHandler(this.butAdd_Click);
  365. // 
  366. // butAlter
  367. // 
  368. this.butAlter.BackColor = System.Drawing.Color.Transparent;
  369. this.butAlter.Location = new System.Drawing.Point(172, 272);
  370. this.butAlter.Name = "butAlter";
  371. this.butAlter.Size = new System.Drawing.Size(64, 24);
  372. this.butAlter.TabIndex = 46;
  373. this.butAlter.Text = "修改";
  374. this.butAlter.Click += new System.EventHandler(this.butAlter_Click);
  375. // 
  376. // butShowAll
  377. // 
  378. this.butShowAll.BackColor = System.Drawing.Color.Transparent;
  379. this.butShowAll.Location = new System.Drawing.Point(364, 272);
  380. this.butShowAll.Name = "butShowAll";
  381. this.butShowAll.Size = new System.Drawing.Size(64, 24);
  382. this.butShowAll.TabIndex = 49;
  383. this.butShowAll.Text = "全部显示";
  384. this.butShowAll.Click += new System.EventHandler(this.butShowAll_Click);
  385. // 
  386. // Form_Customer
  387. // 
  388. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  389. this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
  390. this.ClientSize = new System.Drawing.Size(472, 382);
  391. this.ControlBox = false;
  392. this.Controls.Add(this.butShowAll);
  393. this.Controls.Add(this.butDelete);
  394. this.Controls.Add(this.butAdd);
  395. this.Controls.Add(this.butAlter);
  396. this.Controls.Add(this.butLast);
  397. this.Controls.Add(this.butFirst);
  398. this.Controls.Add(this.butNext);
  399. this.Controls.Add(this.butPrev);
  400. this.Controls.Add(this.comboBox2);
  401. this.Controls.Add(this.textForSearch);
  402. this.Controls.Add(this.customername);
  403. this.Controls.Add(this.customerID);
  404. this.Controls.Add(this.customeremail);
  405. this.Controls.Add(this.customersex);
  406. this.Controls.Add(this.customertelephone);
  407. this.Controls.Add(this.customeraddress);
  408. this.Controls.Add(this.customerinfo);
  409. this.Controls.Add(this.butSearch);
  410. this.Controls.Add(this.comboBox1);
  411. this.Controls.Add(this.label6);
  412. this.Controls.Add(this.label7);
  413. this.Controls.Add(this.label8);
  414. this.Controls.Add(this.AddOrder);
  415. this.Controls.Add(this.butLookOverOrders);
  416. this.Controls.Add(this.label5);
  417. this.Controls.Add(this.label4);
  418. this.Controls.Add(this.label3);
  419. this.Controls.Add(this.label2);
  420. this.Controls.Add(this.label1);
  421. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
  422. this.Name = "Form_Customer";
  423. this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
  424. this.Text = "Form_Customer";
  425. this.Load += new System.EventHandler(this.Form_Customer_Load);
  426. this.ResumeLayout(false);
  427. }
  428. #endregion
  429. SQL sql;
  430. string oldcustomerID="";
  431. public static string CUSTOMERID="";
  432. public static string CUSTOMERNAME="";
  433. private void butLookOverOrders_Click(object sender, System.EventArgs e)
  434. {
  435. Form_Customer_LookOverOrders child=new Form_Customer_LookOverOrders();
  436. child.ShowDialog();
  437. }
  438. private void AddOrder_Click(object sender, System.EventArgs e)
  439. {
  440. if(customerID.Text!="")
  441. {
  442. Form_Customer_AddOrder child=new Form_Customer_AddOrder();
  443. child.ShowDialog();
  444. }
  445. else
  446. {
  447. MessageBox.Show("请先选择一个客户!","提示");
  448. }
  449. }
  450. public void show()
  451. {
  452. if(sql.rows.GetLength(0)!=0)
  453. {
  454. customerID.Text=sql.rows[sql.getPos(),0].ToString();
  455. customername.Text=sql.rows[sql.getPos(),1].ToString();
  456. customerinfo.Text=sql.rows[sql.getPos(),2].ToString();
  457. customeraddress.Text=sql.rows[sql.getPos(),3].ToString();
  458. customertelephone.Text=sql.rows[sql.getPos(),4].ToString();
  459. customersex.Text=sql.rows[sql.getPos(),5].ToString();
  460. customeremail.Text=sql.rows[sql.getPos(),6].ToString();
  461. }
  462. else
  463. {
  464. customerID.Text="";
  465. customername.Text="";
  466. customerinfo.Text="";
  467. customeraddress.Text="";
  468. customertelephone.Text="";
  469. customersex.Text="";
  470. customeremail.Text="";
  471. MessageBox.Show("无符合查询条件的结果!","提示");
  472. }
  473. CUSTOMERID=customerID.Text;
  474. CUSTOMERNAME=customername.Text;
  475. }
  476. private void Form_Customer_Load(object sender, System.EventArgs e)
  477. {
  478. sql=new SQL("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=图书管理系统数据库.mdb");
  479. sql.ExecuteSQL("select * from 客户信息表 order by customerID");
  480. show();
  481. }
  482. private void butFirst_Click(object sender, System.EventArgs e)
  483. {
  484. sql.pointToFirst();
  485. show();
  486. }
  487. private void butPrev_Click(object sender, System.EventArgs e)
  488. {
  489. sql.pointToPrev();
  490. show();
  491. }
  492. private void butNext_Click(object sender, System.EventArgs e)
  493. {
  494. sql.pointToNext();
  495. show();
  496. }
  497. private void butLast_Click(object sender, System.EventArgs e)
  498. {
  499. sql.pointToLast();
  500. show();
  501. }
  502. private void butAlter_Click(object sender, System.EventArgs e)
  503. {
  504. if(butAlter.Text=="修改")
  505. {
  506. butAlter.Text="更新";
  507. oldcustomerID=customerID.Text;
  508. customerID.ReadOnly=false;
  509. customername.ReadOnly=false;
  510. customerinfo.ReadOnly=false;
  511. customeraddress.ReadOnly=false;
  512. customertelephone.ReadOnly=false;
  513. customersex.ReadOnly=false;
  514. customeremail.ReadOnly=false;
  515. butAdd.Enabled=false;
  516. butDelete.Enabled=false;
  517. butFirst.Enabled=false;
  518. butPrev.Enabled=false;
  519. butNext.Enabled=false;
  520. butLast.Enabled=false;
  521. butSearch.Enabled=false;
  522. butLookOverOrders.Enabled=false;
  523. butShowAll.Enabled=false;
  524. AddOrder.Enabled=false;
  525. }
  526. else
  527. {
  528. if(sql.ExecuteSQL("update 客户信息表 set customerID='"+customerID.Text
  529. +"',customername='"+customername.Text
  530. +"',customerinfo='"+customerinfo.Text
  531. +"',customeraddress='"+customeraddress.Text
  532. +"',customertelephone='"+customertelephone.Text
  533. +"',customersex='"+customersex.Text
  534. +"',customeremail='"+customeremail.Text+"' where customerID='"+oldcustomerID+"'")
  535. ==false||
  536. sql.ExecuteSQL("update 客户订单信息表 set customerID='"+customerID.Text
  537. +"' where customerID='"+oldcustomerID+"'")
  538. ==false)
  539. {
  540. show();
  541. }
  542. else
  543. {
  544. CUSTOMERID=customerID.Text;
  545. CUSTOMERNAME=customername.Text;
  546. }
  547. customerID.ReadOnly=true;
  548. customername.ReadOnly=true;
  549. customerinfo.ReadOnly=true;
  550. customeraddress.ReadOnly=true;
  551. customertelephone.ReadOnly=true;
  552. customersex.ReadOnly=true;
  553. customeremail.ReadOnly=true;
  554. butAlter.Text="修改";
  555. butAdd.Enabled=true;
  556. butDelete.Enabled=true;
  557. butFirst.Enabled=true;
  558. butPrev.Enabled=true;
  559. butNext.Enabled=true;
  560. butLast.Enabled=true;
  561. butSearch.Enabled=true;
  562. butLookOverOrders.Enabled=true;
  563. AddOrder.Enabled=true;
  564. butShowAll.Enabled=true;
  565. }
  566. }
  567. private void butAdd_Click(object sender, System.EventArgs e)
  568. {
  569. try
  570. {
  571. if(butAdd.Text=="添加")
  572. {
  573. butAdd.Text="提交";
  574. customerID.Text="";
  575. customername.Text="";
  576. customerinfo.Text="";
  577. customeraddress.Text="";
  578. customertelephone.Text="";
  579. customersex.Text="";
  580. customeremail.Text="";
  581. customerID.ReadOnly=false;
  582. customername.ReadOnly=false;
  583. customerinfo.ReadOnly=false;
  584. customeraddress.ReadOnly=false;
  585. customertelephone.ReadOnly=false;
  586. customersex.ReadOnly=false;
  587. customeremail.ReadOnly=false;
  588. butAlter.Enabled=false;
  589. butDelete.Enabled=false;
  590. butFirst.Enabled=false;
  591. butPrev.Enabled=false;
  592. butNext.Enabled=false;
  593. butLast.Enabled=false;
  594. butSearch.Enabled=false;
  595. butLookOverOrders.Enabled=false;
  596. AddOrder.Enabled=false;
  597. butShowAll.Enabled=false;
  598. }
  599. else
  600. {
  601. if(sql.ExecuteSQL("insert into 客户信息表 values('"
  602. +customerID.Text+"','"+customername.Text+"','"+customerinfo.Text+"','"
  603. +customeraddress.Text+"','"+customertelephone.Text+"','"
  604. +customersex.Text+"','"+customeremail.Text+"')")
  605. ==false)
  606. {
  607. show();
  608. }
  609. else
  610. {
  611. CUSTOMERID=customerID.Text;
  612. CUSTOMERNAME=customername.Text;
  613. }
  614. customerID.ReadOnly=true;
  615. customername.ReadOnly=true;
  616. customerinfo.ReadOnly=true;
  617. customeraddress.ReadOnly=true;
  618. customertelephone.ReadOnly=true;
  619. customersex.ReadOnly=true;
  620. customeremail.ReadOnly=true;
  621. butAdd.Text="添加";
  622. butAlter.Enabled=true;
  623. butDelete.Enabled=true;
  624. butFirst.Enabled=true;
  625. butPrev.Enabled=true;
  626. butNext.Enabled=true;
  627. butLast.Enabled=true;
  628. butSearch.Enabled=true;
  629. butLookOverOrders.Enabled=true;
  630. AddOrder.Enabled=true;
  631. butShowAll.Enabled=true;
  632. }
  633. }
  634. catch(Exception e1)
  635. {
  636. MessageBox.Show(e1.Message);
  637. }
  638. }
  639. private void butDelete_Click(object sender, System.EventArgs e)
  640. {
  641. sql.ExecuteSQL("delete from 客户信息表 where customerID='"+customerID.Text+"'");
  642. show();
  643. }
  644. private void butSearch_Click(object sender, System.EventArgs e)
  645. {
  646. if(comboBox1.Text=="客户名称")
  647. {
  648. if(comboBox2.Text=="精确")
  649. {
  650. sql.ExecuteSQL("select * from 客户信息表 where customername='"+textForSearch.Text+"' order by customerID");
  651. show();
  652. }
  653. else
  654. {
  655. sql.ExecuteSQL("select * from 客户信息表 where customername like '%"+textForSearch.Text+"%' order by customerID");
  656. show();
  657. }
  658. }
  659. else
  660. {
  661. if(comboBox2.Text=="精确")
  662. {
  663. sql.ExecuteSQL("select * from 客户信息表 where customeremail='"+textForSearch.Text+"' order by customerID");
  664. show();
  665. }
  666. else
  667. {
  668. sql.ExecuteSQL("select * from 客户信息表 where customeremail like '%"+textForSearch.Text+"%' order by customerID");
  669. show();
  670. }
  671. }
  672. }
  673. private void butShowAll_Click(object sender, System.EventArgs e)
  674. {
  675. sql.ExecuteSQL("select * from 客户信息表 order by customerID");
  676. show();
  677. }
  678. }
  679. }