天津投入产出系统后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

370 lines
15 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using QM.Common;
using QMAPP.FJC.Entity;
using QMAPP.FJC.Entity.Basic;
using QMAPP.FJC.Entity.Injection;
using QMAPP.ServicesAgent;
using QMAPP.WinForm.Common;
using QMAPP.Entity;
using QMAPP.FJC.Entity.ProduceManage;
using QMAPP.FJC.BLL.Dict;
using QMAPP.FJC.Entity.Produce;
using QMAPP.FJC.BLL.ProduceManage;
namespace QMAPP.WinForm.Forms.Mend
{
/// <summary>
/// 模块编号:M15-3
/// 作 用:返修完成
/// 作 者:王丹丹
/// 编写日期:2015年07月7日
///</summary>
public partial class MendRecorderFinishForm : Form
{
MendRecorder recorder = new MendRecorder();//查询条件
MendRecorder model = new MendRecorder();
//是否查询(0:未查询,1:已查询)
int searchStatus = 1;
#region 编辑
/// <summary>
/// 编辑
/// </summary>
/// <param name="pid"></param>
public MendRecorderFinishForm(string pid)
{
recorder.PID = pid;
model.PID = pid;
InitializeComponent();
}
#endregion
#region 窗体数据初始化
/// <summary>
/// 窗体数据初始化
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Form_Load(object sender, EventArgs e)
{
#region 绑定下拉列表
BasicData basicData = new BasicData();
//设置焦点
this.ActiveControl = this.txtProductCode;
this.txtProductCode.Focus();
//加载返修原因下拉列表
this.comMendResult.DataSource = basicData.GetDictionaryList("REGISTERSTATUS");
this.comMendResult.DisplayMember = "value";
this.comMendResult.ValueMember = "key";
//返修原因
this.comMendReason.DataSource = basicData.GetDictionaryList("MENDREASON");
this.comMendReason.DisplayMember = "value";
this.comMendReason.ValueMember = "key";
//返修方式
this.comMendType.DataSource = basicData.GetDictionaryList("MENDTYPE");
this.comMendType.DisplayMember = "value";
this.comMendType.ValueMember = "key";
//返修结果
this.comMendResult.DataSource = basicData.GetDictionaryList("MENDRESULT");
this.comMendResult.DisplayMember = "value";
this.comMendResult.ValueMember = "key";
#endregion
#region 获取数据
//查询条码信息
if (string.IsNullOrEmpty(recorder.PID) == false)
{
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
recorder = agent.InvokeServiceFunction<MendRecorder>(B9IPCService.MendRecorderBLL_GetMendRecorderInfo.ToString(), recorder);
//不是返修中的零件,不能进行返修完成操作
if (recorder.REGISTERSTATUS != EnumGeter.REGISTERSTATUS.mendIng.GetHashCode().ToString())
{
MessageBox.Show(Resource1.ProductCodeNotMendIng, Resource1.ProductCodeNotMendIng, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
#region 转换零件类别、工序类别、产品状态显示类型
DictManageBLL dictProductTypeBll = new DictManageBLL(DictKind.PRODUCTTYPE);
DictManageBLL dictProcessTypeBll = new DictManageBLL(DictKind.PROCESSTYPE);
DictManageBLL dictProductStatusBll = new DictManageBLL(DictKind.PRODUCTSTATUS);
//零件类别
recorder.PRODUCTTYPETXT = dictProductTypeBll.GetDictValue(recorder.PRODUCTTYPE);
//工序类别
recorder.CURRENTPROCESSTXT = dictProcessTypeBll.GetDictValue(recorder.CURRENTPROCESS);
//产品状态
recorder.STATUSTXT = dictProductStatusBll.GetDictValue(recorder.STATUS);
#endregion
//窗口内数据赋值
this.txtProductCode.Text = recorder.PRODUCTCODE;
this.txtProductType.Text = recorder.PRODUCTTYPETXT;
this.txtProcessType.Text = recorder.CURRENTPROCESSTXT;
this.txtProductStatus.Text = recorder.STATUSTXT;
if (!string.IsNullOrEmpty(recorder.MENDRESULT))
{
this.comMendResult.SelectedValue = recorder.MENDRESULT;
}
if (!string.IsNullOrEmpty(recorder.MENDREASON))
{
this.comMendReason.SelectedValue = recorder.MENDREASON;
}
if (!string.IsNullOrEmpty(recorder.MENDTYPE))
{
this.comMendType.SelectedValue = recorder.MENDTYPE;
}
searchStatus = 1;
}
}
#endregion
}
#endregion
#region 事件
#region 保存事件
/// <summary>
/// 保存事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tsbSave_Click(object sender, EventArgs e)
{
Product product = new Product();
//窗体数据校验及设置保存数据
bool isExist=SetSaveModel();
//校验成功
if (isExist)
{
try
{
#region 保存
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
DataResult<int> result;//判断是否成功
//MendRecorderBLL frBll = new MendRecorderBLL();
//frBll.LoginUser =
//更新返修记录
recorder.REGISTERSTATUS = this.comMendResult.SelectedValue.ToString();
result = agent.InvokeServiceFunction<DataResult<int>>(B9IPCService.MendRecorderBLL_UpdateMendRecorder.ToString(), recorder);
//更新零件信息
product.STATUS = this.comMendResult.SelectedValue.ToString();
product.PID = recorder.PPID;
result = agent.InvokeServiceFunction<DataResult<int>>(B9BasicService.ProductBLL_MendUpdate.ToString(), product);
//保存成功
MessageBox.Show(result.Msg);
if (result.IsSuccess)
{
searchStatus = 0;
//清空窗口上数据
Clear();
this.DialogResult = System.Windows.Forms.DialogResult.OK;
this.Close();
}
#endregion
}
catch (Exception ex)
{
throw ex;
}
}
}
#endregion
#region 窗体关闭事件
/// <summary>
/// 窗体关闭事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tsbClose_Click(object sender, EventArgs e)
{
this.Close();
}
#endregion
#region 查询事件
/// <summary>
/// 查询事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tsbSearch_Click(object sender, EventArgs e)
{
//窗体数据校验及设置保存数据
bool isExist=SetSearchModel();
//校验成功
if (isExist)
{
try
{
//查询条码信息
if (string.IsNullOrEmpty(recorder.PID) == false)
{
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
recorder.PRODUCTCODETXT = this.txtProductCode.Text.Trim();
recorder.PRODUCTCODE = "";
recorder = agent.InvokeServiceFunction<MendRecorder>(B9IPCService.MendRecorderBLL_GetMendRecorderInfo.ToString(), recorder);
if (recorder == null)
{
MessageBox.Show(Resource1.NotProductCode, Resource1.NotProductCode, MessageBoxButtons.OK, MessageBoxIcon.Warning);
Clear();
this.txtProductCode.Focus();
model.PID = "";
recorder.PID = "";
searchStatus = 0;
}
else
{
//不是返修中的零件,不能进行返修完成操作
if (recorder.REGISTERSTATUS != EnumGeter.REGISTERSTATUS.mendIng.GetHashCode().ToString())
{
MessageBox.Show(Resource1.ProductCodeNotMendIng, Resource1.ProductCodeNotMendIng, MessageBoxButtons.OK, MessageBoxIcon.Warning);
searchStatus = 0;
}
else
{
#region 转换零件类别、工序类别、产品状态显示类型
DictManageBLL dictProductTypeBll = new DictManageBLL(DictKind.PRODUCTTYPE);
DictManageBLL dictProcessTypeBll = new DictManageBLL(DictKind.PROCESSTYPE);
DictManageBLL dictProductStatusBll = new DictManageBLL(DictKind.PRODUCTSTATUS);
//零件类别
recorder.PRODUCTTYPETXT = dictProductTypeBll.GetDictValue(recorder.PRODUCTTYPE);
//工序类别
recorder.CURRENTPROCESSTXT = dictProcessTypeBll.GetDictValue(recorder.CURRENTPROCESS);
//产品状态
recorder.STATUSTXT = dictProductStatusBll.GetDictValue(recorder.STATUS);
#endregion
//窗口内数据赋值
this.txtProductType.Text = recorder.PRODUCTTYPETXT;
this.txtProcessType.Text = recorder.CURRENTPROCESSTXT;
this.txtProductStatus.Text = recorder.STATUSTXT;
if (!string.IsNullOrEmpty(recorder.MENDRESULT))
{
this.comMendResult.SelectedValue = recorder.MENDRESULT;
}
if (!string.IsNullOrEmpty(recorder.MENDREASON))
{
this.comMendReason.SelectedValue = recorder.MENDREASON;
}
if (!string.IsNullOrEmpty(recorder.MENDTYPE))
{
this.comMendType.SelectedValue = recorder.MENDTYPE;
}
searchStatus = 1;
}
}
}
}
catch (Exception ex)
{
throw ex;
}
}
}
#endregion
#endregion
#region 校验
#region 设置查询条件并校验
/// <summary>
/// 设置查询条件
/// </summary>
private bool SetSearchModel()
{
//数据校验
recorder = new MendRecorder();
recorder.PID = model.PID;
//校验条码不能为空
if (string.IsNullOrEmpty(this.txtProductCode.Text.Trim()) == true){
MessageBox.Show(Resource1.ProductCodeNullValidate, Resource1.ProductCodeNullValidate, MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.txtProductCode.Focus();
searchStatus = 0;
return false;
}
recorder.PRODUCTCODE = this.txtProductCode.Text.Trim();
return true;
}
#endregion
#region 设置保存内容,并校验
/// <summary>
/// 设置查询条件
/// </summary>
private bool SetSaveModel()
{
//数据校验
string strMessage = "";
if (searchStatus == 0)
{
MessageBox.Show(Resource1.ProductCodeValidate, Resource1.ProductCodeValidate, MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.txtProductCode.Focus();
return false;
}
//返修结果
if (this.comMendResult.SelectedValue == null || string.IsNullOrEmpty(this.comMendResult.SelectedValue.ToString().Trim()) == true)
{
strMessage += Resource1.MendResultValidate + "\r\n";
}
//返修原因
if (this.comMendReason.SelectedValue == null || string.IsNullOrEmpty(this.comMendReason.SelectedValue.ToString().Trim()) == true)
{
strMessage += Resource1.MendReasonValidate + "\r\n";
}
//返修方式
if (this.comMendType.SelectedValue == null || string.IsNullOrEmpty(this.comMendType.SelectedValue.ToString().Trim()) == true)
{
strMessage += Resource1.MendTypeValidate + "\r\n";
}
if (strMessage != "")
{
MessageBox.Show(strMessage, Resource1.ConfirmTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.txtProductCode.Focus();
searchStatus = 0;
return false;
}
//校验成功后赋值
//返修结果
recorder.MENDRESULT = this.comMendResult.SelectedValue.ToString().Trim();
//返修原因
recorder.MENDREASON = this.comMendReason.SelectedValue.ToString().Trim();
//返修方式
recorder.MENDTYPE = this.comMendType.SelectedValue.ToString().Trim();
return true;
}
#endregion
#endregion
#region 清空窗口数据
private void Clear()
{
this.txtProductCode.Text = "";
this.txtProcessType.Text = "";
this.txtProductType.Text = "";
this.txtProductStatus.Text = "";
this.comMendResult.SelectedValue = "";
this.comMendReason.SelectedValue = "";
this.comMendType.SelectedValue = "";
}
#endregion
}
}