RequirePlan.cs
资源名称:VCSDB.rar [点击查看]
上传用户:hjieqiu
上传日期:2013-05-11
资源大小:16494k
文件大小:44k
源码类别:
企业管理
开发平台:
C#
- 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, "年份"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@计划期", System.Data.SqlDbType.Int, 4, "计划期"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@开始日期", System.Data.SqlDbType.Int, 4, "开始日期"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@结束日期", System.Data.SqlDbType.Int, 4, "结束日期"));
- this.sqlUpdateCommand1.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.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@记帐人", System.Data.SqlDbType.VarChar, 10, "记帐人"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@修改日期", System.Data.SqlDbType.Int, 4, "修改日期"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@状态", System.Data.SqlDbType.VarChar, 10, "状态"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@备注", System.Data.SqlDbType.VarChar, 40, "备注"));
- this.sqlUpdateCommand1.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.sqlUpdateCommand1.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.sqlUpdateCommand1.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.sqlUpdateCommand1.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.sqlUpdateCommand1.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.sqlUpdateCommand1.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.sqlUpdateCommand1.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.sqlUpdateCommand1.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.sqlUpdateCommand1.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.sqlUpdateCommand1.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.sqlUpdateCommand1.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));
- //
- // groupBox1
- //
- this.groupBox1.Controls.Add(this.txt10);
- this.groupBox1.Controls.Add(this.label6);
- this.groupBox1.Controls.Add(this.btnSearch);
- this.groupBox1.Controls.Add(this.txt9);
- this.groupBox1.Controls.Add(this.label7);
- this.groupBox1.Controls.Add(this.txt8);
- this.groupBox1.Controls.Add(this.label1);
- this.groupBox1.Location = new System.Drawing.Point(0, 48);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(688, 56);
- this.groupBox1.TabIndex = 30;
- this.groupBox1.TabStop = false;
- //
- // txt10
- //
- this.txt10.Location = new System.Drawing.Point(440, 24);
- this.txt10.Name = "txt10";
- this.txt10.TabIndex = 7;
- this.txt10.Text = "";
- //
- // label6
- //
- this.label6.Location = new System.Drawing.Point(392, 27);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(48, 16);
- this.label6.TabIndex = 5;
- this.label6.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, 20);
- this.btnSearch.Name = "btnSearch";
- this.btnSearch.Size = new System.Drawing.Size(72, 24);
- this.btnSearch.TabIndex = 3;
- this.btnSearch.Text = " 搜索";
- this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
- //
- // txt9
- //
- this.txt9.Location = new System.Drawing.Point(280, 24);
- this.txt9.Name = "txt9";
- this.txt9.TabIndex = 6;
- this.txt9.Text = "";
- //
- // label7
- //
- this.label7.Location = new System.Drawing.Point(248, 28);
- this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(32, 16);
- this.label7.TabIndex = 4;
- this.label7.Text = "年份";
- //
- // txt8
- //
- this.txt8.Location = new System.Drawing.Point(160, 24);
- this.txt8.Name = "txt8";
- this.txt8.Size = new System.Drawing.Size(80, 21);
- this.txt8.TabIndex = 6;
- this.txt8.Text = "";
- //
- // label1
- //
- this.label1.Location = new System.Drawing.Point(109, 27);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(56, 16);
- this.label1.TabIndex = 4;
- this.label1.Text = "物料编号";
- //
- // toolBar1
- //
- this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
- this.tBtnFirst,
- this.tBtnPre,
- this.tBtnNext,
- this.tBtnLast,
- this.tBtnNew,
- this.tBtnEdit,
- this.tBtnDelete,
- this.tBtnSubmit,
- this.tBtnCancel,
- this.tBtnQuit});
- this.toolBar1.DropDownArrows = true;
- this.toolBar1.ImageList = this.imageList1;
- this.toolBar1.Location = new System.Drawing.Point(0, 0);
- this.toolBar1.Name = "toolBar1";
- this.toolBar1.ShowToolTips = true;
- this.toolBar1.Size = new System.Drawing.Size(696, 41);
- this.toolBar1.TabIndex = 29;
- this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
- //
- // tBtnFirst
- //
- this.tBtnFirst.ImageIndex = 0;
- this.tBtnFirst.Text = "首记录";
- this.tBtnFirst.ToolTipText = "首记录";
- //
- // tBtnPre
- //
- this.tBtnPre.ImageIndex = 1;
- this.tBtnPre.Text = "上一记录";
- this.tBtnPre.ToolTipText = "上一记录";
- //
- // tBtnNext
- //
- this.tBtnNext.ImageIndex = 2;
- this.tBtnNext.Text = "下一记录";
- this.tBtnNext.ToolTipText = "下一记录";
- //
- // tBtnLast
- //
- this.tBtnLast.ImageIndex = 3;
- this.tBtnLast.Text = "尾记录";
- this.tBtnLast.ToolTipText = "尾记录";
- //
- // tBtnNew
- //
- this.tBtnNew.ImageIndex = 4;
- this.tBtnNew.Text = "新增";
- this.tBtnNew.ToolTipText = "新增";
- //
- // tBtnEdit
- //
- this.tBtnEdit.ImageIndex = 5;
- this.tBtnEdit.Text = "修改";
- this.tBtnEdit.ToolTipText = "修改";
- //
- // tBtnDelete
- //
- this.tBtnDelete.ImageIndex = 6;
- this.tBtnDelete.Text = "删除";
- this.tBtnDelete.ToolTipText = "删除";
- //
- // tBtnSubmit
- //
- this.tBtnSubmit.ImageIndex = 7;
- this.tBtnSubmit.Text = "提交";
- this.tBtnSubmit.ToolTipText = "提交";
- //
- // tBtnCancel
- //
- this.tBtnCancel.ImageIndex = 8;
- this.tBtnCancel.Text = "取消";
- this.tBtnCancel.ToolTipText = "取消";
- //
- // tBtnQuit
- //
- this.tBtnQuit.ImageIndex = 9;
- this.tBtnQuit.Text = "退出";
- this.tBtnQuit.ToolTipText = "退出";
- //
- // imageList1
- //
- this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
- this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
- this.imageList1.TransparentColor = System.Drawing.SystemColors.ControlLightLight;
- //
- // dataGrid1
- //
- this.dataGrid1.CaptionVisible = false;
- this.dataGrid1.DataMember = "主需求计划";
- this.dataGrid1.DataSource = this.dataSet11;
- this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
- this.dataGrid1.Location = new System.Drawing.Point(0, 104);
- this.dataGrid1.Name = "dataGrid1";
- this.dataGrid1.ReadOnly = true;
- this.dataGrid1.RowHeaderWidth = 15;
- this.dataGrid1.Size = new System.Drawing.Size(416, 336);
- this.dataGrid1.TabIndex = 31;
- this.dataGrid1.TableStyles.AddRange(new System.Windows.Forms.DataGridTableStyle[] {
- this.dataGridTableStyle1});
- //
- // dataSet11
- //
- this.dataSet11.DataSetName = "DataSet1";
- this.dataSet11.Locale = new System.Globalization.CultureInfo("zh-CN");
- //
- // dataGridTableStyle1
- //
- this.dataGridTableStyle1.DataGrid = this.dataGrid1;
- this.dataGridTableStyle1.GridColumnStyles.AddRange(new System.Windows.Forms.DataGridColumnStyle[] {
- this.dataGridTextBoxColumn1,
- this.dataGridTextBoxColumn2,
- this.dataGridTextBoxColumn3,
- this.dataGridTextBoxColumn4,
- this.dataGridTextBoxColumn5});
- this.dataGridTableStyle1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
- this.dataGridTableStyle1.MappingName = "主需求计划";
- this.dataGridTableStyle1.RowHeaderWidth = 15;
- //
- // dataGridTextBoxColumn1
- //
- this.dataGridTextBoxColumn1.Format = "";
- this.dataGridTextBoxColumn1.FormatInfo = null;
- this.dataGridTextBoxColumn1.HeaderText = "物料编号";
- this.dataGridTextBoxColumn1.MappingName = "物料编号";
- this.dataGridTextBoxColumn1.Width = 75;
- //
- // dataGridTextBoxColumn2
- //
- this.dataGridTextBoxColumn2.Format = "";
- this.dataGridTextBoxColumn2.FormatInfo = null;
- this.dataGridTextBoxColumn2.HeaderText = "年份";
- this.dataGridTextBoxColumn2.MappingName = "年份";
- this.dataGridTextBoxColumn2.Width = 75;
- //
- // dataGridTextBoxColumn3
- //
- this.dataGridTextBoxColumn3.Format = "";
- this.dataGridTextBoxColumn3.FormatInfo = null;
- this.dataGridTextBoxColumn3.HeaderText = "计划期";
- this.dataGridTextBoxColumn3.MappingName = "计划期";
- this.dataGridTextBoxColumn3.Width = 75;
- //
- // dataGridTextBoxColumn4
- //
- this.dataGridTextBoxColumn4.Format = "";
- this.dataGridTextBoxColumn4.FormatInfo = null;
- this.dataGridTextBoxColumn4.HeaderText = "需求数量";
- this.dataGridTextBoxColumn4.MappingName = "需求数量";
- this.dataGridTextBoxColumn4.Width = 75;
- //
- // dataGridTextBoxColumn5
- //
- this.dataGridTextBoxColumn5.Format = "";
- this.dataGridTextBoxColumn5.FormatInfo = null;
- this.dataGridTextBoxColumn5.HeaderText = "状态";
- this.dataGridTextBoxColumn5.MappingName = "状态";
- this.dataGridTextBoxColumn5.Width = 75;
- //
- // label5
- //
- this.label5.Location = new System.Drawing.Point(456, 384);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(32, 16);
- this.label5.TabIndex = 43;
- this.label5.Text = "备注";
- //
- // label2
- //
- this.label2.Location = new System.Drawing.Point(448, 160);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(56, 16);
- this.label2.TabIndex = 41;
- this.label2.Text = "物料名称";
- //
- // txtMemo
- //
- this.txtMemo.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "主需求计划.备注"));
- this.txtMemo.Location = new System.Drawing.Point(504, 392);
- this.txtMemo.Name = "txtMemo";
- this.txtMemo.ReadOnly = true;
- this.txtMemo.Size = new System.Drawing.Size(100, 48);
- this.txtMemo.TabIndex = 38;
- this.txtMemo.Text = "";
- //
- // txt2
- //
- this.txt2.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "工厂日历.计划期"));
- this.txt2.Enabled = false;
- this.txt2.Location = new System.Drawing.Point(504, 152);
- this.txt2.Name = "txt2";
- this.txt2.ReadOnly = true;
- this.txt2.TabIndex = 37;
- this.txt2.Text = "";
- //
- // txt1
- //
- this.txt1.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "主需求计划.物料编号"));
- this.txt1.Enabled = false;
- this.txt1.Location = new System.Drawing.Point(504, 120);
- this.txt1.Name = "txt1";
- this.txt1.ReadOnly = true;
- this.txt1.TabIndex = 34;
- this.txt1.Text = "";
- this.txt1.TextChanged += new System.EventHandler(this.txt1_TextChanged);
- //
- // txt3
- //
- this.txt3.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "主需求计划.年份"));
- this.txt3.Enabled = false;
- this.txt3.Location = new System.Drawing.Point(504, 184);
- this.txt3.Name = "txt3";
- this.txt3.ReadOnly = true;
- this.txt3.TabIndex = 35;
- this.txt3.Text = "";
- //
- // txt4
- //
- this.txt4.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "主需求计划.计划期"));
- this.txt4.Enabled = false;
- this.txt4.Location = new System.Drawing.Point(504, 216);
- this.txt4.Name = "txt4";
- this.txt4.ReadOnly = true;
- this.txt4.TabIndex = 36;
- this.txt4.Text = "";
- //
- // label3
- //
- this.label3.Location = new System.Drawing.Point(448, 120);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(56, 16);
- this.label3.TabIndex = 39;
- this.label3.Text = "物料编号";
- //
- // label4
- //
- this.label4.Location = new System.Drawing.Point(448, 288);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(56, 16);
- this.label4.TabIndex = 40;
- this.label4.Text = "结束日期";
- //
- // label8
- //
- this.label8.Location = new System.Drawing.Point(448, 264);
- this.label8.Name = "label8";
- this.label8.Size = new System.Drawing.Size(56, 16);
- this.label8.TabIndex = 42;
- this.label8.Text = "开始日期";
- //
- // label9
- //
- this.label9.Location = new System.Drawing.Point(448, 224);
- this.label9.Name = "label9";
- this.label9.Size = new System.Drawing.Size(56, 16);
- this.label9.TabIndex = 41;
- this.label9.Text = "计划期";
- //
- // label10
- //
- this.label10.Location = new System.Drawing.Point(456, 192);
- this.label10.Name = "label10";
- this.label10.Size = new System.Drawing.Size(56, 16);
- this.label10.TabIndex = 39;
- this.label10.Text = "年份";
- //
- // txt5
- //
- this.txt5.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "主需求计划.开始日期"));
- this.txt5.Enabled = false;
- this.txt5.Location = new System.Drawing.Point(504, 248);
- this.txt5.Name = "txt5";
- this.txt5.ReadOnly = true;
- this.txt5.TabIndex = 35;
- this.txt5.Text = "";
- //
- // txt6
- //
- this.txt6.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "主需求计划.结束日期"));
- this.txt6.Enabled = false;
- this.txt6.Location = new System.Drawing.Point(504, 280);
- this.txt6.Name = "txt6";
- this.txt6.ReadOnly = true;
- this.txt6.TabIndex = 36;
- this.txt6.Text = "";
- //
- // txt7
- //
- this.txt7.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "主需求计划.需求数量"));
- this.txt7.Location = new System.Drawing.Point(504, 312);
- this.txt7.Name = "txt7";
- this.txt7.ReadOnly = true;
- this.txt7.TabIndex = 36;
- this.txt7.Text = "";
- //
- // label11
- //
- this.label11.Location = new System.Drawing.Point(448, 320);
- this.label11.Name = "label11";
- this.label11.Size = new System.Drawing.Size(56, 16);
- this.label11.TabIndex = 40;
- this.label11.Text = "需求数量";
- //
- // cm1
- //
- this.cm1.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "主需求计划.状态"));
- this.cm1.Items.AddRange(new object[] {
- "正常",
- "无效"});
- this.cm1.Location = new System.Drawing.Point(504, 352);
- this.cm1.Name = "cm1";
- this.cm1.Size = new System.Drawing.Size(104, 20);
- this.cm1.TabIndex = 44;
- //
- // selBtn1
- //
- this.selBtn1.Enabled = false;
- this.selBtn1.Image = ((System.Drawing.Image)(resources.GetObject("selBtn1.Image")));
- this.selBtn1.Location = new System.Drawing.Point(608, 120);
- this.selBtn1.Name = "selBtn1";
- this.selBtn1.Size = new System.Drawing.Size(24, 23);
- this.selBtn1.TabIndex = 45;
- this.selBtn1.Click += new System.EventHandler(this.selBtn1_Click);
- this.selBtn1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.selBtn1_MouseUp);
- //
- // selBtn2
- //
- this.selBtn2.Enabled = false;
- this.selBtn2.Image = ((System.Drawing.Image)(resources.GetObject("selBtn2.Image")));
- this.selBtn2.Location = new System.Drawing.Point(608, 184);
- this.selBtn2.Name = "selBtn2";
- this.selBtn2.Size = new System.Drawing.Size(24, 23);
- this.selBtn2.TabIndex = 46;
- this.selBtn2.Click += new System.EventHandler(this.selBtn2_Click);
- this.selBtn2.MouseUp += new System.Windows.Forms.MouseEventHandler(this.selBtn2_MouseUp);
- //
- // label12
- //
- this.label12.Location = new System.Drawing.Point(456, 352);
- this.label12.Name = "label12";
- this.label12.Size = new System.Drawing.Size(32, 16);
- this.label12.TabIndex = 43;
- this.label12.Text = "状态";
- //
- // RequirePlan
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
- this.ClientSize = new System.Drawing.Size(696, 453);
- this.Controls.Add(this.selBtn2);
- this.Controls.Add(this.selBtn1);
- this.Controls.Add(this.cm1);
- this.Controls.Add(this.label5);
- this.Controls.Add(this.label2);
- this.Controls.Add(this.txtMemo);
- this.Controls.Add(this.txt2);
- this.Controls.Add(this.txt1);
- this.Controls.Add(this.txt3);
- this.Controls.Add(this.txt4);
- this.Controls.Add(this.txt5);
- this.Controls.Add(this.txt6);
- this.Controls.Add(this.txt7);
- this.Controls.Add(this.label3);
- this.Controls.Add(this.label4);
- this.Controls.Add(this.label8);
- this.Controls.Add(this.dataGrid1);
- this.Controls.Add(this.toolBar1);
- this.Controls.Add(this.groupBox1);
- this.Controls.Add(this.label9);
- this.Controls.Add(this.label10);
- this.Controls.Add(this.label11);
- this.Controls.Add(this.label12);
- this.Name = "RequirePlan";
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.Text = "【主需求计划】";
- this.Load += new System.EventHandler(this.RequirePlan_Load);
- this.groupBox1.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
- this.ResumeLayout(false);
- }
- #endregion
- //--------------创建窗体时,将表中数据全部读入------------
- private void RequirePlan_Load(object sender, System.EventArgs e)
- {
- da1.SelectCommand.Parameters[0].Value="%%";
- da1.SelectCommand.Parameters[1].Value="%%";
- da1.SelectCommand.Parameters[2].Value="%%";
- da1.Fill(dataSet11);
- cmOrders=(CurrencyManager) BindingContext[dataSet11,"主需求计划"];
- }
- //----------------设置工具栏处理代码---------------
- private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
- {
- if (e.Button.ToolTipText == "首记录")
- {
- this.dataGrid1.UnSelect(cmOrders.Position); //取消原选中的行
- cmOrders.Position = 0;
- this.dataGrid1.Select(cmOrders.Position); //选中当前行
- this.dataGrid1.CurrentRowIndex = cmOrders.Position; //移动表头指示图标
- return;
- }
- if (e.Button.ToolTipText == "上一记录")
- {
- if (cmOrders.Position >= 0)
- {
- this.dataGrid1.UnSelect(cmOrders.Position);
- cmOrders.Position--;
- this.dataGrid1.Select(cmOrders.Position);
- this.dataGrid1.CurrentRowIndex = cmOrders.Position;
- }
- return;
- }
- if (e.Button.ToolTipText == "下一记录")
- {
- if (cmOrders.Position <= cmOrders.Count-1)
- {
- this.dataGrid1.UnSelect(cmOrders.Position);
- cmOrders.Position++;
- this.dataGrid1.Select(cmOrders.Position);
- this.dataGrid1.CurrentRowIndex = cmOrders.Position;
- }
- return;
- }
- if (e.Button.ToolTipText == "尾记录")
- {
- this.dataGrid1.UnSelect(cmOrders.Position);
- cmOrders.Position = cmOrders.Count-1;
- this.dataGrid1.Select(cmOrders.Position);
- this.dataGrid1.CurrentRowIndex = cmOrders.Position;
- return;
- }
- if(e.Button.ToolTipText=="新增")
- {
- cmOrders.AddNew();
- txt7.Text="0";//设置默认值
- cm1.SelectedIndex=0;
- //设置按钮
- SetModifyMode(true);
- }
- if(e.Button.ToolTipText=="修改")
- {
- SetModifyMode(true);
- }
- if(e.Button.ToolTipText=="删除")
- {
- DialogResult result=MessageBox.Show("确认删除?","删除数据",MessageBoxButtons.OKCancel);
- if(result==DialogResult.OK)
- if(cmOrders.Count>0)
- cmOrders.RemoveAt(cmOrders.Position);
- else
- MessageBox.Show("表中为空,已无可删除数据","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
- }
- if(e.Button.ToolTipText=="提交")
- {
- if (this.txt1.Text.Trim() == "")//检查不能为空的字段
- {
- MessageBox.Show("请先选择物料!","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
- return;
- }
- if (this.txt3.Text.Trim() == "")//检查不能为空的字段
- {
- MessageBox.Show("请先选择计划期!","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
- return;
- }
- if (this.txt7.Text.Trim() == "")//检查不能为空的字段
- {
- MessageBox.Show("需求数量不能为空!","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
- return;
- }
- cmOrders.EndCurrentEdit();//结束当前编辑操作并提交修改
- if (dataSet11.GetChanges()!=null)
- {
- try
- {
- this.da1.Update(dataSet11);
- }
- catch(Exception express)
- {
- MessageBox.Show(express.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
- dataSet11.RejectChanges();
- }
- }
- return;
- }
- if (e.Button.ToolTipText == "取消")
- {
- try
- {
- cmOrders.CancelCurrentEdit(); //取消编辑
- SetModifyMode(false);
- }
- catch(Exception express)
- {
- MessageBox.Show(express.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
- }
- return;
- }
- if(e.Button.ToolTipText=="退出")
- {
- if(dataSet11.HasChanges())
- {
- DialogResult result=MessageBox.Show("数据集有被修改但尚未提交的数据,是否提交?","确认",MessageBoxButtons.OKCancel);
- if(result==DialogResult.OK)
- da1.Update(dataSet11);
- }
- this.Close();
- }
- }
- //--------------对控件的Enable属性做设置---------------
- private void SetModifyMode(bool blnModify)
- {
- //设置文本框
- txt1.ReadOnly=!blnModify;
- txt3.ReadOnly=!blnModify;
- txt4.ReadOnly=!blnModify;
- txt5.ReadOnly=!blnModify;
- txt6.ReadOnly=!blnModify;
- txt7.ReadOnly=!blnModify;
- txtMemo.ReadOnly=!blnModify;
- //设置表格的只读模式
- dataGrid1.ReadOnly=!blnModify;
- //编辑时不允许搜索数据
- btnSearch.Enabled=!blnModify;
- //允许使用选择按钮
- selBtn1.Enabled=blnModify;
- selBtn2.Enabled=blnModify;
- //设置下拉列表框
- cm1.Enabled=blnModify;
- }
- //---------------根据计划期等数据查询主需求计划信息---------------
- private void btnSearch_Click(object sender, System.EventArgs e)
- {
- da1.SelectCommand.Parameters[0].Value="%%";
- da1.SelectCommand.Parameters[1].Value="%%";
- da1.SelectCommand.Parameters[2].Value="%%";
- //根据用户在文本框中的输入来设置SQL查询的参数
- if(txt8.Text.Trim()!="")
- {
- da1.SelectCommand.Parameters[0].Value="%"+txt8.Text.Trim()+"%";
- }
- if(txt9.Text.Trim()!="")
- {
- da1.SelectCommand.Parameters[1].Value="%"+txt9.Text.Trim()+"%";
- }
- if(txt10.Text.Trim()!="")
- {
- da1.SelectCommand.Parameters[2].Value="%"+txt10.Text.Trim()+"%";
- }
- //清空数据表,并根据新设置的查询参数重新填充
- dataSet11.主需求计划.Clear();
- da1.Fill(dataSet11);
- }
- //------------根据物料编号查询并显示物料名称----------------
- private void txt1_TextChanged(object sender, System.EventArgs e)
- {
- if(txt1.Text!="")
- {
- string strConn="workstation id=localhost;Integrated Security=SSPI;Database=mrpbook;";
- SqlConnection cn=new SqlConnection(strConn);
- cn.Open();
- SqlCommand cmd=cn.CreateCommand();
- cmd.CommandText="select 物料名称 from 物料主文件 where 物料编号='"+txt1.Text.Trim()+"'";
- txt2.Text=Convert.ToString(cmd.ExecuteScalar());
- }
- else
- txt2.Text="";
- }
- //------------调出窗体,选择物料--------------
- private void selBtn1_Click(object sender, System.EventArgs e)
- {
- SelectMaterial.callForm=1;//表示由主需求计划窗体调用
- SelectMaterial selFrm=new SelectMaterial();
- selFrm.ShowDialog();
- SendKeys.Send("{Tab}");//向活动应用程序发送Tab键,跳到下一控件
- }
- //---------将选择得到的物料编号和名称填入文本框----------
- private void selBtn1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
- {
- txt1.Text=mID;
- txt2.Text=mName;
- SendKeys.Send("{Tab}");
- }
- //------------调出窗体,选择工厂日历--------------
- private void selBtn2_Click(object sender, System.EventArgs e)
- {
- FactorySchedule.callForm=1;//表示由主需求窗体调用
- FactorySchedule newFrm=new FactorySchedule();
- newFrm.closeToolbar();
- newFrm.Text+=",双击表格首列选择";
- newFrm.ShowDialog();
- SendKeys.Send("{Tab}");//向活动应用程序发送Tab键,跳到下一控件
- }
- //---------将选择得到的工厂日历信息填入文本框----------
- private void selBtn2_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
- {
- txt3.Text=sYear;
- txt4.Text=sOrder;
- txt5.Text=sBegin;
- txt6.Text=sEnd;
- }
- }
- }