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

📄 purchaseform.cs

📁 超市管理系统的完整版文档
💻 CS
📖 第 1 页 / 共 2 页
字号:
			// 
			// 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(179, 264);
			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(394, 264);
			this.button2.Name = "button2";
			this.button2.TabIndex = 15;
			this.button2.Text = "重置";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// m_PurchaseDataGrid
			// 
			this.m_PurchaseDataGrid.DataMember = "";
			this.m_PurchaseDataGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.m_PurchaseDataGrid.Location = new System.Drawing.Point(13, 293);
			this.m_PurchaseDataGrid.Name = "m_PurchaseDataGrid";
			this.m_PurchaseDataGrid.ReadOnly = true;
			this.m_PurchaseDataGrid.Size = new System.Drawing.Size(617, 211);
			this.m_PurchaseDataGrid.TabIndex = 18;
			// 
			// label9
			// 
			this.label9.AutoSize = true;
			this.label9.Location = new System.Drawing.Point(175, 245);
			this.label9.Name = "label9";
			this.label9.Size = new System.Drawing.Size(313, 17);
			this.label9.TabIndex = 19;
			this.label9.Text = "友情提示:名称和姓名支持模糊查询;缺省为查询所有。";
			// 
			// PurchaseForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(642, 516);
			this.Controls.Add(this.label9);
			this.Controls.Add(this.m_PurchaseDataGrid);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.groupBox1);
			this.MaximizeBox = false;
			this.Name = "PurchaseForm";
			this.Text = "进货记录查询";
			this.groupBox1.ResumeLayout(false);
			this.groupBox2.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.m_PurchaseDataGrid)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		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)
			{
				purchaserNameTextBox.Enabled = true;
			}
			else
			{
				purchaserNameTextBox.Enabled = false;
			}
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			string query = "select * from PurchaseRecord inner join Goods on Goods.GoodsID = PurchaseRecord.GoodsID inner join Employee on Employee.EmployeeID = PurchaseRecord.PurchaserID inner join Supplier on Supplier.SupplierID = PurchaseRecord.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 += "Employee.EmployeeName like '%" + purchaserNameTextBox.Text + "%' and ";
			}
			if (checkBox6.Checked == true)
			{
				query += "Supplier.Name like '%" + supplierNameTextBox.Text + "%' and ";
			}
			if (checkBox4.Checked == true)
			{
				if (radioButton1.Checked == true)
				{//今日进货
					query += "convert(varchar(10),PurchaseRecord.PurchaseDate,20) = convert(varchar(10),GETDATE(),20)";
				}
				else
				{//日期范围
					DateTime startDateTime = startDateTimePicker.Value;
					DateTime endDateTime = endDateTimePicker.Value;
					query += "PurchaseRecord.PurchaseDate > '" + startDateTime + "' and PurchaseRecord.PurchaseDate < '" + endDateTime + "'";
				}

			}

			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("进货单价(元)"));

			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["PurchaseRecordID"];
				datarow[1] = reader["PurchaseDate"];
				datarow[2] = reader["GoodsName"];
				datarow[3] = reader["EmployeeName"];
				datarow[4] = reader["Name"];
				datarow[5] = reader["PurchaserNumber"];
				datarow[6] = reader["PurchaseUnitPrice"];
				datatable.Rows.Add(datarow);
			}
			System.Data.DataView dataview = new System.Data.DataView(datatable);
			m_PurchaseDataGrid.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;
			checkBox6.Checked = false;

			goodsCodeTextBox.Text = "";
			goodsNameTextBox.Text = "";
			purchaserNameTextBox.Text = "";
			supplierNameTextBox.Text = "";

			startDateTimePicker.ResetText();
			endDateTimePicker.ResetText();
		}

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

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

		private void radioButton2_CheckedChanged(object sender, System.EventArgs e)
		{
			if (radioButton2.Checked == true)
			{
				startDateTimePicker.Enabled = true;
				endDateTimePicker.Enabled = true;
			}
			else
			{
				startDateTimePicker.Enabled = false;
				endDateTimePicker.Enabled = false;
			}
		}

		private void radioButton1_CheckedChanged(object sender, System.EventArgs e)
		{
			if (radioButton1.Checked == true)
			{
				startDateTimePicker.Enabled = false;
				endDateTimePicker.Enabled = false;
			}
		}

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

⌨️ 快捷键说明

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