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

教育系统应用

开发平台:

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_AddOrder 的摘要说明。
  10. /// </summary>
  11. public class Form_Customer_AddOrder : System.Windows.Forms.Form
  12. {
  13. private System.Windows.Forms.Button butExit;
  14. private System.Windows.Forms.Button butCommit;
  15. private System.Windows.Forms.TextBox orderquantity;
  16. private System.Windows.Forms.TextBox bookISBN;
  17. private System.Windows.Forms.TextBox bookname;
  18. private System.Windows.Forms.Label label3;
  19. private System.Windows.Forms.Label label2;
  20. private System.Windows.Forms.Label label1;
  21. private System.Windows.Forms.Button butSelect;
  22. private System.Windows.Forms.TextBox customername;
  23. private System.Windows.Forms.TextBox customerID;
  24. private System.Windows.Forms.Label label4;
  25. private System.Windows.Forms.Label label5;
  26. private System.Windows.Forms.TextBox orderID;
  27. private System.Windows.Forms.Label label6;
  28. /// <summary>
  29. /// 必需的设计器变量。
  30. /// </summary>
  31. private System.ComponentModel.Container components = null;
  32. public Form_Customer_AddOrder()
  33. {
  34. //
  35. // Windows 窗体设计器支持所必需的
  36. //
  37. InitializeComponent();
  38. //
  39. // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
  40. //
  41. }
  42. /// <summary>
  43. /// 清理所有正在使用的资源。
  44. /// </summary>
  45. protected override void Dispose( bool disposing )
  46. {
  47. if( disposing )
  48. {
  49. if(components != null)
  50. {
  51. components.Dispose();
  52. }
  53. }
  54. base.Dispose( disposing );
  55. }
  56. #region Windows 窗体设计器生成的代码
  57. /// <summary>
  58. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  59. /// 此方法的内容。
  60. /// </summary>
  61. private void InitializeComponent()
  62. {
  63. System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form_Customer_AddOrder));
  64. this.butExit = new System.Windows.Forms.Button();
  65. this.butCommit = new System.Windows.Forms.Button();
  66. this.orderquantity = new System.Windows.Forms.TextBox();
  67. this.bookISBN = new System.Windows.Forms.TextBox();
  68. this.bookname = new System.Windows.Forms.TextBox();
  69. this.label3 = new System.Windows.Forms.Label();
  70. this.label2 = new System.Windows.Forms.Label();
  71. this.label1 = new System.Windows.Forms.Label();
  72. this.butSelect = new System.Windows.Forms.Button();
  73. this.customername = new System.Windows.Forms.TextBox();
  74. this.customerID = new System.Windows.Forms.TextBox();
  75. this.label4 = new System.Windows.Forms.Label();
  76. this.label5 = new System.Windows.Forms.Label();
  77. this.orderID = new System.Windows.Forms.TextBox();
  78. this.label6 = new System.Windows.Forms.Label();
  79. this.SuspendLayout();
  80. // 
  81. // butExit
  82. // 
  83. this.butExit.BackColor = System.Drawing.Color.Transparent;
  84. this.butExit.Location = new System.Drawing.Point(232, 264);
  85. this.butExit.Name = "butExit";
  86. this.butExit.Size = new System.Drawing.Size(80, 24);
  87. this.butExit.TabIndex = 25;
  88. this.butExit.Text = "退出";
  89. this.butExit.Click += new System.EventHandler(this.butExit_Click);
  90. // 
  91. // butCommit
  92. // 
  93. this.butCommit.BackColor = System.Drawing.Color.Transparent;
  94. this.butCommit.Location = new System.Drawing.Point(96, 264);
  95. this.butCommit.Name = "butCommit";
  96. this.butCommit.Size = new System.Drawing.Size(80, 24);
  97. this.butCommit.TabIndex = 24;
  98. this.butCommit.Text = "提交订单";
  99. this.butCommit.Click += new System.EventHandler(this.butCommit_Click);
  100. // 
  101. // orderquantity
  102. // 
  103. this.orderquantity.Location = new System.Drawing.Point(120, 216);
  104. this.orderquantity.Name = "orderquantity";
  105. this.orderquantity.Size = new System.Drawing.Size(208, 21);
  106. this.orderquantity.TabIndex = 23;
  107. this.orderquantity.Text = "";
  108. // 
  109. // bookISBN
  110. // 
  111. this.bookISBN.Location = new System.Drawing.Point(120, 136);
  112. this.bookISBN.Name = "bookISBN";
  113. this.bookISBN.ReadOnly = true;
  114. this.bookISBN.Size = new System.Drawing.Size(208, 21);
  115. this.bookISBN.TabIndex = 22;
  116. this.bookISBN.Text = "";
  117. // 
  118. // bookname
  119. // 
  120. this.bookname.Location = new System.Drawing.Point(120, 176);
  121. this.bookname.Name = "bookname";
  122. this.bookname.ReadOnly = true;
  123. this.bookname.Size = new System.Drawing.Size(208, 21);
  124. this.bookname.TabIndex = 21;
  125. this.bookname.Text = "";
  126. // 
  127. // label3
  128. // 
  129. this.label3.BackColor = System.Drawing.Color.Transparent;
  130. this.label3.Location = new System.Drawing.Point(32, 216);
  131. this.label3.Name = "label3";
  132. this.label3.Size = new System.Drawing.Size(68, 16);
  133. this.label3.TabIndex = 20;
  134. this.label3.Text = "订购数量";
  135. // 
  136. // label2
  137. // 
  138. this.label2.BackColor = System.Drawing.Color.Transparent;
  139. this.label2.Location = new System.Drawing.Point(32, 136);
  140. this.label2.Name = "label2";
  141. this.label2.Size = new System.Drawing.Size(68, 16);
  142. this.label2.TabIndex = 19;
  143. this.label2.Text = "ISBN";
  144. // 
  145. // label1
  146. // 
  147. this.label1.BackColor = System.Drawing.Color.Transparent;
  148. this.label1.Location = new System.Drawing.Point(32, 176);
  149. this.label1.Name = "label1";
  150. this.label1.Size = new System.Drawing.Size(68, 16);
  151. this.label1.TabIndex = 18;
  152. this.label1.Text = "书名";
  153. // 
  154. // butSelect
  155. // 
  156. this.butSelect.BackColor = System.Drawing.Color.Transparent;
  157. this.butSelect.Location = new System.Drawing.Point(344, 136);
  158. this.butSelect.Name = "butSelect";
  159. this.butSelect.Size = new System.Drawing.Size(32, 20);
  160. this.butSelect.TabIndex = 26;
  161. this.butSelect.Text = "...";
  162. this.butSelect.Click += new System.EventHandler(this.butSelect_Click);
  163. // 
  164. // customername
  165. // 
  166. this.customername.Location = new System.Drawing.Point(120, 96);
  167. this.customername.Name = "customername";
  168. this.customername.ReadOnly = true;
  169. this.customername.Size = new System.Drawing.Size(208, 21);
  170. this.customername.TabIndex = 30;
  171. this.customername.Text = "";
  172. // 
  173. // customerID
  174. // 
  175. this.customerID.Location = new System.Drawing.Point(120, 56);
  176. this.customerID.Name = "customerID";
  177. this.customerID.ReadOnly = true;
  178. this.customerID.Size = new System.Drawing.Size(208, 21);
  179. this.customerID.TabIndex = 29;
  180. this.customerID.Text = "";
  181. // 
  182. // label4
  183. // 
  184. this.label4.BackColor = System.Drawing.Color.Transparent;
  185. this.label4.Location = new System.Drawing.Point(32, 96);
  186. this.label4.Name = "label4";
  187. this.label4.Size = new System.Drawing.Size(68, 16);
  188. this.label4.TabIndex = 28;
  189. this.label4.Text = "客户名称";
  190. // 
  191. // label5
  192. // 
  193. this.label5.BackColor = System.Drawing.Color.Transparent;
  194. this.label5.Location = new System.Drawing.Point(32, 56);
  195. this.label5.Name = "label5";
  196. this.label5.Size = new System.Drawing.Size(68, 16);
  197. this.label5.TabIndex = 27;
  198. this.label5.Text = "客户ID";
  199. // 
  200. // orderID
  201. // 
  202. this.orderID.Location = new System.Drawing.Point(120, 16);
  203. this.orderID.Name = "orderID";
  204. this.orderID.Size = new System.Drawing.Size(208, 21);
  205. this.orderID.TabIndex = 32;
  206. this.orderID.Text = "";
  207. // 
  208. // label6
  209. // 
  210. this.label6.BackColor = System.Drawing.Color.Transparent;
  211. this.label6.Location = new System.Drawing.Point(32, 16);
  212. this.label6.Name = "label6";
  213. this.label6.Size = new System.Drawing.Size(68, 16);
  214. this.label6.TabIndex = 31;
  215. this.label6.Text = "订单号";
  216. // 
  217. // Form_Customer_AddOrder
  218. // 
  219. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  220. this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
  221. this.ClientSize = new System.Drawing.Size(408, 310);
  222. this.Controls.Add(this.orderID);
  223. this.Controls.Add(this.label6);
  224. this.Controls.Add(this.customername);
  225. this.Controls.Add(this.customerID);
  226. this.Controls.Add(this.label4);
  227. this.Controls.Add(this.label5);
  228. this.Controls.Add(this.butSelect);
  229. this.Controls.Add(this.butExit);
  230. this.Controls.Add(this.butCommit);
  231. this.Controls.Add(this.orderquantity);
  232. this.Controls.Add(this.bookISBN);
  233. this.Controls.Add(this.bookname);
  234. this.Controls.Add(this.label3);
  235. this.Controls.Add(this.label2);
  236. this.Controls.Add(this.label1);
  237. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  238. this.Name = "Form_Customer_AddOrder";
  239. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  240. this.Text = "添加订单";
  241. this.Load += new System.EventHandler(this.Form_Customer_AddOrder_Load);
  242. this.ResumeLayout(false);
  243. }
  244. #endregion
  245. SQL sql;
  246. private void butSelect_Click(object sender, System.EventArgs e)
  247. {
  248. Form_Customer_AddOrder_SelectBook child=new Form_Customer_AddOrder_SelectBook();
  249. child.ShowDialog();
  250. bookISBN.Text=Form_Customer_AddOrder_SelectBook.BOOKISBN;
  251. bookname.Text=Form_Customer_AddOrder_SelectBook.BOOKNAME;
  252. }
  253. private void Form_Customer_AddOrder_Load(object sender, System.EventArgs e)
  254. {
  255. sql=new SQL("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=图书管理系统数据库.mdb");
  256. customerID.Text=Form_Customer.CUSTOMERID;
  257. customername.Text=Form_Customer.CUSTOMERNAME;
  258. }
  259. private void butCommit_Click(object sender, System.EventArgs e)
  260. {
  261. try
  262. {
  263. int.Parse(orderquantity.Text);
  264. }
  265. catch
  266. {
  267. MessageBox.Show("订购数量必须为整型数,提交失败!","提示");
  268. return;
  269. }
  270. if(Form_Customer_AddOrder_SelectBook.BOOKPRICE=="")
  271. {
  272. MessageBox.Show("请先选择一本书!","提示");
  273. return;
  274. }
  275. string orderdate=System.DateTime.Now.Year.ToString()+STR.add0(System.DateTime.Now.Month.ToString())+STR.add0(System.DateTime.Now.Day.ToString());
  276. double orderprice=Convert.ToDouble(Convert.ToDouble(orderquantity.Text)*Convert.ToDouble(Form_Customer_AddOrder_SelectBook.BOOKPRICE));
  277. if(sql.ExecuteSQL("insert into 客户订单信息表 values('"
  278. +orderID.Text+"','"+customerID.Text+"','"+bookISBN.Text+"','"
  279. +orderdate+"','"+orderprice+"','"+orderquantity.Text+"','0')")
  280. ==false)
  281. {
  282. orderID.Text="";
  283. orderquantity.Text="";
  284. }
  285. else MessageBox.Show("提交成功!","提示");
  286. }
  287. private void butExit_Click(object sender, System.EventArgs e)
  288. {
  289. this.Close();
  290. }
  291. }
  292. }