SelectMaterial.cs
资源名称:VCSDB.rar [点击查看]
上传用户:hjieqiu
上传日期:2013-05-11
资源大小:16494k
文件大小:13k
源码类别:
企业管理
开发平台:
C#
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Data;
- namespace 生产管理系统
- {
- /// <summary>
- /// SelectMaterial 的摘要说明。
- /// </summary>
- public class SelectMaterial : System.Windows.Forms.Form
- {
- public static int callForm;//确认是由主需求计划还是主生产计划调出该窗体
- private System.Windows.Forms.DataGrid dataGrid1;
- private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
- private System.Data.SqlClient.SqlConnection sqlConnection1;
- private 生产管理系统.DataSet2 dataSet21;
- private System.Data.DataView dataView1;
- private System.Windows.Forms.TextBox txt1;
- private System.Data.SqlClient.SqlDataAdapter da1;
- private System.Windows.Forms.TextBox txt2;
- private System.Windows.Forms.TextBox txt3;
- private System.Windows.Forms.Button btnSearch;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.Label label3;
- /// <summary>
- /// 必需的设计器变量。
- /// </summary>
- private System.ComponentModel.Container components = null;
- public SelectMaterial()
- {
- //
- // 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()
- {
- System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(SelectMaterial));
- this.dataGrid1 = new System.Windows.Forms.DataGrid();
- this.dataView1 = new System.Data.DataView();
- this.dataSet21 = new 生产管理系统.DataSet2();
- this.da1 = new System.Data.SqlClient.SqlDataAdapter();
- this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
- this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
- this.txt1 = new System.Windows.Forms.TextBox();
- this.txt2 = new System.Windows.Forms.TextBox();
- this.txt3 = new System.Windows.Forms.TextBox();
- this.btnSearch = new System.Windows.Forms.Button();
- this.label1 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.label3 = new System.Windows.Forms.Label();
- ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataView1)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataSet21)).BeginInit();
- this.SuspendLayout();
- //
- // dataGrid1
- //
- this.dataGrid1.CaptionText = "双击首列选择物料";
- this.dataGrid1.DataMember = "";
- this.dataGrid1.DataSource = this.dataView1;
- this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
- this.dataGrid1.Location = new System.Drawing.Point(0, 40);
- this.dataGrid1.Name = "dataGrid1";
- this.dataGrid1.ReadOnly = true;
- this.dataGrid1.Size = new System.Drawing.Size(480, 304);
- this.dataGrid1.TabIndex = 0;
- this.dataGrid1.DoubleClick += new System.EventHandler(this.dataGrid1_DoubleClick);
- //
- // dataView1
- //
- this.dataView1.Table = this.dataSet21.物料主文件;
- //
- // dataSet21
- //
- this.dataSet21.DataSetName = "DataSet2";
- this.dataSet21.Locale = new System.Globalization.CultureInfo("zh-CN");
- //
- // da1
- //
- this.da1.SelectCommand = this.sqlSelectCommand1;
- this.da1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
- new System.Data.Common.DataTableMapping("Table", "物料主文件", new System.Data.Common.DataColumnMapping[] {
- new System.Data.Common.DataColumnMapping("物料编号", "物料编号"),
- new System.Data.Common.DataColumnMapping("条码", "条码"),
- new System.Data.Common.DataColumnMapping("物料名称", "物料名称"),
- new System.Data.Common.DataColumnMapping("拼音编码", "拼音编码"),
- new System.Data.Common.DataColumnMapping("计量单位", "计量单位"),
- new System.Data.Common.DataColumnMapping("规格型号", "规格型号"),
- new System.Data.Common.DataColumnMapping("计划类别", "计划类别"),
- new System.Data.Common.DataColumnMapping("状态类别", "状态类别"),
- new System.Data.Common.DataColumnMapping("归属类别", "归属类别"),
- new System.Data.Common.DataColumnMapping("价值类别", "价值类别"),
- new System.Data.Common.DataColumnMapping("物料特性a", "物料特性a"),
- new System.Data.Common.DataColumnMapping("物料特性b", "物料特性b"),
- new System.Data.Common.DataColumnMapping("物料特性c", "物料特性c"),
- new System.Data.Common.DataColumnMapping("物料特性d", "物料特性d"),
- new System.Data.Common.DataColumnMapping("长", "长"),
- new System.Data.Common.DataColumnMapping("宽", "宽"),
- new System.Data.Common.DataColumnMapping("高", "高"),
- new System.Data.Common.DataColumnMapping("净重", "净重"),
- new System.Data.Common.DataColumnMapping("品牌", "品牌"),
- new System.Data.Common.DataColumnMapping("颜色", "颜色"),
- new System.Data.Common.DataColumnMapping("等级", "等级"),
- new System.Data.Common.DataColumnMapping("进货提前期", "进货提前期"),
- new System.Data.Common.DataColumnMapping("准备周期", "准备周期"),
- new System.Data.Common.DataColumnMapping("生产周期", "生产周期"),
- new System.Data.Common.DataColumnMapping("最小包装量", "最小包装量"),
- new System.Data.Common.DataColumnMapping("最低销售量", "最低销售量"),
- new System.Data.Common.DataColumnMapping("批量", "批量"),
- new System.Data.Common.DataColumnMapping("最高库存", "最高库存"),
- new System.Data.Common.DataColumnMapping("最低库存", "最低库存"),
- new System.Data.Common.DataColumnMapping("库存期限", "库存期限"),
- new System.Data.Common.DataColumnMapping("录入者", "录入者"),
- new System.Data.Common.DataColumnMapping("录入日期", "录入日期"),
- new System.Data.Common.DataColumnMapping("低层码", "低层码"),
- new System.Data.Common.DataColumnMapping("指定供货商", "指定供货商"),
- new System.Data.Common.DataColumnMapping("定货策略", "定货策略"),
- new System.Data.Common.DataColumnMapping("生产车间", "生产车间")})});
- //
- // sqlSelectCommand1
- //
- this.sqlSelectCommand1.CommandText = "SELECT 物料编号, 条码, 物料名称, 拼音编码, 计量单位, 规格型号, 计划类别, 状态类别, 归属类别, 价值类别, 物料特性a, 物料特性b, 物料" +
- "特性c, 物料特性d, 长, 宽, 高, 净重, 品牌, 颜色, 等级, 进货提前期, 准备周期, 生产周期, 最小包装量, 最低销售量, 批量, 最高库存, " +
- "最低库存, 库存期限, 录入者, 录入日期, 低层码, 指定供货商, 定货策略, 生产车间 FROM 物料主文件";
- this.sqlSelectCommand1.Connection = this.sqlConnection1;
- //
- // sqlConnection1
- //
- this.sqlConnection1.ConnectionString = "workstation id=localhost;Integrated Security=SSPI;Database=mrpbook;";
- //
- // txt1
- //
- this.txt1.Location = new System.Drawing.Point(136, 8);
- this.txt1.Name = "txt1";
- this.txt1.Size = new System.Drawing.Size(75, 21);
- this.txt1.TabIndex = 1;
- this.txt1.Text = "";
- //
- // txt2
- //
- this.txt2.Location = new System.Drawing.Point(256, 8);
- this.txt2.Name = "txt2";
- this.txt2.Size = new System.Drawing.Size(75, 21);
- this.txt2.TabIndex = 1;
- this.txt2.Text = "";
- //
- // txt3
- //
- this.txt3.Location = new System.Drawing.Point(376, 8);
- this.txt3.Name = "txt3";
- this.txt3.Size = new System.Drawing.Size(75, 21);
- this.txt3.TabIndex = 1;
- this.txt3.Text = "";
- //
- // btnSearch
- //
- this.btnSearch.Image = ((System.Drawing.Image)(resources.GetObject("btnSearch.Image")));
- this.btnSearch.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
- this.btnSearch.Location = new System.Drawing.Point(16, 8);
- this.btnSearch.Name = "btnSearch";
- this.btnSearch.Size = new System.Drawing.Size(72, 23);
- this.btnSearch.TabIndex = 2;
- this.btnSearch.Text = " 搜索";
- this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
- //
- // label1
- //
- this.label1.Location = new System.Drawing.Point(100, 6);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(32, 32);
- this.label1.TabIndex = 3;
- this.label1.Text = "物料编号";
- //
- // label2
- //
- this.label2.Location = new System.Drawing.Point(216, 8);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(32, 32);
- this.label2.TabIndex = 3;
- this.label2.Text = "物料名称";
- //
- // label3
- //
- this.label3.Location = new System.Drawing.Point(336, 8);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(32, 32);
- this.label3.TabIndex = 3;
- this.label3.Text = "拼音编码";
- //
- // SelectMaterial
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
- this.ClientSize = new System.Drawing.Size(480, 349);
- this.Controls.Add(this.label1);
- this.Controls.Add(this.btnSearch);
- this.Controls.Add(this.txt1);
- this.Controls.Add(this.txt2);
- this.Controls.Add(this.txt3);
- this.Controls.Add(this.dataGrid1);
- this.Controls.Add(this.label2);
- this.Controls.Add(this.label3);
- this.Name = "SelectMaterial";
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.Text = "【双击选择物料】";
- this.Load += new System.EventHandler(this.SelectMaterial_Load);
- ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataView1)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataSet21)).EndInit();
- this.ResumeLayout(false);
- }
- #endregion
- //--------------双击dataGrid,选择物料-----------------
- private void dataGrid1_DoubleClick(object sender, System.EventArgs e)
- {
- int i=dataGrid1.CurrentRowIndex;
- if(callForm==1)//表示由主需求窗体调用
- {
- //将选择的信息反馈回调用窗体
- RequirePlan.mID=dataSet21.物料主文件.Rows[i]["物料编号"].ToString();
- RequirePlan.mName=dataSet21.物料主文件.Rows[i]["物料名称"].ToString();
- }
- if(callForm==2)//表示由主生产计划窗体调用
- {
- ProducePlan.mID=dataSet21.物料主文件.Rows[i]["物料编号"].ToString();
- ProducePlan.mName=dataSet21.物料主文件.Rows[i]["物料名称"].ToString();
- }
- if(callForm==3)//表示由物料清单窗体调用
- {
- BomForm.mID=dataSet21.物料主文件.Rows[i]["物料编号"].ToString();
- BomForm.mName=dataSet21.物料主文件.Rows[i]["物料名称"].ToString();
- }
- this.Close();
- }
- //-------------创建窗体时填充数据集----------------
- private void SelectMaterial_Load(object sender, System.EventArgs e)
- {
- da1.Fill(dataSet21);
- }
- //----------------根据输入条件搜索数据------------------
- private void btnSearch_Click(object sender, System.EventArgs e)
- {
- string strFilter="";
- if(txt1.Text.Trim() != "")//设置表的过滤条件
- strFilter += "物料编号 like '%" + txt1.Text.Trim() + "%' and ";
- if(txt2.Text.Trim() != "")
- strFilter += "物料名称 like '%" + txt2.Text.Trim() + "%' and ";
- if(txt3.Text.Trim() != "")
- strFilter += "拼音编码 like '%" + txt3.Text.Trim() + "%' and ";
- if(strFilter != "") // 存在查询条件
- strFilter = strFilter.Substring(0,strFilter.Length-5);
- dataView1.RowFilter=strFilter;
- }
- }
- }