Files

111 lines
3.9 KiB
C#
Raw Permalink Normal View History

2021-06-05 14:17:30 +08:00
using CleanMachineHMI.Utils;
2021-12-26 21:30:02 +08:00
using Krypton.Toolkit;
2021-06-05 14:17:30 +08:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
2021-12-27 09:51:57 +08:00
2021-06-05 14:17:30 +08:00
using System.Windows.Forms;
namespace CleanMachineHMI.frmChild
{
public partial class frmSwitchRunDirection : KryptonForm
{
public frmSwitchRunDirection()
{
InitializeComponent();
}
private void frmSwitchRunDirection_Load(object sender, EventArgs e)
{
try
{
2022-03-18 19:06:26 +08:00
this.SetFormControlText();
2021-06-05 14:17:30 +08:00
int directNum = Convert.ToInt32(PlcOperationHelper.Instance.ReadPlcItem("DischargeDirectionSelection", PlcItemTypeDesc.D));
2022-03-18 21:25:34 +08:00
if (GlobalHelper.LanguageCode != "zh-CN")
2021-06-05 14:17:30 +08:00
{
if (directNum == 0)
{
ktb_CurrRunDirection.Text = "Positive direction";
}
else
{
ktb_CurrRunDirection.Text = "Negative direction";
}
kcmb_SwitchRunDirection.Items.Clear();
kcmb_SwitchRunDirection.Items.Add(new ListItem
{
Value = "",
Text = "Please Select",
});
kcmb_SwitchRunDirection.Items.Add(new ListItem
{
Value = "1",
Text = "Positive direction",
});
kcmb_SwitchRunDirection.Items.Add(new ListItem
{
Value = "2",
Text = "Negative direction",
});
}
else
{
if (directNum == 0)
{
ktb_CurrRunDirection.Text = "正方向";
}
else
{
ktb_CurrRunDirection.Text = "反方向";
}
}
kcmb_SwitchRunDirection.SelectedIndex = 0;
}
catch (Exception ex)
{
2022-03-18 19:06:26 +08:00
KryptonMessageBox.Show(this.GetInfoText("加载出料运行方向切换界面发生异常", "LoadSwitchRunDirectionExp") + $":【{ex.Message}】!");
2021-06-05 14:17:30 +08:00
}
}
private void btnAdd_Click(object sender, EventArgs e)
{
try
{
if (kcmb_SwitchRunDirection.SelectedIndex == 0)
{
2022-03-18 19:06:26 +08:00
KryptonMessageBox.Show(this.GetInfoText("请选择切换方向!", "SelectSwitchDirectionInfo"));
2021-06-05 14:17:30 +08:00
return;
}
if (!PlcOperationHelper.Instance.isConn)
{
KryptonMessageBox.Show("The PLC is disconnected and unable to operate the equipment.");
return;
}
if (PlcOperationHelper.Instance.WritePlcItem("DischargeDirectionSelection", (kcmb_SwitchRunDirection.SelectedIndex - 1).ToString(), PlcItemTypeDesc.D))
{
2022-03-18 19:06:26 +08:00
KryptonMessageBox.Show(this.GetInfoText("切换出料运行方向成功!", "SwitchDirectionSuccessInfo"));
2021-06-05 14:17:30 +08:00
this.Close();
}
else
{
2022-03-18 19:06:26 +08:00
KryptonMessageBox.Show(this.GetInfoText("切换出料运行方向失败!", "SwitchDirectionFailInfo"));
2021-06-05 14:17:30 +08:00
}
}
catch (Exception ex)
{
2022-03-18 19:06:26 +08:00
KryptonMessageBox.Show(this.GetInfoText("切换出料运行方向的函数发生异常", "SwitchRunDirectionExp") + $":【{ex.Message}】!");
2021-06-05 14:17:30 +08:00
}
}
private void btnEdit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}