天津投入产出系统后端
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.

159 lines
5.3 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QMAPP.FJC.Entity.Operation;
using QMAPP.ServicesAgent;
namespace QMAPP.WinForm.Forms.Operation
{
public partial class frmInspectSkipping : Form
{
QMAPP.ServicesAgent.ServiceAgent _agent = ClientContext.GetServiceAgent();
private FJC.Entity.View.PlanLabel _CurrentLabel;
public frmInspectSkipping()
{
InitializeComponent();
}
private void txtLabelCode_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode != Keys.Enter)//如果输入的是回车键
{
return;
}
LoadProduct();
}
private void LoadProduct()
{
txtPlanNo.Text = "";
txtMaterialCode.Text = "";
txtMaterialName.Text = "";
txtSEQ.Text = "";
_CurrentLabel = null;
txtMaterialCode.Text = "";
if (string.IsNullOrWhiteSpace(txtLabelCode.Text.Trim()))
{
lblMessage.Text = "请扫描门板计划标签!";
txtLabelCode.SelectAll();
txtLabelCode.Focus();
return;
}
var scode = txtLabelCode.Text.Trim().ToUpper();
if (!System.Text.RegularExpressions.Regex.IsMatch(scode, "^DP\\w+(-\\w+)?-DF[LR][FR]\\w+$"))//扫描输入为门板计划标签
{
lblMessage.Text = "格式不正确!请扫描门板计划标签。";
txtLabelCode.SelectAll();
txtLabelCode.Focus();
return;
}
var planno = scode.Substring(0, scode.IndexOf('-'));
scode = scode.Substring(scode.LastIndexOf('-') + 1);
Product product = _agent.InvokeServiceFunction<Product>(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetProductByAssembleCode.ToString(), scode);
if (product == null)
{
lblMessage.Text = "查找产品信息失败!";
txtLabelCode.SelectAll();
txtLabelCode.Focus();
return;
}
if (product.MATERIAL_TYPE.StartsWith("DP_ASSY_"))
{
lblMessage.Text = "此产品已完成终检!无需重复终检。";
txtLabelCode.SelectAll();
txtLabelCode.Focus();
return;
}
if (string.IsNullOrWhiteSpace(product.PLAN_ID))
{
lblMessage.Text = "无法找到与此零件绑定的计划!";
txtLabelCode.SelectAll();
txtLabelCode.Focus();
return;
}
var labeldata = _agent.InvokeServiceFunction<FJC.Entity.View.PlanLabel>(B9IPCService.WorkOrderBLL_GetPlanLabelBindProdut.ToString(), product);
if (labeldata == null)
{
lblMessage.Text = "无法找到与此零件绑定的计划!";
txtLabelCode.SelectAll();
txtLabelCode.Focus();
return;
}
if (!string.Equals(labeldata.PlanNo, planno))
{
lblMessage.Text = "计划标签与产品状态不符!";
txtLabelCode.SelectAll();
txtLabelCode.Focus();
return;
}
labeldata.SN = product.PRODUCTCODE;
txtPlanNo.Text = labeldata.PlanNo;
//txtLabelCode.Text = labeldata.SN;
txtMaterialCode.Text = labeldata.PN;
txtMaterialName.Text = labeldata.ProdName;
txtSEQ.Text = labeldata.SEQ;
_CurrentLabel = labeldata;
}
private void btnInspect_Click(object sender, EventArgs e)
{
try
{
if (_CurrentLabel == null)
{
lblMessage.Text = "请扫描门板计划标签!";
txtLabelCode.SelectAll();
txtLabelCode.Focus();
return;
}
Product result = _agent.InvokeServiceFunction<Product>(B9BasicService.ProductBLL_CreateAssy.ToString(), _CurrentLabel.SN, txtMaterialCode.Text);
if (result == null)
{
lblMessage.Text = "请扫描门板计划标签!";
txtLabelCode.SelectAll();
txtLabelCode.Focus();
return;
}
_CurrentLabel = null;
txtLabelCode.Text = "";
lblMessage.Text = "终检完成";
txtMaterialCode.Text = txtMaterialName.Text = txtPlanNo.Text = txtSEQ.Text = "";
txtLabelCode.SelectAll();
txtLabelCode.Focus();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
}
}
private void btnSubmit_Click(object sender, EventArgs e)
{
LoadProduct();
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
}
}