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.ProduceManage; using QMAPP.FJC.Entity.Operation; using QMAPP.ServicesAgent; using QMAPP.WinForm.Common; using QMAPP.Entity; namespace QMAPP.WinForm.Forms.Operation { /// /// 模块编号:M12-1 /// 作 用:返修,作废 /// 作 者:王庆男 /// 编写日期:2015年06月08日 /// public partial class RepairForm : Form { Product product = new Product();//编辑保存实体 Main main = new Main(); MendRecorder recorder = new MendRecorder(); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); /// /// 新建 /// public RepairForm() { InitializeComponent(); } /// /// 新建 /// public RepairForm(string processCode) { recorder.CURRENTPROCESS = processCode; InitializeComponent(); } /// /// 编辑 /// /// public RepairForm(string pid,string productType,string processCode) { if (productType.Equals(EnumGeter.ProductType.benti.GetHashCode().ToString())) { main.PID = pid; } else { product.PID = pid; } recorder.CURRENTPROCESS = processCode; InitializeComponent(); } /// /// 窗体加载 /// /// /// private void Form_Load(object sender, EventArgs e) { #region 绑定下拉列表 BasicData basicData = new BasicData(); //返修类别 this.comPartStatus.DataSource = basicData.GetDictionaryList(EnumGeter.DictKind.PRODUCTSTATUS.ToString()); this.comPartStatus.DisplayMember = "VALUE"; this.comPartStatus.ValueMember = "KEY"; #endregion #region 加载编辑 //判断是否为编辑加载编辑数据 if (string.IsNullOrEmpty(product.PID) == false) { product = agent.InvokeServiceFunction(B9BasicService.ProductBLL_Get.ToString(), product); //窗口赋值 this.txtPartCode.Text = product.PRODUCTCODE; this.comPartStatus.SelectedValue = product.STATUS; } if (string.IsNullOrEmpty(main.PID) == false) { main = agent.InvokeServiceFunction
(B9IPCService.MainBLL_Get.ToString(), main); //窗口赋值 this.txtPartCode.Text = main.EPIDERMISCODE; this.comPartStatus.SelectedValue = main.STATUS; } #endregion } /// /// 窗体保存事件 /// /// /// private void tsbSave_Click(object sender, EventArgs e) { //窗体数据校验 string errorMessae = ErrorCheck(); if (errorMessae != "") { MessageBox.Show(errorMessae, Resource1.ConfirmTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string pid = ""; //获取零件信息 if (string.IsNullOrEmpty(product.PID) == false) { pid = product.PID; product.STATUS = comPartStatus.SelectedValue.ToString(); } if (string.IsNullOrEmpty(main.PID) == false) { pid = main.PID; main.STATUS = comPartStatus.SelectedValue.ToString(); } //添加返修记录 recorder.PPID = pid; recorder.PRODUCTCODE = product.PRODUCTCODE; recorder.PRODUCTTYPE = product.PRODUCTTYPE; recorder.PRODUCELINE = EnumGeter.PRODUCELINE.B9.ToString(); recorder.PRODUCESHIFTNAME = ClientContext.produceShift.PRODUCESHIFTNAME; recorder.PRODUCESHIFTTCODE = ClientContext.produceShift.PRODUCESHIFTTCODE; recorder.MENDREASON = this.txtReason.Text; recorder.MENDTYPE = this.comPartStatus.SelectedValue.ToString(); recorder.MENDRESULT = ""; #region 保存 DataResult result = new DataResult() ;//判断是否成功 if (string.IsNullOrEmpty(product.PID) == false) { result = agent.InvokeServiceFunction>(B9BasicService.ProductBLL_UpdateStatus.ToString(), product, recorder); } if (string.IsNullOrEmpty(main.PID) == false) { result = agent.InvokeServiceFunction>(B9IPCService.MainBLL_UpdateStatus.ToString(), main, recorder); } //保存成功 MessageBox.Show(result.Msg); if (result.IsSuccess) { this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } #endregion } /// /// 窗体关闭 /// /// /// private void tsbClose_Click(object sender, EventArgs e) { this.Close(); } /// ///错误检测 /// /// private string ErrorCheck() { #region 校验 string strMessage = ""; //物料号 if (this.txtPartCode.Text.Trim() == string.Empty) { strMessage += Resource1.ProductCodeNullValidate + "\r\n"; } //零件状态 if (this.comPartStatus.SelectedValue == null || this.comPartStatus.SelectedValue == string.Empty) { strMessage += Resource1.ProductStatusNullValidate + "\r\n"; } return strMessage; #endregion } } }