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

📄 seloutstg.cs

📁 物流行业的仓库库存管理系统DOTNET平台下的源码
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;

namespace WindowsApplication4
{
	/// <summary>
	/// Form1 的摘要说明。
	/// </summary>
	public class SelOutStg : System.Windows.Forms.Form
	{
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.TextBox textNum;
		private System.Windows.Forms.DataGrid dataGrid1;
		private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
		private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
		private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
		private System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
		private System.Data.SqlClient.SqlConnection sqlConnection1;
		private System.Data.SqlClient.SqlDataAdapter OutStgAdapter;
		private DataTable OutStgInfo=new DataTable();
		private System.Windows.Forms.Button sel_button;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public SelOutStg()
		{
			//
			// 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()
		{
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.sel_button = new System.Windows.Forms.Button();
			this.textNum = new System.Windows.Forms.TextBox();
			this.label1 = new System.Windows.Forms.Label();
			this.dataGrid1 = new System.Windows.Forms.DataGrid();
			this.OutStgAdapter = new System.Data.SqlClient.SqlDataAdapter();
			this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
			this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
			this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
			this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
			this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
			this.groupBox1.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
			this.SuspendLayout();
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this.sel_button);
			this.groupBox1.Controls.Add(this.textNum);
			this.groupBox1.Controls.Add(this.label1);
			this.groupBox1.Location = new System.Drawing.Point(24, 8);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(432, 56);
			this.groupBox1.TabIndex = 0;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "检索项";
			// 
			// sel_button
			// 
			this.sel_button.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.sel_button.Location = new System.Drawing.Point(320, 16);
			this.sel_button.Name = "sel_button";
			this.sel_button.Size = new System.Drawing.Size(72, 24);
			this.sel_button.TabIndex = 4;
			this.sel_button.Text = "检索";
			this.sel_button.Click += new System.EventHandler(this.sel_button_Click);
			// 
			// textNum
			// 
			this.textNum.Location = new System.Drawing.Point(136, 16);
			this.textNum.Name = "textNum";
			this.textNum.Size = new System.Drawing.Size(104, 21);
			this.textNum.TabIndex = 2;
			this.textNum.Text = "";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(40, 24);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(96, 16);
			this.label1.TabIndex = 0;
			this.label1.Text = "按设备号查询:";
			// 
			// dataGrid1
			// 
			this.dataGrid1.DataMember = "";
			this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGrid1.Location = new System.Drawing.Point(24, 72);
			this.dataGrid1.Name = "dataGrid1";
			this.dataGrid1.Size = new System.Drawing.Size(432, 232);
			this.dataGrid1.TabIndex = 1;
			// 
			// OutStgAdapter
			// 
			this.OutStgAdapter.DeleteCommand = this.sqlDeleteCommand1;
			this.OutStgAdapter.InsertCommand = this.sqlInsertCommand1;
			this.OutStgAdapter.SelectCommand = this.sqlSelectCommand1;
			this.OutStgAdapter.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
																									new System.Data.Common.DataTableMapping("Table", "storage_out", new System.Data.Common.DataColumnMapping[] {
																																																				   new System.Data.Common.DataColumnMapping("Expr1", "Expr1"),
																																																				   new System.Data.Common.DataColumnMapping("Expr2", "Expr2"),
																																																				   new System.Data.Common.DataColumnMapping("供应商", "供应商"),
																																																				   new System.Data.Common.DataColumnMapping("数量", "数量"),
																																																				   new System.Data.Common.DataColumnMapping("经办人", "经办人")})});
			this.OutStgAdapter.UpdateCommand = this.sqlUpdateCommand1;
			// 
			// sqlDeleteCommand1
			// 
			this.sqlDeleteCommand1.CommandText = @"DELETE FROM storage_out WHERE (设备号 = @Original_Expr2) AND (供应商 = @Original_供应商 OR @Original_供应商 IS NULL AND 供应商 IS NULL) AND (出库日期 = @Original_Expr1 OR @Original_Expr1 IS NULL AND 出库日期 IS NULL) AND (数量 = @Original_数量 OR @Original_数量 IS NULL AND 数量 IS NULL) AND (经办人 = @Original_经办人 OR @Original_经办人 IS NULL AND 经办人 IS NULL)";
			this.sqlDeleteCommand1.Connection = this.sqlConnection1;
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Expr2", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Expr2", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_供应商", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "供应商", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Expr1", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Expr1", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_数量", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "数量", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_经办人", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "经办人", System.Data.DataRowVersion.Original, null));
			// 
			// sqlConnection1
			// 
			this.sqlConnection1.ConnectionString = "workstation id=727CE26111204C4;packet size=4096;user id=sa;data source=\".\";persis" +
				"t security info=False;initial catalog=storage";
			// 
			// sqlInsertCommand1
			// 
			this.sqlInsertCommand1.CommandText = "INSERT INTO storage_out(出库日期, 设备号, 供应商, 数量, 经办人) VALUES (@出库日期, @设备号, @供应商, @数量, " +
				"@经办人); SELECT 出库日期 AS Expr1, 设备号 AS Expr2, 供应商, 数量, 经办人 FROM storage_out WHERE (" +
				"设备号 = @Expr2)";
			this.sqlInsertCommand1.Connection = this.sqlConnection1;
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@出库日期", System.Data.SqlDbType.VarChar, 10, "Expr1"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@设备号", System.Data.SqlDbType.VarChar, 10, "Expr2"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@供应商", System.Data.SqlDbType.VarChar, 10, "供应商"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@数量", System.Data.SqlDbType.VarChar, 10, "数量"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@经办人", System.Data.SqlDbType.VarChar, 10, "经办人"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Expr2", System.Data.SqlDbType.VarChar, 10, "Expr2"));
			// 
			// sqlSelectCommand1
			// 
			this.sqlSelectCommand1.CommandText = "SELECT 出库日期 AS Expr1, 设备号 AS Expr2, 供应商, 数量, 经办人 FROM storage_out";
			this.sqlSelectCommand1.Connection = this.sqlConnection1;
			// 
			// sqlUpdateCommand1
			// 
			this.sqlUpdateCommand1.CommandText = @"UPDATE storage_out SET 出库日期 = @出库日期, 设备号 = @设备号, 供应商 = @供应商, 数量 = @数量, 经办人 = @经办人 WHERE (设备号 = @Original_Expr2) AND (供应商 = @Original_供应商 OR @Original_供应商 IS NULL AND 供应商 IS NULL) AND (出库日期 = @Original_Expr1 OR @Original_Expr1 IS NULL AND 出库日期 IS NULL) AND (数量 = @Original_数量 OR @Original_数量 IS NULL AND 数量 IS NULL) AND (经办人 = @Original_经办人 OR @Original_经办人 IS NULL AND 经办人 IS NULL); SELECT 出库日期 AS Expr1, 设备号 AS Expr2, 供应商, 数量, 经办人 FROM storage_out WHERE (设备号 = @Expr2)";
			this.sqlUpdateCommand1.Connection = this.sqlConnection1;
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@出库日期", System.Data.SqlDbType.VarChar, 10, "Expr1"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@设备号", System.Data.SqlDbType.VarChar, 10, "Expr2"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@供应商", System.Data.SqlDbType.VarChar, 10, "供应商"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@数量", System.Data.SqlDbType.VarChar, 10, "数量"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@经办人", System.Data.SqlDbType.VarChar, 10, "经办人"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Expr2", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Expr2", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_供应商", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "供应商", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Expr1", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Expr1", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_数量", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "数量", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_经办人", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "经办人", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Expr2", System.Data.SqlDbType.VarChar, 10, "Expr2"));
			// 
			// SelOutStg
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(480, 318);
			this.Controls.Add(this.dataGrid1);
			this.Controls.Add(this.groupBox1);
			this.Name = "SelOutStg";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "出库信息查询";
			this.Load += new System.EventHandler(this.SelInStg_Load);
			this.groupBox1.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void SelInStg_Load(object sender, System.EventArgs e)
		{
			try
			{
				this.sqlConnection1.ConnectionString= "server=.;Trusted_Connection=yes;user=sa;pwd=1;database=storage";//建立连接
				this.sqlConnection1.Open();
				DataSet OutStgSet=new DataSet();
				OutStgAdapter.SelectCommand.CommandText="SELECT * FROM storage_out";
				OutStgAdapter.SelectCommand.Connection=sqlConnection1;
				OutStgAdapter.Fill(OutStgInfo);
				DataGridTableStyle outstg = new DataGridTableStyle();
				outstg.AlternatingBackColor = Color.Blue;//颜色设置
				outstg.MappingName = OutStgInfo.TableName;
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
			finally
			{
			}
		}

		private void sel_button_Click(object sender, System.EventArgs e)
		{
			string condition = "";
			if(this.textNum.Text.Trim() != "")//设置表的过滤条件
			{
				condition += "设备号 like '%" + textNum.Text.Trim()  + "%'";
			}
			else
			{
				MessageBox.Show("请输入检索条件");
				return;
			}
			OutStgInfo.DefaultView.RowFilter=condition;
			this.dataGrid1.DataSource = OutStgInfo.DefaultView;//设置数据源
			if(this.dataGrid1.VisibleRowCount==1)//判断检索条件是否与记录匹配
			{
				MessageBox.Show("对不起,出库数据中没有与您检索条件相匹配的记录!");
				return;
			}
			this.textNum.Clear();
			
		}


	}
}

⌨️ 快捷键说明

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