using DataBlockHelper.DBHelpers; using Mesnac.Action.Base; using Mesnac.Action.ChemicalWeighing.FreeDb; using Mesnac.Action.ChemicalWeighing.Report.Entity; using Mesnac.Basic; using Mesnac.Controls.ChemicalWeighing; using Mesnac.Controls.Default; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Mesnac.Action.ChemicalWeighing.ManualControl { public class ForceWaterInitAction : ChemicalWeighingAction, IAction { FMCTextBoxEntity MCTextBoxE = new FMCTextBoxEntity(); FMCButtonEntity ButtonE = new FMCButtonEntity(); FMCRadioButtonEntity RadioButtonE = new FMCRadioButtonEntity(); DB2105Helper DB2105 = new DB2105Helper(); private List Controls; private byte GelChooseA = 0; private byte GelChooseB = 0; public void Run(RuntimeParameter runtime) { base.RunIni(runtime); Controls = GetAllControls(); SetAllControls(); BottomSelect(runtime); } private void SetAllControls() { ControlsHelper.ControlImport(MCTextBoxE, Controls); ControlsHelper.ControlImport(ButtonE, Controls); ControlsHelper.ControlImport(RadioButtonE, Controls); } private void BottomSelect(RuntimeParameter runtime) { DB2105 = new DB2105Helper(); SingleSelect(); if (ButtonE.StartMetage1 == runtime.Sender) { if (GelChooseA == 0) { MessageBox.Show("请先选择糊化锅!"); return; } if (!DB2105.Force_CA.forceOn) { MessageBox.Show("冷水称A强制控制按钮未打开!"); return; } if (MessageBox.Show("确认向冷水称A补充?", "强制模式启动确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } DB2105WriteHelper.AddCaAddValue(Convert.ToInt16(MCTextBoxE.SetWaterValue1.Text)); DB2105WriteHelper.AddCaAddForceBin(GelChooseA); DB2105WriteHelper.AddCaAddStartIn(true); ManualLogControl("冷水称A强制补充", Convert.ToInt16(MCTextBoxE.SetWaterValue1.Text), GelChooseA); MessageBox.Show("冷水称A强制补充"); } if (ButtonE.StartMetage2 == runtime.Sender) { if (GelChooseA == 0) { MessageBox.Show("请先选择糊化锅!"); return; } if (!DB2105.Force_HA.forceOn) { MessageBox.Show("热水称A强制控制按钮未打开!"); return; } if (MessageBox.Show("确认向热水称A补充?", "强制模式启动确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } DB2105WriteHelper.AddHaAddValue(Convert.ToInt16(MCTextBoxE.SetWaterValue2.Text)); DB2105WriteHelper.AddHaAddForceBin(GelChooseA); DB2105WriteHelper.AddHaAddStartIn(true); ManualLogControl("热水称A强制补充", Convert.ToInt16(MCTextBoxE.SetWaterValue2.Text), GelChooseA); MessageBox.Show("热水称A强制补充"); } if (ButtonE.StartMetage3 == runtime.Sender) { if (GelChooseB == 0) { MessageBox.Show("请先选择糊化锅!"); return; } if (!DB2105.Force_CB.forceOn) { MessageBox.Show("冷水称B强制控制按钮未打开!"); return; } if (MessageBox.Show("确认向冷水称B补充?", "强制模式启动确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } DB2105WriteHelper.AddCbAddValue(Convert.ToInt16(MCTextBoxE.SetWaterValue3.Text)); DB2105WriteHelper.AddCbAddForceBin(GelChooseB); DB2105WriteHelper.AddCbAddStartIn(true); ManualLogControl("冷水称B强制补充", Convert.ToInt16(MCTextBoxE.SetWaterValue3.Text), GelChooseB + 4); MessageBox.Show("冷水称B强制补充"); } if (ButtonE.StartMetage4 == runtime.Sender) { if (GelChooseB == 0) { MessageBox.Show("请先选择糊化锅!"); return; } if (!DB2105.Force_HB.forceOn) { MessageBox.Show("热水称B强制控制按钮未打开!"); return; } if (MessageBox.Show("确认向热水称B补充?", "强制模式启动确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } DB2105WriteHelper.AddHbAddValue(Convert.ToInt16(MCTextBoxE.SetWaterValue4.Text)); DB2105WriteHelper.AddHbAddForceBin(GelChooseB); DB2105WriteHelper.AddHbAddStartIn(true); ManualLogControl("热水称B强制补充", Convert.ToInt16(MCTextBoxE.SetWaterValue4.Text), GelChooseB + 4); MessageBox.Show("热水称B强制补充"); } if (ButtonE.StartOut1 == runtime.Sender) { if (GelChooseA == 0) { MessageBox.Show("请先选择糊化锅!"); return; } if (!DB2105.Force_CA.forceOn) { MessageBox.Show("冷水称A强制控制按钮未打开!"); return; } if (MessageBox.Show("确认向" + GelChooseA + "排水?", "强制模式启动确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } DB2105WriteHelper.AddCaAddRemainValue(Convert.ToInt16(MCTextBoxE.StayWaterValue1.Text)); DB2105WriteHelper.AddCaAddForceBin(GelChooseA); DB2105WriteHelper.AddCaAddStartOut(true); ManualLogControl("冷水称A强制排水", Convert.ToInt16(MCTextBoxE.StayWaterValue1.Text), GelChooseA); MessageBox.Show("冷水称A强制排水"); } if (ButtonE.StartOut2 == runtime.Sender) { if (GelChooseA == 0) { MessageBox.Show("请先选择糊化锅!"); return; } if (!DB2105.Force_HA.forceOn) { MessageBox.Show("热水称A强制控制按钮未打开!"); return; } if (MessageBox.Show("确认向" + GelChooseA + "排水?", "强制模式启动确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } DB2105WriteHelper.AddHaAddRemainValue(Convert.ToInt16(MCTextBoxE.StayWaterValue2.Text)); DB2105WriteHelper.AddHaAddForceBin(GelChooseA); DB2105WriteHelper.AddHaAddStartOut(true); ManualLogControl("热水称A强制排水", Convert.ToInt16(MCTextBoxE.StayWaterValue2.Text), GelChooseA); MessageBox.Show("热水称A强制排水"); } if (ButtonE.StartOut3 == runtime.Sender) { if (GelChooseB == 0) { MessageBox.Show("请先选择糊化锅!"); return; } if (!DB2105.Force_CB.forceOn) { MessageBox.Show("冷水称B强制控制按钮未打开!"); return; } if (MessageBox.Show("确认向" + GelChooseB + 4 + "排水?", "强制模式启动确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } DB2105WriteHelper.AddCbAddRemainValue(Convert.ToInt16(MCTextBoxE.StayWaterValue3.Text)); DB2105WriteHelper.AddCbAddForceBin(GelChooseB); DB2105WriteHelper.AddCbAddStartOut(true); ManualLogControl("冷水称B强制排水", Convert.ToInt16(MCTextBoxE.StayWaterValue3.Text), GelChooseB + 4); MessageBox.Show("冷水称B强制排水"); } if (ButtonE.StartOut4 == runtime.Sender) { if (GelChooseB == 0) { MessageBox.Show("请先选择糊化锅!"); return; } if (!DB2105.Force_HB.forceOn) { MessageBox.Show("热水称B强制控制按钮未打开!"); return; } if (MessageBox.Show("确认向" + GelChooseB + 4 + "排水?", "强制模式启动确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } DB2105WriteHelper.AddHbAddRemainValue(Convert.ToInt16(MCTextBoxE.StayWaterValue4.Text)); DB2105WriteHelper.AddHbAddForceBin(GelChooseB); DB2105WriteHelper.AddHbAddStartOut(true); ManualLogControl("热水称B强制排水", Convert.ToInt16(MCTextBoxE.StayWaterValue4.Text), GelChooseB + 4); MessageBox.Show("热水称B强制排水"); } } private void SingleSelect() { if (Convert.ToBoolean(RadioButtonE.Gel1.MCValue) == true) { GelChooseA = 1; } if (Convert.ToBoolean(RadioButtonE.Gel2.MCValue) == true) { GelChooseA = 2; } if (Convert.ToBoolean(RadioButtonE.Gel3.MCValue) == true) { GelChooseA = 3; } if (Convert.ToBoolean(RadioButtonE.Gel4.MCValue) == true) { GelChooseA = 4; } if (Convert.ToBoolean(RadioButtonE.Gel5.MCValue) == true) { GelChooseB = 1; } if (Convert.ToBoolean(RadioButtonE.Gel6.MCValue) == true) { GelChooseB = 2; } if (Convert.ToBoolean(RadioButtonE.Gel7.MCValue) == true) { GelChooseB = 3; } if (Convert.ToBoolean(RadioButtonE.Gel8.MCValue) == true) { GelChooseB = 4; } } /// /// 日志插入 /// /// 日志内容 /// 值 /// 值类型 0无 1水称设定值 2水称称量值 3螺旋设定值 4螺旋称量值 /// 设备编号 /// 设备类型 0无 1水称 2螺旋 public void ManualLogControl(string logName, int value, int deviceno) { var Log = new LjLogEntity() { logtext = logName, logtime = DateTime.Now, userid = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName, value = value, deviceno = deviceno, devicekind = 1, valuekind = 0, createdate = DateTime.Now.ToString("yyyyMMdd") }; FreeSqlUnit.Instance.Insert(Log).ExecuteIdentity(); } } }