311 lines
9.1 KiB
C#
311 lines
9.1 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: 0x0200001F RID: 31
|
|
public partial class frmwarnfind : Form
|
|
{
|
|
// Token: 0x060001C2 RID: 450 RVA: 0x0004AB54 File Offset: 0x00048D54
|
|
public frmwarnfind()
|
|
{
|
|
this.InitializeComponent();
|
|
base.WindowState = FormWindowState.Maximized;
|
|
this.dateTimePicker2.Value = DateTime.Now;
|
|
this.dateTimePicker1.Value = DateTime.Now.AddHours(-1.0);
|
|
this.ds = this.db.connDt("SELECT [Warn_Info] FROM [dbo].[Warn_Info] where Warn_Info not like'%正常%'");
|
|
bool flag = this.ds.Tables.Count > 0;
|
|
if (flag)
|
|
{
|
|
bool flag2 = this.ds.Tables[0].Rows.Count > 0;
|
|
if (flag2)
|
|
{
|
|
foreach (object obj in this.ds.Tables[0].Rows)
|
|
{
|
|
DataRow dataRow = (DataRow)obj;
|
|
this.cmb_gz.Items.Add(dataRow[0].ToString());
|
|
}
|
|
}
|
|
}
|
|
this.cmb_gz.SelectedIndex = 0;
|
|
}
|
|
|
|
// Token: 0x060001C3 RID: 451 RVA: 0x0004ACA8 File Offset: 0x00048EA8
|
|
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: 0x060001C4 RID: 452 RVA: 0x0004ADB0 File Offset: 0x00048FB0
|
|
private void button2_Click(object sender, EventArgs e)
|
|
{
|
|
string text = "";
|
|
bool flag = this.Text == "异常报警日志";
|
|
if (flag)
|
|
{
|
|
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 '设备编号' ,Warn_Log.[Type] as '故障类型' ,[Reset] as '故障恢复时间' FROM [Warn_Log],AgvInfo,Assembly_Line where Warn_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 flag2 = this.cmb_linelist.Text != "";
|
|
if (flag2)
|
|
{
|
|
text = text + " and Assembly_Line.id= " + this.cmb_linelist.Text.Split(new char[]
|
|
{
|
|
'.'
|
|
})[0];
|
|
}
|
|
bool flag3 = this.cmb_agv.Text != "";
|
|
if (flag3)
|
|
{
|
|
text = text + " and AgvInfo.Internal_ID= " + this.cmb_agv.Text;
|
|
}
|
|
bool flag4 = this.cmb_gz.SelectedIndex != 0;
|
|
if (flag4)
|
|
{
|
|
text = text + " and warn_log.type like '%" + this.cmb_gz.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 flag5 = this.Text == "异常报警日志";
|
|
if (flag5)
|
|
{
|
|
this.dataGridView1.Columns[4].DefaultCellStyle.Format = "yyyy-MM-dd HH:mm:ss";
|
|
this.dataGridView1.Columns[4].Width = 200;
|
|
}
|
|
bool flag6 = this.ds.Tables[0].Rows.Count > 0;
|
|
if (flag6)
|
|
{
|
|
bool flag7 = this.cmb_gz.SelectedIndex == 0;
|
|
DataSet dataSet;
|
|
if (flag7)
|
|
{
|
|
text = string.Concat(new string[]
|
|
{
|
|
"SELECT Warn_Log.[Type] as '故障类型' ,count(*) as 次数 FROM [Warn_Log],AgvInfo,Assembly_Line where Warn_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 flag8 = this.cmb_linelist.Text != "";
|
|
if (flag8)
|
|
{
|
|
text = text + " and Assembly_Line.id= " + this.cmb_linelist.Text.Split(new char[]
|
|
{
|
|
'.'
|
|
})[0];
|
|
}
|
|
bool flag9 = this.cmb_agv.Text != "";
|
|
if (flag9)
|
|
{
|
|
text = text + " and AgvInfo.Internal_ID= " + this.cmb_agv.Text;
|
|
}
|
|
text += "group by Warn_Log.[Type] ";
|
|
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(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
|
|
});
|
|
}
|
|
text = string.Concat(new string[]
|
|
{
|
|
"SELECT agvinfo.id ,count(*) as 次数 FROM [Warn_Log],AgvInfo,Assembly_Line where Warn_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 flag10 = this.cmb_linelist.Text != "";
|
|
if (flag10)
|
|
{
|
|
text = text + " and Assembly_Line.id= " + this.cmb_linelist.Text.Split(new char[]
|
|
{
|
|
'.'
|
|
})[0];
|
|
}
|
|
bool flag11 = this.cmb_agv.Text != "";
|
|
if (flag11)
|
|
{
|
|
text = text + " and AgvInfo.Internal_ID= " + this.cmb_agv.Text;
|
|
}
|
|
text += "group by agvinfo.id ";
|
|
dataSet = this.db.connDt(text);
|
|
List<string> list3 = new List<string>();
|
|
List<int> list4 = new List<int>();
|
|
foreach (object obj2 in dataSet.Tables[0].Rows)
|
|
{
|
|
DataRow dataRow2 = (DataRow)obj2;
|
|
list3.Add("agv-" + dataRow2[0].ToString());
|
|
list4.Add((int)Convert.ToInt16(dataRow2[1].ToString()));
|
|
}
|
|
this.chart2.Series[0]["PieLabelStyle"] = "Outside";
|
|
this.chart2.Series[0]["PieLineColor"] = "Black";
|
|
this.chart2.Series[0].Points.DataBindXY(list3, new IEnumerable[]
|
|
{
|
|
list4
|
|
});
|
|
}
|
|
}
|
|
|
|
// Token: 0x060001C5 RID: 453 RVA: 0x0004B3E0 File Offset: 0x000495E0
|
|
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: 0x060001C6 RID: 454 RVA: 0x0004B530 File Offset: 0x00049730
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
bool flag = this.dataGridView1.RowCount > 0;
|
|
if (flag)
|
|
{
|
|
this.SaveAs();
|
|
}
|
|
}
|
|
|
|
// Token: 0x060001C7 RID: 455 RVA: 0x0004B558 File Offset: 0x00049758
|
|
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: 0x060001C8 RID: 456 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: 0x060001C9 RID: 457 RVA: 0x00002460 File Offset: 0x00000660
|
|
private void splitContainer1_Panel1_Paint(object sender, PaintEventArgs e)
|
|
{
|
|
}
|
|
|
|
// Token: 0x04000585 RID: 1413
|
|
private ClsDBConn_sql db = new ClsDBConn_sql();
|
|
|
|
// Token: 0x04000586 RID: 1414
|
|
private DataSet ds = new DataSet();
|
|
}
|
|
}
|