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

311 lines
11 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;
using QMAPP.MD.Entity;
using QMAPP.Entity;
using QMAPP.FJC.Entity;
namespace QMAPP.WinForm.Forms.Mend
{
/// <summary>
///
/// </summary>
public partial class DPLabelReplace : Form
{
QMAPP.ServicesAgent.ServiceAgent _agent = ClientContext.GetServiceAgent();
private Product _product;
/// <summary>
///
/// </summary>
public DPLabelReplace()
{
InitializeComponent();
}
private void btnSubmit_Click(object sender, EventArgs e)
{
if (txtFISCode.Enabled)
{
LoadProduct();
return;
}
if (txtNewFISCode.Enabled)
{
ReplaceFIS();
}
}
private void txtFISCodeLabel_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode != Keys.Enter)//如果输入的是回车键
{
return;
}
LoadProduct();
}
private void ReplaceFIS()
{
infolabel.ForeColor = Color.Red;
if (string.IsNullOrWhiteSpace(txtNewFISCode.Text.Trim()))
{
infolabel.Text = "请扫描新的门板FIS标签!";
txtNewFISCode.SelectAll();
txtNewFISCode.Focus();
return;
}
string newfiscode=txtNewFISCode.Text.Trim().ToUpper();
if (string.Equals(newfiscode, _product.PLAN_NO))
{
infolabel.Text = "请扫描新的门板FIS标签!";
txtNewFISCode.SelectAll();
txtNewFISCode.Focus();
return;
}
if (!(newfiscode.StartsWith("D01") || newfiscode.StartsWith("DP2")))
{
infolabel.Text = "输入条码格式不正确!";
txtNewFISCode.SelectAll();
txtNewFISCode.Focus();
return;
}
Product nproduct = _agent.InvokeServiceFunction<Product>("ProductBLL_GetProductByAssembleCode", newfiscode);
if (nproduct != null)
{
if (cbType.SelectedIndex == 0) //新FIS码替换 新条码应为未使用状态
{
infolabel.Text = string.Format("此FIS码已与产品“{0}”绑定,不可重复使用!", nproduct.PRODUCTCODE);
txtNewFISCode.SelectAll();
txtNewFISCode.Focus();
return;
}
}
else
{
if (cbType.SelectedIndex == 1) //备件替换 备件信息需要存在
{
infolabel.Text = string.Format("未查询到备件信息!", nproduct.PRODUCTCODE);
txtNewFISCode.SelectAll();
txtNewFISCode.Focus();
return;
}
}
var oplan = _agent.InvokeServiceFunction<DataResult<FJC.Entity.FIS.OrderPlan>>("OrderPlanBLL_GetPlanWithOrderNo", _product.PLAN_NO,false);
if (!oplan.IsSuccess)
{
infolabel.Text = oplan.Ex.Message;
txtNewFISCode.SelectAll();
txtNewFISCode.Focus();
return;
}
var nplan = _agent.InvokeServiceFunction<DataResult<FJC.Entity.FIS.OrderPlan>>("OrderPlanBLL_GetPlanWithOrderNo", newfiscode,false);
if (!nplan.IsSuccess)
{
infolabel.Text = nplan.Ex.Message;
txtNewFISCode.SelectAll();
txtNewFISCode.Focus();
return;
}
if (cbType.SelectedIndex == 0) //新FIS码替换必须保证与原FIS码计划物料号一致
{
List<PbomItem> SubItems = _agent.InvokeServiceFunction<List<PbomItem>>("PbomBLL_GetSubItem", nplan.Result.MATERIAL_CODE);
if (!SubItems.Exists(p => p.MATERIAL_CODE == _product.MATERIAL_CODE))
{
infolabel.Text = "原FIS码产品物料号与新FIS码物料号不匹配!";
txtNewFISCode.SelectAll();
txtNewFISCode.Focus();
return;
}
}
else if (cbType.SelectedIndex == 1)
{
if (!string.Equals(oplan.Result.MATERIAL_CODE, nplan.Result.MATERIAL_CODE))
{
infolabel.Text = "原件FIS码产品物料号与备件FIS码物料号不匹配!";
txtNewFISCode.SelectAll();
txtNewFISCode.Focus();
return;
}
}
DataResult result=new DataResult();
if (cbType.SelectedIndex == 0)
{
result = _agent.InvokeServiceFunction<DataResult>("MainCodeChangeBLL_ReplacePlanNo", _product, newfiscode);
}
else if (cbType.SelectedIndex == 1)
{
result = _agent.InvokeServiceFunction<DataResult>("MainCodeChangeBLL_ExchangePlanNo", _product, nproduct);
}
if (result.IsSuccess)
{
txtNewFIS.Text = newfiscode;
infolabel.Text = "替换成功";
infolabel.ForeColor = Color.Black;
txtFISCode.Enabled = true;
txtFISCode.SelectAll();
txtFISCode.Focus();
txtNewFISCode.Text = "";
txtNewFISCode.Enabled = false;
cbType.Enabled = true;
}
else
{
infolabel.Text = result.Msg;
infolabel.ForeColor = Color.Red;
txtNewFISCode.SelectAll();
txtNewFISCode.Focus();
return;
}
}
private void LoadProduct()
{
infolabel.ForeColor = Color.Red;
txtNewFIS.Text = "";
txtMaterialCode.Text = "";
txtMaterialName.Text = "";
txtOldFIS.Text = "";
txtMaterialCode.Text = "";
infolabel.Text = "";
txtProductCode.Text = "";
if (string.IsNullOrWhiteSpace(txtFISCode.Text.Trim()))
{
infolabel.Text = "请扫描门板FIS标签!";
txtFISCode.SelectAll();
txtFISCode.Focus();
return;
}
//1.判断扫描条形码是否存在
string Code = txtFISCode.Text.Trim().ToUpper();
Product product = _agent.InvokeServiceFunction<Product>("ProductBLL_GetProductByAssembleCode",Code);
if (product == null)
{
infolabel.Text = "未能查询到FIS码绑定的产品信息!";
txtFISCode.SelectAll();
txtFISCode.Focus();
return;
}
if (string.IsNullOrWhiteSpace(product.PLAN_NO))
{
infolabel.Text = "此产品未绑定FIS码!";
txtFISCode.SelectAll();
txtFISCode.Focus();
return;
}
if (product.OUTFLAG != "0")
{
infolabel.Text = "此产品码已出库!";
txtFISCode.SelectAll();
txtFISCode.Focus();
return;
}
if (product.STATUS != "0")
{
infolabel.Text = "此产品为不合格状态!";
txtFISCode.SelectAll();
txtFISCode.Focus();
return;
}
var mcresult = _agent.InvokeServiceFunction<DataResult<MaterialClass>>("MaterialClassBLL_Get", new MaterialClass { MATERIAL_TYPE_CODE = product.MATERIAL_TYPE });
var mc = mcresult.IsSuccess ? mcresult.Result : new MaterialClass { };
var mresult = _agent.InvokeServiceFunction<DataResult<Material>>("MaterialBLL_Get", new Material { MATERIAL_CODE = product.MATERIAL_CODE });
var m = mresult.IsSuccess ? mresult.Result : new Material { };
//if(cbType.SelectedIndex==0)
//if (!string.Equals(mc.MATERIAL_ATTRIBUTE, "2"))
//{
// infolabel.Text = "输入的产品码不是总成件!";
// txtFISCode.SelectAll();
// txtFISCode.Focus();
// return;
//}
//FJC.Entity.ProductIn.ProductIn inrecord = _agent.InvokeServiceFunction<FJC.Entity.ProductIn.ProductIn>("ProductInBLL_GetInRecord", product.PRODUCTCODE);
//if (inrecord == null)
//{
// infolabel.Text = "无此产品的退返入库记录!";
// txtPlanLabel.SelectAll();
// txtPlanLabel.Focus();
// return;
//}
_product = product;
txtNewFIS.Text = "";
txtMaterialCode.Text = product.MATERIAL_CODE;
txtMaterialName.Text = m.MATERIAL_NAME;//; product.MATERIAL_NAME;
txtOldFIS.Text = product.PLAN_NO;
txtProductCode.Text = product.PRODUCTCODE;
txtFISCode.Text = "";
txtFISCode.SelectAll();
//txtFISCode.Focus();
txtFISCode.Enabled = false;
txtNewFISCode.Enabled = true;
cbType.Enabled = false;
txtNewFISCode.SelectAll();
txtNewFISCode.Focus();
}
private void btnReset_Click(object sender, EventArgs e)
{
txtProductCode.Text = "";
txtNewFIS.Text = "";
txtMaterialCode.Text = "";
txtMaterialName.Text = "";
txtOldFIS.Text = "";
txtMaterialCode.Text = "";
infolabel.Text = "";
txtFISCode.Enabled = true;
txtFISCode.SelectAll();
txtFISCode.Focus();
txtNewFISCode.Text = "";
txtNewFISCode.Enabled = false;
cbType.Enabled = true;
}
private void txtNewFISCode_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode != Keys.Enter)//如果输入的是回车键
{
return;
}
ReplaceFIS();
}
private void DPLabelReplace_Load(object sender, EventArgs e)
{
cbType.SelectedIndex = 0;
}
private void cbType_SelectedIndexChanged(object sender, EventArgs e)
{
if (cbType.SelectedIndex == 0)
{
lblOriginalTitle.Text = "原门板FIS码:";
lblNewTitle.Text = "新门板FIS码:";
}
else if (cbType.SelectedIndex == 1)
{
lblOriginalTitle.Text = "原件门板FIS码:";
lblNewTitle.Text = "备件门板FIS码:";
}
}
}
}