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; MCButton SwitchModeSelect; //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; SwitchModeSelect = control.FirstOrDefault(x => x != null && x.Name == "SwitchModeSelect") 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; SwitchModeSelect.Click += SwitchModeSelectAction; } private void SwitchModeSelectAction(object sender, EventArgs e) { SetForm("切换", Convert.ToInt32(Line.MCValue.ToString())); } /// /// 转移去年的数据 /// /// /// 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("数据切割成功"); } /// /// 按时间查询日志 /// /// /// 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("手动", Convert.ToInt32(Line.MCValue.ToString())); } /// /// 刷新日志按钮 /// /// /// private void RefreshAction(object sender, EventArgs e) { SetForm(""); } /// /// 根据文本模糊查询 /// /// /// private void SelectByTextAction(object sender, EventArgs e) { SetForm(SelectText.MCValue.ToString()); } /// /// 根据文本查询绑定控件2 /// /// 文本 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); } } } }