diff --git a/01调度窗口.sln b/01调度窗口.sln new file mode 100644 index 0000000..23462e9 --- /dev/null +++ b/01调度窗口.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.35026.282 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "01调度窗口", "01调度窗口\01调度窗口.csproj", "{1C6E2A6D-7563-4CA0-BB08-0C31D70D9B66}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1C6E2A6D-7563-4CA0-BB08-0C31D70D9B66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1C6E2A6D-7563-4CA0-BB08-0C31D70D9B66}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1C6E2A6D-7563-4CA0-BB08-0C31D70D9B66}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1C6E2A6D-7563-4CA0-BB08-0C31D70D9B66}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D5FCCAC3-7EA9-4A0E-A844-2AF67E09902D} + EndGlobalSection +EndGlobal diff --git a/01调度窗口/01调度窗口.csproj b/01调度窗口/01调度窗口.csproj new file mode 100644 index 0000000..379573b --- /dev/null +++ b/01调度窗口/01调度窗口.csproj @@ -0,0 +1,92 @@ + + + + + Debug + AnyCPU + {1C6E2A6D-7563-4CA0-BB08-0C31D70D9B66} + WinExe + _01调度窗口 + 01调度窗口 + v4.7.2 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + Form + + + addmenu.cs + + + Form + + + Form1.cs + + + + + addmenu.cs + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + \ No newline at end of file diff --git a/01调度窗口/App.config b/01调度窗口/App.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/01调度窗口/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/01调度窗口/Form1.Designer.cs b/01调度窗口/Form1.Designer.cs new file mode 100644 index 0000000..0a5c871 --- /dev/null +++ b/01调度窗口/Form1.Designer.cs @@ -0,0 +1,189 @@ + +namespace _01调度窗口 +{ + partial class Form1 + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows 窗体设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.comboBox1 = new System.Windows.Forms.ComboBox(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.btsearch = new System.Windows.Forms.Button(); + this.showitem = new System.Windows.Forms.Button(); + this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.任务完成ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.任务删除ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.btadd = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); + this.contextMenuStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // splitContainer1 + // + this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer1.Location = new System.Drawing.Point(0, 0); + this.splitContainer1.Name = "splitContainer1"; + this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.btadd); + this.splitContainer1.Panel1.Controls.Add(this.comboBox1); + this.splitContainer1.Panel1.Controls.Add(this.textBox1); + this.splitContainer1.Panel1.Controls.Add(this.btsearch); + this.splitContainer1.Panel1.Controls.Add(this.showitem); + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.Controls.Add(this.dataGridView1); + this.splitContainer1.Size = new System.Drawing.Size(1349, 561); + this.splitContainer1.SplitterDistance = 52; + this.splitContainer1.TabIndex = 0; + // + // comboBox1 + // + this.comboBox1.FormattingEnabled = true; + this.comboBox1.Items.AddRange(new object[] { + "条码", + "调度任务索引"}); + this.comboBox1.Location = new System.Drawing.Point(127, 16); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(157, 23); + this.comboBox1.TabIndex = 3; + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(330, 16); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(168, 25); + this.textBox1.TabIndex = 2; + // + // btsearch + // + this.btsearch.Location = new System.Drawing.Point(517, 8); + this.btsearch.Name = "btsearch"; + this.btsearch.Size = new System.Drawing.Size(90, 37); + this.btsearch.TabIndex = 1; + this.btsearch.Text = "开始查询"; + this.btsearch.UseVisualStyleBackColor = true; + this.btsearch.Click += new System.EventHandler(this.btsearch_Click); + // + // showitem + // + this.showitem.Location = new System.Drawing.Point(12, 8); + this.showitem.Name = "showitem"; + this.showitem.Size = new System.Drawing.Size(90, 37); + this.showitem.TabIndex = 0; + this.showitem.Text = "任务刷新"; + this.showitem.UseVisualStyleBackColor = true; + this.showitem.Click += new System.EventHandler(this.showitem_Click); + // + // dataGridView1 + // + this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataGridView1.Location = new System.Drawing.Point(0, 0); + this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.RowHeadersWidth = 51; + this.dataGridView1.RowTemplate.Height = 27; + this.dataGridView1.Size = new System.Drawing.Size(1349, 505); + this.dataGridView1.TabIndex = 0; + this.dataGridView1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.dataGridView1_MouseUp); + // + // contextMenuStrip1 + // + this.contextMenuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); + this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.任务完成ToolStripMenuItem, + this.任务删除ToolStripMenuItem}); + this.contextMenuStrip1.Name = "contextMenuStrip1"; + this.contextMenuStrip1.Size = new System.Drawing.Size(139, 52); + // + // 任务完成ToolStripMenuItem + // + this.任务完成ToolStripMenuItem.Name = "任务完成ToolStripMenuItem"; + this.任务完成ToolStripMenuItem.Size = new System.Drawing.Size(138, 24); + this.任务完成ToolStripMenuItem.Text = "任务完成"; + this.任务完成ToolStripMenuItem.Click += new System.EventHandler(this.任务完成ToolStripMenuItem_Click); + // + // 任务删除ToolStripMenuItem + // + this.任务删除ToolStripMenuItem.Name = "任务删除ToolStripMenuItem"; + this.任务删除ToolStripMenuItem.Size = new System.Drawing.Size(138, 24); + this.任务删除ToolStripMenuItem.Text = "任务删除"; + this.任务删除ToolStripMenuItem.Click += new System.EventHandler(this.任务删除ToolStripMenuItem_Click); + // + // btadd + // + this.btadd.Location = new System.Drawing.Point(629, 8); + this.btadd.Name = "btadd"; + this.btadd.Size = new System.Drawing.Size(90, 37); + this.btadd.TabIndex = 4; + this.btadd.Text = "新增任务"; + this.btadd.UseVisualStyleBackColor = true; + this.btadd.Click += new System.EventHandler(this.btadd_Click); + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1349, 561); + this.Controls.Add(this.splitContainer1); + this.Name = "Form1"; + this.Text = "调度任务管理"; + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel1.PerformLayout(); + this.splitContainer1.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + this.splitContainer1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); + this.contextMenuStrip1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.SplitContainer splitContainer1; + private System.Windows.Forms.ComboBox comboBox1; + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.Button btsearch; + private System.Windows.Forms.Button showitem; + private System.Windows.Forms.DataGridView dataGridView1; + private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; + private System.Windows.Forms.ToolStripMenuItem 任务完成ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem 任务删除ToolStripMenuItem; + private System.Windows.Forms.Button btadd; + } +} + diff --git a/01调度窗口/Form1.cs b/01调度窗口/Form1.cs new file mode 100644 index 0000000..14115d1 --- /dev/null +++ b/01调度窗口/Form1.cs @@ -0,0 +1,133 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Data; +using System.Data.SqlClient; + +namespace _01调度窗口 +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + } + + //全部任务 + private void showitem_Click(object sender, EventArgs e) + { + string constr = @"Server=DESKTOP-PE4T4D8;Database=Test;Trusted_Connection=true;"; + SqlConnection con = new SqlConnection(constr); + con.Open(); + + string sql = "select * from Table_1"; + SqlDataAdapter da = new SqlDataAdapter(sql, con); + DataTable dt = new DataTable(); + da.Fill(dt); + dataGridView1.DataSource = dt; + con.Close(); + } + + //按照下拉栏开始查询 + private void btsearch_Click(object sender, EventArgs e) + { + string constr = @"Server=DESKTOP-PE4T4D8;Database=Test;Trusted_Connection=true;"; + SqlConnection con = new SqlConnection(constr); + con.Open(); + + string sql = null; + if(comboBox1.Text == "条码") + { + sql = $"select * from Table_1 where 条码 = '" + textBox1.Text + "'"; + } + else if(comboBox1.Text == "调度任务索引") + { + sql = $"select * from Table_1 where 调度任务索引 ='" + textBox1.Text + "' "; + } + SqlDataAdapter da = new SqlDataAdapter(sql, con); + DataTable dt = new DataTable(); + da.Fill(dt); + dataGridView1.DataSource = dt; + con.Close(); + } + + //右键显示菜单 + private void dataGridView1_MouseUp(object sender, MouseEventArgs e) + { + + if (e.Button == MouseButtons.Right) + { + if (dataGridView1.SelectedRows.Count > 0) + { + this.contextMenuStrip1.Show(dataGridView1, e.Location); + } + else + { + //MessageBox.Show("当前没有选中行"); + } + } + } + + //任务完成按键 + private void 任务完成ToolStripMenuItem_Click(object sender, EventArgs e) + { + string constr = @"Server=DESKTOP-PE4T4D8;Database=Test;Trusted_Connection=true;"; + SqlConnection con = new SqlConnection(constr); + con.Open(); + + if(dataGridView1.CurrentRow != null) + { + int selectrow = dataGridView1.CurrentRow.Index; //得到选中行的索引 + DataGridViewColumn dataGridViewColumn = dataGridView1.Columns["条码"]; //得到指定列 + int selectcol = dataGridView1.Columns.IndexOf(dataGridViewColumn); //得到指定列的索引 + string selectvalue = dataGridView1.Rows[selectrow].Cells["条码"].Value.ToString(); //得到指定行 列索引的内容 + + string finsql = $"update Table_1 set 任务状态 = '已完成' where 条码 = '{selectvalue}'"; + SqlDataAdapter da = new SqlDataAdapter(finsql, con); + DataTable dt = new DataTable(); + da.Fill(dt); + dataGridView1.DataSource = dt; + MessageBox.Show("更改状态成功,请刷新界面!"); + con.Close(); + } + } + + //任务删除按键 + private void 任务删除ToolStripMenuItem_Click(object sender, EventArgs e) + { + string constr = @"Server=DESKTOP-PE4T4D8;Database=Test;Trusted_Connection=true;"; + SqlConnection con = new SqlConnection(constr); + con.Open(); + + if (dataGridView1.CurrentRow != null) + { + int selectrow = dataGridView1.CurrentRow.Index; + DataGridViewColumn dataGridViewColumn = dataGridView1.Columns["条码"]; + int selectcol = dataGridView1.Columns.IndexOf(dataGridViewColumn); + string selectvalue = dataGridView1.Rows[selectrow].Cells["条码"].Value.ToString(); + + string delsql = $"delete from Table_1 where 条码 = '{selectvalue}'"; + SqlDataAdapter da = new SqlDataAdapter(delsql, con); + DataTable dt = new DataTable(); + da.Fill(dt); + dataGridView1.DataSource = dt; + MessageBox.Show("删除成功,请刷新界面!"); + con.Close(); + } + } + + //打开子窗口->实现增加任务行 实例化子窗口!!! + private void btadd_Click(object sender, EventArgs e) + { + //实例化子窗口!!!! + addmenu menu = new addmenu(); + menu.Show(); + } + } +} diff --git a/01调度窗口/Form1.resx b/01调度窗口/Form1.resx new file mode 100644 index 0000000..ad53752 --- /dev/null +++ b/01调度窗口/Form1.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/01调度窗口/Program.cs b/01调度窗口/Program.cs new file mode 100644 index 0000000..93007c8 --- /dev/null +++ b/01调度窗口/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace _01调度窗口 +{ + static class Program + { + /// + /// 应用程序的主入口点。 + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/01调度窗口/Properties/AssemblyInfo.cs b/01调度窗口/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..3ed7f8c --- /dev/null +++ b/01调度窗口/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("01调度窗口")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("01调度窗口")] +[assembly: AssemblyCopyright("Copyright © 2024")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("1c6e2a6d-7563-4ca0-bb08-0c31d70d9b66")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/01调度窗口/Properties/Resources.Designer.cs b/01调度窗口/Properties/Resources.Designer.cs new file mode 100644 index 0000000..ac1f9f2 --- /dev/null +++ b/01调度窗口/Properties/Resources.Designer.cs @@ -0,0 +1,70 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本: 4.0.30319.42000 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + + +namespace _01调度窗口.Properties +{ + /// + /// 强类型资源类,用于查找本地化字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// 返回此类使用的缓存 ResourceManager 实例。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("_01调度窗口.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 重写当前线程的 CurrentUICulture 属性,对 + /// 使用此强类型资源类的所有资源查找执行重写。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/01调度窗口/Properties/Resources.resx b/01调度窗口/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/01调度窗口/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/01调度窗口/Properties/Settings.Designer.cs b/01调度窗口/Properties/Settings.Designer.cs new file mode 100644 index 0000000..9e9eac8 --- /dev/null +++ b/01调度窗口/Properties/Settings.Designer.cs @@ -0,0 +1,29 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +namespace _01调度窗口.Properties +{ + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/01调度窗口/Properties/Settings.settings b/01调度窗口/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/01调度窗口/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/01调度窗口/addmenu.Designer.cs b/01调度窗口/addmenu.Designer.cs new file mode 100644 index 0000000..f689803 --- /dev/null +++ b/01调度窗口/addmenu.Designer.cs @@ -0,0 +1,381 @@ + +namespace _01调度窗口 +{ + partial class addmenu + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.addtextBox1 = new System.Windows.Forms.TextBox(); + this.btsave = new System.Windows.Forms.Button(); + this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.addtextBox2 = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.addtextBox3 = new System.Windows.Forms.TextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.addtextBox4 = new System.Windows.Forms.TextBox(); + this.label4 = new System.Windows.Forms.Label(); + this.addtextBox5 = new System.Windows.Forms.TextBox(); + this.label5 = new System.Windows.Forms.Label(); + this.addtextBox6 = new System.Windows.Forms.TextBox(); + this.label6 = new System.Windows.Forms.Label(); + this.addtextBox7 = new System.Windows.Forms.TextBox(); + this.label7 = new System.Windows.Forms.Label(); + this.addtextBox8 = new System.Windows.Forms.TextBox(); + this.label8 = new System.Windows.Forms.Label(); + this.addtextBox9 = new System.Windows.Forms.TextBox(); + this.label9 = new System.Windows.Forms.Label(); + this.addtextBox10 = new System.Windows.Forms.TextBox(); + this.label10 = new System.Windows.Forms.Label(); + this.addtextBox11 = new System.Windows.Forms.TextBox(); + this.label11 = new System.Windows.Forms.Label(); + this.addtextBox12 = new System.Windows.Forms.TextBox(); + this.label12 = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); + this.SuspendLayout(); + // + // label1 + // + this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("宋体", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label1.Location = new System.Drawing.Point(19, 27); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(66, 19); + this.label1.TabIndex = 0; + this.label1.Text = "条码:"; + // + // addtextBox1 + // + this.addtextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.addtextBox1.Location = new System.Drawing.Point(183, 24); + this.addtextBox1.Name = "addtextBox1"; + this.addtextBox1.Size = new System.Drawing.Size(305, 25); + this.addtextBox1.TabIndex = 1; + // + // btsave + // + this.btsave.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.btsave.Font = new System.Drawing.Font("宋体", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btsave.Location = new System.Drawing.Point(177, 544); + this.btsave.Name = "btsave"; + this.btsave.Size = new System.Drawing.Size(117, 36); + this.btsave.TabIndex = 2; + this.btsave.Text = "保存"; + this.btsave.UseVisualStyleBackColor = true; + this.btsave.Click += new System.EventHandler(this.btsave_Click); + // + // dataGridView1 + // + this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataGridView1.Location = new System.Drawing.Point(0, 0); + this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.RowHeadersWidth = 51; + this.dataGridView1.RowTemplate.Height = 27; + this.dataGridView1.Size = new System.Drawing.Size(530, 592); + this.dataGridView1.TabIndex = 3; + // + // addtextBox2 + // + this.addtextBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.addtextBox2.Location = new System.Drawing.Point(183, 64); + this.addtextBox2.Name = "addtextBox2"; + this.addtextBox2.Size = new System.Drawing.Size(305, 25); + this.addtextBox2.TabIndex = 5; + // + // label2 + // + this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("宋体", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label2.Location = new System.Drawing.Point(19, 67); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(142, 19); + this.label2.TabIndex = 4; + this.label2.Text = "调度任务索引:"; + // + // addtextBox3 + // + this.addtextBox3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.addtextBox3.Location = new System.Drawing.Point(183, 105); + this.addtextBox3.Name = "addtextBox3"; + this.addtextBox3.Size = new System.Drawing.Size(305, 25); + this.addtextBox3.TabIndex = 7; + // + // label3 + // + this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("宋体", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label3.Location = new System.Drawing.Point(19, 108); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(142, 19); + this.label3.TabIndex = 6; + this.label3.Text = "关联任务索引:"; + // + // addtextBox4 + // + this.addtextBox4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.addtextBox4.Location = new System.Drawing.Point(183, 147); + this.addtextBox4.Name = "addtextBox4"; + this.addtextBox4.Size = new System.Drawing.Size(305, 25); + this.addtextBox4.TabIndex = 9; + // + // label4 + // + this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("宋体", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label4.Location = new System.Drawing.Point(19, 150); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(104, 19); + this.label4.TabIndex = 8; + this.label4.Text = "任务类型:"; + // + // addtextBox5 + // + this.addtextBox5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.addtextBox5.Location = new System.Drawing.Point(183, 190); + this.addtextBox5.Name = "addtextBox5"; + this.addtextBox5.Size = new System.Drawing.Size(305, 25); + this.addtextBox5.TabIndex = 11; + // + // label5 + // + this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.label5.AutoSize = true; + this.label5.Font = new System.Drawing.Font("宋体", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label5.Location = new System.Drawing.Point(19, 193); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(104, 19); + this.label5.TabIndex = 10; + this.label5.Text = "作业类型:"; + // + // addtextBox6 + // + this.addtextBox6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.addtextBox6.Location = new System.Drawing.Point(183, 230); + this.addtextBox6.Name = "addtextBox6"; + this.addtextBox6.Size = new System.Drawing.Size(305, 25); + this.addtextBox6.TabIndex = 13; + // + // label6 + // + this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.label6.AutoSize = true; + this.label6.Font = new System.Drawing.Font("宋体", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label6.Location = new System.Drawing.Point(19, 233); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(66, 19); + this.label6.TabIndex = 12; + this.label6.Text = "起点:"; + // + // addtextBox7 + // + this.addtextBox7.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.addtextBox7.Location = new System.Drawing.Point(183, 272); + this.addtextBox7.Name = "addtextBox7"; + this.addtextBox7.Size = new System.Drawing.Size(305, 25); + this.addtextBox7.TabIndex = 15; + // + // label7 + // + this.label7.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.label7.AutoSize = true; + this.label7.Font = new System.Drawing.Font("宋体", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label7.Location = new System.Drawing.Point(19, 275); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(104, 19); + this.label7.TabIndex = 14; + this.label7.Text = "起点货拉:"; + // + // addtextBox8 + // + this.addtextBox8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.addtextBox8.Location = new System.Drawing.Point(183, 312); + this.addtextBox8.Name = "addtextBox8"; + this.addtextBox8.Size = new System.Drawing.Size(305, 25); + this.addtextBox8.TabIndex = 17; + // + // label8 + // + this.label8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.label8.AutoSize = true; + this.label8.Font = new System.Drawing.Font("宋体", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label8.Location = new System.Drawing.Point(19, 315); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(66, 19); + this.label8.TabIndex = 16; + this.label8.Text = "终点:"; + // + // addtextBox9 + // + this.addtextBox9.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.addtextBox9.Location = new System.Drawing.Point(183, 350); + this.addtextBox9.Name = "addtextBox9"; + this.addtextBox9.Size = new System.Drawing.Size(305, 25); + this.addtextBox9.TabIndex = 19; + // + // label9 + // + this.label9.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.label9.AutoSize = true; + this.label9.Font = new System.Drawing.Font("宋体", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label9.Location = new System.Drawing.Point(19, 353); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(104, 19); + this.label9.TabIndex = 18; + this.label9.Text = "终点货拉:"; + // + // addtextBox10 + // + this.addtextBox10.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.addtextBox10.Location = new System.Drawing.Point(183, 392); + this.addtextBox10.Name = "addtextBox10"; + this.addtextBox10.Size = new System.Drawing.Size(305, 25); + this.addtextBox10.TabIndex = 21; + // + // label10 + // + this.label10.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.label10.AutoSize = true; + this.label10.Font = new System.Drawing.Font("宋体", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label10.Location = new System.Drawing.Point(19, 395); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(104, 19); + this.label10.TabIndex = 20; + this.label10.Text = "任务状态:"; + // + // addtextBox11 + // + this.addtextBox11.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.addtextBox11.Location = new System.Drawing.Point(183, 433); + this.addtextBox11.Name = "addtextBox11"; + this.addtextBox11.Size = new System.Drawing.Size(305, 25); + this.addtextBox11.TabIndex = 23; + // + // label11 + // + this.label11.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.label11.AutoSize = true; + this.label11.Font = new System.Drawing.Font("宋体", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label11.Location = new System.Drawing.Point(19, 436); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(104, 19); + this.label11.TabIndex = 22; + this.label11.Text = "开始时间:"; + // + // addtextBox12 + // + this.addtextBox12.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.addtextBox12.Location = new System.Drawing.Point(183, 475); + this.addtextBox12.Name = "addtextBox12"; + this.addtextBox12.Size = new System.Drawing.Size(305, 25); + this.addtextBox12.TabIndex = 25; + // + // label12 + // + this.label12.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.label12.AutoSize = true; + this.label12.Font = new System.Drawing.Font("宋体", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label12.Location = new System.Drawing.Point(19, 478); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(104, 19); + this.label12.TabIndex = 24; + this.label12.Text = "故障信息:"; + // + // addmenu + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(530, 592); + this.Controls.Add(this.addtextBox12); + this.Controls.Add(this.label12); + this.Controls.Add(this.addtextBox11); + this.Controls.Add(this.label11); + this.Controls.Add(this.addtextBox10); + this.Controls.Add(this.label10); + this.Controls.Add(this.addtextBox9); + this.Controls.Add(this.label9); + this.Controls.Add(this.addtextBox8); + this.Controls.Add(this.label8); + this.Controls.Add(this.addtextBox7); + this.Controls.Add(this.label7); + this.Controls.Add(this.addtextBox6); + this.Controls.Add(this.label6); + this.Controls.Add(this.addtextBox5); + this.Controls.Add(this.label5); + this.Controls.Add(this.addtextBox4); + this.Controls.Add(this.label4); + this.Controls.Add(this.addtextBox3); + this.Controls.Add(this.label3); + this.Controls.Add(this.addtextBox2); + this.Controls.Add(this.label2); + this.Controls.Add(this.btsave); + this.Controls.Add(this.addtextBox1); + this.Controls.Add(this.label1); + this.Controls.Add(this.dataGridView1); + this.Name = "addmenu"; + this.Text = "添加菜单"; + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + public System.Windows.Forms.TextBox addtextBox1; + private System.Windows.Forms.Button btsave; + private System.Windows.Forms.DataGridView dataGridView1; + public System.Windows.Forms.TextBox addtextBox2; + private System.Windows.Forms.Label label2; + public System.Windows.Forms.TextBox addtextBox3; + private System.Windows.Forms.Label label3; + public System.Windows.Forms.TextBox addtextBox4; + private System.Windows.Forms.Label label4; + public System.Windows.Forms.TextBox addtextBox5; + private System.Windows.Forms.Label label5; + public System.Windows.Forms.TextBox addtextBox6; + private System.Windows.Forms.Label label6; + public System.Windows.Forms.TextBox addtextBox7; + private System.Windows.Forms.Label label7; + public System.Windows.Forms.TextBox addtextBox8; + private System.Windows.Forms.Label label8; + public System.Windows.Forms.TextBox addtextBox9; + private System.Windows.Forms.Label label9; + public System.Windows.Forms.TextBox addtextBox10; + private System.Windows.Forms.Label label10; + public System.Windows.Forms.TextBox addtextBox11; + private System.Windows.Forms.Label label11; + public System.Windows.Forms.TextBox addtextBox12; + private System.Windows.Forms.Label label12; + } +} \ No newline at end of file diff --git a/01调度窗口/addmenu.cs b/01调度窗口/addmenu.cs new file mode 100644 index 0000000..40f74b6 --- /dev/null +++ b/01调度窗口/addmenu.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Data.SqlClient; + +namespace _01调度窗口 +{ + public partial class addmenu : Form + { + public addmenu() + { + InitializeComponent(); + } + //子窗口实现添加行操作 + private void btsave_Click(object sender, EventArgs e) + { + string constr = @"Server=DESKTOP-PE4T4D8;Database=Test;Trusted_Connection=true;"; + SqlConnection con = new SqlConnection(constr); + con.Open(); + + string a = addtextBox1.Text.ToString(); //将输入的条码值取出来 tostring() + bool b = a.Skip(1).All(char.IsDigit); //判断除第一个字符后面的五位是不是数字 + if (addtextBox1.Text.Length == 6 && a[0] == 'T'&& b) //char.IsLetter(char.Parse(addtextBox1.Text)) + { + MessageBox.Show("输入成功!"); + string addsql = $"insert into Table_1(条码, 调度任务索引, 关联任务索引, 任务类型," + + $"作业类型, 起点, 起点货位, 终点, 终点货位, 任务状态, 开始时间, 故障信息) " + + $"values ('" + addtextBox1.Text.ToString() + "', '" + addtextBox2.Text.ToString() + "', '" + addtextBox3.Text.ToString() + "', " + + "'" + addtextBox4.Text.ToString() + "', '" + addtextBox5.Text.ToString() + "', '" + addtextBox6.Text.ToString() + "', " + + "'" + addtextBox7.Text.ToString() + "', '" + addtextBox8.Text.ToString() + "', '" + addtextBox9.Text.ToString() + "'," + + "'" + addtextBox10.Text.ToString() + "', '" + addtextBox11.Text.ToString() + "', '" + addtextBox12.Text.ToString() + "' )"; + SqlDataAdapter da = new SqlDataAdapter(addsql, con); + + DataTable dt = new DataTable(); + dataGridView1.DataSource = dt; + da.Fill(dt); + MessageBox.Show("新增成功,请刷新界面!"); + con.Close(); + } + else + { + MessageBox.Show("输入有误!"); + } + } + + } +} diff --git a/01调度窗口/addmenu.resx b/01调度窗口/addmenu.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/01调度窗口/addmenu.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Test.bak b/Test.bak new file mode 100644 index 0000000..29f5f2e Binary files /dev/null and b/Test.bak differ