using CompressorXN.Untils;
using CompressorXN_Service;
using System.Windows.Forms;
namespace CompressorXN
{
public partial class FrmCopyPara : Form
{
private static readonly ParaService _paraService = new ParaService();
public FrmCopyPara()
{
InitializeComponent();
BindDropdownHelper.BindProductType(lkup_SourceMachine);
BindDropdownHelper.BindProductType(lkup_TargetMachine);
}
///
/// 点击确认
///
///
///
private void btn_Confirm_Click(object sender, System.EventArgs e)
{
string sourceVal = lkup_SourceMachine.EditValue?.ToString();
string targetVal = lkup_TargetMachine.EditValue?.ToString();
if (string.IsNullOrEmpty(sourceVal))
{
new FrmDialog("请选择源机种!").ShowDialog();
return;
}
if (string.IsNullOrEmpty(targetVal))
{
new FrmDialog("请选择目标机种!").ShowDialog();
return;
}
if (!_paraService.CheckIsExistParaByProductTypeName(sourceVal))
{
new FrmDialog($"【{sourceVal}】机种不存在测试项!").ShowDialog();
return;
}
if (_paraService.CheckIsExistParaByProductTypeName(targetVal))
{
new FrmDialog($"【{targetVal}】机种已存在测试项!").ShowDialog();
return;
}
bool copyResult = _paraService.CopyPara(sourceVal, targetVal);
if (copyResult)
{
new FrmDialog("操作成功!").ShowDialog();
DialogResult = DialogResult.OK;
}
else
{
new FrmDialog("操作失败!").ShowDialog();
}
}
///
/// 点击取消
///
///
///
private void btn_Cancel_Click(object sender, System.EventArgs e)
{
DialogResult = DialogResult.OK;
}
}
}