⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 goodsform.cs

📁 超市管理系统的完整版文档
💻 CS
📖 第 1 页 / 共 2 页
字号:
			// 
			this.salePriceMinTextBox.Enabled = false;
			this.salePriceMinTextBox.Location = new System.Drawing.Point(519, 105);
			this.salePriceMinTextBox.Name = "salePriceMinTextBox";
			this.salePriceMinTextBox.Size = new System.Drawing.Size(123, 21);
			this.salePriceMinTextBox.TabIndex = 19;
			this.salePriceMinTextBox.Text = "";
			// 
			// purchasePriceMaxTextBox
			// 
			this.purchasePriceMaxTextBox.Enabled = false;
			this.purchasePriceMaxTextBox.Location = new System.Drawing.Point(519, 66);
			this.purchasePriceMaxTextBox.Name = "purchasePriceMaxTextBox";
			this.purchasePriceMaxTextBox.Size = new System.Drawing.Size(123, 21);
			this.purchasePriceMaxTextBox.TabIndex = 18;
			this.purchasePriceMaxTextBox.Text = "";
			// 
			// purchasePriceMinTextBox
			// 
			this.purchasePriceMinTextBox.Enabled = false;
			this.purchasePriceMinTextBox.Location = new System.Drawing.Point(519, 29);
			this.purchasePriceMinTextBox.Name = "purchasePriceMinTextBox";
			this.purchasePriceMinTextBox.Size = new System.Drawing.Size(123, 21);
			this.purchasePriceMinTextBox.TabIndex = 17;
			this.purchasePriceMinTextBox.Text = "";
			// 
			// supplierNameTextBox
			// 
			this.supplierNameTextBox.Enabled = false;
			this.supplierNameTextBox.Location = new System.Drawing.Point(121, 143);
			this.supplierNameTextBox.Name = "supplierNameTextBox";
			this.supplierNameTextBox.Size = new System.Drawing.Size(123, 21);
			this.supplierNameTextBox.TabIndex = 16;
			this.supplierNameTextBox.Text = "";
			// 
			// goodsNameTextBox
			// 
			this.goodsNameTextBox.Enabled = false;
			this.goodsNameTextBox.Location = new System.Drawing.Point(121, 88);
			this.goodsNameTextBox.Name = "goodsNameTextBox";
			this.goodsNameTextBox.Size = new System.Drawing.Size(123, 21);
			this.goodsNameTextBox.TabIndex = 15;
			this.goodsNameTextBox.Text = "";
			// 
			// goodsCodeTextBox
			// 
			this.goodsCodeTextBox.Enabled = false;
			this.goodsCodeTextBox.Location = new System.Drawing.Point(121, 28);
			this.goodsCodeTextBox.Name = "goodsCodeTextBox";
			this.goodsCodeTextBox.Size = new System.Drawing.Size(123, 21);
			this.goodsCodeTextBox.TabIndex = 14;
			this.goodsCodeTextBox.Text = "";
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(235, 226);
			this.button1.Name = "button1";
			this.button1.TabIndex = 14;
			this.button1.Text = "查询";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(435, 226);
			this.button2.Name = "button2";
			this.button2.TabIndex = 15;
			this.button2.Text = "重置";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// m_GoodsDataGrid
			// 
			this.m_GoodsDataGrid.DataMember = "";
			this.m_GoodsDataGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.m_GoodsDataGrid.Location = new System.Drawing.Point(12, 255);
			this.m_GoodsDataGrid.Name = "m_GoodsDataGrid";
			this.m_GoodsDataGrid.ReadOnly = true;
			this.m_GoodsDataGrid.Size = new System.Drawing.Size(718, 189);
			this.m_GoodsDataGrid.TabIndex = 16;
			// 
			// label9
			// 
			this.label9.AutoSize = true;
			this.label9.Location = new System.Drawing.Point(245, 205);
			this.label9.Name = "label9";
			this.label9.Size = new System.Drawing.Size(276, 17);
			this.label9.TabIndex = 17;
			this.label9.Text = "友情提示:名称支持模糊查询;缺省为查询所有。";
			// 
			// GoodsForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(742, 456);
			this.Controls.Add(this.label9);
			this.Controls.Add(this.m_GoodsDataGrid);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.groupBox1);
			this.MaximizeBox = false;
			this.Name = "GoodsForm";
			this.Text = "商品信息查询";
			this.Load += new System.EventHandler(this.GoodsForm_Load);
			this.groupBox1.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.m_GoodsDataGrid)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void GoodsForm_Load(object sender, System.EventArgs e)
		{
		
		}

		private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
		{
			if (checkBox1.Checked == true)
			{
				goodsCodeTextBox.Enabled = true;
			}
			else
			{
				goodsCodeTextBox.Enabled = false;
			}
		}

		private void checkBox2_CheckedChanged(object sender, System.EventArgs e)
		{
			if (checkBox2.Checked == true)
			{
				goodsNameTextBox.Enabled = true;
			}
			else
			{
				goodsNameTextBox.Enabled = false;
			}
		}

		private void checkBox3_CheckedChanged(object sender, System.EventArgs e)
		{
			if (checkBox3.Checked == true)
			{
				supplierNameTextBox.Enabled = true;
			}
			else
			{
				supplierNameTextBox.Enabled = false;
			}
		}

		private void checkBox4_CheckedChanged(object sender, System.EventArgs e)
		{
			if (checkBox4.Checked == true)
			{
				purchasePriceMinTextBox.Enabled = true;
				purchasePriceMaxTextBox.Enabled = true;
			}
			else
			{
				purchasePriceMinTextBox.Enabled = false;
				purchasePriceMaxTextBox.Enabled = false;
			}
		}

		private void checkBox5_CheckedChanged(object sender, System.EventArgs e)
		{
			if (checkBox5.Checked == true)
			{
				salePriceMinTextBox.Enabled = true;
				salePriceMaxTextBox.Enabled = true;
			}
			else
			{
				salePriceMinTextBox.Enabled = false;
				salePriceMaxTextBox.Enabled = false;
			}
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			string query = "select * from Goods inner join Supplier on Goods.SupplierID = Supplier.SupplierID where ";

			if (checkBox1.Checked == true)
			{
				query += "Goods.GoodsCode = '" + goodsCodeTextBox.Text + "' and ";
			}
			if (checkBox2.Checked == true)
			{
				query += "Goods.GoodsName like '%" + goodsNameTextBox.Text + "%' and ";
			}
			if (checkBox3.Checked == true)
			{
				query += "Supplier.Name like '%" + supplierNameTextBox.Text + "%' and ";
			}
			if (checkBox4.Checked == true)
			{
				query += "Goods.PurchasePrice between " + purchasePriceMinTextBox.Text + " and " + purchasePriceMaxTextBox.Text + " and ";
			}
			if (checkBox5.Checked == true)
			{
				query += "Goods.SalePrice between " + salePriceMinTextBox.Text + " and " + salePriceMaxTextBox.Text;
			}

			if(query.EndsWith("and "))
			{
				query = query.Substring(0,query.LastIndexOf("and "));
			}
			if (query.EndsWith("where "))
			{
				query = query.Substring(0, query.LastIndexOf("where "));
			}

			Console.WriteLine(query);

			System.Data.DataTable datatable = new System.Data.DataTable();
			System.Data.DataRow datarow;
			datatable.Columns.Add(new System.Data.DataColumn("商品编号"));
			datatable.Columns.Add(new System.Data.DataColumn("商品条形码"));
			datatable.Columns.Add(new System.Data.DataColumn("商品名称"));
			datatable.Columns.Add(new System.Data.DataColumn("进价(元)"));
			datatable.Columns.Add(new System.Data.DataColumn("售价(元)"));
			datatable.Columns.Add(new System.Data.DataColumn("计量单位"));
			datatable.Columns.Add(new System.Data.DataColumn("供应商名称"));
			datatable.Columns.Add(new System.Data.DataColumn("库存数量"));
			datatable.Columns.Add(new System.Data.DataColumn("备注"));

			SqlConnection conn = DBUtil.GetConnection();
			conn.Open();
			SqlCommand cmd = new SqlCommand(query, conn);
			SqlDataReader reader = cmd.ExecuteReader();
			while (reader.Read())
			{
				datarow = datatable.NewRow();
				datarow[0] = reader["GoodsID"];
				datarow[1] = reader["GoodsCode"];
				datarow[2] = reader["GoodsName"];
				datarow[3] = reader["PurchasePrice"];
				datarow[4] = reader["SalePrice"];
				datarow[5] = reader["Unit"];
				datarow[6] = reader["Name"];
				datarow[7] = reader["StockNumber"];
				datarow[8] = reader["Remark"];
				datatable.Rows.Add(datarow);
			}
			System.Data.DataView dataview = new System.Data.DataView(datatable);
			m_GoodsDataGrid.DataSource = dataview;
			conn.Close();
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			checkBox1.Checked = false;
			checkBox2.Checked = false;
			checkBox3.Checked = false;
			checkBox4.Checked = false;
			checkBox5.Checked = false;

			goodsCodeTextBox.Text = "";
			goodsNameTextBox.Text = "";
			supplierNameTextBox.Text = "";
			purchasePriceMinTextBox.Text = "";
			purchasePriceMaxTextBox.Text = "";
			salePriceMinTextBox.Text = "";
			salePriceMaxTextBox.Text = "";
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -