namespace Test_Capacity_Pane
{
partial class test_capacity
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Title title1 = new System.Windows.Forms.DataVisualization.Charting.Title();
System.Windows.Forms.DataVisualization.Charting.Title title2 = new System.Windows.Forms.DataVisualization.Charting.Title();
System.Windows.Forms.DataVisualization.Charting.Title title3 = new System.Windows.Forms.DataVisualization.Charting.Title();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(test_capacity));
this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabel3 = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabel4 = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabel5 = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabel6 = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabel7 = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabel8 = new System.Windows.Forms.ToolStripStatusLabel();
this.listView1 = new System.Windows.Forms.ListView();
this.button2 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.comboBox3 = new System.Windows.Forms.ComboBox();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.timer2 = new System.Windows.Forms.Timer(this.components);
this.label2 = new System.Windows.Forms.Label();
this.timer3 = new System.Windows.Forms.Timer(this.components);
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit();
this.groupBox1.SuspendLayout();
this.statusStrip1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// chart1
//
chartArea1.Name = "ChartArea1";
this.chart1.ChartAreas.Add(chartArea1);
legend1.Alignment = System.Drawing.StringAlignment.Center;
legend1.Docking = System.Windows.Forms.DataVisualization.Charting.Docking.Top;
legend1.Name = "Legend1";
legend1.TitleAlignment = System.Drawing.StringAlignment.Far;
legend1.TitleFont = new System.Drawing.Font("华文楷体", 36F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
legend1.TitleSeparatorColor = System.Drawing.Color.BlanchedAlmond;
this.chart1.Legends.Add(legend1);
this.chart1.Location = new System.Drawing.Point(15, 32);
this.chart1.Name = "chart1";
this.chart1.Size = new System.Drawing.Size(1851, 390);
this.chart1.TabIndex = 0;
this.chart1.Text = "chart1";
title1.BorderColor = System.Drawing.Color.White;
title1.Docking = System.Windows.Forms.DataVisualization.Charting.Docking.Bottom;
title1.Name = "吴伟华";
title2.Alignment = System.Drawing.ContentAlignment.BottomCenter;
title2.BorderColor = System.Drawing.Color.White;
title2.Name = "沈波";
title3.Alignment = System.Drawing.ContentAlignment.BottomCenter;
title3.BorderColor = System.Drawing.Color.White;
title3.Name = "严永宽";
this.chart1.Titles.Add(title1);
this.chart1.Titles.Add(title2);
this.chart1.Titles.Add(title3);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.statusStrip1);
this.groupBox1.Controls.Add(this.listView1);
this.groupBox1.Controls.Add(this.button2);
this.groupBox1.Controls.Add(this.button1);
this.groupBox1.Controls.Add(this.comboBox3);
this.groupBox1.Controls.Add(this.comboBox1);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Location = new System.Drawing.Point(7, 4);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(1885, 588);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
//
// statusStrip1
//
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabel1,
this.toolStripStatusLabel2,
this.toolStripStatusLabel3,
this.toolStripStatusLabel4,
this.toolStripStatusLabel5,
this.toolStripStatusLabel6,
this.toolStripStatusLabel7,
this.toolStripStatusLabel8});
this.statusStrip1.Location = new System.Drawing.Point(3, 563);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(1879, 22);
this.statusStrip1.TabIndex = 4;
this.statusStrip1.Text = "statusStrip1";
//
// toolStripStatusLabel1
//
this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
this.toolStripStatusLabel1.Size = new System.Drawing.Size(83, 17);
this.toolStripStatusLabel1.Text = "鼠标移动位置:";
//
// toolStripStatusLabel2
//
this.toolStripStatusLabel2.Name = "toolStripStatusLabel2";
this.toolStripStatusLabel2.Size = new System.Drawing.Size(88, 17);
this.toolStripStatusLabel2.Text = " ";
//
// toolStripStatusLabel3
//
this.toolStripStatusLabel3.Name = "toolStripStatusLabel3";
this.toolStripStatusLabel3.Size = new System.Drawing.Size(83, 17);
this.toolStripStatusLabel3.Text = "当前系统时间:";
//
// toolStripStatusLabel4
//
this.toolStripStatusLabel4.Name = "toolStripStatusLabel4";
this.toolStripStatusLabel4.Size = new System.Drawing.Size(92, 17);
this.toolStripStatusLabel4.Text = " ";
//
// toolStripStatusLabel5
//
this.toolStripStatusLabel5.Name = "toolStripStatusLabel5";
this.toolStripStatusLabel5.Size = new System.Drawing.Size(164, 17);
this.toolStripStatusLabel5.Text = " ";
//
// toolStripStatusLabel6
//
this.toolStripStatusLabel6.Name = "toolStripStatusLabel6";
this.toolStripStatusLabel6.Size = new System.Drawing.Size(148, 17);
this.toolStripStatusLabel6.Text = " ";
//
// toolStripStatusLabel7
//
this.toolStripStatusLabel7.Name = "toolStripStatusLabel7";
this.toolStripStatusLabel7.Size = new System.Drawing.Size(176, 17);
this.toolStripStatusLabel7.Text = " ";
//
// toolStripStatusLabel8
//
this.toolStripStatusLabel8.Name = "toolStripStatusLabel8";
this.toolStripStatusLabel8.Size = new System.Drawing.Size(192, 17);
this.toolStripStatusLabel8.Text = " ";
//
// listView1
//
this.listView1.FullRowSelect = true;
this.listView1.GridLines = true;
this.listView1.Location = new System.Drawing.Point(3, 59);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(1879, 503);
this.listView1.TabIndex = 3;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.View = System.Windows.Forms.View.Details;
this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged);
//
// button2
//
this.button2.Location = new System.Drawing.Point(1635, 25);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(113, 26);
this.button2.TabIndex = 2;
this.button2.Text = "重置(&R)";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button1
//
this.button1.Enabled = false;
this.button1.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.button1.Location = new System.Drawing.Point(1754, 25);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(113, 26);
this.button1.TabIndex = 2;
this.button1.Text = "执行(&S)";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// comboBox3
//
this.comboBox3.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
this.comboBox3.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
this.comboBox3.Enabled = false;
this.comboBox3.FormattingEnabled = true;
this.comboBox3.Location = new System.Drawing.Point(659, 24);
this.comboBox3.Name = "comboBox3";
this.comboBox3.Size = new System.Drawing.Size(485, 29);
this.comboBox3.TabIndex = 1;
this.comboBox3.SelectedIndexChanged += new System.EventHandler(this.comboBox3_SelectedIndexChanged);
//
// comboBox1
//
this.comboBox1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
this.comboBox1.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
this.comboBox1.Enabled = false;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(98, 24);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(485, 29);
this.comboBox1.TabIndex = 1;
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(589, 28);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(67, 21);
this.label3.TabIndex = 0;
this.label3.Text = "线体:";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(6, 28);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(105, 21);
this.label1.TabIndex = 0;
this.label1.Text = "产品类型:";
//
// groupBox2
//
this.groupBox2.Controls.Add(this.richTextBox1);
this.groupBox2.Controls.Add(this.chart1);
this.groupBox2.Location = new System.Drawing.Point(9, 598);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(1883, 439);
this.groupBox2.TabIndex = 2;
this.groupBox2.TabStop = false;
//
// timer1
//
this.timer1.Enabled = true;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// timer2
//
this.timer2.Interval = 1000;
this.timer2.Tick += new System.EventHandler(this.timer2_Tick);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(1167, 27);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(0, 21);
this.label2.TabIndex = 6;
//
// timer3
//
this.timer3.Interval = 1000;
this.timer3.Tick += new System.EventHandler(this.timer3_Tick);
//
// richTextBox1
//
this.richTextBox1.BackColor = System.Drawing.Color.SteelBlue;
this.richTextBox1.Enabled = false;
this.richTextBox1.Font = new System.Drawing.Font("华文楷体", 8.999999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.richTextBox1.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.richTextBox1.Location = new System.Drawing.Point(1585, 14);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(279, 205);
this.richTextBox1.TabIndex = 1;
this.richTextBox1.Text = "";
this.richTextBox1.Visible = false;
//
// test_capacity
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1904, 1042);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Font = new System.Drawing.Font("华文楷体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Margin = new System.Windows.Forms.Padding(5);
this.MaximizeBox = false;
this.Name = "test_capacity";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "测试产能电子看板.V3.00";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.test_capacity_FormClosing);
this.Load += new System.EventHandler(this.Form1_Load);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.test_capacity_MouseMove);
((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.DataVisualization.Charting.Chart chart1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.ComboBox comboBox3;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.StatusStrip statusStrip1;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel2;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel3;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel4;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel5;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel6;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel7;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel8;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.Timer timer2;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Timer timer3;
private System.Windows.Forms.RichTextBox richTextBox1;
}
}
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;
using System.IO;
using System.Threading;
using System.Collections;
using System.Drawing;
using System.Configuration;
using System.Net;
using System.Windows;
using System.Windows.Forms.DataVisualization.Charting;
namespace Test_Capacity_Pane
{
public partial class test_capacity : Form
{
public List<String> Product_Info_Lists;//主品信息集
public List<String> Employee_Info;//员工信息
public List<String> User_Name;//名称
public List<String> Job_Number;//工号
public String Item_Count;//项目数
public String SERVER_Name;//服务器名称
public String DataBase_Name;//数据库名称
public String SERVER_UserName;//用户名
public String SERVER_Password;//用户密码
public String TABLE_Name;//表名
public String Stored_Procedure;//存储过程
public String Key_Info;//关键信息
public Boolean IsBoot;//产能统计启动开关
public String[] Hours_Str ={"08","09","10","11","12","13","14","15","16","17",
"18","19","20","21","22","23","00","01","02",
"03","04","05","06","07"};//提交数据日的方式提交关键字
public List<String> KeyValues;//关键值
public List<List<String>> All_Capacity_Data;//所有产能数据存储
public List<String> TestEmployee_Total_Capacity;//测试员测试总产能
public List<String> Total_Output_Per_Hour;//线体每小时总产能
public List<List<int>> MonthCpaacity_Data;//月度产能数据
public test_capacity()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
String strFullPath = Application.ExecutablePath;//读取执行路径
String strFileName = System.IO.Path.GetFileName(strFullPath);//读取程式名称
String FileName = strFileName.Substring(0, strFileName.Length - 4);
System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcessesByName(FileName);
if (myProcesses.Length > 1)//判断程式是否启动
{
MessageBox.Show("程式已启动", "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
System.Environment.Exit(0);
}
Set_Product_Type(comboBox1, "SELECT * FROM Querying_Product_Grammar_Wasd");
IsBoot = false;//启动关闭
//this.reportViewer1.RefreshReport();
}
public Boolean Separate_EmployeeInfo(String String_Handle)//分离员工信息数据
{
Boolean Flag = false;
User_Name = new List<string>();//员工姓名集
Job_Number = new List<string>();//员工工号集
int n = 0;
foreach (String ss in Employee_Info)
{
String[] Array_Str = ss.Split(new String[] { "#" }, StringSplitOptions.RemoveEmptyEntries);
if (Array_Str[0] == String_Handle)
{
Job_Number.Add(Array_Str[1]);
User_Name.Add(Array_Str[2]);
n++;
}
}
if (n > 1) Flag = true;
return Flag;
}
public Boolean Set_Employee_Info(ComboBox Item, String Stored_Procedure)//设置员工信息
{
Boolean Flag = false;
Employee_Info = new List<string>();
OperationDataBase GetEmployee_Info = new OperationDataBase("GPUSERVER", "E_Test_Capacity_Coordination", "sa", "adminsystem", Stored_Procedure);
Item.Items.Clear();
if (GetEmployee_Info.Get_Employee_Info(Employee_Info, Item))
{
Flag = true;
}
return Flag;
}
public Boolean Set_Product_Type(ComboBox Item, String Stored_Procedure)//设置产品类型
{
Boolean Flag = false;
Product_Info_Lists=new List<string>();
OperationDataBase GetProduct_Type = new OperationDataBase("GPUSERVER", "E_Test_Capacity_Coordination", "sa", "adminsystem",Stored_Procedure);
Item.Items.Clear();
if (GetProduct_Type.Get_Product_Type_Info(Product_Info_Lists,Item))
{
Item.Enabled = true;
Flag = true;
}
return Flag;
}
public Boolean Separate_Data_Information(String String_Handle)//分离对应产品内容关键信息
{
Boolean Flag = false;
foreach (String ss in Product_Info_Lists)
{
String[] Array_Str = ss.Split(new String[] { "#" }, StringSplitOptions.RemoveEmptyEntries);
if (String_Handle == Array_Str[0])
{
this.Item_Count = Array_Str[1];
this.SERVER_Name = Array_Str[2];
this.DataBase_Name = Array_Str[3];
this.SERVER_UserName = Array_Str[4];
this.SERVER_Password = Array_Str[5];
this.TABLE_Name = Array_Str[6];
this.Stored_Procedure = Array_Str[7];
Flag = true;
return Flag;
}
}
return Flag;
}
public void Year_InitListView(ListView Table)//年产能报表统筹
{
Table.Clear();
Table.Columns.Add("NO.", 60, HorizontalAlignment.Left);
Table.Columns.Add("姓名", 95, HorizontalAlignment.Left);
Table.Columns.Add("工号", 95, HorizontalAlignment.Left);
Table.Columns.Add(DateTime.Now.ToString("yyyy年"), 95, HorizontalAlignment.Left);
}
public void Month_InitListView(ListView Table)//月产能报表统筹
{
Table.Clear();
Table.Columns.Add("NO.", 60, HorizontalAlignment.Left);
Table.Columns.Add("姓名", 95, HorizontalAlignment.Left);
Table.Columns.Add("工号", 95, HorizontalAlignment.Left);
Table.Columns.Add(DateTime.Now.ToString("yyyy年MM月"), 95, HorizontalAlignment.Left);
}
//初始化ListView1
public void Day_InitListView(ListView Table)//日产能报表统筹
{
Table.Clear();
Table.Columns.Add("NO.", 60, HorizontalAlignment.Left);
Table.Columns.Add("姓名", 95, HorizontalAlignment.Left);
Table.Columns.Add("工号", 95, HorizontalAlignment.Left);
Table.Columns.Add("8:00~9:00", 90, HorizontalAlignment.Left);
Table.Columns.Add("9:00~10:00", 90, HorizontalAlignment.Left);
Table.Columns.Add("10:00~11:00", 90, HorizontalAlignment.Left);
Table.Columns.Add("11:00~12:00", 90, HorizontalAlignment.Left);
Table.Columns.Add("12:00~13:00", 90, HorizontalAlignment.Left);
Table.Columns.Add("13:00~14:00", 90, HorizontalAlignment.Left);
Table.Columns.Add("14:00~15:00", 90, HorizontalAlignment.Left);
Table.Columns.Add("15:00~16:00", 90, HorizontalAlignment.Left);
Table.Columns.Add("16:00~17:00", 90, HorizontalAlignment.Left);
Table.Columns.Add("17:00~18:00", 90, HorizontalAlignment.Left);
Table.Columns.Add("18:00~19:00", 90, HorizontalAlignment.Left);
Table.Columns.Add("19:00~20:00", 90, HorizontalAlignment.Left);
Table.Columns.Add("20:00~21:00", 90, HorizontalAlignment.Left);
Table.Columns.Add("21:00~22:00", 90, HorizontalAlignment.Left);
Table.Columns.Add("22:00~23:00", 90, HorizontalAlignment.Left);
Table.Columns.Add("23:00~24:00", 90, HorizontalAlignment.Left);
Table.Columns.Add("00:00~01:00", 90, HorizontalAlignment.Left);
Table.Columns.Add("01:00~02:00", 90, HorizontalAlignment.Left);
Table.Columns.Add("02:00~03:00", 90, HorizontalAlignment.Left);
Table.Columns.Add("03:00~04:00", 90, HorizontalAlignment.Left);
Table.Columns.Add("04:00~05:00", 90, HorizontalAlignment.Left);
Table.Columns.Add("05:00~06:00", 90, HorizontalAlignment.Left);
Table.Columns.Add("06:00~07:00", 90, HorizontalAlignment.Left);
Table.Columns.Add("07:00~08:00", 90, HorizontalAlignment.Left);
Table.Columns.Add("... ...", 100, HorizontalAlignment.Left);
}
private void timer1_Tick(object sender, EventArgs e)//系统时间显示
{
try
{
toolStripStatusLabel4.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
catch (Exception)
{
timer1.Enabled = false;
timer2.Enabled = false;
timer3.Enabled = false;
}
}
private void test_capacity_MouseMove(object sender, MouseEventArgs e)//鼠标移动
{
toolStripStatusLabel2.Text = String.Format("{0},{1}", e.X, e.Y);
}
private void listView1_SelectedIndexChanged(object sender, EventArgs e)//选择控件事件
{
listView1.FullRowSelect = true;
if (this.listView1.SelectedItems.Count > 0)
{
listView1.SelectedItems[0].SubItems[0].ForeColor = Color.Blue;
//先清除原有格式
foreach (ListViewItem item in listView1.Items)
{
item.ForeColor = Color.Black;
}
foreach (ListViewItem item in listView1.Items)
{
item.BackColor = Color.White;
//Font f = new Font(Control.DefaultFont, FontStyle.Regular);
//item.Font = f;
}
//加粗字体
//Font f2 = new Font(Control.DefaultFont, FontStyle.Bold);
//listView1.SelectedItems[0].SubItems[0].Font = f2;
//设置选中行背景颜色
listView1.SelectedItems[0].BackColor = Color.LightBlue;
listView1.SelectedItems[0].Selected = false;
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)//选择产品类型
{
if (comboBox1.Text != null && comboBox1.Text != String.Empty)
{
if (Separate_Data_Information(comboBox1.Text))
{
//MessageBox.Show(Item_Count+"|"+SERVER_Name+"|"+DataBase_Name+"|"+SERVER_UserName+"|"+SERVER_Password+"|"+TABLE_Name+"|"+Stored_Procedure);
if (Set_Employee_Info(comboBox3, "SELECT * FROM Employee_Info"))
{
Key_Info = DateTime.Now.ToString("yyyy-MM-dd");
Day_InitListView(listView1);//初始化日listView1
comboBox1.Enabled = false;
comboBox3.Enabled = true;
comboBox3.Focus();
}
else
{
comboBox1.Focus();
comboBox1.SelectAll();
}
}
else
{
comboBox1.Focus();
comboBox1.SelectAll();
}
}
}
private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)//选择线体
{
if (comboBox3.Text != null && comboBox3.Text != String.Empty)
{
if (Separate_EmployeeInfo(comboBox3.Text))
{
comboBox3.Enabled = false;
button1.Enabled = true;
button1.Focus();
}
else
{
comboBox3.Focus();
comboBox3.SelectAll();
}
}
}
private void test_capacity_FormClosing(object sender, FormClosingEventArgs e)//退出
{
System.Environment.Exit(1);
}
public void Create_New_Table()//清空所有多余空间内容
{
foreach (Control ss in this.Controls)
{
if (ss.Name.ToString() == "groupBox1")
{
foreach (Control s in ss.Controls)
{
if (s.Name.ToString() == "groupBox3")
{
foreach (Control s1 in s.Controls)
{
if (s1.GetType().ToString() == "System.Windows.Forms.ComboBox" ||
s1.GetType().ToString() == "System.Windows.Forms.TextBox")
{
s1.Text = "";
s1.Enabled = false;
}
}
}
else if (s.GetType().ToString() == "System.Windows.Forms.ComboBox" ||
s.GetType().ToString() == "System.Windows.Forms.TextBox")
{
s.Text = "";
s.Enabled = false;
}
}
}
else if (ss.GetType().ToString() == "System.Windows.Forms.Button")
ss.Enabled = false;
}
timer1.Enabled = false;
timer2.Enabled = false;
timer3.Enabled = false;
button2.Enabled = true;
comboBox1.Enabled = true;
comboBox1.Focus();
comboBox1.SelectAll();
}
private void button2_Click(object sender, EventArgs e)//重置
{
Create_New_Table();
}
public String The_Chart_First = String.Empty;
//public List<String>Item_Discription;//项目描述
private void button1_Click(object sender, EventArgs e)//执行产能统筹
{
//Item_Discription=new List<String>();
FillEmloyeeInfo(listView1, User_Name, Job_Number);//初始化ListView1并填充员工信息
//Item_Discription.Add(comboBox3.Text+"月度测试产能汇总");
The_Chart_First = DateTime.Now.ToString("yyyy年MM月");
String Key1 = DateTime.Now.ToString("yyyy-MM-dd ");
KeyValues = new List<String>();
foreach (String ss in Hours_Str)
//KeyValues.Add(@"'" + Key1 + ss + @"%" + @"'");
KeyValues.Add(Key1 + ss + @"%");
timer3.Enabled = true;
IsBoot = true;
button1.Enabled = false;
}
public Boolean IsComplete = false;//是否完成执行进度
public void Day_Test_Capacity_Plan_As_A_Whole()//日测试产能统筹
{
All_Capacity_Data=new List<List<string>>();//所有产能数据
TestEmployee_Total_Capacity = new List<String>();//个人当前总产能
Total_Output_Per_Hour = new List<String>();//线体每小时总产能
Boolean Total_IsInit = false;//确认每小时总产能项是否已经初始化
foreach (String j1 in Job_Number)//每小时产能
{
List<String> Temp = new List<string>();
int n=0;
foreach (String h1 in KeyValues)
{
OperationDataBase GetCapacity = new OperationDataBase(this.SERVER_Name, this.DataBase_Name, this.SERVER_UserName, this.SERVER_Password, this.Stored_Procedure);
if (GetCapacity.Get_Capacity_Data(j1, h1))
{
Temp.Add(GetCapacity.Get_Capacity_values);
if (!Total_IsInit)
Total_Output_Per_Hour.Add(GetCapacity.Get_Capacity_values);
else
Total_Output_Per_Hour[n] = (Convert.ToInt32(Total_Output_Per_Hour[n]) + Convert.ToInt32(GetCapacity.Get_Capacity_values)).ToString();
//Line_TotalCapacity += Convert.ToInt32(GetCapacity.Get_Capacity_values);
}
else
{
Total_Output_Per_Hour.Add("0");
Temp.Add("0");
}
n++;
}
Total_IsInit=true;
All_Capacity_Data.Add(Temp);
}
int DayTotalCapacity=0;
foreach (String j1 in Job_Number)//当前每个作业员总产能
{
OperationDataBase GetCapacity_2 = new OperationDataBase(this.SERVER_Name, this.DataBase_Name, this.SERVER_UserName, this.SERVER_Password, this.Stored_Procedure);
if (GetCapacity_2.Get_Capacity_Data(j1,DateTime.Now.ToString("yyyy-MM-dd")+@"%"))
{
TestEmployee_Total_Capacity.Add(GetCapacity_2.Get_Capacity_values);
DayTotalCapacity+=Convert.ToInt32(GetCapacity_2.Get_Capacity_values);
}
else
TestEmployee_Total_Capacity.Add("0");
}
Total_Output_Per_Hour.Add(DayTotalCapacity.ToString());
IsComplete = true;
}
//设置员工信息到ListView
public void FillEmloyeeInfo(ListView Key, List<String> Employee_Name, List<String> Employee_JobNumber)
{
int n = 1;
ListViewItem item = new ListViewItem();
foreach (String Employees in Employee_Name)
{
item = Key.Items.Add(n.ToString());//序号
item.SubItems.Add(Employees);//员工姓名
item.SubItems.Add(Employee_JobNumber[n-1]);//员工工号
for (int s = 0; s < 25; s++)
item.SubItems.Add("0");
n++;
}
item = Key.Items.Add("");
item = Key.Items.Add("");
item = Key.Items.Add("");
for (int y = 0; y < 27; y++)
{
if (y > 1)
item.SubItems.Add("0");
else
item.SubItems.Add("");
}
}
//设置产能数据到ListView
public void FullListViewTestCapacity(ListView Key, List<List<String>> Key1, List<String> Key2, List<String> Key3)
{
//Key1--测试员每小时产能数据包
//Key2--每个测试员当前总产能
//Key3--每个小时总产能
int x = 0;
int z = 0;
foreach (List<String> Houre_C in Key1)
{
int y = 3;
foreach (String Houre_Cs in Houre_C)//每个作业员每小时产能
{
Key.Items[x].SubItems[y].Text = Houre_Cs;
y++;
}
Key.Items[x].SubItems[y].Text = Key2[z];//每个作业当天总产能
z++;
x++;
}
int h = 3;
foreach (String Now_Houre in Key3)//每小时线体产能
{
Key.Items[x+2].SubItems[h].Text = Now_Houre;
h++;
}
}
//读取每个月
public Boolean GetMonth_Total_Capacity_Lists()
{
Boolean Flag = true;
MonthCpaacity_Data = new List<List<int>>();//存储指方图产能
foreach (String nn in Job_Number)
{
List<int> Temp = new List<int>();
OperationDataBase GetMonthCp = new OperationDataBase(this.SERVER_Name, this.DataBase_Name, this.SERVER_UserName, this.SERVER_Password,
this.Stored_Procedure);
if (GetMonthCp.Get_Capacity_Data(nn, DateTime.Now.ToString("yyyy-MM") + @"%"))
{
Temp.Add(Convert.ToInt32(GetMonthCp.Get_Capacity_values));
}
else
Temp.Add(0);
MonthCpaacity_Data.Add(Temp);
}
return Flag;
}
//刷新直方图
public void Refresh_The_Histogram(Chart Item,List<String>Item_Name)//,List<String>Item_Values)
{
//Item指方图表名
//Item_Number指方图项目数
//Item_Values指向图项目值
//List<Color> LabelBackColorS = new List<Color>();{Color.AliceBlue,Color.AntiqueWhite,Color.Aqua};
List<String> x = new List<String>(){comboBox1.Text+"."+comboBox3.Text+"."+"产能月度统筹"};
Color[] ItemColorS = { Color.Red, Color.Gold, Color.Green,Color.Yellow,Color.SlateBlue,Color.Salmon,Color.Pink,Color.Orange,Color.MidnightBlue,
Color.LightCyan,Color.DarkGreen,Color.AntiqueWhite,Color.Cyan,Color.DarkCyan,Color.DimGray,Color.CadetBlue,Color.DarkBlue,
Color.DarkMagenta,Color.GreenYellow,Color.LemonChiffon,Color.LightCyan,Color.LightSeaGreen,Color.MediumBlue,Color.OrangeRed,
Color.PapayaWhip,Color.PowderBlue,Color.SandyBrown};
//指方图1表名
Item.Legends[0].Title = "FEREX" +comboBox1.Text + @"产能统筹(" + The_Chart_First + @")";
//添加项目
Item.Series.Clear();//清空
foreach (String Item_Names in Item_Name)
Item.Series.Add(Item_Names);
GetMonth_Total_Capacity_Lists();//读取每个测试员每月总产能
int n = 0;
foreach (List<int> vl in MonthCpaacity_Data)
{
Item.Series[Item_Name[n]].Points.DataBindXY(x, vl);
Item.Series[Item_Name[n]].LabelBackColor = Color.GreenYellow;//文本表头颜色
Item.Series[Item_Name[n]].ToolTip = Item_Name[n] + "测试产能";
Item.Series[Item_Name[n]].Color = ItemColorS[n];//项目背景颜色
Item.Series[Item_Name[n]].Points[0].Label = vl[0].ToString();// +"PCS";//总产能
n++;
}
}
public List<String> Product_Name;
public List<String> Product_Total;
public void GetNow_Produce_A_Product()//获取现在生产产品数据
{
richTextBox1.Text = "";
String Line = String.Empty;
//if (comboBox3.Text == "6F-TEST-L03") Line = "2F-TEST-L01";
//if (comboBox3.Text == "6F-TEST-L06") Line = "2F-TEST-L03";
Line = comboBox3.Text;
Product_Name=new List<String>();
Product_Total = new List<String>();
OperationDataBase GetProduce_Name = new OperationDataBase("GPUSERVER", "E_MainBoard", "sa", "adminsystem",
@"SELECT * FROM MainBoardData WHERE Station='" + Line + @"' and Date_Time like '" + DateTime.Now.ToString("yyyy-MM-dd") + @"%'");
int n = 0;
if (GetProduce_Name.Get_Product_Name(Product_Name, "Product_Name"))
{
richTextBox1.Text = comboBox3.Text + "生产测试日志:\n";
foreach(String ss in Product_Name)
{
OperationDataBase GetProduce_Name_1 = new OperationDataBase("GPUSERVER", "E_MainBoard", "sa", "adminsystem",
@"SELECT count(*) FROM MainBoardData WHERE Product_Name='"+ss+@"' And Station='" + Line + @"' and Date_Time like '" + DateTime.Now.ToString("yyyy-MM-dd") + @"%'");
if (GetProduce_Name_1.Get_Product_Total(Product_Total))
{
richTextBox1.Visible = true;
richTextBox1.Text =richTextBox1.Text+(n+1).ToString()+"."+ ss + "机型当前测试产能合计:" + Product_Total[n]+"PCS\n";
n++;
}
}
}
}
private void timer2_Tick(object sender, EventArgs e)//启动产能统筹
{
try
{
if (To_The_Timing <= 0)
{
FullListViewTestCapacity(listView1, All_Capacity_Data, TestEmployee_Total_Capacity, Total_Output_Per_Hour);//填充产能数据
Refresh_The_Histogram(chart1, User_Name);
timer2.Enabled = false;
timer3.Enabled = true;
IsBoot = true;
To_The_Timing = 60;
}
else
{
To_The_Timing--;
label2.Text = To_The_Timing + "秒倒计时刷新产能数据";
}
}
catch (Exception)
{
timer1.Enabled = false;
timer2.Enabled = false;
timer3.Enabled = false;
}
}
public int Scoreboard = 1;
public int To_The_Timing = 60;//秒;
private void timer3_Tick(object sender, EventArgs e)
{
try
{
if (IsBoot)
{
IsBoot = false;
Thread GetAllCapacityData = new Thread(Day_Test_Capacity_Plan_As_A_Whole);
GetAllCapacityData.Start();
}
else if (IsComplete)
{
IsComplete = false;
GetNow_Produce_A_Product();
timer3.Enabled = false;
timer2.Enabled = true;
Scoreboard = 1;
}
else
{
label2.BackColor = Color.Green;
label2.Text = "数据统筹执行中..." + " " + Scoreboard + "秒";
Scoreboard++;
}
}
catch (Exception)
{
timer3.Enabled = false;
timer2.Enabled = false;
timer1.Enabled = false;
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using System.Data.SqlClient;
using System.IO;
using System.Threading;
using System.Collections;
using System.Windows.Forms;
using System.Web;
using System.Net;
using System.Net.NetworkInformation;
using System.Data;
namespace Test_Capacity_Pane
{
public class OperationDataBase
{
public String server;
public String database;
public String uid;
public String pwd;
public String Sql_Connection_Str;//连接数据库串
public String Sql_Stored_Procedure;//存储过程
private SqlConnection sqlcon;//连接方式
public String Get_Capacity_values=String.Empty;//产能数据
public OperationDataBase(String server,String database,String uid,String pwd,String Stored_Procedure)
{
this.server = server;
this.database = database;
this.uid = uid;
this.pwd = pwd;
this.Sql_Connection_Str = @"server=" + this.server + ";database=" + this.database + ";pwd=" + this.pwd + ";uid=" + this.uid;
this.Sql_Stored_Procedure = Stored_Procedure;
}
public Boolean Sqlconnection_Way()//数据库连接
{
Boolean Flag = false;
sqlcon = new SqlConnection(this.Sql_Connection_Str);
sqlcon.Open();
try
{
Flag = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message,"系统提醒",MessageBoxButtons.OK,MessageBoxIcon.Error);
Flag = false;
}
return Flag;
}
public Boolean Get_Product_Total(List<String> Store_Product_Name)//获取对应机型名称产能
{
Boolean Flag = false;
try
{
if (this.Sqlconnection_Way())//连接数据库
{
SqlCommand cmd = new SqlCommand(this.Sql_Stored_Procedure, this.sqlcon);
Store_Product_Name.Add(cmd.ExecuteScalar().ToString());
//SqlDataReader sdr = cmd.ExecuteReader();
//if (sdr.Read())
//{
// Store_Product_Name.Add(sdr[Read_Product_Name].ToString());
// }
}
Flag = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
Flag = false;
}
finally
{
this.sqlcon.Close();
}
return Flag;
}
public Boolean Get_Product_Name(List<String> Store_Product_Name, String Read_Product_Name)//获取机型名称
{
Boolean Flag = false;
int n = 0;
try
{
if (this.Sqlconnection_Way())//连接数据库
{
SqlCommand cmd = new SqlCommand(this.Sql_Stored_Procedure,this.sqlcon);
SqlDataReader sdr = cmd.ExecuteReader();
while(sdr.Read())
{
if (n == 0)
Store_Product_Name.Add(sdr[Read_Product_Name].ToString());
else
{
Boolean ss=false;
foreach (String i in Store_Product_Name)
{
if (i == sdr[Read_Product_Name].ToString())
{
ss = true;
break;
}
}
if(!ss)
Store_Product_Name.Add(sdr[Read_Product_Name].ToString());
}
n++;
}
}
Flag = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
Flag = false;
}
finally
{
this.sqlcon.Close();
}
return Flag;
}
public Boolean Get_Capacity_Data(String JobNumber, String Year_Month_Day)//获取产能数据
{
Boolean Flag = false;
try
{
if (this.Sqlconnection_Way())//连接数据库
{
SqlCommand cmd = new SqlCommand(this.Sql_Stored_Procedure,this.sqlcon);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@JobNumber", JobNumber);
cmd.Parameters.Add("@Year_Month_Day", Year_Month_Day);
cmd.Parameters.Add("@GetTotalCount", SqlDbType.Int).Direction = ParameterDirection.Output;
cmd.Parameters.Add("@rs", SqlDbType.Int).Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
if ((int)cmd.Parameters["@rs"].Value == 0)
{
this.Get_Capacity_values = cmd.Parameters["@GetTotalCount"].Value.ToString();
Flag = true;
}
else
{
Flag = false;
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
Flag = false;
}
finally
{
this.sqlcon.Close();
}
return Flag;
}
public Boolean Get_Month_Capacity_Data(List<List<int>> Month_Capacity_Data, List<String> KeyInfo)//获取当前月度汇总总产能
{
Boolean Flag = false;
try
{
if (Sqlconnection_Way())//连接数据库
{
foreach (String ss in KeyInfo)
{
List<int> Temp=new List<int>();
SqlCommand cmd = new SqlCommand(this.Sql_Stored_Procedure,this.sqlcon);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@JobNumber",ss);
cmd.Parameters.Add("@Date_Time", DateTime.Now.ToString("yyyy-MM-dd") + @"%");
cmd.Parameters.Add("@TotoNumber", SqlDbType.Int).Direction = ParameterDirection.Output;//返回
cmd.Parameters.Add("@rs", SqlDbType.Int).Direction = ParameterDirection.Output;//返回
cmd.ExecuteNonQuery();
if ((int)cmd.Parameters["@rs"].Value == 0)
{
Temp.Add(Convert.ToInt32(cmd.Parameters["@TotoNumber"].Value));
}
else
Temp.Add(0);
Month_Capacity_Data.Add(Temp);
}
}
Flag = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
Flag = false;
}
finally
{
this.sqlcon.Close();
}
return Flag;
}
public Boolean Get_Employee_Info(List<String> Item_Values, ComboBox Item)//获取员工信息
{
Boolean Flag = false;
int n = 0;
try
{
if (Sqlconnection_Way())//连接数据库
{
SqlCommand cmd = new SqlCommand(this.Sql_Stored_Procedure, this.sqlcon);
SqlDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
if (n == 0)
{
Item.Items.Add(sdr["Line_Body"].ToString());
}
else
{
Boolean IsFind = false;
foreach (String ss in Item.Items)
{
if (ss == sdr["Line_Body"].ToString())
{
IsFind = true;
break;
}
}
if (!IsFind)
Item.Items.Add(sdr["Line_Body"].ToString());
}
Item_Values.Add(sdr["Line_Body"].ToString() + "#" + sdr["Job_Number"].ToString() + "#" + sdr["Name"].ToString());
n++;
}
Flag = true;
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
Flag = false;
}
finally
{
this.sqlcon.Close();
}
return Flag;
}
public Boolean Get_Product_Type_Info(List<String> Item_Values, ComboBox Item)//获取产品型号信息
{
Boolean Flag = false;
int n = 0;
try
{
if (Sqlconnection_Way())//连接数据库
{
SqlCommand cmd = new SqlCommand(this.Sql_Stored_Procedure, this.sqlcon);
SqlDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
if (n == 0)
{
Item.Items.Add(sdr["Product_Type"].ToString());
}
else
{
Boolean IsFind = false;
foreach (String ss in Item.Items)
{
if (ss == sdr["Product_Type"].ToString())
{
IsFind = true;
break;
}
}
if (!IsFind)
Item.Items.Add(sdr["Product_Type"].ToString());
}
Item_Values.Add(sdr["Product_Type"].ToString() + "#" + sdr["Item_Count"].ToString() + "#" + sdr["SERVER_Name"].ToString() + "#" +
sdr["DataBase_Name"].ToString() + "#" + sdr["SERVER_UserName"].ToString() + "#" + sdr["SERVER_Password"].ToString() + "#" +
sdr["TABLE_Name"].ToString() + "#" + sdr["Stored_Procedure"].ToString());// + "#" + sdr["Date_Time"].ToString());
n++;
}
Flag = true;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
Flag = false;
}
finally
{
this.sqlcon.Close();
}
return Flag;
}
}
}