?? requireplan.cs
字號:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace 生產管理系統
{
/// <summary>
/// RequirePlan 的摘要說明。
/// </summary>
public class RequirePlan : System.Windows.Forms.Form
{
CurrencyManager cmOrders;
public static string mID,mName;//保存物料編號和名稱
public static string sYear,sOrder,sBegin,sEnd;//保存工廠日歷信息
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 da1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Button btnSearch;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.ToolBar toolBar1;
private System.Windows.Forms.ToolBarButton tBtnFirst;
private System.Windows.Forms.ToolBarButton tBtnPre;
private System.Windows.Forms.ToolBarButton tBtnNext;
private System.Windows.Forms.ToolBarButton tBtnLast;
private System.Windows.Forms.ToolBarButton tBtnNew;
private System.Windows.Forms.ToolBarButton tBtnEdit;
private System.Windows.Forms.ToolBarButton tBtnDelete;
private System.Windows.Forms.ToolBarButton tBtnSubmit;
private System.Windows.Forms.ToolBarButton tBtnQuit;
private System.Windows.Forms.ImageList imageList1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.DataGrid dataGrid1;
private 生產管理系統.DataSet1 dataSet11;
private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn1;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn2;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn3;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn4;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn5;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txt2;
private System.Windows.Forms.TextBox txt1;
private System.Windows.Forms.TextBox txt3;
private System.Windows.Forms.TextBox txt4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.RichTextBox txtMemo;
private System.Windows.Forms.TextBox txt5;
private System.Windows.Forms.TextBox txt6;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.TextBox txt7;
private System.Windows.Forms.TextBox txt10;
private System.Windows.Forms.TextBox txt9;
private System.Windows.Forms.TextBox txt8;
private System.Windows.Forms.Button selBtn1;
private System.Windows.Forms.Button selBtn2;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.ComboBox cm1;
private System.Windows.Forms.ToolBarButton tBtnCancel;
private System.ComponentModel.IContainer components;
public RequirePlan()
{
//
// 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.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(RequirePlan));
this.da1 = 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 = new System.Windows.Forms.GroupBox();
this.txt10 = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.btnSearch = new System.Windows.Forms.Button();
this.txt9 = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.txt8 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.toolBar1 = new System.Windows.Forms.ToolBar();
this.tBtnFirst = new System.Windows.Forms.ToolBarButton();
this.tBtnPre = new System.Windows.Forms.ToolBarButton();
this.tBtnNext = new System.Windows.Forms.ToolBarButton();
this.tBtnLast = new System.Windows.Forms.ToolBarButton();
this.tBtnNew = new System.Windows.Forms.ToolBarButton();
this.tBtnEdit = new System.Windows.Forms.ToolBarButton();
this.tBtnDelete = new System.Windows.Forms.ToolBarButton();
this.tBtnSubmit = new System.Windows.Forms.ToolBarButton();
this.tBtnCancel = new System.Windows.Forms.ToolBarButton();
this.tBtnQuit = new System.Windows.Forms.ToolBarButton();
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.dataSet11 = new 生產管理系統.DataSet1();
this.dataGridTableStyle1 = new System.Windows.Forms.DataGridTableStyle();
this.dataGridTextBoxColumn1 = new System.Windows.Forms.DataGridTextBoxColumn();
this.dataGridTextBoxColumn2 = new System.Windows.Forms.DataGridTextBoxColumn();
this.dataGridTextBoxColumn3 = new System.Windows.Forms.DataGridTextBoxColumn();
this.dataGridTextBoxColumn4 = new System.Windows.Forms.DataGridTextBoxColumn();
this.dataGridTextBoxColumn5 = new System.Windows.Forms.DataGridTextBoxColumn();
this.label5 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.txtMemo = new System.Windows.Forms.RichTextBox();
this.txt2 = new System.Windows.Forms.TextBox();
this.txt1 = new System.Windows.Forms.TextBox();
this.txt3 = new System.Windows.Forms.TextBox();
this.txt4 = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.txt5 = new System.Windows.Forms.TextBox();
this.txt6 = new System.Windows.Forms.TextBox();
this.txt7 = new System.Windows.Forms.TextBox();
this.label11 = new System.Windows.Forms.Label();
this.cm1 = new System.Windows.Forms.ComboBox();
this.selBtn1 = new System.Windows.Forms.Button();
this.selBtn2 = new System.Windows.Forms.Button();
this.label12 = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dataSet11)).BeginInit();
this.SuspendLayout();
//
// da1
//
this.da1.DeleteCommand = this.sqlDeleteCommand1;
this.da1.InsertCommand = this.sqlInsertCommand1;
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("備注", "備注")})});
this.da1.UpdateCommand = this.sqlUpdateCommand1;
//
// sqlDeleteCommand1
//
this.sqlDeleteCommand1.CommandText = @"DELETE FROM 主需求計劃 WHERE (年份 = @Original_年份) AND (物料編號 = @Original_物料編號) AND (計劃期 = @Original_計劃期) AND (修改日期 = @Original_修改日期 OR @Original_修改日期 IS NULL AND 修改日期 IS NULL) AND (備注 = @Original_備注 OR @Original_備注 IS NULL AND 備注 IS NULL) AND (開始日期 = @Original_開始日期 OR @Original_開始日期 IS NULL AND 開始日期 IS NULL) AND (狀態 = @Original_狀態) AND (結束日期 = @Original_結束日期 OR @Original_結束日期 IS NULL AND 結束日期 IS NULL) AND (編號 = @Original_編號 OR @Original_編號 IS NULL AND 編號 IS NULL) AND (記帳人 = @Original_記帳人 OR @Original_記帳人 IS NULL AND 記帳人 IS NULL) AND (需求數量 = @Original_需求數量)";
this.sqlDeleteCommand1.Connection = this.sqlConnection1;
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_年份", System.Data.SqlDbType.Int, 4, 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, 14, 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.Int, 4, 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.Int, 4, 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, 40, 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.Int, 4, 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));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_結束日期", System.Data.SqlDbType.Int, 4, 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, 14, 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));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_需求數量", System.Data.SqlDbType.Decimal, 9, System.Data.ParameterDirection.Input, false, ((System.Byte)(15)), ((System.Byte)(2)), "需求數量", System.Data.DataRowVersion.Original, null));
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "workstation id=localhost;Integrated Security=SSPI;Database=mrpbook;";
//
// sqlInsertCommand1
//
this.sqlInsertCommand1.CommandText = @"INSERT INTO 主需求計劃(編號, 物料編號, 年份, 計劃期, 開始日期, 結束日期, 需求數量, 記帳人, 修改日期, 狀態, 備注) VALUES (@編號, @物料編號, @年份, @計劃期, @開始日期, @結束日期, @需求數量, @記帳人, @修改日期, @狀態, @備注); SELECT 編號, 物料編號, 年份, 計劃期, 開始日期, 結束日期, 需求數量, 記帳人, 修改日期, 狀態, 備注 FROM 主需求計劃 WHERE (年份 = @年份) AND (物料編號 = @物料編號) AND (計劃期 = @計劃期)";
this.sqlInsertCommand1.Connection = this.sqlConnection1;
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@編號", System.Data.SqlDbType.VarChar, 14, "編號"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@物料編號", System.Data.SqlDbType.VarChar, 14, "物料編號"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@年份", System.Data.SqlDbType.Int, 4, "年份"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@計劃期", System.Data.SqlDbType.Int, 4, "計劃期"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@開始日期", System.Data.SqlDbType.Int, 4, "開始日期"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@結束日期", System.Data.SqlDbType.Int, 4, "結束日期"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@需求數量", System.Data.SqlDbType.Decimal, 9, System.Data.ParameterDirection.Input, false, ((System.Byte)(15)), ((System.Byte)(2)), "需求數量", System.Data.DataRowVersion.Current, null));
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.Int, 4, "修改日期"));
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, 40, "備注"));
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT 編號, 物料編號, 年份, 計劃期, 開始日期, 結束日期, 需求數量, 記帳人, 修改日期, 狀態, 備注 FROM 主需求計劃 WHERE (物" +
"料編號 LIKE @Param4) AND (年份 LIKE @Param5) AND (計劃期 LIKE @Param6)";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param4", System.Data.SqlDbType.VarChar, 20, "物料編號"));
this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param5", System.Data.SqlDbType.VarChar, 20, "年份"));
this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param6", System.Data.SqlDbType.VarChar, 10, "計劃期"));
//
// sqlUpdateCommand1
//
this.sqlUpdateCommand1.CommandText = @"UPDATE 主需求計劃 SET 編號 = @編號, 物料編號 = @物料編號, 年份 = @年份, 計劃期 = @計劃期, 開始日期 = @開始日期, 結束日期 = @結束日期, 需求數量 = @需求數量, 記帳人 = @記帳人, 修改日期 = @修改日期, 狀態 = @狀態, 備注 = @備注 WHERE (年份 = @Original_年份) AND (物料編號 = @Original_物料編號) AND (計劃期 = @Original_計劃期) AND (修改日期 = @Original_修改日期 OR @Original_修改日期 IS NULL AND 修改日期 IS NULL) AND (備注 = @Original_備注 OR @Original_備注 IS NULL AND 備注 IS NULL) AND (開始日期 = @Original_開始日期 OR @Original_開始日期 IS NULL AND 開始日期 IS NULL) AND (狀態 = @Original_狀態) AND (結束日期 = @Original_結束日期 OR @Original_結束日期 IS NULL AND 結束日期 IS NULL) AND (編號 = @Original_編號 OR @Original_編號 IS NULL AND 編號 IS NULL) AND (記帳人 = @Original_記帳人 OR @Original_記帳人 IS NULL AND 記帳人 IS NULL) AND (需求數量 = @Original_需求數量); SELECT 編號, 物料編號, 年份, 計劃期, 開始日期, 結束日期, 需求數量, 記帳人, 修改日期, 狀態, 備注 FROM 主需求計劃 WHERE (年份 = @年份) AND (物料編號 = @物料編號) AND (計劃期 = @計劃期)";
this.sqlUpdateCommand1.Connection = this.sqlConnection1;
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@編號", System.Data.SqlDbType.VarChar, 14, "編號"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@物料編號", System.Data.SqlDbType.VarChar, 14, "物料編號"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@年份", System.Data.SqlDbType.Int, 4, "年份"));
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -