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; namespace QMAPP.WinForm.Forms.Mend { /// /// 模块编号:M15-2 /// 作 用:返修件登记 /// 作 者:王丹丹 /// 编写日期:2015年07月7日 /// public partial class MendRecorderCreateForm : Form { MendRecorder recorder = new MendRecorder();//查询条件 Product product = new Product(); //是否查询(0:未查询,1:已查询) int searchStatus = 0; #region 编辑 /// /// 编辑 /// public MendRecorderCreateForm() { //recorder.PID = pid; //model.PID = pid; InitializeComponent(); } #endregion #region 窗体数据初始化 /// /// 窗体数据初始化 /// /// /// private void Form_Load(object sender, EventArgs e) { //绑定下拉列表 BasicData basicData = new BasicData(); //设置焦点 this.ActiveControl = this.txtProductCode; this.txtProductCode.Focus(); //加载登记状态下拉列表 this.comRegisterStatus.DataSource = basicData.GetDictionaryList("REGISTERSTATUS"); this.comRegisterStatus.DisplayMember = "value"; this.comRegisterStatus.ValueMember = "key"; } #endregion #region 事件 #region 保存事件 /// /// 保存事件 /// /// /// private void tsbSave_Click(object sender, EventArgs e) { //窗体数据校验及设置保存数据 bool isExist = SetSaveModel(); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); DataResult result = new DataResult(); Product product = new Product(); //校验成功 if (isExist) { try { if (!string.IsNullOrEmpty(recorder.PID)) { //更新返修记录 result = agent.InvokeServiceFunction>(B9IPCService.MendRecorderBLL_UpdateMendRecorder.ToString(), recorder); } else { //插入返修记录 result = agent.InvokeServiceFunction>(B9IPCService.MendRecorderBLL_InsertMendRecorder.ToString(), recorder); } //更新零件信息 product.STATUS = this.comRegisterStatus.SelectedValue.ToString(); product.PID = recorder.PPID; result = agent.InvokeServiceFunction>(B9BasicService.ProductBLL_MendUpdate.ToString(), product); //保存成功 MessageBox.Show(result.Msg); if (result.IsSuccess) { searchStatus = 0; this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } } catch (Exception ex) { throw ex; } } } #endregion #region 窗体关闭事件 /// /// 窗体关闭事件 /// /// /// private void tsbClose_Click(object sender, EventArgs e) { this.Close(); } #endregion #region 查询事件 /// /// 查询事件 /// /// /// private void tsbSearch_Click(object sender, EventArgs e) { bool isExist=SetSearchModel(); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); DictManageBLL dictProductTypeBll = new DictManageBLL(DictKind.PRODUCTTYPE); DictManageBLL dictProcessTypeBll = new DictManageBLL(DictKind.PROCESSTYPE); DictManageBLL dictProductStatusBll = new DictManageBLL(DictKind.PRODUCTSTATUS); recorder.PRODUCTCODETXT = this.txtProductCode.Text.Trim(); recorder.PRODUCTCODE = ""; //校验成功 if (isExist) { try { //获取维修记录 recorder = agent.InvokeServiceFunction(B9IPCService.MendRecorderBLL_GetMendRecorderInfo.ToString(), recorder); //获取零件信息 product = agent.InvokeServiceFunction(B9BasicService.ProductBLL_GetProductInfo.ToString(), product); if (product == null) { MessageBox.Show(Resource1.NotProductCode, Resource1.NotProductCode, MessageBoxButtons.OK, MessageBoxIcon.Warning); Clear(); this.txtProductCode.Focus(); } else { //如果返修记录不存在 if (recorder == null) { #region 转换零件类别、工序类别、产品状态显示类型 //零件类别 product.PRODUCTTYPETXT = dictProductTypeBll.GetDictValue(product.PRODUCTTYPE); //工序类别 product.CURRENTPROCESSTXT = dictProcessTypeBll.GetDictValue(product.CURRENTPROCESS); //产品状态 product.STATUSTXT = dictProductStatusBll.GetDictValue(product.STATUS); #endregion //窗口只读文本框赋值 this.txtProductType.Text = product.PRODUCTTYPETXT; this.txtProcessType.Text = product.CURRENTPROCESSTXT; this.txtProductStatus.Text = product.STATUSTXT; searchStatus = 1; } //返修记录存在 else { //如果登记状态为返修中,不能进行返修登记 if (recorder.REGISTERSTATUS == EnumGeter.REGISTERSTATUS.mendIng.GetHashCode().ToString()) { MessageBox.Show(Resource1.ProductCodeMendIng, Resource1.ProductCodeMendIng, MessageBoxButtons.OK, MessageBoxIcon.Warning); recorder.PID = ""; searchStatus = 0; } else { #region 转换零件类别、工序类别、产品状态显示类型 //零件类别 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.REGISTERSTATUS)) { this.comRegisterStatus.SelectedValue = recorder.REGISTERSTATUS; } searchStatus = 1; } } } } catch (Exception ex) { throw ex; } } } #endregion #endregion #region 校验 #region 设置查询条件并校验 /// /// 设置查询条件 /// private bool SetSearchModel() { //数据校验 recorder = new MendRecorder(); product = new Product(); //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(); return false; } //条码 recorder.PRODUCTCODE = this.txtProductCode.Text.Trim(); product.PRODUCTCODE = this.txtProductCode.Text.Trim(); return true; } #endregion #region 设置保存内容,并校验 /// /// 设置查询条件 /// private bool SetSaveModel() { if (recorder == null) { recorder = new MendRecorder(); } //数据校验 if (searchStatus == 0) { MessageBox.Show(Resource1.ProductCodeValidate, Resource1.ProductCodeValidate, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.txtProductCode.Focus(); return false; } //登记状态 if (this.comRegisterStatus.SelectedValue != null && string.IsNullOrEmpty(this.comRegisterStatus.SelectedValue.ToString().Trim()) == false) { recorder.REGISTERSTATUS = this.comRegisterStatus.SelectedValue.ToString().Trim(); recorder.PRODUCTCODE = product.PRODUCTCODE; recorder.PRODUCTTYPE = product.PRODUCTTYPE; recorder.CURRENTPROCESS = product.CURRENTPROCESS; recorder.STATUS = product.STATUS; recorder.PRODUCELINE = EnumGeter.PRODUCELINE.B9.ToString(); recorder.PPID = product.PID; recorder.PRODUCESHIFTNAME = product.PRODUCESHIFTNAME; recorder.PRODUCESHIFTTCODE = product.PRODUCESHIFTTCODE; recorder.REGISTERSTATUS = this.comRegisterStatus.SelectedValue.ToString(); } else { MessageBox.Show(Resource1.RegisterStatusValidate, Resource1.RegisterStatusValidate, MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } return true; } #endregion #endregion #region 清空窗口数据 private void Clear() { this.txtProductCode.Text = ""; this.txtProcessType.Text = ""; this.txtProductType.Text = ""; this.txtProductStatus.Text = ""; this.comRegisterStatus.SelectedValue = ""; } #endregion } }