Form1.cs
上传用户:miknos
上传日期:2022-04-30
资源大小:802k
文件大小:65k
源码类别:

百货/超市行业

开发平台:

Visual 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;
  7. using System.Data.SqlClient;
  8. namespace supershop
  9. {
  10. /// <summary>
  11. /// Form1 的摘要说明。
  12. /// </summary>
  13. public class Form1 : System.Windows.Forms.Form
  14. {
  15. private System.Windows.Forms.StatusBar statusBar1;
  16. private System.Windows.Forms.MainMenu mainMenu1;
  17. private System.Windows.Forms.MenuItem menuItem1;
  18. private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
  19. private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
  20. private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
  21. private System.Windows.Forms.Label label1;
  22. private System.Windows.Forms.Label label2;
  23. private System.Windows.Forms.TextBox textBox1;
  24. private System.Windows.Forms.TextBox textBox2;
  25. private System.Windows.Forms.Button button1;
  26. private System.Windows.Forms.Button button2;
  27. private System.Data.SqlClient.SqlCommand sqlCommand1;
  28. private System.Windows.Forms.ListView listView1;
  29. private System.Data.OleDb.OleDbCommand oleDbSelectCommand1;
  30. private System.Data.OleDb.OleDbCommand oleDbInsertCommand1;
  31. private System.Data.OleDb.OleDbCommand oleDbUpdateCommand1;
  32. private System.Data.OleDb.OleDbCommand oleDbDeleteCommand1;
  33. private System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter1;
  34. private System.Data.OleDb.OleDbConnection oleDbConnection1;
  35. private System.Data.OleDb.OleDbCommand oleDbCommand1;
  36. private System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter2;
  37. private System.Data.OleDb.OleDbCommand oleDbSelectCommand2;
  38. private System.Data.OleDb.OleDbConnection oleDbConnection2;
  39. private System.Windows.Forms.ColumnHeader columnHeader1;
  40. private System.Windows.Forms.ColumnHeader columnHeader2;
  41. private System.Windows.Forms.ColumnHeader columnHeader3;
  42. private System.Windows.Forms.ColumnHeader columnHeader4;
  43. private supershop.DataSet1 dataSet11;
  44. private System.Data.SqlClient.SqlConnection myConnection;
  45. private System.Windows.Forms.ColumnHeader columnHeader5;
  46. private System.Windows.Forms.Button button3;
  47. private System.Windows.Forms.MenuItem menuItem2;
  48. private System.Windows.Forms.MenuItem menuItem3;
  49. private System.Windows.Forms.MenuItem menuItem4;
  50. private System.Windows.Forms.MenuItem menuItem5;
  51. private System.Windows.Forms.MenuItem menuItem6;
  52. private System.Windows.Forms.MenuItem menuItem7;
  53. private System.Windows.Forms.MenuItem menuItem8;
  54. private System.Windows.Forms.MenuItem menuItem9;
  55. private System.Windows.Forms.MenuItem menuItem10;
  56. private System.Windows.Forms.MenuItem menuItem11;
  57. private System.Windows.Forms.MenuItem menuItem12;
  58. private System.Windows.Forms.Panel panel1;
  59. private System.Windows.Forms.ListView listView2;
  60. private System.Windows.Forms.ColumnHeader columnHeader6;
  61. private System.Windows.Forms.ColumnHeader columnHeader7;
  62. private System.Windows.Forms.ColumnHeader columnHeader8;
  63. private System.Windows.Forms.GroupBox groupBox1;
  64. private System.Windows.Forms.Label label3;
  65. private System.Windows.Forms.Label label4;
  66. private System.Windows.Forms.Label label5;
  67. private System.Windows.Forms.ComboBox comboBox1;
  68. private System.Windows.Forms.Button button4;
  69. private System.Windows.Forms.Button button5;
  70. private System.Windows.Forms.Button button6;
  71. private System.Windows.Forms.ColumnHeader columnHeader9;
  72. private System.Windows.Forms.TextBox textBox3;
  73. private System.Windows.Forms.TextBox textBox4;
  74. private System.Windows.Forms.Panel panel2;
  75. private System.Windows.Forms.ListView listView3;
  76. private System.Windows.Forms.ColumnHeader columnHeader10;
  77. private System.Windows.Forms.ColumnHeader columnHeader11;
  78. private System.Windows.Forms.ColumnHeader columnHeader12;
  79. private System.Windows.Forms.ColumnHeader columnHeader13;
  80. private System.Windows.Forms.ColumnHeader columnHeader14;
  81. private System.Windows.Forms.ColumnHeader columnHeader15;
  82. private System.Windows.Forms.ColumnHeader columnHeader16;
  83. private System.Windows.Forms.GroupBox groupBox2;
  84. private System.Windows.Forms.Label label6;
  85. private System.Windows.Forms.Label label7;
  86. private System.Windows.Forms.Label label8;
  87. private System.Windows.Forms.Label label9;
  88. private System.Windows.Forms.Label label10;
  89. private System.Windows.Forms.TextBox textBox5;
  90. private System.Windows.Forms.TextBox textBox6;
  91. private System.Windows.Forms.TextBox textBox7;
  92. private System.Windows.Forms.TextBox textBox8;
  93. private System.Windows.Forms.TextBox textBox9;
  94. private System.Windows.Forms.GroupBox groupBox3;
  95. private System.Windows.Forms.Label label11;
  96. private System.Windows.Forms.TextBox textBox10;
  97. private System.Windows.Forms.Button button7;
  98. private System.Windows.Forms.Button button8;
  99. private System.Windows.Forms.Button button9;
  100. private System.Windows.Forms.Button button10;
  101. private System.Windows.Forms.Button button11;
  102. private System.Windows.Forms.ColumnHeader columnHeader17;
  103. private System.Data.SqlClient.SqlConnection myConnection2;
  104. private System.Windows.Forms.Label floglb;
  105. private System.Windows.Forms.Button button12;
  106. //要想在类未创建的时候引用必须将其设为static类型如下边的name
  107. public static string name;
  108. public static string isman;
  109. /// <summary>
  110. /// 必需的设计器变量。
  111. /// </summary>
  112. private System.ComponentModel.Container components = null;
  113. public Form1()
  114. {
  115. //
  116. // Windows 窗体设计器支持所必需的
  117. //
  118. InitializeComponent();
  119. //
  120. // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
  121. //
  122. }
  123. /// <summary>
  124. /// 清理所有正在使用的资源。
  125. /// </summary>
  126. protected override void Dispose( bool disposing )
  127. {
  128. if( disposing )
  129. {
  130. if (components != null) 
  131. {
  132. components.Dispose();
  133. }
  134. }
  135. base.Dispose( disposing );
  136. }
  137. #region Windows 窗体设计器生成的代码
  138. /// <summary>
  139. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  140. /// 此方法的内容。
  141. /// </summary>
  142. private void InitializeComponent()
  143. {
  144. System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
  145. this.statusBar1 = new System.Windows.Forms.StatusBar();
  146. this.mainMenu1 = new System.Windows.Forms.MainMenu();
  147. this.menuItem1 = new System.Windows.Forms.MenuItem();
  148. this.menuItem3 = new System.Windows.Forms.MenuItem();
  149. this.menuItem4 = new System.Windows.Forms.MenuItem();
  150. this.menuItem2 = new System.Windows.Forms.MenuItem();
  151. this.menuItem5 = new System.Windows.Forms.MenuItem();
  152. this.menuItem6 = new System.Windows.Forms.MenuItem();
  153. this.menuItem7 = new System.Windows.Forms.MenuItem();
  154. this.menuItem9 = new System.Windows.Forms.MenuItem();
  155. this.menuItem8 = new System.Windows.Forms.MenuItem();
  156. this.menuItem10 = new System.Windows.Forms.MenuItem();
  157. this.menuItem11 = new System.Windows.Forms.MenuItem();
  158. this.menuItem12 = new System.Windows.Forms.MenuItem();
  159. this.myConnection = new System.Data.SqlClient.SqlConnection();
  160. this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
  161. this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
  162. this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
  163. this.label1 = new System.Windows.Forms.Label();
  164. this.label2 = new System.Windows.Forms.Label();
  165. this.textBox1 = new System.Windows.Forms.TextBox();
  166. this.textBox2 = new System.Windows.Forms.TextBox();
  167. this.button1 = new System.Windows.Forms.Button();
  168. this.button2 = new System.Windows.Forms.Button();
  169. this.sqlCommand1 = new System.Data.SqlClient.SqlCommand();
  170. this.listView1 = new System.Windows.Forms.ListView();
  171. this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
  172. this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
  173. this.columnHeader3 = new System.Windows.Forms.ColumnHeader();
  174. this.columnHeader17 = new System.Windows.Forms.ColumnHeader();
  175. this.columnHeader4 = new System.Windows.Forms.ColumnHeader();
  176. this.columnHeader5 = new System.Windows.Forms.ColumnHeader();
  177. this.oleDbSelectCommand1 = new System.Data.OleDb.OleDbCommand();
  178. this.oleDbInsertCommand1 = new System.Data.OleDb.OleDbCommand();
  179. this.oleDbUpdateCommand1 = new System.Data.OleDb.OleDbCommand();
  180. this.oleDbDeleteCommand1 = new System.Data.OleDb.OleDbCommand();
  181. this.oleDbDataAdapter1 = new System.Data.OleDb.OleDbDataAdapter();
  182. this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
  183. this.oleDbCommand1 = new System.Data.OleDb.OleDbCommand();
  184. this.oleDbDataAdapter2 = new System.Data.OleDb.OleDbDataAdapter();
  185. this.oleDbSelectCommand2 = new System.Data.OleDb.OleDbCommand();
  186. this.oleDbConnection2 = new System.Data.OleDb.OleDbConnection();
  187. this.dataSet11 = new supershop.DataSet1();
  188. this.button3 = new System.Windows.Forms.Button();
  189. this.panel1 = new System.Windows.Forms.Panel();
  190. this.button6 = new System.Windows.Forms.Button();
  191. this.button5 = new System.Windows.Forms.Button();
  192. this.button4 = new System.Windows.Forms.Button();
  193. this.groupBox1 = new System.Windows.Forms.GroupBox();
  194. this.textBox4 = new System.Windows.Forms.TextBox();
  195. this.textBox3 = new System.Windows.Forms.TextBox();
  196. this.comboBox1 = new System.Windows.Forms.ComboBox();
  197. this.label5 = new System.Windows.Forms.Label();
  198. this.label4 = new System.Windows.Forms.Label();
  199. this.label3 = new System.Windows.Forms.Label();
  200. this.listView2 = new System.Windows.Forms.ListView();
  201. this.columnHeader9 = new System.Windows.Forms.ColumnHeader();
  202. this.columnHeader6 = new System.Windows.Forms.ColumnHeader();
  203. this.columnHeader7 = new System.Windows.Forms.ColumnHeader();
  204. this.columnHeader8 = new System.Windows.Forms.ColumnHeader();
  205. this.panel2 = new System.Windows.Forms.Panel();
  206. this.button11 = new System.Windows.Forms.Button();
  207. this.button10 = new System.Windows.Forms.Button();
  208. this.button9 = new System.Windows.Forms.Button();
  209. this.groupBox3 = new System.Windows.Forms.GroupBox();
  210. this.button8 = new System.Windows.Forms.Button();
  211. this.button7 = new System.Windows.Forms.Button();
  212. this.textBox10 = new System.Windows.Forms.TextBox();
  213. this.label11 = new System.Windows.Forms.Label();
  214. this.groupBox2 = new System.Windows.Forms.GroupBox();
  215. this.textBox9 = new System.Windows.Forms.TextBox();
  216. this.textBox8 = new System.Windows.Forms.TextBox();
  217. this.textBox7 = new System.Windows.Forms.TextBox();
  218. this.textBox6 = new System.Windows.Forms.TextBox();
  219. this.textBox5 = new System.Windows.Forms.TextBox();
  220. this.label10 = new System.Windows.Forms.Label();
  221. this.label9 = new System.Windows.Forms.Label();
  222. this.label8 = new System.Windows.Forms.Label();
  223. this.label7 = new System.Windows.Forms.Label();
  224. this.label6 = new System.Windows.Forms.Label();
  225. this.listView3 = new System.Windows.Forms.ListView();
  226. this.columnHeader10 = new System.Windows.Forms.ColumnHeader();
  227. this.columnHeader11 = new System.Windows.Forms.ColumnHeader();
  228. this.columnHeader12 = new System.Windows.Forms.ColumnHeader();
  229. this.columnHeader13 = new System.Windows.Forms.ColumnHeader();
  230. this.columnHeader14 = new System.Windows.Forms.ColumnHeader();
  231. this.columnHeader15 = new System.Windows.Forms.ColumnHeader();
  232. this.columnHeader16 = new System.Windows.Forms.ColumnHeader();
  233. this.myConnection2 = new System.Data.SqlClient.SqlConnection();
  234. this.floglb = new System.Windows.Forms.Label();
  235. this.button12 = new System.Windows.Forms.Button();
  236. ((System.ComponentModel.ISupportInitialize)(this.dataSet11)).BeginInit();
  237. this.panel1.SuspendLayout();
  238. this.groupBox1.SuspendLayout();
  239. this.panel2.SuspendLayout();
  240. this.groupBox3.SuspendLayout();
  241. this.groupBox2.SuspendLayout();
  242. this.SuspendLayout();
  243. // 
  244. // statusBar1
  245. // 
  246. this.statusBar1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
  247. this.statusBar1.Location = new System.Drawing.Point(0, 361);
  248. this.statusBar1.Name = "statusBar1";
  249. this.statusBar1.Size = new System.Drawing.Size(728, 16);
  250. this.statusBar1.TabIndex = 0;
  251. this.statusBar1.PanelClick += new System.Windows.Forms.StatusBarPanelClickEventHandler(this.statusBar1_PanelClick);
  252. // 
  253. // mainMenu1
  254. // 
  255. this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  256.   this.menuItem1,
  257.   this.menuItem2,
  258.   this.menuItem7,
  259.   this.menuItem8,
  260.   this.menuItem11});
  261. // 
  262. // menuItem1
  263. // 
  264. this.menuItem1.Index = 0;
  265. this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  266.   this.menuItem3,
  267.   this.menuItem4});
  268. this.menuItem1.Text = "系统管理";
  269. // 
  270. // menuItem3
  271. // 
  272. this.menuItem3.Index = 0;
  273. this.menuItem3.Text = "退出登录";
  274. this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
  275. // 
  276. // menuItem4
  277. // 
  278. this.menuItem4.Index = 1;
  279. this.menuItem4.Text = "关闭系统";
  280. this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
  281. // 
  282. // menuItem2
  283. // 
  284. this.menuItem2.Index = 1;
  285. this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  286.   this.menuItem5,
  287.   this.menuItem6});
  288. this.menuItem2.Text = "销售管理";
  289. // 
  290. // menuItem5
  291. // 
  292. this.menuItem5.Index = 0;
  293. this.menuItem5.Text = "销售商品";
  294. this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);
  295. // 
  296. // menuItem6
  297. // 
  298. this.menuItem6.Index = 1;
  299. this.menuItem6.Text = "销售历史";
  300. this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
  301. // 
  302. // menuItem7
  303. // 
  304. this.menuItem7.Index = 2;
  305. this.menuItem7.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  306.   this.menuItem9});
  307. this.menuItem7.Text = "商品管理";
  308. // 
  309. // menuItem9
  310. // 
  311. this.menuItem9.Index = 0;
  312. this.menuItem9.Text = "商品概况";
  313. this.menuItem9.Click += new System.EventHandler(this.menuItem9_Click);
  314. // 
  315. // menuItem8
  316. // 
  317. this.menuItem8.Index = 3;
  318. this.menuItem8.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  319.   this.menuItem10});
  320. this.menuItem8.Text = "人事管理";
  321. // 
  322. // menuItem10
  323. // 
  324. this.menuItem10.Index = 0;
  325. this.menuItem10.Text = "人员安排";
  326. this.menuItem10.Click += new System.EventHandler(this.menuItem10_Click);
  327. // 
  328. // menuItem11
  329. // 
  330. this.menuItem11.Index = 4;
  331. this.menuItem11.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  332.    this.menuItem12});
  333. this.menuItem11.Text = "关于";
  334. // 
  335. // menuItem12
  336. // 
  337. this.menuItem12.Index = 0;
  338. this.menuItem12.Text = "橙子超市管理系统1.0版";
  339. this.menuItem12.Click += new System.EventHandler(this.menuItem12_Click);
  340. // 
  341. // myConnection
  342. // 
  343. this.myConnection.ConnectionString = "workstation id=MICROSOFTPANG;packet size=4096;integrated security=SSPI;data sourc" +
  344. "e=MICROSOFTPANG;persist security info=False;initial catalog=supershop";
  345. // 
  346. // sqlDataAdapter1
  347. // 
  348. this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;
  349. this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
  350. this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
  351.   new System.Data.Common.DataTableMapping("Table", "production", new System.Data.Common.DataColumnMapping[] {
  352. new System.Data.Common.DataColumnMapping("pid", "pid"),
  353. new System.Data.Common.DataColumnMapping("pname", "pname"),
  354. new System.Data.Common.DataColumnMapping("price", "price"),
  355. new System.Data.Common.DataColumnMapping("totle", "totle")})});
  356. // 
  357. // sqlInsertCommand1
  358. // 
  359. this.sqlInsertCommand1.CommandText = "INSERT INTO production(pid, pname, price, totle) VALUES (@pid, @pname, @price, @t" +
  360. "otle); SELECT pid, pname, price, totle FROM production";
  361. this.sqlInsertCommand1.Connection = this.myConnection;
  362. this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@pid", System.Data.SqlDbType.Int, 4, "pid"));
  363. this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@pname", System.Data.SqlDbType.VarChar, 20, "pname"));
  364. this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@price", System.Data.SqlDbType.Int, 4, "price"));
  365. this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@totle", System.Data.SqlDbType.Int, 4, "totle"));
  366. // 
  367. // sqlSelectCommand1
  368. // 
  369. this.sqlSelectCommand1.CommandText = "SELECT production.* FROM production";
  370. this.sqlSelectCommand1.Connection = this.myConnection;
  371. // 
  372. // label1
  373. // 
  374. this.label1.Location = new System.Drawing.Point(0, 288);
  375. this.label1.Name = "label1";
  376. this.label1.Size = new System.Drawing.Size(48, 23);
  377. this.label1.TabIndex = 2;
  378. this.label1.Text = "货号:";
  379. // 
  380. // label2
  381. // 
  382. this.label2.Location = new System.Drawing.Point(160, 288);
  383. this.label2.Name = "label2";
  384. this.label2.Size = new System.Drawing.Size(48, 23);
  385. this.label2.TabIndex = 3;
  386. this.label2.Text = "数量:";
  387. // 
  388. // textBox1
  389. // 
  390. this.textBox1.Location = new System.Drawing.Point(48, 288);
  391. this.textBox1.Name = "textBox1";
  392. this.textBox1.TabIndex = 4;
  393. this.textBox1.Text = "";
  394. // 
  395. // textBox2
  396. // 
  397. this.textBox2.Location = new System.Drawing.Point(208, 288);
  398. this.textBox2.Name = "textBox2";
  399. this.textBox2.TabIndex = 5;
  400. this.textBox2.Text = "";
  401. // 
  402. // button1
  403. // 
  404. this.button1.Location = new System.Drawing.Point(432, 288);
  405. this.button1.Name = "button1";
  406. this.button1.TabIndex = 6;
  407. this.button1.Text = "确  认";
  408. this.button1.Visible = false;
  409. this.button1.Click += new System.EventHandler(this.button1_Click);
  410. // 
  411. // button2
  412. // 
  413. this.button2.Location = new System.Drawing.Point(624, 288);
  414. this.button2.Name = "button2";
  415. this.button2.TabIndex = 7;
  416. this.button2.Text = "统  计";
  417. this.button2.Visible = false;
  418. this.button2.Click += new System.EventHandler(this.button2_Click);
  419. // 
  420. // sqlCommand1
  421. // 
  422. this.sqlCommand1.Connection = this.myConnection;
  423. // 
  424. // listView1
  425. // 
  426. this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
  427. this.columnHeader1,
  428. this.columnHeader2,
  429. this.columnHeader3,
  430. this.columnHeader17,
  431. this.columnHeader4,
  432. this.columnHeader5});
  433. this.listView1.FullRowSelect = true;
  434. this.listView1.Location = new System.Drawing.Point(0, 16);
  435. this.listView1.Name = "listView1";
  436. this.listView1.Size = new System.Drawing.Size(728, 248);
  437. this.listView1.TabIndex = 8;
  438. this.listView1.View = System.Windows.Forms.View.Details;
  439. // 
  440. // columnHeader1
  441. // 
  442. this.columnHeader1.Text = "商品货号";
  443. this.columnHeader1.Width = 118;
  444. // 
  445. // columnHeader2
  446. // 
  447. this.columnHeader2.Text = "商品名称";
  448. this.columnHeader2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
  449. this.columnHeader2.Width = 126;
  450. // 
  451. // columnHeader3
  452. // 
  453. this.columnHeader3.Text = "商品价格";
  454. this.columnHeader3.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
  455. this.columnHeader3.Width = 118;
  456. // 
  457. // columnHeader17
  458. // 
  459. this.columnHeader17.Text = "商品单位";
  460. this.columnHeader17.Width = 102;
  461. // 
  462. // columnHeader4
  463. // 
  464. this.columnHeader4.Text = "商品数量";
  465. this.columnHeader4.Width = 125;
  466. // 
  467. // columnHeader5
  468. // 
  469. this.columnHeader5.Text = "商品总价格";
  470. this.columnHeader5.Width = 134;
  471. // 
  472. // oleDbDataAdapter1
  473. // 
  474. this.oleDbDataAdapter1.DeleteCommand = this.oleDbDeleteCommand1;
  475. this.oleDbDataAdapter1.InsertCommand = this.oleDbInsertCommand1;
  476. this.oleDbDataAdapter1.SelectCommand = this.oleDbSelectCommand1;
  477. this.oleDbDataAdapter1.UpdateCommand = this.oleDbUpdateCommand1;
  478. // 
  479. // oleDbConnection1
  480. // 
  481. this.oleDbConnection1.ConnectionString = @"Integrated Security=SSPI;Packet Size=4096;Data Source=MICROSOFTPANG;Tag with column collation when possible=False;Initial Catalog=supershop;Use Procedure for Prepare=1;Auto Translate=True;Persist Security Info=False;Provider=""SQLOLEDB.1"";Workstation ID=MICROSOFTPANG;Use Encryption for Data=False";
  482. // 
  483. // oleDbDataAdapter2
  484. // 
  485. this.oleDbDataAdapter2.SelectCommand = this.oleDbSelectCommand2;
  486. // 
  487. // oleDbSelectCommand2
  488. // 
  489. this.oleDbSelectCommand2.CommandText = "SELECT FROM production";
  490. this.oleDbSelectCommand2.Connection = this.oleDbConnection2;
  491. // 
  492. // oleDbConnection2
  493. // 
  494. this.oleDbConnection2.ConnectionString = @"Integrated Security=SSPI;Packet Size=4096;Data Source=MICROSOFTPANG;Tag with column collation when possible=False;Initial Catalog=supershop;Use Procedure for Prepare=1;Auto Translate=True;Persist Security Info=False;Provider=""SQLOLEDB.1"";Workstation ID=MICROSOFTPANG;Use Encryption for Data=False";
  495. // 
  496. // dataSet11
  497. // 
  498. this.dataSet11.DataSetName = "DataSet1";
  499. this.dataSet11.Locale = new System.Globalization.CultureInfo("zh-CN");
  500. // 
  501. // button3
  502. // 
  503. this.button3.Location = new System.Drawing.Point(344, 288);
  504. this.button3.Name = "button3";
  505. this.button3.TabIndex = 9;
  506. this.button3.Text = "新建销售";
  507. this.button3.Click += new System.EventHandler(this.button3_Click);
  508. // 
  509. // panel1
  510. // 
  511. this.panel1.Controls.Add(this.button6);
  512. this.panel1.Controls.Add(this.button5);
  513. this.panel1.Controls.Add(this.button4);
  514. this.panel1.Controls.Add(this.groupBox1);
  515. this.panel1.Controls.Add(this.listView2);
  516. this.panel1.Location = new System.Drawing.Point(0, 0);
  517. this.panel1.Name = "panel1";
  518. this.panel1.Size = new System.Drawing.Size(728, 360);
  519. this.panel1.TabIndex = 10;
  520. this.panel1.Visible = false;
  521. // 
  522. // button6
  523. // 
  524. this.button6.Location = new System.Drawing.Point(624, 288);
  525. this.button6.Name = "button6";
  526. this.button6.TabIndex = 6;
  527. this.button6.Text = "删除帐户";
  528. this.button6.Click += new System.EventHandler(this.button6_Click);
  529. // 
  530. // button5
  531. // 
  532. this.button5.Location = new System.Drawing.Point(504, 288);
  533. this.button5.Name = "button5";
  534. this.button5.TabIndex = 5;
  535. this.button5.Text = "修改帐户";
  536. this.button5.Click += new System.EventHandler(this.button5_Click);
  537. // 
  538. // button4
  539. // 
  540. this.button4.Location = new System.Drawing.Point(376, 288);
  541. this.button4.Name = "button4";
  542. this.button4.TabIndex = 4;
  543. this.button4.Text = "添加帐户";
  544. this.button4.Click += new System.EventHandler(this.button4_Click);
  545. // 
  546. // groupBox1
  547. // 
  548. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
  549. | System.Windows.Forms.AnchorStyles.Left) 
  550. | System.Windows.Forms.AnchorStyles.Right)));
  551. this.groupBox1.Controls.Add(this.textBox4);
  552. this.groupBox1.Controls.Add(this.textBox3);
  553. this.groupBox1.Controls.Add(this.comboBox1);
  554. this.groupBox1.Controls.Add(this.label5);
  555. this.groupBox1.Controls.Add(this.label4);
  556. this.groupBox1.Controls.Add(this.label3);
  557. this.groupBox1.Location = new System.Drawing.Point(360, 16);
  558. this.groupBox1.Name = "groupBox1";
  559. this.groupBox1.Size = new System.Drawing.Size(352, 344);
  560. this.groupBox1.TabIndex = 3;
  561. this.groupBox1.TabStop = false;
  562. this.groupBox1.Text = "编辑区:";
  563. // 
  564. // textBox4
  565. // 
  566. this.textBox4.Location = new System.Drawing.Point(144, 72);
  567. this.textBox4.Name = "textBox4";
  568. this.textBox4.TabIndex = 7;
  569. this.textBox4.Text = "";
  570. // 
  571. // textBox3
  572. // 
  573. this.textBox3.Location = new System.Drawing.Point(144, 32);
  574. this.textBox3.Name = "textBox3";
  575. this.textBox3.TabIndex = 6;
  576. this.textBox3.Text = "";
  577. // 
  578. // comboBox1
  579. // 
  580. this.comboBox1.Items.AddRange(new object[] {
  581.    "管理人员",
  582.    "销售人员"});
  583. this.comboBox1.Location = new System.Drawing.Point(144, 112);
  584. this.comboBox1.Name = "comboBox1";
  585. this.comboBox1.Size = new System.Drawing.Size(112, 20);
  586. this.comboBox1.TabIndex = 5;
  587. // 
  588. // label5
  589. // 
  590. this.label5.Location = new System.Drawing.Point(32, 112);
  591. this.label5.Name = "label5";
  592. this.label5.TabIndex = 2;
  593. this.label5.Text = "帐号类型:";
  594. this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
  595. // 
  596. // label4
  597. // 
  598. this.label4.Location = new System.Drawing.Point(32, 72);
  599. this.label4.Name = "label4";
  600. this.label4.Size = new System.Drawing.Size(104, 23);
  601. this.label4.TabIndex = 1;
  602. this.label4.Text = "登录密码:";
  603. this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
  604. // 
  605. // label3
  606. // 
  607. this.label3.Location = new System.Drawing.Point(32, 32);
  608. this.label3.Name = "label3";
  609. this.label3.TabIndex = 0;
  610. this.label3.Text = "登录帐号:";
  611. this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
  612. // 
  613. // listView2
  614. // 
  615. this.listView2.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
  616. this.columnHeader9,
  617. this.columnHeader6,
  618. this.columnHeader7,
  619. this.columnHeader8});
  620. this.listView2.FullRowSelect = true;
  621. this.listView2.GridLines = true;
  622. this.listView2.Location = new System.Drawing.Point(16, 16);
  623. this.listView2.Name = "listView2";
  624. this.listView2.Size = new System.Drawing.Size(328, 304);
  625. this.listView2.TabIndex = 2;
  626. this.listView2.View = System.Windows.Forms.View.Details;
  627. this.listView2.SelectedIndexChanged += new System.EventHandler(this.select);
  628. this.listView2.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.ifcheck);
  629. // 
  630. // columnHeader9
  631. // 
  632. this.columnHeader9.Text = "ID";
  633. // 
  634. // columnHeader6
  635. // 
  636. this.columnHeader6.Text = "登录帐号";
  637. this.columnHeader6.Width = 97;
  638. // 
  639. // columnHeader7
  640. // 
  641. this.columnHeader7.Text = "登录密码";
  642. this.columnHeader7.Width = 83;
  643. // 
  644. // columnHeader8
  645. // 
  646. this.columnHeader8.Text = "帐号类型";
  647. this.columnHeader8.Width = 84;
  648. // 
  649. // panel2
  650. // 
  651. this.panel2.Controls.Add(this.button11);
  652. this.panel2.Controls.Add(this.button10);
  653. this.panel2.Controls.Add(this.button9);
  654. this.panel2.Controls.Add(this.groupBox3);
  655. this.panel2.Controls.Add(this.groupBox2);
  656. this.panel2.Controls.Add(this.listView3);
  657. this.panel2.Location = new System.Drawing.Point(0, 0);
  658. this.panel2.Name = "panel2";
  659. this.panel2.Size = new System.Drawing.Size(728, 360);
  660. this.panel2.TabIndex = 11;
  661. this.panel2.Visible = false;
  662. // 
  663. // button11
  664. // 
  665. this.button11.Location = new System.Drawing.Point(640, 320);
  666. this.button11.Name = "button11";
  667. this.button11.TabIndex = 5;
  668. this.button11.Text = "修  改";
  669. this.button11.Click += new System.EventHandler(this.button11_Click);
  670. // 
  671. // button10
  672. // 
  673. this.button10.Location = new System.Drawing.Point(544, 320);
  674. this.button10.Name = "button10";
  675. this.button10.TabIndex = 4;
  676. this.button10.Text = "删  除";
  677. this.button10.Click += new System.EventHandler(this.button10_Click);
  678. // 
  679. // button9
  680. // 
  681. this.button9.Location = new System.Drawing.Point(448, 320);
  682. this.button9.Name = "button9";
  683. this.button9.TabIndex = 3;
  684. this.button9.Text = "添  加";
  685. this.button9.Click += new System.EventHandler(this.button9_Click);
  686. // 
  687. // groupBox3
  688. // 
  689. this.groupBox3.Controls.Add(this.button8);
  690. this.groupBox3.Controls.Add(this.button7);
  691. this.groupBox3.Controls.Add(this.textBox10);
  692. this.groupBox3.Controls.Add(this.label11);
  693. this.groupBox3.Location = new System.Drawing.Point(8, 232);
  694. this.groupBox3.Name = "groupBox3";
  695. this.groupBox3.Size = new System.Drawing.Size(424, 112);
  696. this.groupBox3.TabIndex = 2;
  697. this.groupBox3.TabStop = false;
  698. this.groupBox3.Text = "商品查询";
  699. this.groupBox3.Enter += new System.EventHandler(this.groupBox3_Enter);
  700. // 
  701. // button8
  702. // 
  703. this.button8.Location = new System.Drawing.Point(296, 64);
  704. this.button8.Name = "button8";
  705. this.button8.Size = new System.Drawing.Size(104, 23);
  706. this.button8.TabIndex = 3;
  707. this.button8.Text = "列出所有商品";
  708. this.button8.Click += new System.EventHandler(this.button8_Click);
  709. // 
  710. // button7
  711. // 
  712. this.button7.Location = new System.Drawing.Point(160, 64);
  713. this.button7.Name = "button7";
  714. this.button7.Size = new System.Drawing.Size(104, 23);
  715. this.button7.TabIndex = 2;
  716. this.button7.Text = "查    询";
  717. this.button7.Click += new System.EventHandler(this.button7_Click);
  718. // 
  719. // textBox10
  720. // 
  721. this.textBox10.Location = new System.Drawing.Point(160, 24);
  722. this.textBox10.Name = "textBox10";
  723. this.textBox10.Size = new System.Drawing.Size(248, 21);
  724. this.textBox10.TabIndex = 1;
  725. this.textBox10.Text = "";
  726. // 
  727. // label11
  728. // 
  729. this.label11.Location = new System.Drawing.Point(16, 24);
  730. this.label11.Name = "label11";
  731. this.label11.Size = new System.Drawing.Size(144, 23);
  732. this.label11.TabIndex = 0;
  733. this.label11.Text = "关键字(名称):";
  734. this.label11.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
  735. // 
  736. // groupBox2
  737. // 
  738. this.groupBox2.Controls.Add(this.textBox9);
  739. this.groupBox2.Controls.Add(this.textBox8);
  740. this.groupBox2.Controls.Add(this.textBox7);
  741. this.groupBox2.Controls.Add(this.textBox6);
  742. this.groupBox2.Controls.Add(this.textBox5);
  743. this.groupBox2.Controls.Add(this.label10);
  744. this.groupBox2.Controls.Add(this.label9);
  745. this.groupBox2.Controls.Add(this.label8);
  746. this.groupBox2.Controls.Add(this.label7);
  747. this.groupBox2.Controls.Add(this.label6);
  748. this.groupBox2.Location = new System.Drawing.Point(432, 16);
  749. this.groupBox2.Name = "groupBox2";
  750. this.groupBox2.Size = new System.Drawing.Size(288, 200);
  751. this.groupBox2.TabIndex = 1;
  752. this.groupBox2.TabStop = false;
  753. this.groupBox2.Text = "编辑区";
  754. // 
  755. // textBox9
  756. // 
  757. this.textBox9.Location = new System.Drawing.Point(128, 168);
  758. this.textBox9.Name = "textBox9";
  759. this.textBox9.Size = new System.Drawing.Size(144, 21);
  760. this.textBox9.TabIndex = 9;
  761. this.textBox9.Text = "";
  762. // 
  763. // textBox8
  764. // 
  765. this.textBox8.Location = new System.Drawing.Point(128, 128);
  766. this.textBox8.Name = "textBox8";
  767. this.textBox8.Size = new System.Drawing.Size(144, 21);
  768. this.textBox8.TabIndex = 8;
  769. this.textBox8.Text = "";
  770. // 
  771. // textBox7
  772. // 
  773. this.textBox7.Location = new System.Drawing.Point(128, 96);
  774. this.textBox7.Name = "textBox7";
  775. this.textBox7.Size = new System.Drawing.Size(144, 21);
  776. this.textBox7.TabIndex = 7;
  777. this.textBox7.Text = "";
  778. // 
  779. // textBox6
  780. // 
  781. this.textBox6.Location = new System.Drawing.Point(128, 64);
  782. this.textBox6.Name = "textBox6";
  783. this.textBox6.Size = new System.Drawing.Size(144, 21);
  784. this.textBox6.TabIndex = 6;
  785. this.textBox6.Text = "";
  786. // 
  787. // textBox5
  788. // 
  789. this.textBox5.Location = new System.Drawing.Point(128, 32);
  790. this.textBox5.Name = "textBox5";
  791. this.textBox5.Size = new System.Drawing.Size(144, 21);
  792. this.textBox5.TabIndex = 5;
  793. this.textBox5.Text = "";
  794. // 
  795. // label10
  796. // 
  797. this.label10.Location = new System.Drawing.Point(16, 168);
  798. this.label10.Name = "label10";
  799. this.label10.TabIndex = 4;
  800. this.label10.Text = "库存:";
  801. this.label10.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
  802. // 
  803. // label9
  804. // 
  805. this.label9.Location = new System.Drawing.Point(16, 128);
  806. this.label9.Name = "label9";
  807. this.label9.TabIndex = 3;
  808. this.label9.Text = "货架:";
  809. this.label9.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
  810. // 
  811. // label8
  812. // 
  813. this.label8.Location = new System.Drawing.Point(16, 96);
  814. this.label8.Name = "label8";
  815. this.label8.TabIndex = 2;
  816. this.label8.Text = "单位:";
  817. this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
  818. // 
  819. // label7
  820. // 
  821. this.label7.Location = new System.Drawing.Point(16, 64);
  822. this.label7.Name = "label7";
  823. this.label7.TabIndex = 1;
  824. this.label7.Text = "单价:";
  825. this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
  826. // 
  827. // label6
  828. // 
  829. this.label6.Location = new System.Drawing.Point(16, 32);
  830. this.label6.Name = "label6";
  831. this.label6.TabIndex = 0;
  832. this.label6.Text = "名称:";
  833. this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
  834. // 
  835. // listView3
  836. // 
  837. this.listView3.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
  838. this.columnHeader10,
  839. this.columnHeader11,
  840. this.columnHeader12,
  841. this.columnHeader13,
  842. this.columnHeader14,
  843. this.columnHeader15,
  844. this.columnHeader16});
  845. this.listView3.FullRowSelect = true;
  846. this.listView3.GridLines = true;
  847. this.listView3.Location = new System.Drawing.Point(8, 8);
  848. this.listView3.Name = "listView3";
  849. this.listView3.Size = new System.Drawing.Size(424, 208);
  850. this.listView3.TabIndex = 0;
  851. this.listView3.View = System.Windows.Forms.View.Details;
  852. this.listView3.SelectedIndexChanged += new System.EventHandler(this.v3select);
  853. // 
  854. // columnHeader10
  855. // 
  856. this.columnHeader10.Text = "编号";
  857. // 
  858. // columnHeader11
  859. // 
  860. this.columnHeader11.Text = "名称";
  861. // 
  862. // columnHeader12
  863. // 
  864. this.columnHeader12.Text = "单价";
  865. // 
  866. // columnHeader13
  867. // 
  868. this.columnHeader13.Text = "单位";
  869. // 
  870. // columnHeader14
  871. // 
  872. this.columnHeader14.Text = "货架号";
  873. // 
  874. // columnHeader15
  875. // 
  876. this.columnHeader15.Text = "库存";
  877. // 
  878. // columnHeader16
  879. // 
  880. this.columnHeader16.Text = "销量";
  881. // 
  882. // myConnection2
  883. // 
  884. this.myConnection2.ConnectionString = "workstation id=MICROSOFTPANG;packet size=4096;integrated security=SSPI;data sourc" +
  885. "e=MICROSOFTPANG;persist security info=False;initial catalog=supershop";
  886. // 
  887. // floglb
  888. // 
  889. this.floglb.Location = new System.Drawing.Point(608, 320);
  890. this.floglb.Name = "floglb";
  891. this.floglb.TabIndex = 12;
  892. this.floglb.Visible = false;
  893. // 
  894. // button12
  895. // 
  896. this.button12.Location = new System.Drawing.Point(528, 288);
  897. this.button12.Name = "button12";
  898. this.button12.TabIndex = 13;
  899. this.button12.Text = "删  除";
  900. this.button12.Visible = false;
  901. this.button12.Click += new System.EventHandler(this.button12_Click);
  902. // 
  903. // Form1
  904. // 
  905. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  906. this.ClientSize = new System.Drawing.Size(728, 377);
  907. this.Controls.Add(this.panel2);
  908. this.Controls.Add(this.panel1);
  909. this.Controls.Add(this.listView1);
  910. this.Controls.Add(this.button2);
  911. this.Controls.Add(this.button1);
  912. this.Controls.Add(this.textBox2);
  913. this.Controls.Add(this.textBox1);
  914. this.Controls.Add(this.label2);
  915. this.Controls.Add(this.label1);
  916. this.Controls.Add(this.statusBar1);
  917. this.Controls.Add(this.button3);
  918. this.Controls.Add(this.floglb);
  919. this.Controls.Add(this.button12);
  920. this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
  921. this.Menu = this.mainMenu1;
  922. this.Name = "Form1";
  923. this.Text = "橙子超市管理系统";
  924. this.Load += new System.EventHandler(this.Form1_Load);
  925. ((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
  926. this.panel1.ResumeLayout(false);
  927. this.groupBox1.ResumeLayout(false);
  928. this.panel2.ResumeLayout(false);
  929. this.groupBox3.ResumeLayout(false);
  930. this.groupBox2.ResumeLayout(false);
  931. this.ResumeLayout(false);
  932. }
  933. #endregion
  934. /// <summary>
  935. /// 应用程序的主入口点。
  936. /// </summary>
  937. [STAThread]
  938. static void Main() 
  939. {
  940. Application.Run(new Form1());
  941. }
  942. private void Form1_Load(object sender, System.EventArgs e)
  943. {
  944.     supershop2.Form2 f2=new supershop2.Form2();
  945. //f2.Visible=true;
  946. f2.ShowDialog();
  947. this.statusBar1.Text=name;
  948. if(isman=="no")
  949. {
  950. this.menuItem6.Enabled=false;
  951. this.menuItem7.Enabled=false;
  952.                 this.menuItem8.Enabled=false;
  953. }
  954. else
  955. {
  956. this.menuItem6.Enabled=true;
  957. this.menuItem7.Enabled=true;
  958. this.menuItem8.Enabled=true;
  959. }
  960. //this.Visible=false;
  961. }
  962. private void button1_Click(object sender, System.EventArgs e)
  963. {
  964. string pid=textBox1.Text;
  965. double solett=Convert.ToDouble(textBox2.Text);
  966. string ss="select * from production where pid="+pid+"";
  967. this.oleDbDataAdapter1.SelectCommand.CommandText=ss;
  968. this.oleDbDataAdapter1.SelectCommand.Connection=this.oleDbConnection1;
  969. //打开数据库连接
  970. this.oleDbConnection1.Open();
  971. System.Data.OleDb.OleDbDataReader MyReader=this.oleDbDataAdapter1.SelectCommand.ExecuteReader();
  972. this.listView1.View=View.Details;
  973. MyReader.Read();
  974. string pname,price;
  975. double kucun,soled;
  976. //kucun=MyReader.GetValue(5).ToString();
  977. //soled=MyReader.GetValue(6).ToString();
  978.             double allp;
  979. try
  980. {
  981. pname=MyReader.GetValue(1).ToString();
  982. price=MyReader.GetValue(2).ToString();
  983. kucun=Convert.ToDouble(MyReader.GetValue(5).ToString())-Convert.ToDouble(textBox2.Text);
  984. soled=Convert.ToDouble(MyReader.GetValue(6).ToString())+Convert.ToDouble(textBox2.Text);
  985. allp=Convert.ToDouble(price) * solett;
  986. allp=Math.Round(allp,2);
  987. ListViewItem MyItem=new ListViewItem();
  988. MyItem.Text=MyReader.GetValue(0).ToString();
  989. for(int j=0;j<MyReader.FieldCount-4;j++)
  990. MyItem.SubItems.Add(MyReader.GetValue(j+1).ToString());
  991. /*int b=MyReader.GetInt32(3);
  992. double c=a*b;
  993. string ff=c.ToString();
  994. MyItem.SubItems.Add(ff);*/
  995. MyItem.SubItems.Add(textBox2.Text);
  996.     MyItem.SubItems.Add(allp.ToString());
  997. this.listView1.Items.Add(MyItem);
  998. MyReader.Close();
  999. this.oleDbConnection1.Close();
  1000. }
  1001. catch
  1002. {
  1003. MyReader.Close();
  1004. this.oleDbConnection1.Close();
  1005. MessageBox.Show(this,"商品不存在!");
  1006. return;
  1007. }
  1008. //for(int i=0;i<MyReader.FieldCount-1;i++)
  1009. //{
  1010. //this.listView1.Columns.Add(MyReader.GetName(i),100,HorizontalAlignment.Left);
  1011. //}
  1012. /*while(MyReader.Read())
  1013. {
  1014. ListViewItem MyItem=new ListViewItem();
  1015. MyItem.Text=MyReader.GetValue(0).ToString();
  1016. for(int j=0;j<MyReader.FieldCount-1;j++)
  1017. MyItem.SubItems.Add(MyReader.GetValue(j+1).ToString());
  1018. this.listView1.Items.Add(MyItem);
  1019. }*/
  1020. //关闭连接
  1021. //textBox1.Text=price.ToString();
  1022. this.oleDbConnection1.Close();
  1023. /*this.sqlConnection1.Open();
  1024. int solett=2;
  1025. float allp=2.0f;
  1026. string insert_soled="insert into soled(pid,pname,price,solett,allp)values("+pid+",""+pname+"","+price+","+solett+","+allp+")";
  1027. this.sqlCommand1.CommandText=insert_soled;
  1028.             this.sqlCommand1.Connection=this.sqlConnection1;
  1029. this.sqlCommand1.ExecuteNonQuery();
  1030. this.sqlConnection1.Close();
  1031. this.sqlDataAdapter1.Fill(this.dataSet11,"soled");*/
  1032. //SqlConnection myConnection;
  1033. //myConnection = new SqlConnection("server=(MICROSOFTPANG);database=supershop;Trusted_Connection=yes");*/
  1034.             //DateTimePicker NowTime = new DateTimePicker();
  1035. //string Now_Time=NowTime.Value.ToLongDateString().ToString();
  1036. //Now_Time+=NowTime.Value.ToLongTimeString().ToString();
  1037. string insertCmd = "insert into soled(pid,solett,allp,sallflog)values(@pid, @solett, @allp,@sallflog)";
  1038. SqlCommand myCommand = new SqlCommand(insertCmd, myConnection);
  1039. myCommand.Parameters.Add(new SqlParameter("@pid", SqlDbType.Int, 4));
  1040. myCommand.Parameters["@pid"].Value = pid;
  1041. //myCommand.Parameters.Add(new SqlParameter("@pname", SqlDbType.NVarChar, 20));
  1042. //myCommand.Parameters["@pname"].Value = pname;
  1043. //myCommand.Parameters.Add(new SqlParameter("@price", SqlDbType.Float, 8));
  1044. //myCommand.Parameters["@price"].Value = price;
  1045. myCommand.Parameters.Add(new SqlParameter("@solett", SqlDbType.Int, 4));
  1046. myCommand.Parameters["@solett"].Value = solett;
  1047. myCommand.Parameters.Add(new SqlParameter("@allp", SqlDbType.Float, 8));
  1048. myCommand.Parameters["@allp"].Value = allp;
  1049. myCommand.Parameters.Add(new SqlParameter("@sallflog", SqlDbType.Int, 4));
  1050. myCommand.Parameters["@sallflog"].Value = floglb.Text;
  1051. myCommand.Connection.Open();
  1052. try 
  1053. {
  1054. myCommand.ExecuteNonQuery();
  1055. myCommand.Connection.Close();
  1056. }
  1057. catch (SqlException ex)
  1058. {
  1059. MessageBox.Show("插入数据错误! " + ex.Message.ToString());
  1060. myCommand.Connection.Close();
  1061. return;
  1062. }
  1063. string upprice="update production set kucun="+kucun+",soled="+soled+" where pid="+pid+"";
  1064. SqlCommand myCommand2 = new SqlCommand(upprice, myConnection);
  1065. myCommand2.Connection.Open();
  1066. try 
  1067. {
  1068. myCommand2.ExecuteNonQuery();
  1069. myCommand2.Connection.Close();
  1070. }
  1071. catch (SqlException ex)
  1072. {
  1073. MessageBox.Show("库存销售数据错误! " + ex.Message.ToString());
  1074. myCommand2.Connection.Close();
  1075. return;
  1076. }
  1077. }
  1078. private void button3_Click(object sender, System.EventArgs e)
  1079. {
  1080. textBox1.Text="";
  1081. textBox2.Text="";
  1082. listView1.Items.Clear();
  1083. DateTimePicker NowTime = new DateTimePicker();
  1084. string Now_Time=NowTime.Value.ToLongDateString().ToString();
  1085. Now_Time+=NowTime.Value.ToLongTimeString().ToString();
  1086.         //string sname=statusBar1.Text;
  1087. //sname为登录人的姓名
  1088.  string sname=this.statusBar1.Text;
  1089. string insall="insert into slist (stime,sname)values(@stime,@sname)";
  1090. SqlCommand myCommand = new SqlCommand(insall, myConnection);
  1091. myCommand.Parameters.Add(new SqlParameter("@stime", SqlDbType.NVarChar, 30));
  1092. myCommand.Parameters["@stime"].Value = Now_Time;
  1093. myCommand.Parameters.Add(new SqlParameter("@sname", SqlDbType.NVarChar, 20));
  1094. myCommand.Parameters["@sname"].Value = sname;
  1095.             myCommand.Connection.Open();
  1096. ///////////////////////////
  1097. string slt="select sallid from slist where sname=@sname order by sallid desc";
  1098. SqlCommand myCommand2 = new SqlCommand(slt, myConnection2);
  1099. myCommand2.Parameters.Add(new SqlParameter("@sname", SqlDbType.NVarChar, 20));
  1100. myCommand2.Parameters["@sname"].Value = sname;
  1101. myCommand2.Connection.Open();
  1102. try 
  1103. {
  1104. myCommand.ExecuteNonQuery();
  1105. floglb.Text=myCommand2.ExecuteScalar().ToString();
  1106. button1.Visible=true;
  1107. button2.Visible=true;
  1108. button12.Visible=true;
  1109. myCommand.Connection.Close();
  1110. myCommand2.Connection.Close();
  1111. MessageBox.Show("新建销售成功!");
  1112. }
  1113. catch (SqlException ex)
  1114. {
  1115. myCommand.Connection.Close();
  1116.                 myCommand2.Connection.Close();
  1117. MessageBox.Show("新建销售错误! " + ex.Message.ToString());
  1118. return;
  1119. }
  1120. }
  1121. private void menuItem4_Click(object sender, System.EventArgs e)
  1122. {
  1123. Application.Exit();
  1124. }
  1125. private void menuItem3_Click(object sender, System.EventArgs e)
  1126. {
  1127. panel2.Visible=false;
  1128. panel1.Visible=false;
  1129. this.Enabled=false;
  1130. supershop2.Form2 f2=new supershop2.Form2();
  1131. f2.ShowDialog();
  1132. this.statusBar1.Text=name;
  1133. this.Enabled=true;
  1134. if(isman=="no")
  1135. {
  1136. this.menuItem6.Enabled=false;
  1137. this.menuItem7.Enabled=false;
  1138. this.menuItem8.Enabled=false;
  1139. }
  1140. else
  1141. {
  1142. this.menuItem6.Enabled=true;
  1143. this.menuItem7.Enabled=true;
  1144. this.menuItem8.Enabled=true;
  1145. }
  1146. //this.Visible=false;
  1147. }
  1148. private void menuItem12_Click(object sender, System.EventArgs e)
  1149. {
  1150. Form3 f3=new Form3();
  1151. f3.Text="关于橙子";
  1152. f3.ShowDialog();
  1153. }
  1154. private void menuItem6_Click(object sender, System.EventArgs e)
  1155. {
  1156. Form4 f4=new Form4();
  1157. f4.ShowDialog();
  1158. }
  1159. private void menuItem10_Click(object sender, System.EventArgs e)
  1160. {
  1161. panel1.Visible=true;
  1162. panel2.Visible=false;
  1163. string str="select * from login";
  1164. this.oleDbDataAdapter1.SelectCommand.CommandText=str;
  1165. this.oleDbDataAdapter1.SelectCommand.Connection=this.oleDbConnection1;
  1166. //打开数据库连接
  1167. this.oleDbConnection1.Open();
  1168. System.Data.OleDb.OleDbDataReader MyReader=this.oleDbDataAdapter1.SelectCommand.ExecuteReader();
  1169. //this.listView1.View=View.Details;
  1170. try
  1171. {
  1172.     this.listView2.Items.Clear();
  1173. while(MyReader.Read())
  1174. {
  1175. ListViewItem MyItem=new ListViewItem();
  1176. MyItem.Text=MyReader.GetValue(0).ToString();
  1177. for(int j=0;j<MyReader.FieldCount-2;j++)
  1178. MyItem.SubItems.Add(MyReader.GetValue(j+1).ToString());
  1179. string flog=MyReader.GetValue(MyReader.FieldCount-1).ToString();
  1180. switch(flog)
  1181. {
  1182. case "yes":MyItem.SubItems.Add("管理人员");break;
  1183. case "no":MyItem.SubItems.Add("销售人员");break;
  1184. }
  1185. this.listView2.Items.Add(MyItem);
  1186. }
  1187. MyReader.Close();
  1188. this.oleDbConnection1.Close();
  1189. }
  1190. catch
  1191. {
  1192. MessageBox.Show(this,"帐户不存在!");
  1193. MyReader.Close();
  1194. this.oleDbConnection1.Close();
  1195. return;
  1196. }
  1197. }
  1198. private void menuItem5_Click(object sender, System.EventArgs e)
  1199. {
  1200. panel1.Visible=false;
  1201. panel2.Visible=false;
  1202. textBox1.Text="";
  1203. textBox2.Text="";
  1204. listView1.Items.Clear();
  1205.          
  1206. }
  1207. private void ifcheck(object sender, System.Windows.Forms.ItemCheckEventArgs e)
  1208. {
  1209. }
  1210. private void select(object sender, System.EventArgs e)
  1211. {
  1212. string j;
  1213. for(int i=this.listView2.SelectedItems.Count-1; i>=0;i--)
  1214. {
  1215. ListViewItem item = this.listView2.SelectedItems[i];
  1216. j=item.Text;
  1217. //j=this.listView2.Items.Add;
  1218. string str="select * from login where id="+j+"";
  1219. this.oleDbDataAdapter1.SelectCommand.CommandText=str;
  1220. this.oleDbDataAdapter1.SelectCommand.Connection=this.oleDbConnection1;
  1221. //打开数据库连接
  1222. this.oleDbConnection1.Open();
  1223. System.Data.OleDb.OleDbDataReader MyReader=this.oleDbDataAdapter1.SelectCommand.ExecuteReader();
  1224. MyReader.Read();
  1225. groupBox1.Text=MyReader.GetValue(0).ToString();
  1226. textBox3.Text=MyReader.GetValue(1).ToString();
  1227. textBox4.Text=MyReader.GetValue(2).ToString();
  1228. switch(MyReader.GetValue(3).ToString())
  1229. {
  1230. case "yes":comboBox1.Text="管理人员";break;
  1231. case "no":comboBox1.Text="销售人员";break;
  1232. }
  1233. MyReader.Close();
  1234. this.oleDbConnection1.Close();
  1235. }
  1236. }
  1237. private void button6_Click(object sender, System.EventArgs e)
  1238. {
  1239. ListViewItem item1 = this.listView2.SelectedItems[0];
  1240. //textBox3.Text=item1.Text;
  1241. for(int i=this.listView2.SelectedItems.Count-1; i>=0;i--)
  1242. {
  1243. ListViewItem item = this.listView2.SelectedItems[i];
  1244. this.listView2.Items.Remove(item);
  1245. string uflog=item.Text;
  1246. string deletesql="delete from login where id="+uflog+"";
  1247.                 SqlCommand myCommand = new SqlCommand(deletesql, myConnection);
  1248. myCommand.Connection.Open();
  1249. try 
  1250. {
  1251. myCommand.ExecuteNonQuery();
  1252. myCommand.Connection.Close();
  1253. MessageBox.Show("删除数据成功! ");
  1254. }
  1255. catch (SqlException ex)
  1256. {
  1257. MessageBox.Show("删除数据错误! " + ex.Message.ToString());
  1258. myCommand.Connection.Close();
  1259. return;
  1260. }
  1261. }
  1262.             
  1263. }
  1264. private void button5_Click(object sender, System.EventArgs e)
  1265. {
  1266. string pname,pwd,ismanage;
  1267. pname=textBox3.Text;
  1268. pwd=textBox4.Text;
  1269. switch(comboBox1.Text)
  1270. {
  1271. case"管理人员":ismanage="yes";break;
  1272. case"销售人员":ismanage="no";break;
  1273. default:
  1274. return;
  1275. }
  1276. string updatesql="update login set uname=@pname,pwd=@pwd,ismanage=@ismanage where id=@id";
  1277.  SqlCommand myCommand = new SqlCommand(updatesql, myConnection);
  1278. myCommand.Parameters.Add(new SqlParameter("@id", SqlDbType.NVarChar, 20));
  1279. myCommand.Parameters["@id"].Value = groupBox1.Text;
  1280. myCommand.Parameters.Add(new SqlParameter("@pname", SqlDbType.NVarChar, 20));
  1281. myCommand.Parameters["@pname"].Value = textBox3.Text;
  1282. myCommand.Parameters.Add(new SqlParameter("@pwd", SqlDbType.NVarChar, 20));
  1283. myCommand.Parameters["@pwd"].Value = textBox4.Text;
  1284. myCommand.Parameters.Add(new SqlParameter("@ismanage", SqlDbType.NVarChar, 3));
  1285. myCommand.Parameters["@ismanage"].Value = ismanage;
  1286. myCommand.Connection.Open();
  1287. try 
  1288. {
  1289. myCommand.ExecuteNonQuery();
  1290. //listView2.Select();
  1291. //listView2.Refresh();
  1292. MessageBox.Show("修改数据成功! ");
  1293. myCommand.Connection.Close();
  1294. }
  1295. catch (SqlException ex)
  1296. {
  1297. MessageBox.Show("修改数据错误! " + ex.Message.ToString());
  1298. myCommand.Connection.Close();
  1299. return;
  1300. }
  1301. string str="select * from login";
  1302. this.oleDbDataAdapter1.SelectCommand.CommandText=str;
  1303. this.oleDbDataAdapter1.SelectCommand.Connection=this.oleDbConnection1;
  1304. //打开数据库连接
  1305. this.oleDbConnection1.Open();
  1306. System.Data.OleDb.OleDbDataReader MyReader=this.oleDbDataAdapter1.SelectCommand.ExecuteReader();
  1307. //this.listView1.View=View.Details;
  1308. try
  1309. {
  1310. this.listView2.Items.Clear();
  1311. while(MyReader.Read())
  1312. {
  1313. ListViewItem MyItem=new ListViewItem();
  1314. MyItem.Text=MyReader.GetValue(0).ToString();
  1315. for(int j=0;j<MyReader.FieldCount-2;j++)
  1316. MyItem.SubItems.Add(MyReader.GetValue(j+1).ToString());
  1317. string flog=MyReader.GetValue(MyReader.FieldCount-1).ToString();
  1318. switch(flog)
  1319. {
  1320. case "yes":MyItem.SubItems.Add("管理人员");break;
  1321. case "no":MyItem.SubItems.Add("销售人员");break;
  1322. }
  1323. this.listView2.Items.Add(MyItem);
  1324. }
  1325. MyReader.Close();
  1326. this.oleDbConnection1.Close();
  1327. }
  1328. catch
  1329. {
  1330. MessageBox.Show(this,"帐户不存在!");
  1331. MyReader.Close();
  1332. this.oleDbConnection1.Close();
  1333. return;
  1334. }
  1335. }
  1336. private void button4_Click(object sender, System.EventArgs e)
  1337. {
  1338. string ismasage;
  1339. switch(comboBox1.Text)
  1340. {
  1341. case"管理人员":ismasage="yes";break;
  1342. case"销售人员":ismasage="no";break;
  1343. default:
  1344. return;
  1345. }
  1346. string insertsql="insert into login (uname,pwd,ismanage)values(@pname,@pwd,@ismanage)";
  1347. SqlCommand myCommand=new SqlCommand(insertsql,myConnection);
  1348. myCommand.Parameters.Add(new SqlParameter("@pname", SqlDbType.NVarChar, 20));
  1349. myCommand.Parameters["@pname"].Value = textBox3.Text;
  1350. myCommand.Parameters.Add(new SqlParameter("@pwd", SqlDbType.NVarChar, 20));
  1351. myCommand.Parameters["@pwd"].Value = textBox4.Text;
  1352. myCommand.Parameters.Add(new SqlParameter("@ismanage", SqlDbType.NVarChar, 3));
  1353. myCommand.Parameters["@ismanage"].Value = ismasage;
  1354. myCommand.Connection.Open();
  1355. try 
  1356. {
  1357. myCommand.ExecuteNonQuery();
  1358. //listView2.Select();
  1359. //listView2.Refresh();
  1360. myCommand.Connection.Close();
  1361. MessageBox.Show("插入数据成功! ");
  1362. }
  1363. catch (SqlException ex)
  1364. {
  1365. MessageBox.Show("插入数据错误! " + ex.Message.ToString());
  1366. myCommand.Connection.Close();
  1367. return;
  1368. }
  1369. string str="select * from login";
  1370. this.oleDbDataAdapter1.SelectCommand.CommandText=str;
  1371. this.oleDbDataAdapter1.SelectCommand.Connection=this.oleDbConnection1;
  1372. //打开数据库连接
  1373. this.oleDbConnection1.Open();
  1374. System.Data.OleDb.OleDbDataReader MyReader=this.oleDbDataAdapter1.SelectCommand.ExecuteReader();
  1375. //this.listView1.View=View.Details;
  1376. try
  1377. {
  1378. this.listView2.Items.Clear();
  1379. while(MyReader.Read())
  1380. {
  1381. ListViewItem MyItem=new ListViewItem();
  1382. MyItem.Text=MyReader.GetValue(0).ToString();
  1383. for(int j=0;j<MyReader.FieldCount-2;j++)
  1384. MyItem.SubItems.Add(MyReader.GetValue(j+1).ToString());
  1385. string flog=MyReader.GetValue(MyReader.FieldCount-1).ToString();
  1386. switch(flog)
  1387. {
  1388. case "yes":MyItem.SubItems.Add("管理人员");break;
  1389. case "no":MyItem.SubItems.Add("销售人员");break;
  1390. }
  1391. this.listView2.Items.Add(MyItem);
  1392. }
  1393. MyReader.Close();
  1394. this.oleDbConnection1.Close();
  1395. }
  1396. catch
  1397. {
  1398. MessageBox.Show(this,"帐户不存在!");
  1399. MyReader.Close();
  1400. this.oleDbConnection1.Close();
  1401. return;
  1402. }
  1403. }
  1404. private void menuItem9_Click(object sender, System.EventArgs e)
  1405. {
  1406. textBox10.Text="";
  1407. panel1.Visible=false;
  1408. panel2.Visible=true;
  1409. string production="select * from production";
  1410. this.oleDbDataAdapter1.SelectCommand.CommandText=production;
  1411. this.oleDbDataAdapter1.SelectCommand.Connection=this.oleDbConnection1;
  1412. //打开数据库连接
  1413. this.oleDbConnection1.Open();
  1414. System.Data.OleDb.OleDbDataReader MyReader2=this.oleDbDataAdapter1.SelectCommand.ExecuteReader();
  1415. //this.listView1.View=View.Details;
  1416. try
  1417. {
  1418. this.listView3.Items.Clear();
  1419. while(MyReader2.Read())
  1420. {
  1421. ListViewItem MyItem=new ListViewItem();
  1422. MyItem.Text=MyReader2.GetValue(0).ToString();
  1423. for(int j=0;j<MyReader2.FieldCount-1;j++)
  1424. MyItem.SubItems.Add(MyReader2.GetValue(j+1).ToString());
  1425. string flog=MyReader2.GetValue(MyReader2.FieldCount-1).ToString();
  1426. this.listView3.Items.Add(MyItem);
  1427. }
  1428. MyReader2.Close();
  1429. this.oleDbConnection1.Close();
  1430. }
  1431. catch
  1432. {
  1433. MessageBox.Show(this,"帐户不存在!");
  1434. MyReader2.Close();
  1435. this.oleDbConnection1.Close();
  1436. return;
  1437. }
  1438. private void v3select(object sender, System.EventArgs e)
  1439. {
  1440. string j;
  1441. for(int i=this.listView3.SelectedItems.Count-1; i>=0;i--)
  1442. {
  1443. ListViewItem item = this.listView3.SelectedItems[i];
  1444. j=item.Text;
  1445. //j=this.listView2.Items.Add;
  1446. string str="select * from production where pid="+j+"";
  1447. this.oleDbDataAdapter1.SelectCommand.CommandText=str;
  1448. this.oleDbDataAdapter1.SelectCommand.Connection=this.oleDbConnection1;
  1449. //打开数据库连接
  1450. this.oleDbConnection1.Open();
  1451. System.Data.OleDb.OleDbDataReader MyReader=this.oleDbDataAdapter1.SelectCommand.ExecuteReader();
  1452. MyReader.Read();
  1453. groupBox2.Text=MyReader.GetValue(0).ToString();
  1454. textBox5.Text=MyReader.GetValue(1).ToString();
  1455. textBox6.Text=MyReader.GetValue(2).ToString();
  1456. textBox7.Text=MyReader.GetValue(3).ToString();
  1457. textBox8.Text=MyReader.GetValue(4).ToString();
  1458. textBox9.Text=MyReader.GetValue(5).ToString();
  1459. MyReader.Close();
  1460. this.oleDbConnection1.Close();
  1461. }
  1462. }
  1463. private void button7_Click(object sender, System.EventArgs e)
  1464. {
  1465. string pkey=textBox10.Text;
  1466. string selectp="select * from production where pname like '%"+pkey+"%'";
  1467. this.oleDbDataAdapter1.SelectCommand.CommandText=selectp;
  1468. this.oleDbDataAdapter1.SelectCommand.Connection=this.oleDbConnection1;
  1469. //打开数据库连接
  1470. this.oleDbConnection1.Open();
  1471. System.Data.OleDb.OleDbDataReader MyReader=this.oleDbDataAdapter1.SelectCommand.ExecuteReader();
  1472. this.listView3.Items.Clear();
  1473. try
  1474. {
  1475. while(MyReader.Read())
  1476. {
  1477. groupBox2.Text=MyReader.GetValue(0).ToString();
  1478. textBox5.Text=MyReader.GetValue(1).ToString();
  1479. textBox6.Text=MyReader.GetValue(2).ToString();
  1480. textBox7.Text=MyReader.GetValue(3).ToString();
  1481. textBox8.Text=MyReader.GetValue(4).ToString();
  1482. textBox9.Text=MyReader.GetValue(5).ToString();
  1483. ListViewItem MyItem=new ListViewItem();
  1484. MyItem.Text=MyReader.GetValue(0).ToString();
  1485. for(int j=0;j<MyReader.FieldCount-1;j++)
  1486. MyItem.SubItems.Add(MyReader.GetValue(j+1).ToString());
  1487. /*int b=MyReader.GetInt32(3);
  1488. double c=a*b;
  1489. string ff=c.ToString();
  1490. MyItem.SubItems.Add(ff);*/
  1491. //MyItem.SubItems.Add(textBox2.Text);
  1492. //MyItem.SubItems.Add(allp.ToString());
  1493.                 
  1494. this.listView3.Items.Add(MyItem);
  1495. }
  1496. MyReader.Close();
  1497. this.oleDbConnection1.Close();
  1498. }
  1499. catch
  1500. {
  1501. MessageBox.Show(this,"商品不存在!");
  1502. this.oleDbConnection1.Close();
  1503. return;
  1504. }
  1505. }
  1506. private void button8_Click(object sender, System.EventArgs e)
  1507. {
  1508.     textBox10.Text="";
  1509. string production="select * from production";
  1510. this.oleDbDataAdapter1.SelectCommand.CommandText=production;
  1511. this.oleDbDataAdapter1.SelectCommand.Connection=this.oleDbConnection1;
  1512. //打开数据库连接
  1513. this.oleDbConnection1.Open();
  1514. System.Data.OleDb.OleDbDataReader MyReader2=this.oleDbDataAdapter1.SelectCommand.ExecuteReader();
  1515. //this.listView1.View=View.Details;
  1516. try
  1517. {
  1518. this.listView3.Items.Clear();
  1519. while(MyReader2.Read())
  1520. {
  1521. ListViewItem MyItem=new ListViewItem();
  1522. MyItem.Text=MyReader2.GetValue(0).ToString();
  1523. for(int j=0;j<MyReader2.FieldCount-1;j++)
  1524. MyItem.SubItems.Add(MyReader2.GetValue(j+1).ToString());
  1525. string flog=MyReader2.GetValue(MyReader2.FieldCount-1).ToString();
  1526. this.listView3.Items.Add(MyItem);
  1527. }
  1528. MyReader2.Close();
  1529. this.oleDbConnection1.Close();
  1530. }
  1531. catch
  1532. {
  1533. MyReader2.Close();
  1534. this.oleDbConnection1.Close();
  1535. MessageBox.Show(this,"帐户不存在!");
  1536. }
  1537. private void button9_Click(object sender, System.EventArgs e)
  1538. {
  1539. textBox10.Text="";
  1540. string insertCmd = "insert into production(pname,price,unit,huojia,kucun)values( @pname, @price, @unit, @huojia,@kucun)";
  1541. SqlCommand myCommand = new SqlCommand(insertCmd, myConnection);
  1542. myCommand.Parameters.Add(new SqlParameter("@pname", SqlDbType.NVarChar, 20));
  1543. myCommand.Parameters["@pname"].Value = textBox5.Text;
  1544. myCommand.Parameters.Add(new SqlParameter("@price", SqlDbType.Float, 8));
  1545. myCommand.Parameters["@price"].Value = textBox6.Text;
  1546. myCommand.Parameters.Add(new SqlParameter("@unit", SqlDbType.NVarChar, 3));
  1547. myCommand.Parameters["@unit"].Value = textBox7.Text;
  1548. myCommand.Parameters.Add(new SqlParameter("@huojia", SqlDbType.NVarChar, 3));
  1549. myCommand.Parameters["@huojia"].Value = textBox8.Text;
  1550. myCommand.Parameters.Add(new SqlParameter("@kucun", SqlDbType.Int, 4));
  1551. myCommand.Parameters["@kucun"].Value = textBox9.Text;
  1552. myCommand.Connection.Open();
  1553. try 
  1554. {
  1555. //this.menuItem9_Click(button9,e);
  1556. myCommand.ExecuteNonQuery();
  1557. MessageBox.Show("插入数据成功! ");
  1558. }
  1559. catch (SqlException ex)
  1560. {
  1561. MessageBox.Show("插入数据错误! " + ex.Message.ToString());
  1562. }
  1563. myCommand.Connection.Close();
  1564. string production="select * from production";
  1565. this.oleDbDataAdapter1.SelectCommand.CommandText=production;
  1566. this.oleDbDataAdapter1.SelectCommand.Connection=this.oleDbConnection1;
  1567. //打开数据库连接
  1568. this.oleDbConnection1.Open();
  1569. System.Data.OleDb.OleDbDataReader MyReader2=this.oleDbDataAdapter1.SelectCommand.ExecuteReader();
  1570. //this.listView1.View=View.Details;
  1571. try
  1572. {
  1573. this.listView3.Items.Clear();
  1574. while(MyReader2.Read())
  1575. {
  1576. ListViewItem MyItem=new ListViewItem();
  1577. MyItem.Text=MyReader2.GetValue(0).ToString();
  1578. for(int j=0;j<MyReader2.FieldCount-1;j++)
  1579. MyItem.SubItems.Add(MyReader2.GetValue(j+1).ToString());
  1580. string flog=MyReader2.GetValue(MyReader2.FieldCount-1).ToString();
  1581. this.listView3.Items.Add(MyItem);
  1582. }
  1583. MyReader2.Close();
  1584. this.oleDbConnection1.Close();
  1585. }
  1586. catch
  1587. {
  1588. MessageBox.Show(this,"帐户不存在!");
  1589. MyReader2.Close();
  1590. this.oleDbConnection1.Close();
  1591. return;
  1592. }
  1593. private void button10_Click(object sender, System.EventArgs e)
  1594. {
  1595. ListViewItem item1 = this.listView3.SelectedItems[0];
  1596. //textBox3.Text=item1.Text;
  1597. for(int i=this.listView3.SelectedItems.Count-1; i>=0;i--)
  1598. {
  1599. ListViewItem item = this.listView3.SelectedItems[i];
  1600. this.listView3.Items.Remove(item);
  1601. string pflog=item.Text;
  1602. string deletesql="delete from production where pid="+pflog+"";
  1603. SqlCommand myCommand = new SqlCommand(deletesql, myConnection);
  1604. myCommand.Connection.Open();
  1605. try 
  1606. {
  1607. myCommand.ExecuteNonQuery();
  1608. MessageBox.Show("删除数据成功! ");
  1609. }
  1610. catch (SqlException ex)
  1611. {
  1612. MessageBox.Show("删除数据错误! " + ex.Message.ToString());
  1613. }
  1614. myCommand.Connection.Close();
  1615. }
  1616. }
  1617. private void button11_Click(object sender, System.EventArgs e)
  1618. {
  1619. string updatesql="update production set pname=@pname,price=@price,unit=@unit,huojia=@huojia,kucun=@kucun where pid=@pid";
  1620. SqlCommand myCommand = new SqlCommand(updatesql, myConnection);
  1621. myCommand.Parameters.Add(new SqlParameter("@pid", SqlDbType.Int, 4));
  1622. myCommand.Parameters["@pid"].Value = groupBox2.Text;
  1623. myCommand.Parameters.Add(new SqlParameter("@pname", SqlDbType.NVarChar, 20));
  1624. myCommand.Parameters["@pname"].Value = textBox5.Text;
  1625. myCommand.Parameters.Add(new SqlParameter("@price", SqlDbType.Real, 8));
  1626. myCommand.Parameters["@price"].Value = Convert.ToDouble(textBox6.Text.ToString());
  1627. myCommand.Parameters.Add(new SqlParameter("@unit", SqlDbType.NVarChar, 3));
  1628. myCommand.Parameters["@unit"].Value = textBox7.Text;
  1629. myCommand.Parameters.Add(new SqlParameter("@huojia", SqlDbType.NVarChar, 3));
  1630. myCommand.Parameters["@huojia"].Value = textBox8.Text;
  1631. myCommand.Parameters.Add(new SqlParameter("@kucun", SqlDbType.Int, 4));
  1632. myCommand.Parameters["@kucun"].Value = textBox9.Text;
  1633. myCommand.Connection.Open();
  1634. try 
  1635. {
  1636. myCommand.ExecuteNonQuery();
  1637. //listView2.Select();
  1638. //listView2.Refresh();
  1639. MessageBox.Show("修改数据成功! ");
  1640. }
  1641. catch (SqlException ex)
  1642. {
  1643. MessageBox.Show("修改数据错误! " + ex.Message.ToString());
  1644. }
  1645. myCommand.Connection.Close();
  1646. string pkey;
  1647. if(textBox10.Text!="")
  1648. {
  1649. pkey=textBox10.Text;
  1650. }
  1651. else
  1652. {
  1653. pkey=textBox5.Text;
  1654. }
  1655. string selectp="select * from production where pname like '%"+pkey+"%'";
  1656. this.oleDbDataAdapter1.SelectCommand.CommandText=selectp;
  1657. this.oleDbDataAdapter1.SelectCommand.Connection=this.oleDbConnection1;
  1658. //打开数据库连接
  1659. this.oleDbConnection1.Open();
  1660. System.Data.OleDb.OleDbDataReader MyReader=this.oleDbDataAdapter1.SelectCommand.ExecuteReader();
  1661. this.listView3.Items.Clear();
  1662. try
  1663. {
  1664. while(MyReader.Read())
  1665. {
  1666. groupBox2.Text=MyReader.GetValue(0).ToString();
  1667. textBox5.Text=MyReader.GetValue(1).ToString();
  1668. textBox6.Text=MyReader.GetValue(2).ToString();
  1669. textBox7.Text=MyReader.GetValue(3).ToString();
  1670. textBox8.Text=MyReader.GetValue(4).ToString();
  1671. textBox9.Text=MyReader.GetValue(5).ToString();
  1672. ListViewItem MyItem=new ListViewItem();
  1673. MyItem.Text=MyReader.GetValue(0).ToString();
  1674. for(int j=0;j<MyReader.FieldCount-1;j++)
  1675. MyItem.SubItems.Add(MyReader.GetValue(j+1).ToString());
  1676. /*int b=MyReader.GetInt32(3);
  1677. double c=a*b;
  1678. string ff=c.ToString();
  1679. MyItem.SubItems.Add(ff);*/
  1680. //MyItem.SubItems.Add(textBox2.Text);
  1681. //MyItem.SubItems.Add(allp.ToString());
  1682.                 
  1683. this.listView3.Items.Add(MyItem);
  1684. }
  1685. MyReader.Close();
  1686. this.oleDbConnection1.Close();
  1687. }
  1688. catch
  1689. {
  1690. MessageBox.Show(this,"商品不存在!");
  1691. this.oleDbConnection1.Close();
  1692. return;
  1693. }
  1694. }
  1695. private void button2_Click(object sender, System.EventArgs e)
  1696. {
  1697. string allprice="select sum(allp) from soled where sallflog=@flog";
  1698. SqlCommand myCommand = new SqlCommand(allprice, myConnection);
  1699.             myCommand.Parameters.Add("@flog",SqlDbType.Int, 4);
  1700. myCommand.Parameters["@flog"].Value=floglb.Text;
  1701. myCommand.Connection.Open();
  1702. try 
  1703. {
  1704. string money=myCommand.ExecuteScalar().ToString();
  1705. myCommand.Connection.Close();
  1706. button1.Visible=false;
  1707. button12.Visible=false;
  1708. MessageBox.Show("应收金额:" + money);
  1709. }
  1710. catch(SqlException ex)
  1711. {
  1712. MessageBox.Show("统计数据错误! " + ex.Message.ToString());
  1713. myCommand.Connection.Close();
  1714. return;
  1715. }
  1716. }
  1717. private void button12_Click(object sender, System.EventArgs e)
  1718. {
  1719. ListViewItem item1 = this.listView1.SelectedItems[0];
  1720. //textBox3.Text=item1.Text;
  1721. for(int i=this.listView1.SelectedItems.Count-1; i>=0;i--)
  1722. {
  1723. ListViewItem item = this.listView1.SelectedItems[i];
  1724. this.listView1.Items.Remove(item);
  1725. string pid=item.Text;
  1726. string pflog=floglb.Text;
  1727. string deletesql="delete from soled where sallflog="+pflog+" and pid="+pid+"";
  1728. SqlCommand myCommand = new SqlCommand(deletesql, myConnection);
  1729. myCommand.Connection.Open();
  1730. try 
  1731. {
  1732. myCommand.ExecuteNonQuery();
  1733. MessageBox.Show("删除数据成功! ");
  1734. myCommand.Connection.Close();
  1735. }
  1736. catch (SqlException ex)
  1737. {
  1738. MessageBox.Show("删除数据错误! " + ex.Message.ToString());
  1739. return;
  1740. }
  1741. }
  1742. }
  1743. private void groupBox3_Enter(object sender, System.EventArgs e)
  1744. {
  1745. }
  1746. private void statusBar1_PanelClick(object sender, System.Windows.Forms.StatusBarPanelClickEventArgs e)
  1747. {
  1748. }
  1749. }
  1750. }