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.
lj_plc/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/LjLogReport.cs

148 lines
4.9 KiB
C#

using DevExpress.XtraExport.Helpers;
using DevExpress.XtraRichEdit.Model;
using Mesnac.Action.Base;
using Mesnac.Controls.Default;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
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;
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;
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;
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;
}
private void SelectByTime(object sender, EventArgs e)
{
SetForm(StartDate.Value.Date.ToString("yyyy-MM-dd"), EndDate.Value.Date.ToString("yyyy-MM-dd"));
}
private void WaterSetSelect(object sender, EventArgs e)
{
SetForm("水", Convert.ToInt32(Line.MCValue.ToString()));
}
private void SpiralSetSelect(object sender, EventArgs e)
{
SetForm("螺旋", Convert.ToInt32(Line.MCValue.ToString()));
}
private void ManualControlSelect(object sender, EventArgs e)
{
SetForm("手动");
}
private void RefreshAction(object sender, EventArgs e)
{
SetForm("");
}
private void SelectByTextAction(object sender, EventArgs e)
{
SetForm(SelectText.MCValue.ToString());
}
private void SetForm(string key)
{
if (LogForm != null)
{
LogForm.BaseControl.BindDataSource = null;
LogForm.BaseControl.BindDataSource = LjLogControl.ManualLogSelect(key);
}
}
private void SetForm(string key, int deviceNo)
{
if (LogForm != null)
{
LogForm.BaseControl.BindDataSource = null;
LogForm.BaseControl.BindDataSource = LjLogControl.ManualLogSelect(key, deviceNo);
}
}
private void SetForm(string startTime, string endTime)
{
if (LogForm != null)
{
LogForm.BaseControl.BindDataSource = null;
LogForm.BaseControl.BindDataSource = LjLogControl.ManualLogSelect(startTime, endTime);
}
}
}
}