📄 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;packet size=4096;user id=sa;data source=NICOLAS;persist security info=False;initial catalog=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 + -