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

教育系统应用

开发平台:

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_LookOverOrders 的摘要说明。
  10. /// </summary>
  11. public class Form_Customer_LookOverOrders : System.Windows.Forms.Form
  12. {
  13. private System.Windows.Forms.Label label2;
  14. private System.Windows.Forms.Label label1;
  15. private System.Windows.Forms.Button butExit;
  16. private System.Windows.Forms.TextBox orderID;
  17. private System.Windows.Forms.Button butUpdate;
  18. private System.Windows.Forms.Button butCommit;
  19. private System.Windows.Forms.Button butLast;
  20. private System.Windows.Forms.Button butFirst;
  21. private System.Windows.Forms.Button butNext;
  22. private System.Windows.Forms.Button butPrev;
  23. private System.Windows.Forms.TextBox orderquantity;
  24. private System.Windows.Forms.TextBox orderprice;
  25. private System.Windows.Forms.Label label5;
  26. private System.Windows.Forms.Label label6;
  27. private System.Windows.Forms.RadioButton radioButton1;
  28. private System.Windows.Forms.RadioButton radioButton2;
  29. private System.Windows.Forms.TextBox customerID;
  30. private System.Windows.Forms.TextBox bookISBN;
  31. private System.Windows.Forms.Label label3;
  32. /// <summary>
  33. /// 必需的设计器变量。
  34. /// </summary>
  35. private System.ComponentModel.Container components = null;
  36. public Form_Customer_LookOverOrders()
  37. {
  38. //
  39. // Windows 窗体设计器支持所必需的
  40. //
  41. InitializeComponent();
  42. //
  43. // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
  44. //
  45. }
  46. /// <summary>
  47. /// 清理所有正在使用的资源。
  48. /// </summary>
  49. protected override void Dispose( bool disposing )
  50. {
  51. if( disposing )
  52. {
  53. if(components != null)
  54. {
  55. components.Dispose();
  56. }
  57. }
  58. base.Dispose( disposing );
  59. }
  60. #region Windows 窗体设计器生成的代码
  61. /// <summary>
  62. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  63. /// 此方法的内容。
  64. /// </summary>
  65. private void InitializeComponent()
  66. {
  67. System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form_Customer_LookOverOrders));
  68. this.butExit = new System.Windows.Forms.Button();
  69. this.customerID = new System.Windows.Forms.TextBox();
  70. this.orderID = new System.Windows.Forms.TextBox();
  71. this.butUpdate = new System.Windows.Forms.Button();
  72. this.butCommit = new System.Windows.Forms.Button();
  73. this.label2 = new System.Windows.Forms.Label();
  74. this.label1 = new System.Windows.Forms.Label();
  75. this.butLast = new System.Windows.Forms.Button();
  76. this.butFirst = new System.Windows.Forms.Button();
  77. this.butNext = new System.Windows.Forms.Button();
  78. this.butPrev = new System.Windows.Forms.Button();
  79. this.orderquantity = new System.Windows.Forms.TextBox();
  80. this.orderprice = new System.Windows.Forms.TextBox();
  81. this.label5 = new System.Windows.Forms.Label();
  82. this.label6 = new System.Windows.Forms.Label();
  83. this.radioButton1 = new System.Windows.Forms.RadioButton();
  84. this.radioButton2 = new System.Windows.Forms.RadioButton();
  85. this.bookISBN = new System.Windows.Forms.TextBox();
  86. this.label3 = new System.Windows.Forms.Label();
  87. this.SuspendLayout();
  88. // 
  89. // butExit
  90. // 
  91. this.butExit.BackColor = System.Drawing.Color.Transparent;
  92. this.butExit.Location = new System.Drawing.Point(212, 304);
  93. this.butExit.Name = "butExit";
  94. this.butExit.Size = new System.Drawing.Size(64, 24);
  95. this.butExit.TabIndex = 25;
  96. this.butExit.Text = "退出";
  97. this.butExit.Click += new System.EventHandler(this.butExit_Click);
  98. // 
  99. // customerID
  100. // 
  101. this.customerID.Location = new System.Drawing.Point(120, 27);
  102. this.customerID.Name = "customerID";
  103. this.customerID.ReadOnly = true;
  104. this.customerID.Size = new System.Drawing.Size(208, 21);
  105. this.customerID.TabIndex = 21;
  106. this.customerID.Text = "customerID";
  107. // 
  108. // orderID
  109. // 
  110. this.orderID.Location = new System.Drawing.Point(120, 67);
  111. this.orderID.Name = "orderID";
  112. this.orderID.ReadOnly = true;
  113. this.orderID.Size = new System.Drawing.Size(208, 21);
  114. this.orderID.TabIndex = 20;
  115. this.orderID.Text = "orderID";
  116. // 
  117. // butUpdate
  118. // 
  119. this.butUpdate.BackColor = System.Drawing.Color.Transparent;
  120. this.butUpdate.Location = new System.Drawing.Point(44, 232);
  121. this.butUpdate.Name = "butUpdate";
  122. this.butUpdate.Size = new System.Drawing.Size(56, 24);
  123. this.butUpdate.TabIndex = 17;
  124. this.butUpdate.Text = "修改";
  125. this.butUpdate.Click += new System.EventHandler(this.butUpdate_Click);
  126. // 
  127. // butCommit
  128. // 
  129. this.butCommit.BackColor = System.Drawing.Color.Transparent;
  130. this.butCommit.Location = new System.Drawing.Point(92, 304);
  131. this.butCommit.Name = "butCommit";
  132. this.butCommit.Size = new System.Drawing.Size(64, 24);
  133. this.butCommit.TabIndex = 16;
  134. this.butCommit.Text = "满足订单";
  135. this.butCommit.Click += new System.EventHandler(this.butCommit_Click);
  136. // 
  137. // label2
  138. // 
  139. this.label2.BackColor = System.Drawing.Color.Transparent;
  140. this.label2.Location = new System.Drawing.Point(40, 27);
  141. this.label2.Name = "label2";
  142. this.label2.Size = new System.Drawing.Size(56, 16);
  143. this.label2.TabIndex = 14;
  144. this.label2.Text = "客户ID";
  145. // 
  146. // label1
  147. // 
  148. this.label1.BackColor = System.Drawing.Color.Transparent;
  149. this.label1.Location = new System.Drawing.Point(40, 67);
  150. this.label1.Name = "label1";
  151. this.label1.Size = new System.Drawing.Size(56, 16);
  152. this.label1.TabIndex = 13;
  153. this.label1.Text = "订单号";
  154. // 
  155. // butLast
  156. // 
  157. this.butLast.BackColor = System.Drawing.Color.Transparent;
  158. this.butLast.Location = new System.Drawing.Point(268, 232);
  159. this.butLast.Name = "butLast";
  160. this.butLast.Size = new System.Drawing.Size(56, 24);
  161. this.butLast.TabIndex = 29;
  162. this.butLast.Text = ">|";
  163. this.butLast.Click += new System.EventHandler(this.butLast_Click);
  164. // 
  165. // butFirst
  166. // 
  167. this.butFirst.BackColor = System.Drawing.Color.Transparent;
  168. this.butFirst.Location = new System.Drawing.Point(100, 232);
  169. this.butFirst.Name = "butFirst";
  170. this.butFirst.Size = new System.Drawing.Size(56, 24);
  171. this.butFirst.TabIndex = 28;
  172. this.butFirst.Text = "|<";
  173. this.butFirst.Click += new System.EventHandler(this.butFirst_Click);
  174. // 
  175. // butNext
  176. // 
  177. this.butNext.BackColor = System.Drawing.Color.Transparent;
  178. this.butNext.Location = new System.Drawing.Point(212, 232);
  179. this.butNext.Name = "butNext";
  180. this.butNext.Size = new System.Drawing.Size(56, 24);
  181. this.butNext.TabIndex = 27;
  182. this.butNext.Text = ">";
  183. this.butNext.Click += new System.EventHandler(this.butNext_Click);
  184. // 
  185. // butPrev
  186. // 
  187. this.butPrev.BackColor = System.Drawing.Color.Transparent;
  188. this.butPrev.Location = new System.Drawing.Point(156, 232);
  189. this.butPrev.Name = "butPrev";
  190. this.butPrev.Size = new System.Drawing.Size(56, 24);
  191. this.butPrev.TabIndex = 26;
  192. this.butPrev.Text = "<";
  193. this.butPrev.Click += new System.EventHandler(this.butPrev_Click);
  194. // 
  195. // orderquantity
  196. // 
  197. this.orderquantity.Location = new System.Drawing.Point(120, 184);
  198. this.orderquantity.Name = "orderquantity";
  199. this.orderquantity.ReadOnly = true;
  200. this.orderquantity.Size = new System.Drawing.Size(208, 21);
  201. this.orderquantity.TabIndex = 33;
  202. this.orderquantity.Text = "orderquantity";
  203. // 
  204. // orderprice
  205. // 
  206. this.orderprice.Location = new System.Drawing.Point(120, 144);
  207. this.orderprice.Name = "orderprice";
  208. this.orderprice.ReadOnly = true;
  209. this.orderprice.Size = new System.Drawing.Size(208, 21);
  210. this.orderprice.TabIndex = 31;
  211. this.orderprice.Text = "orderprice";
  212. // 
  213. // label5
  214. // 
  215. this.label5.BackColor = System.Drawing.Color.Transparent;
  216. this.label5.Location = new System.Drawing.Point(40, 184);
  217. this.label5.Name = "label5";
  218. this.label5.Size = new System.Drawing.Size(56, 16);
  219. this.label5.TabIndex = 32;
  220. this.label5.Text = "订购数量";
  221. // 
  222. // label6
  223. // 
  224. this.label6.BackColor = System.Drawing.Color.Transparent;
  225. this.label6.Location = new System.Drawing.Point(40, 144);
  226. this.label6.Name = "label6";
  227. this.label6.Size = new System.Drawing.Size(56, 16);
  228. this.label6.TabIndex = 30;
  229. this.label6.Text = "订购价格";
  230. // 
  231. // radioButton1
  232. // 
  233. this.radioButton1.BackColor = System.Drawing.Color.Transparent;
  234. this.radioButton1.Location = new System.Drawing.Point(184, 272);
  235. this.radioButton1.Name = "radioButton1";
  236. this.radioButton1.Size = new System.Drawing.Size(136, 24);
  237. this.radioButton1.TabIndex = 34;
  238. this.radioButton1.Text = "查看已完成的订单";
  239. this.radioButton1.Click += new System.EventHandler(this.radioButton1_Click);
  240. // 
  241. // radioButton2
  242. // 
  243. this.radioButton2.BackColor = System.Drawing.Color.Transparent;
  244. this.radioButton2.Checked = true;
  245. this.radioButton2.Location = new System.Drawing.Point(48, 272);
  246. this.radioButton2.Name = "radioButton2";
  247. this.radioButton2.Size = new System.Drawing.Size(136, 24);
  248. this.radioButton2.TabIndex = 35;
  249. this.radioButton2.TabStop = true;
  250. this.radioButton2.Text = "查看未完成的订单";
  251. this.radioButton2.Click += new System.EventHandler(this.radioButton2_Click);
  252. // 
  253. // bookISBN
  254. // 
  255. this.bookISBN.Location = new System.Drawing.Point(121, 104);
  256. this.bookISBN.Name = "bookISBN";
  257. this.bookISBN.ReadOnly = true;
  258. this.bookISBN.Size = new System.Drawing.Size(208, 21);
  259. this.bookISBN.TabIndex = 37;
  260. this.bookISBN.Text = "bookSBN";
  261. // 
  262. // label3
  263. // 
  264. this.label3.BackColor = System.Drawing.Color.Transparent;
  265. this.label3.Location = new System.Drawing.Point(41, 104);
  266. this.label3.Name = "label3";
  267. this.label3.Size = new System.Drawing.Size(56, 16);
  268. this.label3.TabIndex = 36;
  269. this.label3.Text = "图书ISBN";
  270. // 
  271. // Form_Customer_LookOverOrders
  272. // 
  273. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  274. this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
  275. this.ClientSize = new System.Drawing.Size(370, 336);
  276. this.Controls.Add(this.bookISBN);
  277. this.Controls.Add(this.label3);
  278. this.Controls.Add(this.radioButton2);
  279. this.Controls.Add(this.radioButton1);
  280. this.Controls.Add(this.orderquantity);
  281. this.Controls.Add(this.orderprice);
  282. this.Controls.Add(this.customerID);
  283. this.Controls.Add(this.orderID);
  284. this.Controls.Add(this.label5);
  285. this.Controls.Add(this.label6);
  286. this.Controls.Add(this.butLast);
  287. this.Controls.Add(this.butFirst);
  288. this.Controls.Add(this.butNext);
  289. this.Controls.Add(this.butPrev);
  290. this.Controls.Add(this.butExit);
  291. this.Controls.Add(this.butUpdate);
  292. this.Controls.Add(this.butCommit);
  293. this.Controls.Add(this.label2);
  294. this.Controls.Add(this.label1);
  295. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  296. this.Name = "Form_Customer_LookOverOrders";
  297. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  298. this.Text = "查看订单";
  299. this.Load += new System.EventHandler(this.Form_Customer_LookOverOrders_Load);
  300. this.ResumeLayout(false);
  301. }
  302. #endregion
  303. SQL sql;
  304. string oldorderID="";
  305. public void show()
  306. {
  307. if(sql.rows.GetLength(0)!=0)
  308. {
  309. orderID.Text=sql.rows[sql.getPos(),0].ToString();
  310. bookISBN.Text=sql.rows[sql.getPos(),2].ToString();
  311. orderprice.Text=sql.rows[sql.getPos(),4].ToString();
  312. orderquantity.Text=sql.rows[sql.getPos(),5].ToString();
  313. }
  314. else
  315. {
  316. orderID.Text="";
  317. bookISBN.Text="";
  318. orderprice.Text="";
  319. orderquantity.Text="";
  320. MessageBox.Show("无符合查询条件的结果!","提示");
  321. }
  322. }
  323. private void Form_Customer_LookOverOrders_Load(object sender, System.EventArgs e)
  324. {
  325. customerID.Text=Form_Customer.CUSTOMERID;
  326. sql=new SQL("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=图书管理系统数据库.mdb");
  327. sql.ExecuteSQL("select * from 客户订单信息表 where customerID='"+customerID.Text+"' and orderstatus='0' order by orderID");
  328. show();
  329. }
  330. private void butFirst_Click(object sender, System.EventArgs e)
  331. {
  332. sql.pointToFirst();
  333. show();
  334. }
  335. private void butPrev_Click(object sender, System.EventArgs e)
  336. {
  337. sql.pointToPrev();
  338. show();
  339. }
  340. private void butNext_Click(object sender, System.EventArgs e)
  341. {
  342. sql.pointToNext();
  343. show();
  344. }
  345. private void butLast_Click(object sender, System.EventArgs e)
  346. {
  347. sql.pointToLast();
  348. }
  349. private void butUpdate_Click(object sender, System.EventArgs e)
  350. {
  351. if(butUpdate.Text=="修改")
  352. {
  353. butUpdate.Text="更新";
  354. oldorderID=orderID.Text;
  355. orderID.ReadOnly=false;
  356. orderprice.ReadOnly=false;
  357. orderquantity.ReadOnly=false;
  358. butFirst.Enabled=false;
  359. butPrev.Enabled=false;
  360. butNext.Enabled=false;
  361. butLast.Enabled=false;
  362. butCommit.Enabled=false;
  363. butExit.Enabled=false;
  364. }
  365. else
  366. {
  367. if(sql.ExecuteSQL("update 客户订单信息表 set orderID='"+orderID.Text+"',orderprice='"
  368. +orderprice.Text+"',orderquantity='"+orderquantity.Text+"' where customerID='"+customerID.Text
  369. +"'and orderID='"+oldorderID+"'")
  370. ==false)
  371. {
  372. show();
  373. }
  374. orderID.ReadOnly=true;
  375. orderprice.ReadOnly=true;
  376. orderquantity.ReadOnly=true;
  377. butUpdate.Text="修改";
  378. butFirst.Enabled=true;
  379. butPrev.Enabled=true;
  380. butNext.Enabled=true;
  381. butLast.Enabled=true;
  382. butCommit.Enabled=true;
  383. butExit.Enabled=true;
  384. }
  385. }
  386. private void butCommit_Click(object sender, System.EventArgs e)
  387. {
  388. if(orderID.Text!="")
  389. {
  390. if(
  391. sql.ExecuteSQL("update 库存信息表 set bookquantity=bookquantity-"+orderquantity.Text+" where bookISBN='"+bookISBN.Text+"'")
  392. ==true)
  393. {
  394. if(
  395. sql.ExecuteSQL("update 客户订单信息表 set orderstatus='1' where customerID='"+customerID.Text
  396. +"'and orderID='"+orderID.Text+"'")
  397. ==true)
  398. {
  399. MessageBox.Show("订单已满足!","提示");
  400. }
  401. }
  402. show();
  403. }
  404. else
  405. {
  406. MessageBox.Show("还没有选择订单!","提示");
  407. }
  408. }
  409. private void butExit_Click(object sender, System.EventArgs e)
  410. {
  411. this.Close();
  412. }
  413. private void radioButton2_Click(object sender, System.EventArgs e)
  414. {
  415. butCommit.Enabled=true;
  416. sql.ExecuteSQL("select * from 客户订单信息表 where customerID='"+customerID.Text+"' and orderstatus='0' order by orderID");
  417. show();
  418. }
  419. private void radioButton1_Click(object sender, System.EventArgs e)
  420. {
  421. butCommit.Enabled=false;
  422. sql.ExecuteSQL("select * from 客户订单信息表 where customerID='"+customerID.Text+"' and orderstatus='1' order by orderID");
  423. show();
  424. }
  425. }
  426. }