using System; using System.Data; using System.Linq; using Mesnac.Action.Base; using Mesnac.Action.ChemicalWeighing.LjMaterial; namespace Mesnac.Action.ChemicalWeighing.OliveEQSetting { public class InItDbAction: ChemicalWeighingAction, IAction { LjElectrical.UpAction UpActionElectrical = new LjElectrical.UpAction(); LjMetage.UpAction UpActionMetage = new LjMetage.UpAction(); LjPressure.UpAction UpActionPressure = new LjPressure.UpAction(); LjProportional.UpAction UpActionProportional = new LjProportional.UpAction(); LjWeight.UpAction UpActionWeight = new LjWeight.UpAction(); public void Run(RuntimeParameter runtime) { base.RunIni(runtime); //必须调用 //FillPressureSetting(); //FillProportionalSetting(); //FillWeightSetting(); //FillElectricalSetting(); //FillMetageSetting(); InitEvent(); UpActionElectrical.Run(runtime); UpActionMetage.Run(runtime); UpActionPressure.Run(runtime); UpActionProportional.Run(runtime); UpActionWeight.Run(runtime); LoadingHelper.CloseForm(); } private void InitEvent() { LjPressure.UpdateAction.OnUpdate -= null; LjPressure.DownAction.OnHandler -= null; LjPressure.UpAction.OnHandler -= null; LjPressure.UpdateAction.OnUpdate += delegate { FillPressureSetting(); }; LjPressure.DownAction.OnHandler += delegate { FillPressureSetting(); }; LjPressure.UpAction.OnHandler += delegate { FillPressureSetting(); }; LjProportional.UpdateAction.OnUpdate -= null; LjProportional.DownAction.OnHandler -= null; LjProportional.UpAction.OnHandler -= null; LjProportional.UpdateAction.OnUpdate+= delegate { FillProportionalSetting(); }; LjProportional.DownAction.OnHandler+= delegate { FillProportionalSetting(); }; LjProportional.UpAction.OnHandler+= delegate { FillProportionalSetting(); }; LjWeight.UpdateAction.OnUpdate -= null; LjWeight.DownAction.OnHandler -= null; LjWeight.UpAction.OnHandler -= null; LjWeight.UpdateAction.OnUpdate += delegate { FillWeightSetting(); }; LjWeight.DownAction.OnHandler += delegate { FillWeightSetting(); }; LjWeight.UpAction.OnHandler += delegate { FillWeightSetting(); }; LjElectrical.DownAction.OnHandler -= null; LjElectrical.UpAction.OnHandler -= null; LjElectrical.UpdateAction.OnUpdate -= null; LjElectrical.DownAction.OnHandler += delegate { FillElectricalSetting(); }; LjElectrical.UpAction.OnHandler += delegate { FillElectricalSetting(); }; LjElectrical.UpdateAction.OnUpdate += delegate { FillElectricalSetting(); }; LjMetage.DownAction.OnHandler -= null; LjMetage.UpAction.OnHandler -= null; LjMetage.UpdateAction.OnUpdate -= null; LjMetage.DownAction.OnHandler += delegate { FillMetageSetting(); }; LjMetage.UpAction.OnHandler += delegate { FillMetageSetting(); }; LjMetage.UpdateAction.OnUpdate += delegate { FillMetageSetting(); }; } private void FillPressureSetting() { DbMCControl materialGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "pressureSetting") .FirstOrDefault(); //获取物料数据控件 DataTable table = DBHelp.GetTable(@"select Id,Name,ActualValue,LowLimit,HighLimit,Alarm, case Alarm when 1 then '超压' else '正常' end as AlarmValue from pressureSetting;"); if (materialGridControl != null && materialGridControl.BaseControl != null) { materialGridControl.BaseControl.BindDataSource = null; materialGridControl.BaseControl.BindDataSource = table; //DBLog("成功!"); } } private void FillProportionalSetting() { DbMCControl materialGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "ProportionalSetting") .FirstOrDefault(); //获取物料数据控件 DataTable table = DBHelp.GetTable(@"select Id, Name, PV, SV from ProportionalSetting"); if (materialGridControl != null && materialGridControl.BaseControl != null) { materialGridControl.BaseControl.BindDataSource = null; materialGridControl.BaseControl.BindDataSource = table; //DBLog("成功!"); } } // private void FillWeightSetting() { DbMCControl materialGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "WeightSetting") .FirstOrDefault(); //获取物料数据控件 DataTable table = DBHelp.GetTable(@"select Id,Name,ActWeight,HighLevel,HighWeight,LowLevel,LowWeight from WeightSetting"); if (materialGridControl != null && materialGridControl.BaseControl != null) { materialGridControl.BaseControl.BindDataSource = null; materialGridControl.BaseControl.BindDataSource = table; //DBLog("成功!"); } } private void FillElectricalSetting() { DbMCControl materialGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "ElectricalSetting") .FirstOrDefault(); //获取物料数据控件 DataTable table = DBHelp.GetTable(@"select Id, Name, Speed from ElectricalSetting"); if (materialGridControl != null && materialGridControl.BaseControl != null) { materialGridControl.BaseControl.BindDataSource = null; materialGridControl.BaseControl.BindDataSource = table; //DBLog("成功!"); } } private void FillMetageSetting() { DbMCControl materialGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "MetageSetting") .FirstOrDefault(); //获取物料数据控件 DataTable table = DBHelp.GetTable(@"select Id, Name, HighSpeed, LowSpeed, WeightSlow, Precut, JogTime from MetageSetting"); if (materialGridControl != null && materialGridControl.BaseControl != null) { materialGridControl.BaseControl.BindDataSource = null; materialGridControl.BaseControl.BindDataSource = table; //DBLog("成功!"); } } } }