using System; using System.Collections.Generic; using System.Data; using System.Drawing; using System.Windows.Forms; using QMAPP.FJC.Entity.Operation; using QMAPP.ServicesAgent; using QMAPP.FJC.Entity.BZD; using QMAPP.Entity; namespace QMAPP.WinForm.Forms.Operation { public partial class BZDRePrintForm : Form { //获取服务代理 QMAPP.ServicesAgent.ServiceAgent _agent = ClientContext.GetServiceAgent(); List _bzdConfig = null; Product _CurrentProduct = null; private OperationForm _parentForm; private OperationForm_316 operationForm_316; public BZDRePrintForm(OperationForm parentForm) { InitializeComponent(); infolabel.Text = ""; infolabel.ForeColor = Color.Red; _parentForm = parentForm; } public BZDRePrintForm(OperationForm_316 operationForm_316) { this.operationForm_316 = operationForm_316; } #region 打印按钮 /// /// 打印按钮 /// /// /// private void button1_Click(object sender, EventArgs e) { try { if (string.IsNullOrWhiteSpace(cbMaterial.Text)) { infolabel.Text = "请选择总成零件号!"; cbMaterial.Focus(); return; } if (string.IsNullOrEmpty(txtMainCode.Text)) { infolabel.Text = "请扫描或填写装配码!"; txtMainCode.Focus(); return; } //***************************** var _Product = _agent.InvokeServiceFunction(B9IPCService.BZDRecorderBLL_GetRecord.ToString(), new BZDRecorder2() { PRODUCTCODE = txtMainCode.Text }); if (_Product == null) { string BZDRule = ""; DataTable dataTable = _agent.InvokeServiceFunction(B9IPCService.BZDConfigBLL_GetAppConfigValue.ToString(), "BZDRule"); if (dataTable.Rows.Count > 0) { BZDRule = dataTable.Rows[0]["Value"].ToString(); } if (string.IsNullOrEmpty(BZDRule)) { MessageBox.Show("未配置总成规则!"); return; } string MATERIAL_CODE = cbMaterial.Text.Split('|')[0]; if (System.Text.RegularExpressions.Regex.IsMatch(txtMainCode.Text, BZDRule)) { //添加补打记录 _agent.InvokeServiceFunction(B9IPCService.BarCodeReplacementBLL_Insert.ToString(), new BarCodeReplacement() { ProductCode = txtMainCode.Text, Type = "BZD条码补打" }); _parentForm.planMATERIAL_CODE = MATERIAL_CODE; _parentForm.processMainCode = txtMainCode.Text; //_parentForm.cBoxVAN = false; //添加T_AW_PRODUCT var ProductList = SelectProduct(txtMainCode.Text); var PID = Guid.NewGuid().ToString(); var ProductNew = new Product() { PRODUCTCODE = txtMainCode.Text, PID = PID, //MACHINECODDE = _operationServiceParam.machineInfo.MACHINECODDE, //MACHINENAME = _operationServiceParam.machineInfo.MACHINENAME, PRODUCTSOURCE = "0", MATERIAL_CODE = MATERIAL_CODE, STATUS = "0", OUTFLAG = "0", USINGSTATE = "0", CAPACITY = 1, USINGCOUNT = 0, //WORKCELL_CODE = ProductList.WORKCELL_CODE, //WORKLOC_CODE = ProductList.WORKLOC_CODE, //WORKCENTER_CODE = ProductList.WORKCENTER_CODE, WORKCENTER_CODE = "ASSLINE", MATERIAL_TYPE = "IP_FINASSY" }; //_agent.InvokeServiceFunction>(B9BasicService.ProductBLL_Insert.ToString(), ProductNew); DataResult result;//判断是否成功 //result = _agent.InvokeServiceFunction>(B9BasicService.ProductBLL_Insert.ToString(), ProductNew); result = _agent.InvokeServiceFunction>(B9BasicService.ProductBLL_InsertForBundle.ToString(), ProductNew); if (!result.IsSuccess) { MessageBox.Show(result.Msg); return; } _parentForm.Print052QRCODE(false,txtMainCode.Text); } else { MessageBox.Show("条码规则不符合!"); } } else MessageBox.Show("条码已存在!"); } catch (Exception exception) { MessageBox.Show("打印失败!"); throw; } } #endregion #region 查找Product /// /// 查找Product /// /// public Product SelectProduct(string Products) { var list = new List(); var ProductList = _agent.InvokeServiceFunction(B9IPCService.ProductBLL_Get.ToString(), new Product() { PRODUCTCODE = Products }); return ProductList; } #endregion #region 初始界面 /// /// /// /// /// private void PrintForm_Load(object sender, EventArgs e) { _bzdConfig = _agent.InvokeServiceFunction>(B9IPCService.BZDConfigBLL_GetAllList.ToString(),""); foreach (var t in _bzdConfig) { t.MATERIALCODDE = t.MATERIALCODDE + "|" + t.ColorDetail; } LoadAssyMaterial(); } #endregion #region 加载总成物料 /// /// 加载总成物料 /// private void LoadAssyMaterial() { //模腔号 this.cbMaterial.DataSource = _bzdConfig; this.cbMaterial.DisplayMember = "MATERIALCODDE"; this.cbMaterial.ValueMember = "PID"; } #endregion private void label2_Click(object sender, EventArgs e) { } } }