using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data;
using Mesnac.Action.Base;
using Mesnac.Codd.Session;
using Mesnac.Controls.Base;
//using Mesnac.Gui.Common;
using ICSharpCode.Core;
using Mesnac.Controls.Default;
using System.Drawing;
namespace Mesnac.Action.ChemicalWeighing.Basic.SysLog
{
///
/// 系统日志窗体初始化
///
public class InitFormAction : ChemicalWeighingAction, IAction
{
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须要调用的
ICSharpCode.Core.LoggingService.Debug("系统日志-窗体初始化...");
#region 获取界面控件
DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "SysLog").FirstOrDefault(); //获取本机台计划网格控件
if (clientGridControl == null)
{
ICSharpCode.Core.LoggingService.Error("{操作日志-窗体加载} 缺少日志网格控件...");
return;
}
#endregion
#region 界面控件多语言切换
List controls = base.GetAllMCControls();
foreach (IBaseControl c in controls)
{
if (c.GetType().Name == "FrmRunTemplate")
{
//FrmRunTemplate frmRunTemplate = c as FrmRunTemplate;
//if (frmRunTemplate.Name == "FrmOperationRecord")
//{
// frmRunTemplate.TitleName = StringParser.Parse(ResourceService.GetString("Frm_OperationRecord"));
//}
}
if (c.MCKey != null && c.MCKey.ToLower().Contains("mcbuttonSearch".ToLower()))
{
System.Windows.Forms.Button button = c as System.Windows.Forms.Button;
button.Text = StringParser.Parse(ResourceService.GetString("Frm_SelectBtn"));
}
if (c.MCKey != null && c.MCKey.ToLower().Contains("mcbuttonExport".ToLower()))
{
System.Windows.Forms.Button button = c as System.Windows.Forms.Button;
button.Text = StringParser.Parse(ResourceService.GetString("Frm_ExportBtn"));
}
if (c.MCKey != null && c.MCKey == "OperationRecord_StartLable")
{
Label selectLa = c as Label;
selectLa.Text = StringParser.Parse(ResourceService.GetString("Frm_StartLable")); //开始时间
}
if (c.MCKey != null && c.MCKey == "OperationRecord_EndLable")
{
Label selectLa = c as Label;
selectLa.Text = StringParser.Parse(ResourceService.GetString("Frm_EndLable")); //结束时间
}
}
MCDataGridView mCDataGridView = (clientGridControl.BaseControl as MCDataGridView);
mCDataGridView.ColumnHeadersDefaultCellStyle.Font = new Font("微软雅黑", 10, FontStyle.Bold);
mCDataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
mCDataGridView.RowTemplate.Height = 26;
for (int i = 0; i < mCDataGridView.DgvColumn.Count; i++)
{
DataGridViewColumns dataGridViewColumn = mCDataGridView.DgvColumn[i];
if (dataGridViewColumn.FiledData == "RecordTime")
{
dataGridViewColumn.DisplayName = StringParser.Parse(ResourceService.GetString("Frm_DGV_RecordTime"));
}
else if (dataGridViewColumn.FiledData == "UserName")
{
dataGridViewColumn.DisplayName = StringParser.Parse(ResourceService.GetString("Frm_DGV_UserName"));
}
else if (dataGridViewColumn.FiledData == "WorkType")
{
dataGridViewColumn.DisplayName = StringParser.Parse(ResourceService.GetString("Frm_DGV_WorkType"));
}
else if (dataGridViewColumn.FiledData == "OperDest")
{
dataGridViewColumn.DisplayName = StringParser.Parse(ResourceService.GetString("Frm_DGV_OperDest"));
}
else if (dataGridViewColumn.FiledData == "Remark")
{
dataGridViewColumn.DisplayName = StringParser.Parse(ResourceService.GetString("Frm_DGV_Remark"));
}
else
{
continue;
}
}
#endregion
List mcControllist = GetAllDbMCControlsByOption(DbOptionTypes.Query);//获取所有待初始化控件
IBaseControl startdate = mcControllist.Where(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey.ToLower() == "startdate").FirstOrDefault().BaseControl;
startdate.MCValue = DateTime.Now.AddDays(-1);
}
}
}