You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
237 lines
8.8 KiB
C#
237 lines
8.8 KiB
C#
using DataBlockHelper;
|
|
using DevExpress.XtraExport.Helpers;
|
|
using DevExpress.XtraRichEdit.Model;
|
|
using ICSharpCode.Core;
|
|
using Mesnac.Action.Base;
|
|
using Mesnac.Action.ChemicalWeighing.InterfaceDocking;
|
|
using Mesnac.Action.ChemicalWeighing.InterfaceDocking.DockingEntity;
|
|
using Mesnac.Action.ChemicalWeighing.Util;
|
|
using Mesnac.Basic;
|
|
using Mesnac.Controls.ChemicalWeighing;
|
|
using Mesnac.Controls.Default;
|
|
using Mesnac.Core.Service;
|
|
using Steema.TeeChart.Styles;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices.ComTypes;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.Report
|
|
{
|
|
public class LjLogReport : ChemicalWeighingAction, IAction
|
|
{
|
|
MCButton SelectButton;
|
|
MCButton WaterSet;
|
|
MCButton SpiralSet;
|
|
MCButton ManualControl;
|
|
MCButton Refresh;
|
|
MCButton SelectByText;
|
|
MCButton LastYearDataMove;
|
|
|
|
//HslSwitch HslSwitch1;
|
|
//HslSwitch HslSwitch2;
|
|
//HslSwitch HslSwitch3;
|
|
//HslSwitch HslSwitch4;
|
|
//HslSwitch HslSwitch5;
|
|
//HslSwitch HslSwitch6;
|
|
//HslSwitch HslSwitch7;
|
|
//HslSwitch HslSwitch8;
|
|
|
|
MCTextBox SelectText;
|
|
|
|
MCDateTimePicker StartDate;
|
|
MCDateTimePicker EndDate;
|
|
|
|
DbMCControl LogForm;
|
|
|
|
MCCombobox Line;
|
|
|
|
public void Run(RuntimeParameter runtime)
|
|
{
|
|
base.RunIni(runtime);
|
|
|
|
var control = GetAllControls();
|
|
|
|
SelectButton = control.FirstOrDefault(x => x != null && x.Name == "SelectButton") as MCButton;
|
|
WaterSet = control.FirstOrDefault(x => x != null && x.Name == "WaterSet") as MCButton;
|
|
SpiralSet = control.FirstOrDefault(x => x != null && x.Name == "SpiralSet") as MCButton;
|
|
ManualControl = control.FirstOrDefault(x => x != null && x.Name == "ManualControl") as MCButton;
|
|
Refresh = control.FirstOrDefault(x => x != null && x.Name == "Refresh") as MCButton;
|
|
SelectByText = control.FirstOrDefault(x => x != null && x.Name == "SelectByText") as MCButton;
|
|
LastYearDataMove = control.FirstOrDefault(x => x != null && x.Name == "LastYearDataMove") as MCButton;
|
|
StartDate = control.FirstOrDefault(x => x != null && x.Name == "StartDate") as MCDateTimePicker;
|
|
EndDate = control.FirstOrDefault(x => x != null && x.Name == "EndDate") as MCDateTimePicker;
|
|
LogForm = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "ManualLogGridView1").FirstOrDefault();
|
|
SelectText = control.FirstOrDefault(x => x != null && x.Name == "SelectText") as MCTextBox;
|
|
Line = control.FirstOrDefault(x => x != null && x.Name == "Line") as MCCombobox;
|
|
//HslSwitch1 = control.FirstOrDefault(x => x != null && x.Name == "HslSwitch1") as HslSwitch;
|
|
//HslSwitch2 = control.FirstOrDefault(x => x != null && x.Name == "HslSwitch2") as HslSwitch;
|
|
//HslSwitch3 = control.FirstOrDefault(x => x != null && x.Name == "HslSwitch3") as HslSwitch;
|
|
//HslSwitch4 = control.FirstOrDefault(x => x != null && x.Name == "HslSwitch4") as HslSwitch;
|
|
//HslSwitch5 = control.FirstOrDefault(x => x != null && x.Name == "HslSwitch5") as HslSwitch;
|
|
//HslSwitch6 = control.FirstOrDefault(x => x != null && x.Name == "HslSwitch6") as HslSwitch;
|
|
//HslSwitch7 = control.FirstOrDefault(x => x != null && x.Name == "HslSwitch7") as HslSwitch;
|
|
//HslSwitch8 = control.FirstOrDefault(x => x != null && x.Name == "HslSwitch8") as HslSwitch;
|
|
|
|
if (LogForm != null)
|
|
{
|
|
LogForm.BaseControl.BindDataSource = null;
|
|
LogForm.BaseControl.BindDataSource = LjLogControl.ManualLogSelect("");
|
|
}
|
|
|
|
DataTable dataTable = new DataTable();
|
|
dataTable.Columns.Add("CmbValue", typeof(string));
|
|
dataTable.Columns.Add("CmbDisplay", typeof(string));
|
|
DataRow dr = dataTable.NewRow();
|
|
dr[0] = "0";
|
|
dr[1] = "全部机台";
|
|
dataTable.Rows.Add(dr);
|
|
for (int i = 1; i <= 8; i++)
|
|
{
|
|
dr = dataTable.NewRow();
|
|
dr[0] = i.ToString();
|
|
dr[1] = i + "号机台";
|
|
dataTable.Rows.Add(dr);
|
|
}
|
|
Line.DataSource = dataTable;
|
|
|
|
StartDate.MCValue = DateTime.Now.AddDays(-7);
|
|
|
|
SetForm("");
|
|
|
|
SelectButton.Click += SelectByTime;
|
|
WaterSet.Click += WaterSetSelect;
|
|
SpiralSet.Click += SpiralSetSelect;
|
|
ManualControl.Click += ManualControlSelect;
|
|
Refresh.Click += RefreshAction;
|
|
SelectByText.Click += SelectByTextAction;
|
|
LastYearDataMove.Click += DataMoveAction;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 转移去年的数据
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void DataMoveAction(object sender, EventArgs e)
|
|
{
|
|
if (MessageBox.Show("确认要切割数据?", "三次提醒 3/1", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; }
|
|
if (MessageBox.Show("确认要切割数据?", "三次提醒 3/2", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; }
|
|
if (MessageBox.Show("确认要切割数据?", "三次提醒 3/3", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; }
|
|
LjLogControl.LastYearDataCut();
|
|
MessageBox.Show("数据切割成功");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 按时间查询日志
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void SelectByTime(object sender, EventArgs e)
|
|
{
|
|
SetForm(StartDate.Value.Date.ToString("yyyy-MM-dd"), EndDate.Value.Date.ToString("yyyy-MM-dd"));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 水称日志查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void WaterSetSelect(object sender, EventArgs e)
|
|
{
|
|
SetForm("水", Convert.ToInt32(Line.MCValue.ToString()));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 螺旋日志查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void SpiralSetSelect(object sender, EventArgs e)
|
|
{
|
|
SetForm("螺旋", Convert.ToInt32(Line.MCValue.ToString()));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 手动操作查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void ManualControlSelect(object sender, EventArgs e)
|
|
{
|
|
SetForm("手动");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 刷新日志按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void RefreshAction(object sender, EventArgs e)
|
|
{
|
|
SetForm("");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据文本模糊查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void SelectByTextAction(object sender, EventArgs e)
|
|
{
|
|
SetForm(SelectText.MCValue.ToString());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据文本查询绑定控件2
|
|
/// </summary>
|
|
/// <param name="key">文本</param>
|
|
private void SetForm(string key)
|
|
{
|
|
if (LogForm != null)
|
|
{
|
|
LogForm.BaseControl.BindDataSource = null;
|
|
LogForm.BaseControl.BindDataSource = LjLogControl.ManualLogSelect(key);
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据文本和设备编号查询绑定控件
|
|
/// </summary>
|
|
/// <param name="key">文本</param>
|
|
/// <param name="deviceNo">设备编号</param>
|
|
private void SetForm(string key, int deviceNo)
|
|
{
|
|
if (LogForm != null)
|
|
{
|
|
LogForm.BaseControl.BindDataSource = null;
|
|
LogForm.BaseControl.BindDataSource = LjLogControl.ManualLogSelect(key, deviceNo);
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据起始时间查询绑定控件
|
|
/// </summary>
|
|
/// <param name="startTime">开始时间</param>
|
|
/// <param name="endTime">结束时间</param>
|
|
private void SetForm(string startTime, string endTime)
|
|
{
|
|
if (LogForm != null)
|
|
{
|
|
LogForm.BaseControl.BindDataSource = null;
|
|
LogForm.BaseControl.BindDataSource = LjLogControl.ManualLogSelect(startTime, endTime);
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|