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

📄 listforcumstor.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
{
	/// <summary>
	/// ListForCumstor 的摘要说明。
	/// </summary>
	public class ListForCumstor : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.DataGrid list;
		private System.Windows.Forms.Button button3;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;
		private System.Windows.Forms.ContextMenu contextMenu;
		private System.Windows.Forms.MenuItem menuItem1;
		private System.Windows.Forms.MenuItem menuItem2;
		private System.Windows.Forms.MenuItem menuItem5;
		private System.Windows.Forms.MenuItem menuItem6;
		private System.Windows.Forms.Button button4;

		//
		private string comType = "SELL";

		//选中的行的系统编号
		private string autoID  = null;

		private int currentIndex = -1;

		private DataSet ds = null;

		private ReportLibrary.ReportDocument rd = null;
		private System.Windows.Forms.TextBox keyword;
		private System.Windows.Forms.MenuItem menuItem7;
		private System.Windows.Forms.MenuItem menuItem8;
		private System.Windows.Forms.MenuItem menuItem3;
		private System.Windows.Forms.MenuItem menuItem4;
		private System.Windows.Forms.MenuItem menuItem9;

		/// <summary>
		/// 是否查询
		/// </summary>
		private bool isSearch = false;

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

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

			//
		}

		/// <summary>
		/// 载入单位列表
		/// </summary>
		public void LoadList(){
			try{

				//清除原有数据
				if(this.list.DataSource != null) ((DataTable)this.list.DataSource).Rows.Clear();

				string sql = "select autoID as 系统编号,sign as 手工编号,corName as 单位名称,corContactEr as 联系人,areaName as 地区,address as 地址,pcCode as 邮编,tel as 电话,fax as 传真,mobileTel as 手机,email as 电子邮件,content as 备注,openBank as 开户行,bankAccName as 开户名称,bankaccNum as 开户帐号 from CorpColl where comType='"+ this.comType +"'";

				//查询条件
				if(this.keyword.Text.Trim() != ""){
					sql += " and (corName like '%"+ this.keyword.Text +"%' or corContactEr like '%"+ this.keyword.Text +"%' or areaName like '%"+ this.keyword.Text +"%' or address like '%"+ this.keyword.Text +"%' or pcCode like '%"+ this.keyword.Text +"%' or tel like '%"+ this.keyword.Text +"%' or fax like '%"+ this.keyword.Text +"%')";
				}

				sql += " order by autoID desc";

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

				for(int i=0;i<this.ds.Tables[0].Rows.Count;i++){
					string _val = this.ds.Tables[0].Rows[i]["地区"].ToString();
					this.ds.Tables[0].Rows[i]["地区"] = _val.Substring(_val.IndexOf("|")+1,_val.Length-_val.IndexOf("|")-1);
				}

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

				this.rd = new ReportLibrary.ReportDocument(ds.Tables[0]);

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

			}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 );
		}

		/// <summary>
		/// 设置窗体文本,同时载入数据
		/// </summary>
		public void SetFormText(string formText){
			this.Text = formText;
			if(this.Text.StartsWith("供货商")) this.comType = "STOCK";
			if(this.Text.StartsWith("我方公司")) this.comType = "SELF";
			this.LoadList();
			Public.SizeColumnsToContent(this.list,-1,this.ds.Tables[0],new string[]{"系统编号","手工编号"});
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(ListForCumstor));
			this.list = new System.Windows.Forms.DataGrid();
			this.contextMenu = new System.Windows.Forms.ContextMenu();
			this.menuItem1 = new System.Windows.Forms.MenuItem();
			this.menuItem8 = new System.Windows.Forms.MenuItem();
			this.menuItem7 = new System.Windows.Forms.MenuItem();
			this.menuItem9 = new System.Windows.Forms.MenuItem();
			this.menuItem3 = new System.Windows.Forms.MenuItem();
			this.menuItem5 = new System.Windows.Forms.MenuItem();
			this.menuItem2 = new System.Windows.Forms.MenuItem();
			this.menuItem4 = new System.Windows.Forms.MenuItem();
			this.menuItem6 = new System.Windows.Forms.MenuItem();
			this.button2 = new System.Windows.Forms.Button();
			this.button1 = new System.Windows.Forms.Button();
			this.label1 = new System.Windows.Forms.Label();
			this.keyword = new System.Windows.Forms.TextBox();
			this.button3 = new System.Windows.Forms.Button();
			this.button4 = new System.Windows.Forms.Button();
			((System.ComponentModel.ISupportInitialize)(this.list)).BeginInit();
			this.SuspendLayout();
			// 
			// 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, 0);
			this.list.Name = "list";
			this.list.ParentRowsVisible = false;
			this.list.Size = new System.Drawing.Size(544, 328);
			this.list.TabIndex = 0;
			this.list.Navigate += new System.Windows.Forms.NavigateEventHandler(this.list_Navigate);
			this.list.CurrentCellChanged += new System.EventHandler(this.list_CurrentCellChanged);
			// 
			// contextMenu
			// 
			this.contextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																						this.menuItem1,
																						this.menuItem8,
																						this.menuItem7,
																						this.menuItem9,
																						this.menuItem3,
																						this.menuItem5,
																						this.menuItem2,
																						this.menuItem4,
																						this.menuItem6});
			// 
			// menuItem1
			// 
			this.menuItem1.Index = 0;
			this.menuItem1.Text = "修改选中信息";
			this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
			// 
			// menuItem8
			// 
			this.menuItem8.Index = 1;
			this.menuItem8.Text = "新建采购单(&B)";
			this.menuItem8.Click += new System.EventHandler(this.menuItem8_Click);
			// 
			// menuItem7
			// 
			this.menuItem7.Index = 2;
			this.menuItem7.Text = "新建销售单(&S)";
			this.menuItem7.Click += new System.EventHandler(this.menuItem7_Click);
			// 
			// menuItem9
			// 
			this.menuItem9.Index = 3;
			this.menuItem9.Text = "查看我的采购(&B)";
			this.menuItem9.Click += new System.EventHandler(this.menuItem9_Click);
			// 
			// menuItem3
			// 
			this.menuItem3.Index = 4;
			this.menuItem3.Text = "查看全部定单(&S)";
			this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
			// 
			// menuItem5
			// 
			this.menuItem5.Index = 5;
			this.menuItem5.Text = "-";
			// 
			// menuItem2
			// 
			this.menuItem2.Index = 6;
			this.menuItem2.Text = "删除选中信息";
			this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
			// 
			// menuItem4
			// 
			this.menuItem4.Index = 7;
			this.menuItem4.Text = "-";
			// 
			// menuItem6
			// 
			this.menuItem6.Index = 8;
			this.menuItem6.Text = "刷新全部信息";
			this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
			// 
			// 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(496, 336);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(48, 23);
			this.button2.TabIndex = 2;
			this.button2.Text = "打 印";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// 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(312, 336);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(56, 23);
			this.button1.TabIndex = 3;
			this.button1.Text = "查 询";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// 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(0, 344);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(100, 16);
			this.label1.TabIndex = 4;
			this.label1.Text = "共有数据:";
			// 
			// keyword
			// 
			this.keyword.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
			this.keyword.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.keyword.Location = new System.Drawing.Point(104, 336);
			this.keyword.Name = "keyword";
			this.keyword.Size = new System.Drawing.Size(208, 21);
			this.keyword.TabIndex = 5;
			this.keyword.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(440, 336);
			this.button3.Name = "button3";
			this.button3.Size = new System.Drawing.Size(56, 23);
			this.button3.TabIndex = 6;
			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(384, 336);
			this.button4.Name = "button4";
			this.button4.Size = new System.Drawing.Size(56, 23);
			this.button4.TabIndex = 7;
			this.button4.Text = "刷 新";
			this.button4.Click += new System.EventHandler(this.button4_Click);
			// 
			// ListForCumstor
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(544, 365);
			this.Controls.Add(this.button4);
			this.Controls.Add(this.button3);
			this.Controls.Add(this.keyword);
			this.Controls.Add(this.list);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.button2);
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Name = "ListForCumstor";
			this.Text = "供应商资料";
			this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
			((System.ComponentModel.ISupportInitialize)(this.list)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 查询
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void button1_Click(object sender, System.EventArgs e) {
			this.LoadList();
		}

		/// <summary>
		/// 打印
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void button2_Click(object sender, System.EventArgs e) {

⌨️ 快捷键说明

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