using Gs.DevApp.Entity;
|
using Gs.DevApp.ToolBox;
|
using MES.Service.Modes;
|
using Newtonsoft.Json;
|
using System;
|
using System.Collections.Generic;
|
using System.Data;
|
|
|
namespace Gs.DevApp.DevFrm.QC
|
{
|
public partial class Frm_MesDefectCodeShow : DevExpress.XtraEditors.XtraForm
|
{
|
string lbGuid = "";
|
string strTitle = "";
|
string strUpGuid = "";
|
string _webServiceName = "MesDefectCodeManager/";
|
public Frm_MesDefectCodeShow(string _lbGuid, string _strTitle, string _strUpGuid)
|
{
|
InitializeComponent();
|
getSelect();
|
this.lbGuid = _lbGuid;
|
this.strTitle = _strTitle;
|
this.strUpGuid = _strUpGuid;
|
if (string.IsNullOrEmpty(lbGuid))
|
{
|
this.Text = strTitle;
|
}
|
else
|
{
|
this.Text = "更新【" + strTitle + "】";
|
var _obj = new
|
{
|
guid = lbGuid,//主建
|
};
|
try
|
{
|
string strJson = UtilityHelper.HttpPost("", _webServiceName + "GetModel", JsonConvert.SerializeObject(_obj));
|
ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
|
if (_rtn.rtnCode > 0)
|
{
|
dynamic dy = _rtn.rtnData;
|
UtilityHelper.SetValueByObj(this.layoutMx1.Controls, dy, true);
|
txt_sType.Enabled = false;
|
}
|
else
|
ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
|
}
|
catch (Exception ex)
|
{
|
ToolBox.MsgHelper.Warning("提示:" + ex.Message);
|
}
|
}
|
}
|
|
private void btnQuery_Click(object sender, EventArgs e)
|
{
|
if (string.IsNullOrEmpty(txt_defectCode.Text))
|
{
|
Gs.DevApp.ToolBox.MsgHelper.ShowInformation("编号不能为空!");
|
txt_defectCode.Focus();
|
return;
|
}
|
if (txt_sType.SelectedIndex <= 0)
|
{
|
Gs.DevApp.ToolBox.MsgHelper.ShowInformation("类型不能为空!");
|
txt_sType.Focus();
|
return;
|
}
|
if (string.IsNullOrEmpty(txt_defectName.Text))
|
{
|
Gs.DevApp.ToolBox.MsgHelper.ShowInformation("名称不能为空!");
|
txt_defectName.Focus();
|
return;
|
}
|
var _obj = new MesDefectCode()
|
{
|
Guid = UtilityHelper.ToGuid(lbGuid.Trim()),
|
DefectCode = txt_defectCode.Text.Trim(),
|
SType = txt_sType.Text.Trim(),
|
DefectName = txt_defectName.Text.Trim(),
|
Pid= UtilityHelper.ToGuid(strUpGuid.Trim()),
|
};
|
try
|
{
|
string strJson = UtilityHelper.HttpPost("", _webServiceName + "EditModel", JsonConvert.SerializeObject(_obj));
|
ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
|
ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
|
if (_rtn.rtnCode > 0)
|
{
|
UpdateParent?.Invoke(this, new UpdateParentEventArgs { StringSingle = "" });
|
Close();
|
}
|
}
|
catch (Exception ex)
|
{
|
ToolBox.MsgHelper.Warning("提示:" + ex.Message);
|
}
|
}
|
|
private void btnEsc_Click(object sender, EventArgs e)
|
{
|
this.Close();
|
}
|
|
/// <summary>
|
/// 回调事件
|
/// </summary>
|
public event EventHandler<UpdateParentEventArgs> UpdateParent;
|
|
|
private void getSelect() {
|
|
var _obj = new
|
{
|
|
};
|
var strReturn = UtilityHelper.HttpPost("", _webServiceName + "SelectCategory", JsonConvert.SerializeObject(_obj));
|
var dd = UtilityHelper.ReturnToList(strReturn);
|
var dt = dd.rtnData;
|
txt_sType.Properties.Items.Add("-请选择-");
|
txt_sType.SelectedIndex = 0;
|
foreach (DataRow dr in dt.Rows)
|
{
|
txt_sType.Properties.Items.Add(dr["typeMemo"].ToString());
|
}
|
}
|
}
|
}
|