using Gs.DevApp.Entity;
|
using Gs.DevApp.ToolBox;
|
using MES.Service.Modes;
|
using Newtonsoft.Json;
|
using System;
|
using System.Data;
|
|
|
namespace Gs.DevApp.DevFrm.QC
|
{
|
public partial class Frm_MesDefectCodeShow : DevExpress.XtraEditors.XtraForm
|
{
|
string strGuid = "";
|
string strUpGuid = "";
|
string _webServiceName = "MesDefectCodeManager/";
|
public Frm_MesDefectCodeShow(string _strGuid, string _strUpGuid)
|
{
|
InitializeComponent();
|
getSelect();
|
this.strGuid = _strGuid;
|
this.strUpGuid = _strUpGuid;
|
|
//这是更新
|
if (!string.IsNullOrEmpty(this.strGuid))
|
{
|
getMode(strGuid);
|
this.Text = "更新【" + txt_defectName.Text + "】";
|
txt_sType.Enabled = false;
|
return;
|
}
|
//这是增加子项
|
if (!string.IsNullOrEmpty(strUpGuid))
|
{
|
getMode(strUpGuid);
|
this.Text = "增加【" + txt_defectName.Text + "】的子项目";
|
txt_sType.Enabled = false;
|
txt_defectCode.Text = "";
|
txt_defectName.Text = "";
|
return;
|
}
|
|
this.Text = "增加新项";
|
|
}
|
|
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(strGuid.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());
|
}
|
}
|
|
private void getMode(string strGuid)
|
{
|
var _obj = new
|
{
|
guid = strGuid,//主建
|
};
|
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);
|
|
}
|
else
|
ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
|
}
|
catch (Exception ex)
|
{
|
ToolBox.MsgHelper.Warning("提示:" + ex.Message);
|
}
|
}
|
}
|
}
|