?? selectmaterial.cs
字號:
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;packet size=4096;user id=sa;data source=NICOLAS;persist security info=False;initial catalog=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;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -