Form1.cs
上传用户:miknos
上传日期:2022-04-30
资源大小:802k
文件大小:65k
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Data;
- using System.Data.SqlClient;
- namespace supershop
- {
- /// <summary>
- /// Form1 的摘要说明。
- /// </summary>
- public class Form1 : System.Windows.Forms.Form
- {
- private System.Windows.Forms.StatusBar statusBar1;
- private System.Windows.Forms.MainMenu mainMenu1;
- private System.Windows.Forms.MenuItem menuItem1;
- private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
- private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
- private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.TextBox textBox1;
- private System.Windows.Forms.TextBox textBox2;
- private System.Windows.Forms.Button button1;
- private System.Windows.Forms.Button button2;
- private System.Data.SqlClient.SqlCommand sqlCommand1;
- private System.Windows.Forms.ListView listView1;
- private System.Data.OleDb.OleDbCommand oleDbSelectCommand1;
- private System.Data.OleDb.OleDbCommand oleDbInsertCommand1;
- private System.Data.OleDb.OleDbCommand oleDbUpdateCommand1;
- private System.Data.OleDb.OleDbCommand oleDbDeleteCommand1;
- private System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter1;
- private System.Data.OleDb.OleDbConnection oleDbConnection1;
- private System.Data.OleDb.OleDbCommand oleDbCommand1;
- private System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter2;
- private System.Data.OleDb.OleDbCommand oleDbSelectCommand2;
- private System.Data.OleDb.OleDbConnection oleDbConnection2;
- private System.Windows.Forms.ColumnHeader columnHeader1;
- private System.Windows.Forms.ColumnHeader columnHeader2;
- private System.Windows.Forms.ColumnHeader columnHeader3;
- private System.Windows.Forms.ColumnHeader columnHeader4;
- private supershop.DataSet1 dataSet11;
- private System.Data.SqlClient.SqlConnection myConnection;
- private System.Windows.Forms.ColumnHeader columnHeader5;
- private System.Windows.Forms.Button button3;
- private System.Windows.Forms.MenuItem menuItem2;
- private System.Windows.Forms.MenuItem menuItem3;
- private System.Windows.Forms.MenuItem menuItem4;
- private System.Windows.Forms.MenuItem menuItem5;
- private System.Windows.Forms.MenuItem menuItem6;
- private System.Windows.Forms.MenuItem menuItem7;
- private System.Windows.Forms.MenuItem menuItem8;
- private System.Windows.Forms.MenuItem menuItem9;
- private System.Windows.Forms.MenuItem menuItem10;
- private System.Windows.Forms.MenuItem menuItem11;
- private System.Windows.Forms.MenuItem menuItem12;
- private System.Windows.Forms.Panel panel1;
- private System.Windows.Forms.ListView listView2;
- private System.Windows.Forms.ColumnHeader columnHeader6;
- private System.Windows.Forms.ColumnHeader columnHeader7;
- private System.Windows.Forms.ColumnHeader columnHeader8;
- private System.Windows.Forms.GroupBox groupBox1;
- private System.Windows.Forms.Label label3;
- private System.Windows.Forms.Label label4;
- private System.Windows.Forms.Label label5;
- private System.Windows.Forms.ComboBox comboBox1;
- private System.Windows.Forms.Button button4;
- private System.Windows.Forms.Button button5;
- private System.Windows.Forms.Button button6;
- private System.Windows.Forms.ColumnHeader columnHeader9;
- private System.Windows.Forms.TextBox textBox3;
- private System.Windows.Forms.TextBox textBox4;
- private System.Windows.Forms.Panel panel2;
- private System.Windows.Forms.ListView listView3;
- private System.Windows.Forms.ColumnHeader columnHeader10;
- private System.Windows.Forms.ColumnHeader columnHeader11;
- private System.Windows.Forms.ColumnHeader columnHeader12;
- private System.Windows.Forms.ColumnHeader columnHeader13;
- private System.Windows.Forms.ColumnHeader columnHeader14;
- private System.Windows.Forms.ColumnHeader columnHeader15;
- private System.Windows.Forms.ColumnHeader columnHeader16;
- private System.Windows.Forms.GroupBox groupBox2;
- private System.Windows.Forms.Label label6;
- private System.Windows.Forms.Label label7;
- private System.Windows.Forms.Label label8;
- private System.Windows.Forms.Label label9;
- private System.Windows.Forms.Label label10;
- private System.Windows.Forms.TextBox textBox5;
- private System.Windows.Forms.TextBox textBox6;
- private System.Windows.Forms.TextBox textBox7;
- private System.Windows.Forms.TextBox textBox8;
- private System.Windows.Forms.TextBox textBox9;
- private System.Windows.Forms.GroupBox groupBox3;
- private System.Windows.Forms.Label label11;
- private System.Windows.Forms.TextBox textBox10;
- private System.Windows.Forms.Button button7;
- private System.Windows.Forms.Button button8;
- private System.Windows.Forms.Button button9;
- private System.Windows.Forms.Button button10;
- private System.Windows.Forms.Button button11;
- private System.Windows.Forms.ColumnHeader columnHeader17;
- private System.Data.SqlClient.SqlConnection myConnection2;
- private System.Windows.Forms.Label floglb;
- private System.Windows.Forms.Button button12;
- //要想在类未创建的时候引用必须将其设为static类型如下边的name
- public static string name;
- public static string isman;
- /// <summary>
- /// 必需的设计器变量。
- /// </summary>
- private System.ComponentModel.Container components = null;
- public Form1()
- {
- //
- // Windows 窗体设计器支持所必需的
- //
- InitializeComponent();
- //
- // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
- //
- }
- /// <summary>
- /// 清理所有正在使用的资源。
- /// </summary>
- protected override void Dispose( bool disposing )
- {
- if( disposing )
- {
- if (components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose( disposing );
- }
- #region Windows 窗体设计器生成的代码
- /// <summary>
- /// 设计器支持所需的方法 - 不要使用代码编辑器修改
- /// 此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
- this.statusBar1 = new System.Windows.Forms.StatusBar();
- this.mainMenu1 = new System.Windows.Forms.MainMenu();
- this.menuItem1 = new System.Windows.Forms.MenuItem();
- this.menuItem3 = new System.Windows.Forms.MenuItem();
- this.menuItem4 = new System.Windows.Forms.MenuItem();
- this.menuItem2 = new System.Windows.Forms.MenuItem();
- this.menuItem5 = new System.Windows.Forms.MenuItem();
- this.menuItem6 = new System.Windows.Forms.MenuItem();
- this.menuItem7 = new System.Windows.Forms.MenuItem();
- this.menuItem9 = new System.Windows.Forms.MenuItem();
- this.menuItem8 = new System.Windows.Forms.MenuItem();
- this.menuItem10 = new System.Windows.Forms.MenuItem();
- this.menuItem11 = new System.Windows.Forms.MenuItem();
- this.menuItem12 = new System.Windows.Forms.MenuItem();
- this.myConnection = new System.Data.SqlClient.SqlConnection();
- this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
- this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
- this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
- this.label1 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.textBox2 = new System.Windows.Forms.TextBox();
- this.button1 = new System.Windows.Forms.Button();
- this.button2 = new System.Windows.Forms.Button();
- this.sqlCommand1 = new System.Data.SqlClient.SqlCommand();
- this.listView1 = new System.Windows.Forms.ListView();
- this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
- this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
- this.columnHeader3 = new System.Windows.Forms.ColumnHeader();
- this.columnHeader17 = new System.Windows.Forms.ColumnHeader();
- this.columnHeader4 = new System.Windows.Forms.ColumnHeader();
- this.columnHeader5 = new System.Windows.Forms.ColumnHeader();
- this.oleDbSelectCommand1 = new System.Data.OleDb.OleDbCommand();
- this.oleDbInsertCommand1 = new System.Data.OleDb.OleDbCommand();
- this.oleDbUpdateCommand1 = new System.Data.OleDb.OleDbCommand();
- this.oleDbDeleteCommand1 = new System.Data.OleDb.OleDbCommand();
- this.oleDbDataAdapter1 = new System.Data.OleDb.OleDbDataAdapter();
- this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
- this.oleDbCommand1 = new System.Data.OleDb.OleDbCommand();
- this.oleDbDataAdapter2 = new System.Data.OleDb.OleDbDataAdapter();
- this.oleDbSelectCommand2 = new System.Data.OleDb.OleDbCommand();
- this.oleDbConnection2 = new System.Data.OleDb.OleDbConnection();
- this.dataSet11 = new supershop.DataSet1();
- this.button3 = new System.Windows.Forms.Button();
- this.panel1 = new System.Windows.Forms.Panel();
- this.button6 = new System.Windows.Forms.Button();
- this.button5 = new System.Windows.Forms.Button();
- this.button4 = new System.Windows.Forms.Button();
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.textBox4 = new System.Windows.Forms.TextBox();
- this.textBox3 = new System.Windows.Forms.TextBox();
- this.comboBox1 = new System.Windows.Forms.ComboBox();
- this.label5 = new System.Windows.Forms.Label();
- this.label4 = new System.Windows.Forms.Label();
- this.label3 = new System.Windows.Forms.Label();
- this.listView2 = new System.Windows.Forms.ListView();
- this.columnHeader9 = new System.Windows.Forms.ColumnHeader();
- this.columnHeader6 = new System.Windows.Forms.ColumnHeader();
- this.columnHeader7 = new System.Windows.Forms.ColumnHeader();
- this.columnHeader8 = new System.Windows.Forms.ColumnHeader();
- this.panel2 = new System.Windows.Forms.Panel();
- this.button11 = new System.Windows.Forms.Button();
- this.button10 = new System.Windows.Forms.Button();
- this.button9 = new System.Windows.Forms.Button();
- this.groupBox3 = new System.Windows.Forms.GroupBox();
- this.button8 = new System.Windows.Forms.Button();
- this.button7 = new System.Windows.Forms.Button();
- this.textBox10 = new System.Windows.Forms.TextBox();
- this.label11 = new System.Windows.Forms.Label();
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- this.textBox9 = new System.Windows.Forms.TextBox();
- this.textBox8 = new System.Windows.Forms.TextBox();
- this.textBox7 = new System.Windows.Forms.TextBox();
- this.textBox6 = new System.Windows.Forms.TextBox();
- this.textBox5 = new System.Windows.Forms.TextBox();
- this.label10 = new System.Windows.Forms.Label();
- this.label9 = new System.Windows.Forms.Label();
- this.label8 = new System.Windows.Forms.Label();
- this.label7 = new System.Windows.Forms.Label();
- this.label6 = new System.Windows.Forms.Label();
- this.listView3 = new System.Windows.Forms.ListView();
- this.columnHeader10 = new System.Windows.Forms.ColumnHeader();
- this.columnHeader11 = new System.Windows.Forms.ColumnHeader();
- this.columnHeader12 = new System.Windows.Forms.ColumnHeader();
- this.columnHeader13 = new System.Windows.Forms.ColumnHeader();
- this.columnHeader14 = new System.Windows.Forms.ColumnHeader();
- this.columnHeader15 = new System.Windows.Forms.ColumnHeader();
- this.columnHeader16 = new System.Windows.Forms.ColumnHeader();
- this.myConnection2 = new System.Data.SqlClient.SqlConnection();
- this.floglb = new System.Windows.Forms.Label();
- this.button12 = new System.Windows.Forms.Button();
- ((System.ComponentModel.ISupportInitialize)(this.dataSet11)).BeginInit();
- this.panel1.SuspendLayout();
- this.groupBox1.SuspendLayout();
- this.panel2.SuspendLayout();
- this.groupBox3.SuspendLayout();
- this.groupBox2.SuspendLayout();
- this.SuspendLayout();
- //
- // statusBar1
- //
- this.statusBar1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
- this.statusBar1.Location = new System.Drawing.Point(0, 361);
- this.statusBar1.Name = "statusBar1";
- this.statusBar1.Size = new System.Drawing.Size(728, 16);
- this.statusBar1.TabIndex = 0;
- this.statusBar1.PanelClick += new System.Windows.Forms.StatusBarPanelClickEventHandler(this.statusBar1_PanelClick);
- //
- // mainMenu1
- //
- this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.menuItem1,
- this.menuItem2,
- this.menuItem7,
- this.menuItem8,
- this.menuItem11});
- //
- // menuItem1
- //
- this.menuItem1.Index = 0;
- this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.menuItem3,
- this.menuItem4});
- this.menuItem1.Text = "系统管理";
- //
- // menuItem3
- //
- this.menuItem3.Index = 0;
- this.menuItem3.Text = "退出登录";
- this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
- //
- // menuItem4
- //
- this.menuItem4.Index = 1;
- this.menuItem4.Text = "关闭系统";
- this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
- //
- // menuItem2
- //
- this.menuItem2.Index = 1;
- this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.menuItem5,
- this.menuItem6});
- this.menuItem2.Text = "销售管理";
- //
- // menuItem5
- //
- this.menuItem5.Index = 0;
- this.menuItem5.Text = "销售商品";
- this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);
- //
- // menuItem6
- //
- this.menuItem6.Index = 1;
- this.menuItem6.Text = "销售历史";
- this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
- //
- // menuItem7
- //
- this.menuItem7.Index = 2;
- this.menuItem7.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.menuItem9});
- this.menuItem7.Text = "商品管理";
- //
- // menuItem9
- //
- this.menuItem9.Index = 0;
- this.menuItem9.Text = "商品概况";
- this.menuItem9.Click += new System.EventHandler(this.menuItem9_Click);
- //
- // menuItem8
- //
- this.menuItem8.Index = 3;
- this.menuItem8.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.menuItem10});
- this.menuItem8.Text = "人事管理";
- //
- // menuItem10
- //
- this.menuItem10.Index = 0;
- this.menuItem10.Text = "人员安排";
- this.menuItem10.Click += new System.EventHandler(this.menuItem10_Click);
- //
- // menuItem11
- //
- this.menuItem11.Index = 4;
- this.menuItem11.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.menuItem12});
- this.menuItem11.Text = "关于";
- //
- // menuItem12
- //
- this.menuItem12.Index = 0;
- this.menuItem12.Text = "橙子超市管理系统1.0版";
- this.menuItem12.Click += new System.EventHandler(this.menuItem12_Click);
- //
- // myConnection
- //
- this.myConnection.ConnectionString = "workstation id=MICROSOFTPANG;packet size=4096;integrated security=SSPI;data sourc" +
- "e=MICROSOFTPANG;persist security info=False;initial catalog=supershop";
- //
- // sqlDataAdapter1
- //
- this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;
- this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
- this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
- new System.Data.Common.DataTableMapping("Table", "production", new System.Data.Common.DataColumnMapping[] {
- new System.Data.Common.DataColumnMapping("pid", "pid"),
- new System.Data.Common.DataColumnMapping("pname", "pname"),
- new System.Data.Common.DataColumnMapping("price", "price"),
- new System.Data.Common.DataColumnMapping("totle", "totle")})});
- //
- // sqlInsertCommand1
- //
- this.sqlInsertCommand1.CommandText = "INSERT INTO production(pid, pname, price, totle) VALUES (@pid, @pname, @price, @t" +
- "otle); SELECT pid, pname, price, totle FROM production";
- this.sqlInsertCommand1.Connection = this.myConnection;
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@pid", System.Data.SqlDbType.Int, 4, "pid"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@pname", System.Data.SqlDbType.VarChar, 20, "pname"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@price", System.Data.SqlDbType.Int, 4, "price"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@totle", System.Data.SqlDbType.Int, 4, "totle"));
- //
- // sqlSelectCommand1
- //
- this.sqlSelectCommand1.CommandText = "SELECT production.* FROM production";
- this.sqlSelectCommand1.Connection = this.myConnection;
- //
- // label1
- //
- this.label1.Location = new System.Drawing.Point(0, 288);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(48, 23);
- this.label1.TabIndex = 2;
- this.label1.Text = "货号:";
- //
- // label2
- //
- this.label2.Location = new System.Drawing.Point(160, 288);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(48, 23);
- this.label2.TabIndex = 3;
- this.label2.Text = "数量:";
- //
- // textBox1
- //
- this.textBox1.Location = new System.Drawing.Point(48, 288);
- this.textBox1.Name = "textBox1";
- this.textBox1.TabIndex = 4;
- this.textBox1.Text = "";
- //
- // textBox2
- //
- this.textBox2.Location = new System.Drawing.Point(208, 288);
- this.textBox2.Name = "textBox2";
- this.textBox2.TabIndex = 5;
- this.textBox2.Text = "";
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(432, 288);
- this.button1.Name = "button1";
- this.button1.TabIndex = 6;
- this.button1.Text = "确 认";
- this.button1.Visible = false;
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // button2
- //
- this.button2.Location = new System.Drawing.Point(624, 288);
- this.button2.Name = "button2";
- this.button2.TabIndex = 7;
- this.button2.Text = "统 计";
- this.button2.Visible = false;
- this.button2.Click += new System.EventHandler(this.button2_Click);
- //
- // sqlCommand1
- //
- this.sqlCommand1.Connection = this.myConnection;
- //
- // listView1
- //
- this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
- this.columnHeader1,
- this.columnHeader2,
- this.columnHeader3,
- this.columnHeader17,
- this.columnHeader4,
- this.columnHeader5});
- this.listView1.FullRowSelect = true;
- this.listView1.Location = new System.Drawing.Point(0, 16);
- this.listView1.Name = "listView1";
- this.listView1.Size = new System.Drawing.Size(728, 248);
- this.listView1.TabIndex = 8;
- this.listView1.View = System.Windows.Forms.View.Details;
- //
- // columnHeader1
- //
- this.columnHeader1.Text = "商品货号";
- this.columnHeader1.Width = 118;
- //
- // columnHeader2
- //
- this.columnHeader2.Text = "商品名称";
- this.columnHeader2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
- this.columnHeader2.Width = 126;
- //
- // columnHeader3
- //
- this.columnHeader3.Text = "商品价格";
- this.columnHeader3.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
- this.columnHeader3.Width = 118;
- //
- // columnHeader17
- //
- this.columnHeader17.Text = "商品单位";
- this.columnHeader17.Width = 102;
- //
- // columnHeader4
- //
- this.columnHeader4.Text = "商品数量";
- this.columnHeader4.Width = 125;
- //
- // columnHeader5
- //
- this.columnHeader5.Text = "商品总价格";
- this.columnHeader5.Width = 134;
- //
- // oleDbDataAdapter1
- //
- this.oleDbDataAdapter1.DeleteCommand = this.oleDbDeleteCommand1;
- this.oleDbDataAdapter1.InsertCommand = this.oleDbInsertCommand1;
- this.oleDbDataAdapter1.SelectCommand = this.oleDbSelectCommand1;
- this.oleDbDataAdapter1.UpdateCommand = this.oleDbUpdateCommand1;
- //
- // oleDbConnection1
- //
- 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";
- //
- // oleDbDataAdapter2
- //
- this.oleDbDataAdapter2.SelectCommand = this.oleDbSelectCommand2;
- //
- // oleDbSelectCommand2
- //
- this.oleDbSelectCommand2.CommandText = "SELECT FROM production";
- this.oleDbSelectCommand2.Connection = this.oleDbConnection2;
- //
- // oleDbConnection2
- //
- 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";
- //
- // dataSet11
- //
- this.dataSet11.DataSetName = "DataSet1";
- this.dataSet11.Locale = new System.Globalization.CultureInfo("zh-CN");
- //
- // button3
- //
- this.button3.Location = new System.Drawing.Point(344, 288);
- this.button3.Name = "button3";
- this.button3.TabIndex = 9;
- this.button3.Text = "新建销售";
- this.button3.Click += new System.EventHandler(this.button3_Click);
- //
- // panel1
- //
- this.panel1.Controls.Add(this.button6);
- this.panel1.Controls.Add(this.button5);
- this.panel1.Controls.Add(this.button4);
- this.panel1.Controls.Add(this.groupBox1);
- this.panel1.Controls.Add(this.listView2);
- this.panel1.Location = new System.Drawing.Point(0, 0);
- this.panel1.Name = "panel1";
- this.panel1.Size = new System.Drawing.Size(728, 360);
- this.panel1.TabIndex = 10;
- this.panel1.Visible = false;
- //
- // button6
- //
- this.button6.Location = new System.Drawing.Point(624, 288);
- this.button6.Name = "button6";
- this.button6.TabIndex = 6;
- this.button6.Text = "删除帐户";
- this.button6.Click += new System.EventHandler(this.button6_Click);
- //
- // button5
- //
- this.button5.Location = new System.Drawing.Point(504, 288);
- this.button5.Name = "button5";
- this.button5.TabIndex = 5;
- this.button5.Text = "修改帐户";
- this.button5.Click += new System.EventHandler(this.button5_Click);
- //
- // button4
- //
- this.button4.Location = new System.Drawing.Point(376, 288);
- this.button4.Name = "button4";
- this.button4.TabIndex = 4;
- this.button4.Text = "添加帐户";
- this.button4.Click += new System.EventHandler(this.button4_Click);
- //
- // groupBox1
- //
- this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox1.Controls.Add(this.textBox4);
- this.groupBox1.Controls.Add(this.textBox3);
- this.groupBox1.Controls.Add(this.comboBox1);
- this.groupBox1.Controls.Add(this.label5);
- this.groupBox1.Controls.Add(this.label4);
- this.groupBox1.Controls.Add(this.label3);
- this.groupBox1.Location = new System.Drawing.Point(360, 16);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(352, 344);
- this.groupBox1.TabIndex = 3;
- this.groupBox1.TabStop = false;
- this.groupBox1.Text = "编辑区:";
- //
- // textBox4
- //
- this.textBox4.Location = new System.Drawing.Point(144, 72);
- this.textBox4.Name = "textBox4";
- this.textBox4.TabIndex = 7;
- this.textBox4.Text = "";
- //
- // textBox3
- //
- this.textBox3.Location = new System.Drawing.Point(144, 32);
- this.textBox3.Name = "textBox3";
- this.textBox3.TabIndex = 6;
- this.textBox3.Text = "";
- //
- // comboBox1
- //
- this.comboBox1.Items.AddRange(new object[] {
- "管理人员",
- "销售人员"});
- this.comboBox1.Location = new System.Drawing.Point(144, 112);
- this.comboBox1.Name = "comboBox1";
- this.comboBox1.Size = new System.Drawing.Size(112, 20);
- this.comboBox1.TabIndex = 5;
- //
- // label5
- //
- this.label5.Location = new System.Drawing.Point(32, 112);
- this.label5.Name = "label5";
- this.label5.TabIndex = 2;
- this.label5.Text = "帐号类型:";
- this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
- //
- // label4
- //
- this.label4.Location = new System.Drawing.Point(32, 72);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(104, 23);
- this.label4.TabIndex = 1;
- this.label4.Text = "登录密码:";
- this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
- //
- // label3
- //
- this.label3.Location = new System.Drawing.Point(32, 32);
- this.label3.Name = "label3";
- this.label3.TabIndex = 0;
- this.label3.Text = "登录帐号:";
- this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
- //
- // listView2
- //
- this.listView2.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
- this.columnHeader9,
- this.columnHeader6,
- this.columnHeader7,
- this.columnHeader8});
- this.listView2.FullRowSelect = true;
- this.listView2.GridLines = true;
- this.listView2.Location = new System.Drawing.Point(16, 16);
- this.listView2.Name = "listView2";
- this.listView2.Size = new System.Drawing.Size(328, 304);
- this.listView2.TabIndex = 2;
- this.listView2.View = System.Windows.Forms.View.Details;
- this.listView2.SelectedIndexChanged += new System.EventHandler(this.select);
- this.listView2.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.ifcheck);
- //
- // columnHeader9
- //
- this.columnHeader9.Text = "ID";
- //
- // columnHeader6
- //
- this.columnHeader6.Text = "登录帐号";
- this.columnHeader6.Width = 97;
- //
- // columnHeader7
- //
- this.columnHeader7.Text = "登录密码";
- this.columnHeader7.Width = 83;
- //
- // columnHeader8
- //
- this.columnHeader8.Text = "帐号类型";
- this.columnHeader8.Width = 84;
- //
- // panel2
- //
- this.panel2.Controls.Add(this.button11);
- this.panel2.Controls.Add(this.button10);
- this.panel2.Controls.Add(this.button9);
- this.panel2.Controls.Add(this.groupBox3);
- this.panel2.Controls.Add(this.groupBox2);
- this.panel2.Controls.Add(this.listView3);
- this.panel2.Location = new System.Drawing.Point(0, 0);
- this.panel2.Name = "panel2";
- this.panel2.Size = new System.Drawing.Size(728, 360);
- this.panel2.TabIndex = 11;
- this.panel2.Visible = false;
- //
- // button11
- //
- this.button11.Location = new System.Drawing.Point(640, 320);
- this.button11.Name = "button11";
- this.button11.TabIndex = 5;
- this.button11.Text = "修 改";
- this.button11.Click += new System.EventHandler(this.button11_Click);
- //
- // button10
- //
- this.button10.Location = new System.Drawing.Point(544, 320);
- this.button10.Name = "button10";
- this.button10.TabIndex = 4;
- this.button10.Text = "删 除";
- this.button10.Click += new System.EventHandler(this.button10_Click);
- //
- // button9
- //
- this.button9.Location = new System.Drawing.Point(448, 320);
- this.button9.Name = "button9";
- this.button9.TabIndex = 3;
- this.button9.Text = "添 加";
- this.button9.Click += new System.EventHandler(this.button9_Click);
- //
- // groupBox3
- //
- this.groupBox3.Controls.Add(this.button8);
- this.groupBox3.Controls.Add(this.button7);
- this.groupBox3.Controls.Add(this.textBox10);
- this.groupBox3.Controls.Add(this.label11);
- this.groupBox3.Location = new System.Drawing.Point(8, 232);
- this.groupBox3.Name = "groupBox3";
- this.groupBox3.Size = new System.Drawing.Size(424, 112);
- this.groupBox3.TabIndex = 2;
- this.groupBox3.TabStop = false;
- this.groupBox3.Text = "商品查询";
- this.groupBox3.Enter += new System.EventHandler(this.groupBox3_Enter);
- //
- // button8
- //
- this.button8.Location = new System.Drawing.Point(296, 64);
- this.button8.Name = "button8";
- this.button8.Size = new System.Drawing.Size(104, 23);
- this.button8.TabIndex = 3;
- this.button8.Text = "列出所有商品";
- this.button8.Click += new System.EventHandler(this.button8_Click);
- //
- // button7
- //
- this.button7.Location = new System.Drawing.Point(160, 64);
- this.button7.Name = "button7";
- this.button7.Size = new System.Drawing.Size(104, 23);
- this.button7.TabIndex = 2;
- this.button7.Text = "查 询";
- this.button7.Click += new System.EventHandler(this.button7_Click);
- //
- // textBox10
- //
- this.textBox10.Location = new System.Drawing.Point(160, 24);
- this.textBox10.Name = "textBox10";
- this.textBox10.Size = new System.Drawing.Size(248, 21);
- this.textBox10.TabIndex = 1;
- this.textBox10.Text = "";
- //
- // label11
- //
- this.label11.Location = new System.Drawing.Point(16, 24);
- this.label11.Name = "label11";
- this.label11.Size = new System.Drawing.Size(144, 23);
- this.label11.TabIndex = 0;
- this.label11.Text = "关键字(名称):";
- this.label11.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
- //
- // groupBox2
- //
- this.groupBox2.Controls.Add(this.textBox9);
- this.groupBox2.Controls.Add(this.textBox8);
- this.groupBox2.Controls.Add(this.textBox7);
- this.groupBox2.Controls.Add(this.textBox6);
- this.groupBox2.Controls.Add(this.textBox5);
- this.groupBox2.Controls.Add(this.label10);
- this.groupBox2.Controls.Add(this.label9);
- this.groupBox2.Controls.Add(this.label8);
- this.groupBox2.Controls.Add(this.label7);
- this.groupBox2.Controls.Add(this.label6);
- this.groupBox2.Location = new System.Drawing.Point(432, 16);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(288, 200);
- this.groupBox2.TabIndex = 1;
- this.groupBox2.TabStop = false;
- this.groupBox2.Text = "编辑区";
- //
- // textBox9
- //
- this.textBox9.Location = new System.Drawing.Point(128, 168);
- this.textBox9.Name = "textBox9";
- this.textBox9.Size = new System.Drawing.Size(144, 21);
- this.textBox9.TabIndex = 9;
- this.textBox9.Text = "";
- //
- // textBox8
- //
- this.textBox8.Location = new System.Drawing.Point(128, 128);
- this.textBox8.Name = "textBox8";
- this.textBox8.Size = new System.Drawing.Size(144, 21);
- this.textBox8.TabIndex = 8;
- this.textBox8.Text = "";
- //
- // textBox7
- //
- this.textBox7.Location = new System.Drawing.Point(128, 96);
- this.textBox7.Name = "textBox7";
- this.textBox7.Size = new System.Drawing.Size(144, 21);
- this.textBox7.TabIndex = 7;
- this.textBox7.Text = "";
- //
- // textBox6
- //
- this.textBox6.Location = new System.Drawing.Point(128, 64);
- this.textBox6.Name = "textBox6";
- this.textBox6.Size = new System.Drawing.Size(144, 21);
- this.textBox6.TabIndex = 6;
- this.textBox6.Text = "";
- //
- // textBox5
- //
- this.textBox5.Location = new System.Drawing.Point(128, 32);
- this.textBox5.Name = "textBox5";
- this.textBox5.Size = new System.Drawing.Size(144, 21);
- this.textBox5.TabIndex = 5;
- this.textBox5.Text = "";
- //
- // label10
- //
- this.label10.Location = new System.Drawing.Point(16, 168);
- this.label10.Name = "label10";
- this.label10.TabIndex = 4;
- this.label10.Text = "库存:";
- this.label10.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
- //
- // label9
- //
- this.label9.Location = new System.Drawing.Point(16, 128);
- this.label9.Name = "label9";
- this.label9.TabIndex = 3;
- this.label9.Text = "货架:";
- this.label9.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
- //
- // label8
- //
- this.label8.Location = new System.Drawing.Point(16, 96);
- this.label8.Name = "label8";
- this.label8.TabIndex = 2;
- this.label8.Text = "单位:";
- this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
- //
- // label7
- //
- this.label7.Location = new System.Drawing.Point(16, 64);
- this.label7.Name = "label7";
- this.label7.TabIndex = 1;
- this.label7.Text = "单价:";
- this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
- //
- // label6
- //
- this.label6.Location = new System.Drawing.Point(16, 32);
- this.label6.Name = "label6";
- this.label6.TabIndex = 0;
- this.label6.Text = "名称:";
- this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
- //
- // listView3
- //
- this.listView3.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
- this.columnHeader10,
- this.columnHeader11,
- this.columnHeader12,
- this.columnHeader13,
- this.columnHeader14,
- this.columnHeader15,
- this.columnHeader16});
- this.listView3.FullRowSelect = true;
- this.listView3.GridLines = true;
- this.listView3.Location = new System.Drawing.Point(8, 8);
- this.listView3.Name = "listView3";
- this.listView3.Size = new System.Drawing.Size(424, 208);
- this.listView3.TabIndex = 0;
- this.listView3.View = System.Windows.Forms.View.Details;
- this.listView3.SelectedIndexChanged += new System.EventHandler(this.v3select);
- //
- // columnHeader10
- //
- this.columnHeader10.Text = "编号";
- //
- // columnHeader11
- //
- this.columnHeader11.Text = "名称";
- //
- // columnHeader12
- //
- this.columnHeader12.Text = "单价";
- //
- // columnHeader13
- //
- this.columnHeader13.Text = "单位";
- //
- // columnHeader14
- //
- this.columnHeader14.Text = "货架号";
- //
- // columnHeader15
- //
- this.columnHeader15.Text = "库存";
- //
- // columnHeader16
- //
- this.columnHeader16.Text = "销量";
- //
- // myConnection2
- //
- this.myConnection2.ConnectionString = "workstation id=MICROSOFTPANG;packet size=4096;integrated security=SSPI;data sourc" +
- "e=MICROSOFTPANG;persist security info=False;initial catalog=supershop";
- //
- // floglb
- //
- this.floglb.Location = new System.Drawing.Point(608, 320);
- this.floglb.Name = "floglb";
- this.floglb.TabIndex = 12;
- this.floglb.Visible = false;
- //
- // button12
- //
- this.button12.Location = new System.Drawing.Point(528, 288);
- this.button12.Name = "button12";
- this.button12.TabIndex = 13;
- this.button12.Text = "删 除";
- this.button12.Visible = false;
- this.button12.Click += new System.EventHandler(this.button12_Click);
- //
- // Form1
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
- this.ClientSize = new System.Drawing.Size(728, 377);
- this.Controls.Add(this.panel2);
- this.Controls.Add(this.panel1);
- this.Controls.Add(this.listView1);
- this.Controls.Add(this.button2);
- this.Controls.Add(this.button1);
- this.Controls.Add(this.textBox2);
- this.Controls.Add(this.textBox1);
- this.Controls.Add(this.label2);
- this.Controls.Add(this.label1);
- this.Controls.Add(this.statusBar1);
- this.Controls.Add(this.button3);
- this.Controls.Add(this.floglb);
- this.Controls.Add(this.button12);
- this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
- this.Menu = this.mainMenu1;
- this.Name = "Form1";
- this.Text = "橙子超市管理系统";
- this.Load += new System.EventHandler(this.Form1_Load);
- ((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
- this.panel1.ResumeLayout(false);
- this.groupBox1.ResumeLayout(false);
- this.panel2.ResumeLayout(false);
- this.groupBox3.ResumeLayout(false);
- this.groupBox2.ResumeLayout(false);
- this.ResumeLayout(false);
- }
- #endregion
- /// <summary>
- /// 应用程序的主入口点。
- /// </summary>
- [STAThread]
- static void Main()
- {
- Application.Run(new Form1());
-
- }
- private void Form1_Load(object sender, System.EventArgs e)
- {
- supershop2.Form2 f2=new supershop2.Form2();
- //f2.Visible=true;
-
- f2.ShowDialog();
- this.statusBar1.Text=name;
- if(isman=="no")
- {
- this.menuItem6.Enabled=false;
- this.menuItem7.Enabled=false;
- this.menuItem8.Enabled=false;
- }
- else
- {
- this.menuItem6.Enabled=true;
- this.menuItem7.Enabled=true;
- this.menuItem8.Enabled=true;
- }
- //this.Visible=false;
- }
- private void button1_Click(object sender, System.EventArgs e)
- {
- string pid=textBox1.Text;
- double solett=Convert.ToDouble(textBox2.Text);
- string ss="select * from production where pid="+pid+"";
- this.oleDbDataAdapter1.SelectCommand.CommandText=ss;
- this.oleDbDataAdapter1.SelectCommand.Connection=this.oleDbConnection1;
- //打开数据库连接
- this.oleDbConnection1.Open();
- System.Data.OleDb.OleDbDataReader MyReader=this.oleDbDataAdapter1.SelectCommand.ExecuteReader();
-
- this.listView1.View=View.Details;
- MyReader.Read();
- string pname,price;
- double kucun,soled;
- //kucun=MyReader.GetValue(5).ToString();
- //soled=MyReader.GetValue(6).ToString();
-
- double allp;
-
- try
- {
-
- pname=MyReader.GetValue(1).ToString();
- price=MyReader.GetValue(2).ToString();
- kucun=Convert.ToDouble(MyReader.GetValue(5).ToString())-Convert.ToDouble(textBox2.Text);
- soled=Convert.ToDouble(MyReader.GetValue(6).ToString())+Convert.ToDouble(textBox2.Text);
- allp=Convert.ToDouble(price) * solett;
- allp=Math.Round(allp,2);
- ListViewItem MyItem=new ListViewItem();
- MyItem.Text=MyReader.GetValue(0).ToString();
- for(int j=0;j<MyReader.FieldCount-4;j++)
- MyItem.SubItems.Add(MyReader.GetValue(j+1).ToString());
- /*int b=MyReader.GetInt32(3);
- double c=a*b;
- string ff=c.ToString();
- MyItem.SubItems.Add(ff);*/
- MyItem.SubItems.Add(textBox2.Text);
- MyItem.SubItems.Add(allp.ToString());
- this.listView1.Items.Add(MyItem);
- MyReader.Close();
- this.oleDbConnection1.Close();
- }
- catch
- {
- MyReader.Close();
- this.oleDbConnection1.Close();
- MessageBox.Show(this,"商品不存在!");
- return;
- }
- //for(int i=0;i<MyReader.FieldCount-1;i++)
- //{
- //this.listView1.Columns.Add(MyReader.GetName(i),100,HorizontalAlignment.Left);
- //}
- /*while(MyReader.Read())
- {
- ListViewItem MyItem=new ListViewItem();
- MyItem.Text=MyReader.GetValue(0).ToString();
- for(int j=0;j<MyReader.FieldCount-1;j++)
- MyItem.SubItems.Add(MyReader.GetValue(j+1).ToString());
- this.listView1.Items.Add(MyItem);
- }*/
- //关闭连接
- //textBox1.Text=price.ToString();
- this.oleDbConnection1.Close();
- /*this.sqlConnection1.Open();
- int solett=2;
- float allp=2.0f;
- string insert_soled="insert into soled(pid,pname,price,solett,allp)values("+pid+",""+pname+"","+price+","+solett+","+allp+")";
- this.sqlCommand1.CommandText=insert_soled;
- this.sqlCommand1.Connection=this.sqlConnection1;
- this.sqlCommand1.ExecuteNonQuery();
- this.sqlConnection1.Close();
- this.sqlDataAdapter1.Fill(this.dataSet11,"soled");*/
- //SqlConnection myConnection;
- //myConnection = new SqlConnection("server=(MICROSOFTPANG);database=supershop;Trusted_Connection=yes");*/
- //DateTimePicker NowTime = new DateTimePicker();
- //string Now_Time=NowTime.Value.ToLongDateString().ToString();
- //Now_Time+=NowTime.Value.ToLongTimeString().ToString();
- string insertCmd = "insert into soled(pid,solett,allp,sallflog)values(@pid, @solett, @allp,@sallflog)";
- SqlCommand myCommand = new SqlCommand(insertCmd, myConnection);
- myCommand.Parameters.Add(new SqlParameter("@pid", SqlDbType.Int, 4));
- myCommand.Parameters["@pid"].Value = pid;
- //myCommand.Parameters.Add(new SqlParameter("@pname", SqlDbType.NVarChar, 20));
- //myCommand.Parameters["@pname"].Value = pname;
- //myCommand.Parameters.Add(new SqlParameter("@price", SqlDbType.Float, 8));
- //myCommand.Parameters["@price"].Value = price;
- myCommand.Parameters.Add(new SqlParameter("@solett", SqlDbType.Int, 4));
- myCommand.Parameters["@solett"].Value = solett;
- myCommand.Parameters.Add(new SqlParameter("@allp", SqlDbType.Float, 8));
- myCommand.Parameters["@allp"].Value = allp;
- myCommand.Parameters.Add(new SqlParameter("@sallflog", SqlDbType.Int, 4));
- myCommand.Parameters["@sallflog"].Value = floglb.Text;
- myCommand.Connection.Open();
- try
- {
- myCommand.ExecuteNonQuery();
- myCommand.Connection.Close();
- }
- catch (SqlException ex)
- {
- MessageBox.Show("插入数据错误! " + ex.Message.ToString());
- myCommand.Connection.Close();
- return;
- }
- string upprice="update production set kucun="+kucun+",soled="+soled+" where pid="+pid+"";
- SqlCommand myCommand2 = new SqlCommand(upprice, myConnection);
- myCommand2.Connection.Open();
- try
- {
- myCommand2.ExecuteNonQuery();
- myCommand2.Connection.Close();
- }
- catch (SqlException ex)
- {
- MessageBox.Show("库存销售数据错误! " + ex.Message.ToString());
- myCommand2.Connection.Close();
- return;
- }
-
- }
- private void button3_Click(object sender, System.EventArgs e)
- {
- textBox1.Text="";
- textBox2.Text="";
- listView1.Items.Clear();
- DateTimePicker NowTime = new DateTimePicker();
- string Now_Time=NowTime.Value.ToLongDateString().ToString();
- Now_Time+=NowTime.Value.ToLongTimeString().ToString();
- //string sname=statusBar1.Text;
- //sname为登录人的姓名
- string sname=this.statusBar1.Text;
- string insall="insert into slist (stime,sname)values(@stime,@sname)";
- SqlCommand myCommand = new SqlCommand(insall, myConnection);
- myCommand.Parameters.Add(new SqlParameter("@stime", SqlDbType.NVarChar, 30));
- myCommand.Parameters["@stime"].Value = Now_Time;
- myCommand.Parameters.Add(new SqlParameter("@sname", SqlDbType.NVarChar, 20));
- myCommand.Parameters["@sname"].Value = sname;
- myCommand.Connection.Open();
- ///////////////////////////
- string slt="select sallid from slist where sname=@sname order by sallid desc";
- SqlCommand myCommand2 = new SqlCommand(slt, myConnection2);
- myCommand2.Parameters.Add(new SqlParameter("@sname", SqlDbType.NVarChar, 20));
- myCommand2.Parameters["@sname"].Value = sname;
- myCommand2.Connection.Open();
- try
- {
- myCommand.ExecuteNonQuery();
- floglb.Text=myCommand2.ExecuteScalar().ToString();
- button1.Visible=true;
- button2.Visible=true;
- button12.Visible=true;
- myCommand.Connection.Close();
- myCommand2.Connection.Close();
- MessageBox.Show("新建销售成功!");
-
- }
- catch (SqlException ex)
- {
- myCommand.Connection.Close();
- myCommand2.Connection.Close();
- MessageBox.Show("新建销售错误! " + ex.Message.ToString());
- return;
- }
-
- }
- private void menuItem4_Click(object sender, System.EventArgs e)
- {
- Application.Exit();
- }
- private void menuItem3_Click(object sender, System.EventArgs e)
- {
- panel2.Visible=false;
- panel1.Visible=false;
- this.Enabled=false;
- supershop2.Form2 f2=new supershop2.Form2();
- f2.ShowDialog();
- this.statusBar1.Text=name;
-
- this.Enabled=true;
- if(isman=="no")
- {
- this.menuItem6.Enabled=false;
- this.menuItem7.Enabled=false;
- this.menuItem8.Enabled=false;
- }
- else
- {
- this.menuItem6.Enabled=true;
- this.menuItem7.Enabled=true;
- this.menuItem8.Enabled=true;
- }
- //this.Visible=false;
-
- }
- private void menuItem12_Click(object sender, System.EventArgs e)
- {
- Form3 f3=new Form3();
- f3.Text="关于橙子";
- f3.ShowDialog();
- }
- private void menuItem6_Click(object sender, System.EventArgs e)
- {
- Form4 f4=new Form4();
- f4.ShowDialog();
- }
- private void menuItem10_Click(object sender, System.EventArgs e)
- {
-
- panel1.Visible=true;
- panel2.Visible=false;
-
- string str="select * from login";
- this.oleDbDataAdapter1.SelectCommand.CommandText=str;
- this.oleDbDataAdapter1.SelectCommand.Connection=this.oleDbConnection1;
- //打开数据库连接
- this.oleDbConnection1.Open();
- System.Data.OleDb.OleDbDataReader MyReader=this.oleDbDataAdapter1.SelectCommand.ExecuteReader();
-
- //this.listView1.View=View.Details;
-
- try
- {
- this.listView2.Items.Clear();
- while(MyReader.Read())
- {
- ListViewItem MyItem=new ListViewItem();
- MyItem.Text=MyReader.GetValue(0).ToString();
- for(int j=0;j<MyReader.FieldCount-2;j++)
- MyItem.SubItems.Add(MyReader.GetValue(j+1).ToString());
- string flog=MyReader.GetValue(MyReader.FieldCount-1).ToString();
- switch(flog)
- {
- case "yes":MyItem.SubItems.Add("管理人员");break;
- case "no":MyItem.SubItems.Add("销售人员");break;
- }
-
- this.listView2.Items.Add(MyItem);
-
- }
- MyReader.Close();
- this.oleDbConnection1.Close();
- }
- catch
- {
- MessageBox.Show(this,"帐户不存在!");
- MyReader.Close();
- this.oleDbConnection1.Close();
- return;
- }
- }
- private void menuItem5_Click(object sender, System.EventArgs e)
- {
- panel1.Visible=false;
- panel2.Visible=false;
- textBox1.Text="";
- textBox2.Text="";
- listView1.Items.Clear();
-
- }
- private void ifcheck(object sender, System.Windows.Forms.ItemCheckEventArgs e)
- {
- }
- private void select(object sender, System.EventArgs e)
- {
- string j;
- for(int i=this.listView2.SelectedItems.Count-1; i>=0;i--)
- {
- ListViewItem item = this.listView2.SelectedItems[i];
- j=item.Text;
- //j=this.listView2.Items.Add;
- string str="select * from login where id="+j+"";
- this.oleDbDataAdapter1.SelectCommand.CommandText=str;
- this.oleDbDataAdapter1.SelectCommand.Connection=this.oleDbConnection1;
- //打开数据库连接
- this.oleDbConnection1.Open();
- System.Data.OleDb.OleDbDataReader MyReader=this.oleDbDataAdapter1.SelectCommand.ExecuteReader();
- MyReader.Read();
- groupBox1.Text=MyReader.GetValue(0).ToString();
- textBox3.Text=MyReader.GetValue(1).ToString();
- textBox4.Text=MyReader.GetValue(2).ToString();
- switch(MyReader.GetValue(3).ToString())
- {
- case "yes":comboBox1.Text="管理人员";break;
- case "no":comboBox1.Text="销售人员";break;
- }
-
- MyReader.Close();
- this.oleDbConnection1.Close();
- }
-
- }
- private void button6_Click(object sender, System.EventArgs e)
- {
- ListViewItem item1 = this.listView2.SelectedItems[0];
- //textBox3.Text=item1.Text;
- for(int i=this.listView2.SelectedItems.Count-1; i>=0;i--)
- {
- ListViewItem item = this.listView2.SelectedItems[i];
- this.listView2.Items.Remove(item);
- string uflog=item.Text;
- string deletesql="delete from login where id="+uflog+"";
- SqlCommand myCommand = new SqlCommand(deletesql, myConnection);
- myCommand.Connection.Open();
- try
- {
- myCommand.ExecuteNonQuery();
- myCommand.Connection.Close();
- MessageBox.Show("删除数据成功! ");
- }
- catch (SqlException ex)
- {
- MessageBox.Show("删除数据错误! " + ex.Message.ToString());
- myCommand.Connection.Close();
- return;
- }
-
- }
-
- }
- private void button5_Click(object sender, System.EventArgs e)
- {
- string pname,pwd,ismanage;
- pname=textBox3.Text;
- pwd=textBox4.Text;
- switch(comboBox1.Text)
- {
- case"管理人员":ismanage="yes";break;
- case"销售人员":ismanage="no";break;
- default:
- return;
- }
- string updatesql="update login set uname=@pname,pwd=@pwd,ismanage=@ismanage where id=@id";
- SqlCommand myCommand = new SqlCommand(updatesql, myConnection);
- myCommand.Parameters.Add(new SqlParameter("@id", SqlDbType.NVarChar, 20));
- myCommand.Parameters["@id"].Value = groupBox1.Text;
- myCommand.Parameters.Add(new SqlParameter("@pname", SqlDbType.NVarChar, 20));
- myCommand.Parameters["@pname"].Value = textBox3.Text;
- myCommand.Parameters.Add(new SqlParameter("@pwd", SqlDbType.NVarChar, 20));
- myCommand.Parameters["@pwd"].Value = textBox4.Text;
- myCommand.Parameters.Add(new SqlParameter("@ismanage", SqlDbType.NVarChar, 3));
- myCommand.Parameters["@ismanage"].Value = ismanage;
- myCommand.Connection.Open();
- try
- {
- myCommand.ExecuteNonQuery();
- //listView2.Select();
- //listView2.Refresh();
- MessageBox.Show("修改数据成功! ");
- myCommand.Connection.Close();
-
- }
- catch (SqlException ex)
- {
- MessageBox.Show("修改数据错误! " + ex.Message.ToString());
- myCommand.Connection.Close();
- return;
- }
- string str="select * from login";
- this.oleDbDataAdapter1.SelectCommand.CommandText=str;
- this.oleDbDataAdapter1.SelectCommand.Connection=this.oleDbConnection1;
- //打开数据库连接
- this.oleDbConnection1.Open();
- System.Data.OleDb.OleDbDataReader MyReader=this.oleDbDataAdapter1.SelectCommand.ExecuteReader();
-
- //this.listView1.View=View.Details;
-
- try
- {
- this.listView2.Items.Clear();
- while(MyReader.Read())
- {
- ListViewItem MyItem=new ListViewItem();
- MyItem.Text=MyReader.GetValue(0).ToString();
- for(int j=0;j<MyReader.FieldCount-2;j++)
- MyItem.SubItems.Add(MyReader.GetValue(j+1).ToString());
- string flog=MyReader.GetValue(MyReader.FieldCount-1).ToString();
- switch(flog)
- {
- case "yes":MyItem.SubItems.Add("管理人员");break;
- case "no":MyItem.SubItems.Add("销售人员");break;
- }
-
- this.listView2.Items.Add(MyItem);
-
- }
- MyReader.Close();
- this.oleDbConnection1.Close();
- }
- catch
- {
- MessageBox.Show(this,"帐户不存在!");
- MyReader.Close();
- this.oleDbConnection1.Close();
- return;
- }
-
- }
- private void button4_Click(object sender, System.EventArgs e)
- {
-
- string ismasage;
- switch(comboBox1.Text)
- {
- case"管理人员":ismasage="yes";break;
- case"销售人员":ismasage="no";break;
- default:
- return;
- }
- string insertsql="insert into login (uname,pwd,ismanage)values(@pname,@pwd,@ismanage)";
- SqlCommand myCommand=new SqlCommand(insertsql,myConnection);
- myCommand.Parameters.Add(new SqlParameter("@pname", SqlDbType.NVarChar, 20));
- myCommand.Parameters["@pname"].Value = textBox3.Text;
- myCommand.Parameters.Add(new SqlParameter("@pwd", SqlDbType.NVarChar, 20));
- myCommand.Parameters["@pwd"].Value = textBox4.Text;
- myCommand.Parameters.Add(new SqlParameter("@ismanage", SqlDbType.NVarChar, 3));
- myCommand.Parameters["@ismanage"].Value = ismasage;
- myCommand.Connection.Open();
- try
- {
- myCommand.ExecuteNonQuery();
- //listView2.Select();
- //listView2.Refresh();
- myCommand.Connection.Close();
- MessageBox.Show("插入数据成功! ");
-
- }
- catch (SqlException ex)
- {
- MessageBox.Show("插入数据错误! " + ex.Message.ToString());
- myCommand.Connection.Close();
- return;
- }
- string str="select * from login";
- this.oleDbDataAdapter1.SelectCommand.CommandText=str;
- this.oleDbDataAdapter1.SelectCommand.Connection=this.oleDbConnection1;
- //打开数据库连接
- this.oleDbConnection1.Open();
- System.Data.OleDb.OleDbDataReader MyReader=this.oleDbDataAdapter1.SelectCommand.ExecuteReader();
-
- //this.listView1.View=View.Details;
-
- try
- {
- this.listView2.Items.Clear();
- while(MyReader.Read())
- {
- ListViewItem MyItem=new ListViewItem();
- MyItem.Text=MyReader.GetValue(0).ToString();
- for(int j=0;j<MyReader.FieldCount-2;j++)
- MyItem.SubItems.Add(MyReader.GetValue(j+1).ToString());
- string flog=MyReader.GetValue(MyReader.FieldCount-1).ToString();
- switch(flog)
- {
- case "yes":MyItem.SubItems.Add("管理人员");break;
- case "no":MyItem.SubItems.Add("销售人员");break;
- }
-
- this.listView2.Items.Add(MyItem);
-
- }
- MyReader.Close();
- this.oleDbConnection1.Close();
- }
- catch
- {
- MessageBox.Show(this,"帐户不存在!");
- MyReader.Close();
- this.oleDbConnection1.Close();
- return;
- }
-
- }
- private void menuItem9_Click(object sender, System.EventArgs e)
- {
- textBox10.Text="";
- panel1.Visible=false;
- panel2.Visible=true;
- string production="select * from production";
- this.oleDbDataAdapter1.SelectCommand.CommandText=production;
- this.oleDbDataAdapter1.SelectCommand.Connection=this.oleDbConnection1;
- //打开数据库连接
- this.oleDbConnection1.Open();
- System.Data.OleDb.OleDbDataReader MyReader2=this.oleDbDataAdapter1.SelectCommand.ExecuteReader();
-
- //this.listView1.View=View.Details;
-
- try
- {
- this.listView3.Items.Clear();
- while(MyReader2.Read())
- {
- ListViewItem MyItem=new ListViewItem();
- MyItem.Text=MyReader2.GetValue(0).ToString();
- for(int j=0;j<MyReader2.FieldCount-1;j++)
- MyItem.SubItems.Add(MyReader2.GetValue(j+1).ToString());
- string flog=MyReader2.GetValue(MyReader2.FieldCount-1).ToString();
- this.listView3.Items.Add(MyItem);
-
- }
- MyReader2.Close();
- this.oleDbConnection1.Close();
- }
- catch
- {
- MessageBox.Show(this,"帐户不存在!");
- MyReader2.Close();
- this.oleDbConnection1.Close();
- return;
- }
- }
- private void v3select(object sender, System.EventArgs e)
- {
- string j;
- for(int i=this.listView3.SelectedItems.Count-1; i>=0;i--)
- {
- ListViewItem item = this.listView3.SelectedItems[i];
- j=item.Text;
- //j=this.listView2.Items.Add;
- string str="select * from production where pid="+j+"";
- this.oleDbDataAdapter1.SelectCommand.CommandText=str;
- this.oleDbDataAdapter1.SelectCommand.Connection=this.oleDbConnection1;
- //打开数据库连接
- this.oleDbConnection1.Open();
- System.Data.OleDb.OleDbDataReader MyReader=this.oleDbDataAdapter1.SelectCommand.ExecuteReader();
- MyReader.Read();
- groupBox2.Text=MyReader.GetValue(0).ToString();
- textBox5.Text=MyReader.GetValue(1).ToString();
- textBox6.Text=MyReader.GetValue(2).ToString();
- textBox7.Text=MyReader.GetValue(3).ToString();
- textBox8.Text=MyReader.GetValue(4).ToString();
- textBox9.Text=MyReader.GetValue(5).ToString();
-
-
- MyReader.Close();
- this.oleDbConnection1.Close();
- }
- }
- private void button7_Click(object sender, System.EventArgs e)
- {
- string pkey=textBox10.Text;
- string selectp="select * from production where pname like '%"+pkey+"%'";
- this.oleDbDataAdapter1.SelectCommand.CommandText=selectp;
- this.oleDbDataAdapter1.SelectCommand.Connection=this.oleDbConnection1;
- //打开数据库连接
- this.oleDbConnection1.Open();
- System.Data.OleDb.OleDbDataReader MyReader=this.oleDbDataAdapter1.SelectCommand.ExecuteReader();
- this.listView3.Items.Clear();
-
- try
- {
-
-
- while(MyReader.Read())
- {
- groupBox2.Text=MyReader.GetValue(0).ToString();
- textBox5.Text=MyReader.GetValue(1).ToString();
- textBox6.Text=MyReader.GetValue(2).ToString();
- textBox7.Text=MyReader.GetValue(3).ToString();
- textBox8.Text=MyReader.GetValue(4).ToString();
- textBox9.Text=MyReader.GetValue(5).ToString();
- ListViewItem MyItem=new ListViewItem();
- MyItem.Text=MyReader.GetValue(0).ToString();
- for(int j=0;j<MyReader.FieldCount-1;j++)
- MyItem.SubItems.Add(MyReader.GetValue(j+1).ToString());
- /*int b=MyReader.GetInt32(3);
- double c=a*b;
- string ff=c.ToString();
- MyItem.SubItems.Add(ff);*/
- //MyItem.SubItems.Add(textBox2.Text);
- //MyItem.SubItems.Add(allp.ToString());
-
- this.listView3.Items.Add(MyItem);
- }
- MyReader.Close();
- this.oleDbConnection1.Close();
- }
- catch
- {
- MessageBox.Show(this,"商品不存在!");
- this.oleDbConnection1.Close();
- return;
- }
-
- }
- private void button8_Click(object sender, System.EventArgs e)
- {
- textBox10.Text="";
- string production="select * from production";
- this.oleDbDataAdapter1.SelectCommand.CommandText=production;
- this.oleDbDataAdapter1.SelectCommand.Connection=this.oleDbConnection1;
- //打开数据库连接
- this.oleDbConnection1.Open();
- System.Data.OleDb.OleDbDataReader MyReader2=this.oleDbDataAdapter1.SelectCommand.ExecuteReader();
-
- //this.listView1.View=View.Details;
-
- try
- {
- this.listView3.Items.Clear();
- while(MyReader2.Read())
- {
- ListViewItem MyItem=new ListViewItem();
- MyItem.Text=MyReader2.GetValue(0).ToString();
- for(int j=0;j<MyReader2.FieldCount-1;j++)
- MyItem.SubItems.Add(MyReader2.GetValue(j+1).ToString());
- string flog=MyReader2.GetValue(MyReader2.FieldCount-1).ToString();
- this.listView3.Items.Add(MyItem);
-
- }
- MyReader2.Close();
- this.oleDbConnection1.Close();
- }
- catch
- {
- MyReader2.Close();
- this.oleDbConnection1.Close();
- MessageBox.Show(this,"帐户不存在!");
- }
- }
- private void button9_Click(object sender, System.EventArgs e)
- {
- textBox10.Text="";
- string insertCmd = "insert into production(pname,price,unit,huojia,kucun)values( @pname, @price, @unit, @huojia,@kucun)";
- SqlCommand myCommand = new SqlCommand(insertCmd, myConnection);
- myCommand.Parameters.Add(new SqlParameter("@pname", SqlDbType.NVarChar, 20));
- myCommand.Parameters["@pname"].Value = textBox5.Text;
- myCommand.Parameters.Add(new SqlParameter("@price", SqlDbType.Float, 8));
- myCommand.Parameters["@price"].Value = textBox6.Text;
- myCommand.Parameters.Add(new SqlParameter("@unit", SqlDbType.NVarChar, 3));
- myCommand.Parameters["@unit"].Value = textBox7.Text;
- myCommand.Parameters.Add(new SqlParameter("@huojia", SqlDbType.NVarChar, 3));
- myCommand.Parameters["@huojia"].Value = textBox8.Text;
- myCommand.Parameters.Add(new SqlParameter("@kucun", SqlDbType.Int, 4));
- myCommand.Parameters["@kucun"].Value = textBox9.Text;
- myCommand.Connection.Open();
- try
- {
- //this.menuItem9_Click(button9,e);
- myCommand.ExecuteNonQuery();
- MessageBox.Show("插入数据成功! ");
- }
- catch (SqlException ex)
- {
- MessageBox.Show("插入数据错误! " + ex.Message.ToString());
- }
- myCommand.Connection.Close();
- string production="select * from production";
- this.oleDbDataAdapter1.SelectCommand.CommandText=production;
- this.oleDbDataAdapter1.SelectCommand.Connection=this.oleDbConnection1;
- //打开数据库连接
- this.oleDbConnection1.Open();
- System.Data.OleDb.OleDbDataReader MyReader2=this.oleDbDataAdapter1.SelectCommand.ExecuteReader();
-
- //this.listView1.View=View.Details;
-
- try
- {
- this.listView3.Items.Clear();
- while(MyReader2.Read())
- {
- ListViewItem MyItem=new ListViewItem();
- MyItem.Text=MyReader2.GetValue(0).ToString();
- for(int j=0;j<MyReader2.FieldCount-1;j++)
- MyItem.SubItems.Add(MyReader2.GetValue(j+1).ToString());
- string flog=MyReader2.GetValue(MyReader2.FieldCount-1).ToString();
- this.listView3.Items.Add(MyItem);
-
- }
- MyReader2.Close();
- this.oleDbConnection1.Close();
- }
- catch
- {
- MessageBox.Show(this,"帐户不存在!");
- MyReader2.Close();
- this.oleDbConnection1.Close();
- return;
- }
- }
- private void button10_Click(object sender, System.EventArgs e)
- {
- ListViewItem item1 = this.listView3.SelectedItems[0];
- //textBox3.Text=item1.Text;
- for(int i=this.listView3.SelectedItems.Count-1; i>=0;i--)
- {
- ListViewItem item = this.listView3.SelectedItems[i];
- this.listView3.Items.Remove(item);
- string pflog=item.Text;
- string deletesql="delete from production where pid="+pflog+"";
- SqlCommand myCommand = new SqlCommand(deletesql, myConnection);
- myCommand.Connection.Open();
- try
- {
- myCommand.ExecuteNonQuery();
- MessageBox.Show("删除数据成功! ");
- }
- catch (SqlException ex)
- {
- MessageBox.Show("删除数据错误! " + ex.Message.ToString());
- }
- myCommand.Connection.Close();
- }
- }
- private void button11_Click(object sender, System.EventArgs e)
- {
- string updatesql="update production set pname=@pname,price=@price,unit=@unit,huojia=@huojia,kucun=@kucun where pid=@pid";
- SqlCommand myCommand = new SqlCommand(updatesql, myConnection);
- myCommand.Parameters.Add(new SqlParameter("@pid", SqlDbType.Int, 4));
- myCommand.Parameters["@pid"].Value = groupBox2.Text;
- myCommand.Parameters.Add(new SqlParameter("@pname", SqlDbType.NVarChar, 20));
- myCommand.Parameters["@pname"].Value = textBox5.Text;
- myCommand.Parameters.Add(new SqlParameter("@price", SqlDbType.Real, 8));
- myCommand.Parameters["@price"].Value = Convert.ToDouble(textBox6.Text.ToString());
- myCommand.Parameters.Add(new SqlParameter("@unit", SqlDbType.NVarChar, 3));
- myCommand.Parameters["@unit"].Value = textBox7.Text;
- myCommand.Parameters.Add(new SqlParameter("@huojia", SqlDbType.NVarChar, 3));
- myCommand.Parameters["@huojia"].Value = textBox8.Text;
- myCommand.Parameters.Add(new SqlParameter("@kucun", SqlDbType.Int, 4));
- myCommand.Parameters["@kucun"].Value = textBox9.Text;
- myCommand.Connection.Open();
- try
- {
- myCommand.ExecuteNonQuery();
- //listView2.Select();
- //listView2.Refresh();
- MessageBox.Show("修改数据成功! ");
-
- }
- catch (SqlException ex)
- {
- MessageBox.Show("修改数据错误! " + ex.Message.ToString());
- }
- myCommand.Connection.Close();
- string pkey;
- if(textBox10.Text!="")
- {
- pkey=textBox10.Text;
- }
- else
- {
- pkey=textBox5.Text;
- }
- string selectp="select * from production where pname like '%"+pkey+"%'";
- this.oleDbDataAdapter1.SelectCommand.CommandText=selectp;
- this.oleDbDataAdapter1.SelectCommand.Connection=this.oleDbConnection1;
- //打开数据库连接
- this.oleDbConnection1.Open();
- System.Data.OleDb.OleDbDataReader MyReader=this.oleDbDataAdapter1.SelectCommand.ExecuteReader();
- this.listView3.Items.Clear();
-
- try
- {
-
-
- while(MyReader.Read())
- {
- groupBox2.Text=MyReader.GetValue(0).ToString();
- textBox5.Text=MyReader.GetValue(1).ToString();
- textBox6.Text=MyReader.GetValue(2).ToString();
- textBox7.Text=MyReader.GetValue(3).ToString();
- textBox8.Text=MyReader.GetValue(4).ToString();
- textBox9.Text=MyReader.GetValue(5).ToString();
- ListViewItem MyItem=new ListViewItem();
- MyItem.Text=MyReader.GetValue(0).ToString();
- for(int j=0;j<MyReader.FieldCount-1;j++)
- MyItem.SubItems.Add(MyReader.GetValue(j+1).ToString());
- /*int b=MyReader.GetInt32(3);
- double c=a*b;
- string ff=c.ToString();
- MyItem.SubItems.Add(ff);*/
- //MyItem.SubItems.Add(textBox2.Text);
- //MyItem.SubItems.Add(allp.ToString());
-
- this.listView3.Items.Add(MyItem);
- }
- MyReader.Close();
- this.oleDbConnection1.Close();
- }
- catch
- {
- MessageBox.Show(this,"商品不存在!");
- this.oleDbConnection1.Close();
- return;
- }
- }
- private void button2_Click(object sender, System.EventArgs e)
- {
- string allprice="select sum(allp) from soled where sallflog=@flog";
- SqlCommand myCommand = new SqlCommand(allprice, myConnection);
- myCommand.Parameters.Add("@flog",SqlDbType.Int, 4);
- myCommand.Parameters["@flog"].Value=floglb.Text;
- myCommand.Connection.Open();
- try
- {
- string money=myCommand.ExecuteScalar().ToString();
- myCommand.Connection.Close();
- button1.Visible=false;
- button12.Visible=false;
- MessageBox.Show("应收金额:" + money);
- }
- catch(SqlException ex)
- {
- MessageBox.Show("统计数据错误! " + ex.Message.ToString());
- myCommand.Connection.Close();
- return;
- }
- }
- private void button12_Click(object sender, System.EventArgs e)
- {
- ListViewItem item1 = this.listView1.SelectedItems[0];
- //textBox3.Text=item1.Text;
- for(int i=this.listView1.SelectedItems.Count-1; i>=0;i--)
- {
- ListViewItem item = this.listView1.SelectedItems[i];
- this.listView1.Items.Remove(item);
- string pid=item.Text;
- string pflog=floglb.Text;
- string deletesql="delete from soled where sallflog="+pflog+" and pid="+pid+"";
- SqlCommand myCommand = new SqlCommand(deletesql, myConnection);
- myCommand.Connection.Open();
- try
- {
- myCommand.ExecuteNonQuery();
- MessageBox.Show("删除数据成功! ");
- myCommand.Connection.Close();
- }
- catch (SqlException ex)
- {
- MessageBox.Show("删除数据错误! " + ex.Message.ToString());
- return;
- }
-
- }
- }
- private void groupBox3_Enter(object sender, System.EventArgs e)
- {
-
- }
- private void statusBar1_PanelClick(object sender, System.Windows.Forms.StatusBarPanelClickEventArgs e)
- {
-
- }
- }
- }