|
|
|
|
using DevExpress.XtraEditors;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Web.UI.WebControls;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using ZJ_BYD.Common;
|
|
|
|
|
using ZJ_BYD.DB;
|
|
|
|
|
using ZJ_BYD.Model;
|
|
|
|
|
|
|
|
|
|
namespace ZJ_BYD.UserControls.TestItem
|
|
|
|
|
{
|
|
|
|
|
public partial class EditTestItem : XtraForm
|
|
|
|
|
{
|
|
|
|
|
public EditTestItem(int id = 0)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
BindCombox.BindMachineType(cmbMachineType);
|
|
|
|
|
if (id > 0)
|
|
|
|
|
{
|
|
|
|
|
GetTestItemById(id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void GetTestItemById(int id)
|
|
|
|
|
{
|
|
|
|
|
var model = TestItemHelper.QueryTestItemVM().First(a => a.Id == id);
|
|
|
|
|
if (model != null)
|
|
|
|
|
{
|
|
|
|
|
this.lblId.Text = model.Id.ToString();
|
|
|
|
|
this.txtPoint.Text = string.Format("{0}-{1}", model.PointCode, model.PointName);
|
|
|
|
|
this.txtVal.Text = model.Val;
|
|
|
|
|
cmbMachineType.SelectedItem = new ListItem { Text = model.MachineTypeName, Value = model.MachineTypeCode };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCancel_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnSave_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
int row;
|
|
|
|
|
var t_TestItem = new T_TestItem();
|
|
|
|
|
var selectedMachineType = cmbMachineType.SelectedItem as ListItem;
|
|
|
|
|
t_TestItem.Id = int.Parse(lblId.Text);
|
|
|
|
|
t_TestItem.IpcId = Program.CurrentIpcId;
|
|
|
|
|
t_TestItem.LineCode = Program.CurrentLineCode;
|
|
|
|
|
t_TestItem.StationCode = Program.ActiveStatinCode;
|
|
|
|
|
t_TestItem.MachineTypeCode = selectedMachineType.Value;
|
|
|
|
|
t_TestItem.Val = txtVal.Text.Trim();
|
|
|
|
|
t_TestItem.IsUsed = ckIsUsed.Checked;
|
|
|
|
|
t_TestItem.UpdatedBy = CurrentUser.UserName;
|
|
|
|
|
t_TestItem.UpdatedTime = DateTime.Now;
|
|
|
|
|
splashScreenManager1.ShowWaitForm();
|
|
|
|
|
if (t_TestItem.IsUsed)
|
|
|
|
|
{
|
|
|
|
|
var usedModel = TestItemHelper.GetUsedTestItem(t_TestItem.Id);
|
|
|
|
|
if (usedModel != null)
|
|
|
|
|
{
|
|
|
|
|
XtraMessageBox.Show("已存在启用记录!");
|
|
|
|
|
splashScreenManager1.CloseWaitForm();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
row = TestItemHelper.UpdateTestItem(t_TestItem);
|
|
|
|
|
if (row <= 0)
|
|
|
|
|
{
|
|
|
|
|
XtraMessageBox.Show("操作失败!");
|
|
|
|
|
splashScreenManager1.CloseWaitForm();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
XtraMessageBox.Show("操作成功!");
|
|
|
|
|
DialogResult = DialogResult.OK;
|
|
|
|
|
splashScreenManager1.CloseWaitForm();
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|