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/GelDoser/SelectAction.cs

89 lines
4.1 KiB
C#

using Mesnac.Action.Base;
using Mesnac.Codd.Session;
using Mesnac.Controls.Base;
11 months ago
using Mesnac.Controls.Default;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Mesnac.Action.ChemicalWeighing.Report.GelDoser
{
/// <summary>
/// 糊化机报表查询事件
/// </summary>
public class SelectAction : ChemicalWeighingAction, IAction
{
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须要调用的
ICSharpCode.Core.LoggingService<SelectAction>.Debug("糊化机报表-查询...");
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
if (dbHelper == null)
{
ICSharpCode.Core.LoggingService<ExportAction>.Error("获取本地数据连接失败...");
return;
}
dbHelper.ClearParameter();
11 months ago
StringBuilder sbSql = new StringBuilder(@" select objId, gelNo, recordTime, reportId, recipeCode, recipeName, planCode, planName,
Batch from Report_Gel
where 1=1");
List<DbMCControl> mcControllist = GetAllDbMCControlsByOption(DbOptionTypes.Query);//获取所有待初始化控件
IBaseControl startdate = mcControllist.Where(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey.ToLower() == "startdate").FirstOrDefault().BaseControl;
IBaseControl starttime = mcControllist.Where(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey.ToLower() == "starttime").FirstOrDefault().BaseControl;
if (startdate != null && starttime != null)
{
//Append
sbSql.AppendLine(@"AND recordTime>='" + Convert.ToDateTime(startdate.MCValue).ToString("yyyy-MM-dd") + " " + Convert.ToDateTime(starttime.MCValue).ToShortTimeString() + "' ");
}
else
{
ICSharpCode.Core.LoggingService<SelectAction>.Debug("{糊化机报表-查询} 缺少key值为startdate或者starttime的时间查询条件...");
return;
}
IBaseControl enddate = mcControllist.Where(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey.ToLower() == "enddate").FirstOrDefault().BaseControl;
IBaseControl endtime = mcControllist.Where(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey.ToLower() == "endtime").FirstOrDefault().BaseControl;
if (enddate != null && endtime != null)
{
sbSql.AppendLine(@"AND recordTime<='" + Convert.ToDateTime(enddate.MCValue).ToString("yyyy-MM-dd") + " " + Convert.ToDateTime(endtime.MCValue).ToShortTimeString() + "' ");
}
else
{
ICSharpCode.Core.LoggingService<SelectAction>.Debug("{糊化机报表-查询} 缺少key值为enddate或者enddate的时间查询条件...");
return;
}
11 months ago
var MCCombobox1 = GetAllControls().FirstOrDefault(x => x.Name == "MCCombobox1") as MCCombobox;
sbSql.Append(" and gelNo=" + MCCombobox1.MCValue);
sbSql.Append(" ORDER BY recordTime desc");
dbHelper.CommandText = sbSql.ToString();
dbHelper.CommandType = System.Data.CommandType.Text;
DataTable table = dbHelper.ToDataTable();
//刷新DataGridView数据
DbMCControl _dgvGelDoser = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Report_GelDoser").FirstOrDefault();
if (_dgvGelDoser == null || !(_dgvGelDoser.BaseControl is DataGridView))
{
ICSharpCode.Core.LoggingService<SelectAction>.Warn("{糊化机报表-查询} 缺少系统日志DataGridView控件...");
runtime.IsReturn = false;
return;
}
_dgvGelDoser.BaseControl.BindDataSource = table;
}
}
}