DHDHSoftware/DHSoftware/Views/AddCubicleControl.cs
liyaobang ed53c8e5db 1.三色灯提交
2.设置重命名时带出之前名称
2025-04-27 09:26:18 +08:00

71 lines
2.1 KiB
C#

using DH.Commons.Enums;
namespace DHSoftware.Views
{
public partial class AddCubicleControl : UserControl
{
private AntdUI.Window window;
public bool submit;
public string CubicleName;
public EnumDetectionType DetectionType;
public AddCubicleControl(AntdUI.Window _window,string TitleName)
{
this.window = _window;
InitializeComponent();
lbTitleName.Text = TitleName;
sltdetectionType.Items.Clear();
foreach (EnumDetectionType value in Enum.GetValues(typeof(EnumDetectionType)))
{
sltdetectionType.Items.Add(value.ToString());
}
// 绑定事件
BindEventHandler();
}
private void BindEventHandler()
{
button_ok.Click += Button_ok_Click;
button_cancel.Click += Button_cancel_Click;
Load += AddCubicleControl_Load;
}
private void AddCubicleControl_Load(object? sender, EventArgs e)
{
input_name.Text = CubicleName;
sltdetectionType.SelectedIndex =(int)DetectionType;
}
private void Button_cancel_Click(object sender, EventArgs e)
{
submit = false;
this.Dispose();
}
private void Button_ok_Click(object sender, EventArgs e)
{
input_name.Status = AntdUI.TType.None;
//检查输入内容
if (String.IsNullOrEmpty(input_name.Text))
{
input_name.Status = AntdUI.TType.Error;
AntdUI.Message.warn(window, "工位名称不能为空!", autoClose: 3);
return;
}
if (String.IsNullOrEmpty(sltdetectionType.Text))
{
input_name.Status = AntdUI.TType.Error;
AntdUI.Message.warn(window, "请选择检测类型!", autoClose: 3);
return;
}
CubicleName =input_name.Text;
DetectionType = (EnumDetectionType)sltdetectionType.SelectedIndex;
submit = true;
this.Dispose();
}
}
}