Files
6150-HMI/CowainHmi/Alarm/AlarmHistory.cs
2026-01-15 15:06:36 +08:00

63 lines
1.8 KiB
C#

using CowainHmi.Alarm;
using PCHMI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CowainHmi
{
[DefaultEvent(""), ToolboxBitmap(typeof(AlarmHistory), "alarm.png")]
public partial class AlarmHistory : UserControl
{
public AlarmHistory()
{
InitializeComponent();
this.dgvErr.AutoGenerateColumns = false;
this.dtDate.Value = DateTime.Now;
}
private void btnUpdate_Click(object sender, EventArgs e)
{
if (PClass.SystemRun)
{
string name = this.dtDate.Value.ToString("yyMMdd");
this.dgvErr.DataSource = null;
this.dgvErr.DataSource = AlarmExcelHelper.GetAlarmLog(name);
}
}
private void dgvErr_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
DgvRowPostPaint2(this.dgvErr, e);
}
public void DgvRowPostPaint2(DataGridView dgv, DataGridViewRowPostPaintEventArgs e)
{
Color color = Color.Black;
string val = dgv.Rows[e.RowIndex].Cells[5].Value.ToString();
if (val == "1")
{
color = Color.Red;
}
if (val == "0")
{
color = Color.Green;
}
dgv.Rows[e.RowIndex].DefaultCellStyle.ForeColor = color;
new DataGridViewStyle().DgvRowPostPaint(dgv, e);
}
private void dgvErr_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
e.CellStyle.SelectionForeColor = e.CellStyle.ForeColor;
}
}
}