229 lines
6.5 KiB
C#
229 lines
6.5 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using System.Windows.Forms.DataVisualization.Charting;
|
|
|
|
namespace AGVSystem
|
|
{
|
|
// Token: 0x02000021 RID: 33
|
|
public partial class frmnetfind : Form
|
|
{
|
|
// Token: 0x060001D5 RID: 469 RVA: 0x0004DCA0 File Offset: 0x0004BEA0
|
|
public frmnetfind(string str)
|
|
{
|
|
this.InitializeComponent();
|
|
this.Text = str;
|
|
base.WindowState = FormWindowState.Maximized;
|
|
this.dateTimePicker2.Value = DateTime.Now;
|
|
this.dateTimePicker1.Value = DateTime.Now.AddHours(-1.0);
|
|
}
|
|
|
|
// Token: 0x060001D6 RID: 470 RVA: 0x0004DD1C File Offset: 0x0004BF1C
|
|
private void frmfind_Load(object sender, EventArgs e)
|
|
{
|
|
this.ds = this.db.connDt("select CONVERT( VARCHAR(10),id) +' . '+ line_name as info from Assembly_Line order by id");
|
|
bool flag = this.ds.Tables.Count > 0;
|
|
if (flag)
|
|
{
|
|
bool flag2 = this.ds.Tables[0].Rows.Count > 0;
|
|
if (flag2)
|
|
{
|
|
this.cmb_linelist.Items.Add("");
|
|
foreach (object obj in this.ds.Tables[0].Rows)
|
|
{
|
|
DataRow dataRow = (DataRow)obj;
|
|
this.cmb_linelist.Items.Add(dataRow[0].ToString());
|
|
}
|
|
}
|
|
}
|
|
this.ds.Tables.Clear();
|
|
}
|
|
|
|
// Token: 0x060001D7 RID: 471 RVA: 0x0004DE24 File Offset: 0x0004C024
|
|
private void button2_Click(object sender, EventArgs e)
|
|
{
|
|
string text = string.Concat(new string[]
|
|
{
|
|
"SELECT Dt as '发生时间',Assembly_Line.line_name as '所属线体' ,'* '+convert (nvarchar(10),agvinfo.id) +' / '+convert (nvarchar(10),AgvInfo.Internal_ID) as '设备编号' ,net_Log.[Type] as '故障类型' FROM [net_Log],AgvInfo,Assembly_Line where net_Log.Agv_id = AgvInfo.ID and AgvInfo.Assembly_Line = Assembly_Line.id and Dt between '",
|
|
this.dateTimePicker1.Value.ToString(),
|
|
"' and '",
|
|
this.dateTimePicker2.Value.ToString(),
|
|
"' "
|
|
});
|
|
bool flag = this.cmb_linelist.Text != "";
|
|
if (flag)
|
|
{
|
|
text = text + " and Assembly_Line.id= " + this.cmb_linelist.Text.Split(new char[]
|
|
{
|
|
'.'
|
|
})[0];
|
|
}
|
|
bool flag2 = this.cmb_agv.Text != "";
|
|
if (flag2)
|
|
{
|
|
text = text + " and AgvInfo.Internal_ID= " + this.cmb_agv.Text;
|
|
}
|
|
text += " order by Assembly_Line.ID , dt";
|
|
this.ds.Tables.Clear();
|
|
this.ds = this.db.connDt(text);
|
|
this.dataGridView1.DataSource = this.ds.Tables[0];
|
|
this.dataGridView1.Columns[0].DefaultCellStyle.Format = "yyyy-MM-dd HH:mm:ss";
|
|
this.dataGridView1.Columns[0].Width = 200;
|
|
this.dataGridView1.Columns[3].Width = 200;
|
|
bool flag3 = this.ds.Tables[0].Rows.Count > 0;
|
|
if (flag3)
|
|
{
|
|
text = string.Concat(new string[]
|
|
{
|
|
"SELECT agvinfo.id ,count(*) as 次数 FROM [net_Log],AgvInfo,Assembly_Line where net_Log.Agv_id = AgvInfo.ID and AgvInfo.Assembly_Line = Assembly_Line.id and Dt between '",
|
|
this.dateTimePicker1.Value.ToString(),
|
|
"' and '",
|
|
this.dateTimePicker2.Value.ToString(),
|
|
"' "
|
|
});
|
|
bool flag4 = this.cmb_linelist.Text != "";
|
|
if (flag4)
|
|
{
|
|
text = text + " and Assembly_Line.id= " + this.cmb_linelist.Text.Split(new char[]
|
|
{
|
|
'.'
|
|
})[0];
|
|
}
|
|
text += "group by agvinfo.id ";
|
|
DataSet dataSet = this.db.connDt(text);
|
|
List<string> list = new List<string>();
|
|
List<int> list2 = new List<int>();
|
|
foreach (object obj in dataSet.Tables[0].Rows)
|
|
{
|
|
DataRow dataRow = (DataRow)obj;
|
|
list.Add("agv-" + dataRow[0].ToString());
|
|
list2.Add((int)Convert.ToInt16(dataRow[1].ToString()));
|
|
}
|
|
this.chart1.Series[0]["PieLabelStyle"] = "Outside";
|
|
this.chart1.Series[0]["PieLineColor"] = "Black";
|
|
this.chart1.Series[0].Points.DataBindXY(list, new IEnumerable[]
|
|
{
|
|
list2
|
|
});
|
|
}
|
|
}
|
|
|
|
// Token: 0x060001D8 RID: 472 RVA: 0x0004E188 File Offset: 0x0004C388
|
|
private void cmb_linelist_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
bool flag = this.cmb_linelist.Text != "";
|
|
if (flag)
|
|
{
|
|
this.ds = this.db.connDt("select Internal_ID from AgvInfo where [Assembly_Line] =" + this.cmb_linelist.Text.Split(new char[]
|
|
{
|
|
'.'
|
|
})[0] + " order by Internal_ID");
|
|
bool flag2 = this.ds.Tables.Count > 0;
|
|
if (flag2)
|
|
{
|
|
bool flag3 = this.ds.Tables[0].Rows.Count > 0;
|
|
if (flag3)
|
|
{
|
|
this.cmb_agv.Items.Clear();
|
|
this.cmb_agv.Items.Add("");
|
|
foreach (object obj in this.ds.Tables[0].Rows)
|
|
{
|
|
DataRow dataRow = (DataRow)obj;
|
|
this.cmb_agv.Items.Add(dataRow[0].ToString());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Token: 0x060001D9 RID: 473 RVA: 0x0004E2D8 File Offset: 0x0004C4D8
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
bool flag = this.dataGridView1.RowCount > 0;
|
|
if (flag)
|
|
{
|
|
this.SaveAs();
|
|
}
|
|
}
|
|
|
|
// Token: 0x060001DA RID: 474 RVA: 0x0004E300 File Offset: 0x0004C500
|
|
private void SaveAs()
|
|
{
|
|
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
|
saveFileDialog.Filter = "Execl files (*.xls)|*.xls";
|
|
saveFileDialog.FilterIndex = 0;
|
|
saveFileDialog.RestoreDirectory = true;
|
|
saveFileDialog.CreatePrompt = true;
|
|
saveFileDialog.Title = "Export Excel File To";
|
|
saveFileDialog.ShowDialog();
|
|
Stream stream;
|
|
try
|
|
{
|
|
stream = saveFileDialog.OpenFile();
|
|
}
|
|
catch
|
|
{
|
|
return;
|
|
}
|
|
StreamWriter streamWriter = new StreamWriter(stream, Encoding.GetEncoding(0));
|
|
string text = "";
|
|
try
|
|
{
|
|
for (int i = 0; i < this.dataGridView1.ColumnCount; i++)
|
|
{
|
|
bool flag = i > 0;
|
|
if (flag)
|
|
{
|
|
text += "\t";
|
|
}
|
|
text += this.dataGridView1.Columns[i].HeaderText;
|
|
}
|
|
streamWriter.WriteLine(text);
|
|
for (int j = 0; j < this.dataGridView1.Rows.Count; j++)
|
|
{
|
|
string text2 = "";
|
|
for (int k = 0; k < this.dataGridView1.Columns.Count; k++)
|
|
{
|
|
bool flag2 = k > 0;
|
|
if (flag2)
|
|
{
|
|
text2 += "\t";
|
|
}
|
|
text2 += this.dataGridView1.Rows[j].Cells[k].Value.ToString();
|
|
}
|
|
streamWriter.WriteLine(text2);
|
|
}
|
|
streamWriter.Close();
|
|
stream.Close();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.ToString());
|
|
}
|
|
finally
|
|
{
|
|
streamWriter.Close();
|
|
stream.Close();
|
|
}
|
|
}
|
|
|
|
// Token: 0x060001DB RID: 475 RVA: 0x0000A0B4 File Offset: 0x000082B4
|
|
private void dataGridView1_RowStateChanged(object sender, DataGridViewRowStateChangedEventArgs e)
|
|
{
|
|
e.Row.HeaderCell.Value = string.Format("{0}", e.Row.Index + 1);
|
|
}
|
|
|
|
// Token: 0x040005AF RID: 1455
|
|
private ClsDBConn_sql db = new ClsDBConn_sql();
|
|
|
|
// Token: 0x040005B0 RID: 1456
|
|
private DataSet ds = new DataSet();
|
|
}
|
|
}
|