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

📄 stocklist.cs

📁 机械制造业信息管理系统(含源码) 是为一个粮仪厂开发的
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

using System.Data;
using System.Data.OleDb;

namespace Eboer.MIS.MF.WinForm.Stock
{
	/// <summary>
	/// StockList 的摘要说明。
	/// </summary>
	public class StockList : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Button button3;
		private System.Windows.Forms.Button button4;
		private System.Windows.Forms.DataGrid list;
		private System.Windows.Forms.ContextMenu contextMenu;
		private System.Windows.Forms.MenuItem menuItem1;
		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.Button button5;
		private System.Windows.Forms.Button button6;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		/// <summary>
		/// 数据源
		/// </summary>
		private DataSet ds = null;

		/// <summary>
		/// 当前选中的行中相应的编号
		/// </summary>
		private string autoID       = null;
		private int    currentIndex = -1;

		//查询条件 ===================================

		public string corpSign  = null;   //客户编号
		public string corpName  = null;   //客户名称
		public string startDate = null;   //起始时间
		public string endDate   = null;   //结束时间
		public string timeType  = "JY";   //时间类型,默认为签约
		public string proSign   = null;   //产品编号
		public string proName   = null;   //产品名称
		public string executeEr = null;   //经办人
		public string djhm      = null;   //单据号码
		public string viewType  = "LIST"; //显示方式,默认列表,否则为明细
		public string areaName  = null;

		public string tjStr     = "NULL";

		private ReportLibrary.ReportDocument rd = null;

		public StockList()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//两个事件
			this.list.MouseDown   += new MouseEventHandler(this.ClickInDG);
			this.list.MouseUp     += new MouseEventHandler(this.UPInDG);
		}

		public void ListInit(){
			this.tjStr = null;
			this.LoadList();
			Public.SizeColumnsToContent(this.list,-1,this.ds.Tables[0],new string[]{"系统编号","信息编号","供货商编号"});
			this.GridStyle();
		}

		public void LoadList(){
			if(this.viewType == "LIST"){
				this.LoadListForList();
			}else{
				this.Text = "采购明细";
				this.list.ContextMenu = null;
				this.LoadListForItem();
			}

			//去掉空行
			((DataTable)this.list.DataSource).DefaultView.AllowNew = false;
		}

		private void LoadListForItem(){
			try{

				string sql = "select b.writeDate as 订购日期,b.offerName as 供货商名称,b.thisExecuteEr as 经办人,b.pageSign as 凭证编号,a.modelName as 规格,a.proName as 品名,a.nums as 数量,a.unitName as 单位,a.price as 单价,a.allExes as 总额,a.content as 备注,b.fc1 as 付款状况 from StockList a,StockOrder b,CorpColl c where a.stockSign=b.soSign and b.offerSign = c.sign";

				//限制公司名称
				if(this.corpSign != null && this.corpSign.Trim() != ""){
					sql += " and b.offerSign='"+ this.corpSign +"'";
					this.tjStr += "$供 货 商:" + this.corpName;
				}else if(this.corpName != null && this.corpName.Trim() != ""){
					sql += " and (b.offerName like '%"+ this.corpName +"%' or c.corContactEr = '"+ this.corpName +"')";
					this.tjStr += "$供 货 商:" + this.corpName;
				}

				//按时间段查询
				if(this.startDate != null && this.endDate != null){
					if(this.timeType == "JY"){//签约日期
						sql += " and b.writeDate >= #"+ this.startDate +"# and b.writeDate <= #"+ this.endDate +"#";
					}else if(this.timeType == "JH"){ //交货日期
						sql += " and b.rgDate >= #"+ this.startDate +"# and b.rgDate <= #"+ this.endDate +"#";
					}

					if(this.timeType != "NO") this.tjStr += "$时间区间:" + this.startDate + " 至 " + this.endDate;
				}

				//按产品名称
				if(this.proSign != null && this.proSign.Trim() != ""){
					sql += " and a.spec = '"+ this.proSign +"'";
					this.tjStr += "$产品名称:" + this.proName;
				}else if(this.proName != null && this.proName.Trim() != ""){
					sql += " and a.proName = '"+ this.proName +"'";
					this.tjStr += "$产品名称:" + this.proName;
				}

				//按我方经办人查询
				if(this.executeEr != null && this.executeEr.Trim() != ""){
					sql += " and b.thisExecuteEr='"+ this.executeEr +"'";
					this.tjStr += "$经 办 人:" + this.executeEr;
				}

				if(this.djhm != null && this.djhm.Trim() != ""){
					sql += " and b.pageSign='"+ this.djhm +"'";
					this.tjStr += "$单据号码:" + this.djhm;
				}

				//按地区
				if(this.areaName != null && this.areaName.Trim().Length > 0){
					sql += " and c.areaName like '%"+ this.areaName +"%'";
					this.tjStr += "$所属地区:" + this.areaName;
				}

				if(this.timeType == "JY"){
					sql += " order by b.writeDate desc";
				}else{
					sql += " order by b.rgDate desc";
				}

				this.ds = new DataSet();

				OleDbDataAdapter  ad = new OleDbDataAdapter(sql,Public.conn);
				ad.Fill(this.ds,"list");

				this.list.SetDataBinding(ds.Tables[0],"");

				this.label2.Text = "共有采购明细数据 "+ this.ds.Tables[0].Rows.Count.ToString() +" 条";

			}catch(Exception ex){
				MessageBox.Show(ex.Message.ToString());
				return;
			}
		}

		/// <summary>
		/// 载入
		/// </summary>
		private void LoadListForList(){
			try{

				if(this.list.DataSource != null) ((DataTable)this.list.DataSource).Rows.Clear();

				string sql = "select a.autoID as 系统编号,a.soSign as 信息编号,a.writeDate as 签约日期,fc2 as 总件数,a.offerSign as 供货商编号,a.offerName as 供货商名称,a.offerContacter as 对方联系人,d.tel as 电话,d.mobileTel as 手机,a.thisExecuteEr as 经办人,a.allExes as 总金额,a.fc1 as 付款状态 from StockOrder a,StockList b,CorpColl d where a.soSign=b.stockSign and a.offerSign=d.sign and d.comType='STOCK'";

				//限制公司名称
				if(this.corpSign != null && this.corpSign.Trim() != ""){
					sql += " and a.offerSign='"+ this.corpSign +"'";
					this.tjStr += "$供 货 商:" + this.corpName;
				}else if(this.corpName != null && this.corpName.Trim() != ""){
					sql += " and (a.offerName like '%"+ this.corpName +"%' or d.corContactEr = '"+ this.corpName +"')";
					this.tjStr += "$供 货 商:" + this.corpName;
				}

				//按时间段查询
				if(this.startDate != null && this.endDate != null){
					if(this.timeType == "JY"){//签约日期
						sql += " and a.writeDate >= #"+ this.startDate +"# and a.writeDate <= #"+ this.endDate +"#";
					}else if(this.timeType == "JH"){ //交货日期
						sql += " and a.rgDate >= #"+ this.startDate +"# and a.rgDate <= #"+ this.endDate +"#";
					}

					if(this.timeType != "NO") this.tjStr += "$时间区间:" + this.startDate + " 至 " + this.endDate;
				}

				//按产品名称
				if(this.proSign != null && this.proSign.Trim() != ""){
					sql += " and b.spec = '"+ this.proSign +"'";
					this.tjStr += "$产品名称:" + this.proName;
				}else if(this.proName != null && this.proName.Trim() != ""){
					sql += " and b.proName = '"+ this.proName +"'";
					this.tjStr += "$产品名称:" + this.proName;
				}

				//按我方经办人查询
				if(this.executeEr != null && this.executeEr.Trim() != ""){
					sql += " and a.thisExecuteEr='"+ this.executeEr +"'";
					this.tjStr += "$经 办 人:" + this.executeEr;
				}

				if(this.djhm != null && this.djhm.Trim() != ""){
					sql += " and a.pageSign='"+ this.djhm +"'";
					this.tjStr += "$单据号码:" + this.djhm;
				}

				//按地区
				if(this.areaName != null && this.areaName.Trim().Length > 0){
					sql += " and d.areaName like '%"+ this.areaName +"%'";
					this.tjStr += "$所属地区:" + this.areaName;
				}

				sql += " Group by a.autoID,a.pageSign,a.soSign,a.pactSign,a.writeDate,a.offerSign,a.offerName,a.offerContacter,a.thisExecuteEr,a.allExes,a.fc1,d.tel,d.mobileTel,a.fc2";
				
				if(this.startDate != null){
					if(this.timeType == "JY"){
						sql += " order by a.writeDate desc";
					}else{
						sql += " order by a.rgDate desc";
					}
				}else{
					sql += " order by soSign desc";
				}

				this.ds = new DataSet();

				OleDbDataAdapter  ad = new OleDbDataAdapter(sql,Public.conn);
				ad.Fill(this.ds,"list");

				this.list.SetDataBinding(ds.Tables[0],"");

				this.label2.Text = "共有采购单数据 "+ this.ds.Tables[0].Rows.Count.ToString() +" 条";

			}catch(Exception ex){
				MessageBox.Show(ex.Message.ToString());
				return;
			}
		}

		/// <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(StockList));
			this.label1 = new System.Windows.Forms.Label();
			this.button1 = new System.Windows.Forms.Button();
			this.button2 = new System.Windows.Forms.Button();
			this.label2 = new System.Windows.Forms.Label();
			this.button3 = new System.Windows.Forms.Button();
			this.button4 = new System.Windows.Forms.Button();
			this.list = new System.Windows.Forms.DataGrid();
			this.contextMenu = new System.Windows.Forms.ContextMenu();
			this.menuItem1 = new System.Windows.Forms.MenuItem();
			this.menuItem2 = new System.Windows.Forms.MenuItem();
			this.menuItem3 = new System.Windows.Forms.MenuItem();
			this.menuItem4 = 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.menuItem8 = new System.Windows.Forms.MenuItem();
			this.button5 = new System.Windows.Forms.Button();
			this.button6 = new System.Windows.Forms.Button();
			((System.ComponentModel.ISupportInitialize)(this.list)).BeginInit();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
			this.label1.Location = new System.Drawing.Point(-24, 392);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(100, 16);
			this.label1.TabIndex = 8;
			this.label1.Text = "共有数据:";
			// 
			// button1
			// 
			this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
			this.button1.Location = new System.Drawing.Point(480, 384);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(96, 23);
			this.button1.TabIndex = 7;
			this.button1.Text = "综合查询";
			// 
			// button2
			// 
			this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
			this.button2.Location = new System.Drawing.Point(576, 384);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(72, 23);
			this.button2.TabIndex = 6;
			this.button2.Text = "打 印";
			// 
			// label2
			// 
			this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
			this.label2.Location = new System.Drawing.Point(0, 344);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(100, 16);
			this.label2.TabIndex = 12;
			this.label2.Text = "共有数据:";
			// 
			// button3
			// 
			this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
			this.button3.Location = new System.Drawing.Point(336, 336);
			this.button3.Name = "button3";
			this.button3.Size = new System.Drawing.Size(96, 23);
			this.button3.TabIndex = 11;
			this.button3.Text = "综合查询";
			this.button3.Click += new System.EventHandler(this.button3_Click);
			// 
			// button4
			// 
			this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
			this.button4.Location = new System.Drawing.Point(560, 336);
			this.button4.Name = "button4";
			this.button4.Size = new System.Drawing.Size(64, 23);
			this.button4.TabIndex = 10;
			this.button4.Text = "打 印";
			this.button4.Click += new System.EventHandler(this.button4_Click);
			// 
			// list
			// 
			this.list.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.list.CaptionVisible = false;
			this.list.ContextMenu = this.contextMenu;
			this.list.DataMember = "";
			this.list.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.list.Location = new System.Drawing.Point(0, 2);
			this.list.Name = "list";
			this.list.ParentRowsVisible = false;
			this.list.Size = new System.Drawing.Size(624, 318);
			this.list.TabIndex = 9;
			// 
			// contextMenu
			// 
			this.contextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																						this.menuItem1,
																						this.menuItem2,
																						this.menuItem3,
																						this.menuItem4,
																						this.menuItem5,
																						this.menuItem6,
																						this.menuItem7,
																						this.menuItem8});
			// 
			// menuItem1
			// 
			this.menuItem1.Index = 0;
			this.menuItem1.Text = "修改选中信息";
			this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
			// 
			// menuItem2
			// 
			this.menuItem2.Index = 1;
			this.menuItem2.Text = "删除选中信息";
			this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
			// 
			// menuItem3
			// 
			this.menuItem3.Index = 2;
			this.menuItem3.Text = "-";
			// 
			// menuItem4
			// 
			this.menuItem4.Index = 3;
			this.menuItem4.Text = "查看供货商信息";
			this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
			// 
			// menuItem5
			// 
			this.menuItem5.Index = 4;
			this.menuItem5.Text = "-";

⌨️ 快捷键说明

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