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.
244 lines
8.4 KiB
244 lines
8.4 KiB
4 years ago
|
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.KB.Entity;
|
||
|
using QMAPP.ServicesAgent;
|
||
|
using QMAPP.FJC.Entity.Operation;
|
||
|
using QMAPP.FJC.Entity;
|
||
|
using QMAPP.WinForm.Common;
|
||
|
|
||
|
namespace QMAPP.WinForm.Forms.Injection
|
||
|
{
|
||
|
public partial class InjectionCheckForm : Form
|
||
|
{
|
||
|
public InjectionCheckForm()
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
|
||
|
}
|
||
|
|
||
|
private void btnClose_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
this.Close();
|
||
|
}
|
||
|
|
||
|
private void txtProductCode_KeyDown(object sender, KeyEventArgs e)
|
||
|
{
|
||
|
if (e.KeyCode != Keys.Enter)//如果输入的是回车键
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (comMachine.SelectedIndex == 0)
|
||
|
{
|
||
|
lblError.Text = string.Format("请选择注塑设备!");
|
||
|
this.lblError.ForeColor = Color.Red;
|
||
|
comMachine.Focus();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (string.IsNullOrEmpty(txtProductCode.Text))
|
||
|
{
|
||
|
lblError.Text = string.Format("请输入要查验的条码!");
|
||
|
this.lblError.ForeColor = Color.Red;
|
||
|
txtProductCode.Focus();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
|
||
|
if (txtProductCode.Text.IndexOf("B9A") != 0
|
||
|
&& txtProductCode.Text.IndexOf("B9B") != 0
|
||
|
&& txtProductCode.Text.IndexOf("B9C") != 0
|
||
|
&& txtProductCode.Text.IndexOf("FJC") != 0
|
||
|
)
|
||
|
{
|
||
|
|
||
|
lblError.Text = "请输入注塑产品条码!";
|
||
|
this.lblError.ForeColor = Color.Red;
|
||
|
txtProductCode.Text = "";
|
||
|
txtProductCode.Focus();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
InjectionCheck entity = new InjectionCheck();
|
||
|
entity.PID = Guid.NewGuid().ToString();
|
||
|
entity.MACHINECODDE = comMachine.SelectedValue.ToString();
|
||
|
entity.MACHINENAME = comMachine.Text;
|
||
|
entity.PRODUCTCODE = txtProductCode.Text.Trim().ToUpper().ToString();
|
||
|
entity.CREATEDATE = System.DateTime.Now;
|
||
|
entity.PRODUCTTYPE = GetProductType(entity.PRODUCTCODE);
|
||
|
|
||
|
try
|
||
|
{
|
||
|
entity.PRODUCEDATE = Convert.ToDateTime("20" + entity.PRODUCTCODE.Substring(3, 2)
|
||
|
+ "-" + entity.PRODUCTCODE.Substring(5, 2)
|
||
|
+ "-" + entity.PRODUCTCODE.Substring(7, 2)
|
||
|
+ " " + entity.PRODUCTCODE.Substring(9, 2)
|
||
|
+ ":" + entity.PRODUCTCODE.Substring(11, 2)
|
||
|
+ ":00");
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
lblError.Text = string.Format("条码中时间格式不正确!", txtProductCode.Text); ;
|
||
|
this.lblError.ForeColor = Color.Red;
|
||
|
txtProductCode.Text = "";
|
||
|
txtProductCode.Focus();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
|
||
|
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
|
||
|
DataResult result = agent.InvokeServiceFunction<DataResult>(B9IPCService.InjectionCheckBLL_Insert.ToString(), entity);
|
||
|
|
||
|
if (result.IsSuccess == true)
|
||
|
{
|
||
|
lblError.Text = string.Format("{0}扫描成功!", txtProductCode.Text);
|
||
|
this.lblError.ForeColor = Color.Green;
|
||
|
txtProductCode.Text = "";
|
||
|
txtProductCode.Focus();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
lblError.Text = string.Format("{0}扫描失败!", txtProductCode.Text); ;
|
||
|
this.lblError.ForeColor = Color.Red;
|
||
|
txtProductCode.Text = "";
|
||
|
txtProductCode.Focus();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void btnScarp_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
|
||
|
if (comMachine.SelectedIndex == 0)
|
||
|
{
|
||
|
lblError.Text = string.Format("请选择注塑设备!");
|
||
|
this.lblError.ForeColor = Color.Red;
|
||
|
comMachine.Focus();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (string.IsNullOrEmpty(txtProductCode.Text))
|
||
|
{
|
||
|
lblError.Text = string.Format("请输入要查验的条码!");
|
||
|
this.lblError.ForeColor = Color.Red;
|
||
|
txtProductCode.Focus();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
|
||
|
if (txtProductCode.Text.IndexOf("B9A") != 0
|
||
|
&& txtProductCode.Text.IndexOf("B9B") != 0
|
||
|
&& txtProductCode.Text.IndexOf("B9C") != 0
|
||
|
&& txtProductCode.Text.IndexOf("FJC") != 0
|
||
|
)
|
||
|
{
|
||
|
|
||
|
lblError.Text = "请输入注塑产品条码!";
|
||
|
this.lblError.ForeColor = Color.Red;
|
||
|
txtProductCode.Text = "";
|
||
|
txtProductCode.Focus();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
InjectionCheck entity = new InjectionCheck();
|
||
|
entity.PID = Guid.NewGuid().ToString();
|
||
|
entity.MACHINECODDE = comMachine.SelectedValue.ToString();
|
||
|
entity.MACHINENAME = comMachine.Text;
|
||
|
entity.PRODUCTCODE = txtProductCode.Text.Trim().ToUpper().ToString();
|
||
|
entity.CREATEDATE = System.DateTime.Now;
|
||
|
entity.PRODUCTTYPE = GetProductType(entity.PRODUCTCODE);
|
||
|
|
||
|
try
|
||
|
{
|
||
|
entity.PRODUCEDATE = Convert.ToDateTime("20" + entity.PRODUCTCODE.Substring(3, 2)
|
||
|
+ "-" + entity.PRODUCTCODE.Substring(5, 2)
|
||
|
+ "-" + entity.PRODUCTCODE.Substring(7, 2)
|
||
|
+ " " + entity.PRODUCTCODE.Substring(9, 2)
|
||
|
+ ":" + entity.PRODUCTCODE.Substring(11, 2)
|
||
|
+ ":00");
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
lblError.Text = string.Format("条码中时间格式不正确!", txtProductCode.Text); ;
|
||
|
this.lblError.ForeColor = Color.Red;
|
||
|
txtProductCode.Text = "";
|
||
|
txtProductCode.Focus();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
|
||
|
DataResult result = agent.InvokeServiceFunction<DataResult>(B9IPCService.InjectionCheckBLL_Insert.ToString(), entity);
|
||
|
|
||
|
if (result.IsSuccess == true)
|
||
|
{
|
||
|
lblError.Text = string.Format("{0}扫描成功!", txtProductCode.Text);
|
||
|
this.lblError.ForeColor = Color.Green;
|
||
|
txtProductCode.Text = "";
|
||
|
txtProductCode.Focus();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
lblError.Text = string.Format("{0}扫描失败!", txtProductCode.Text); ;
|
||
|
this.lblError.ForeColor = Color.Red;
|
||
|
txtProductCode.Text = "";
|
||
|
txtProductCode.Focus();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void InjectionCheckForm_Load(object sender, EventArgs e)
|
||
|
{
|
||
|
#region 绑定下拉列表
|
||
|
|
||
|
BasicData basicData = new BasicData();
|
||
|
//初始化控件属性
|
||
|
//加载注塑设备列表
|
||
|
this.comMachine.DataSource = basicData.GetMachineInfoList(new string[] { EnumGeter.ProcessType_M.Injection.GetHashCode().ToString() }, true);
|
||
|
this.comMachine.DisplayMember = "MACHINENAME";
|
||
|
this.comMachine.ValueMember = "MACHINECODDE";
|
||
|
//产品类型
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
comMachine.Focus();
|
||
|
}
|
||
|
|
||
|
private string GetProductType(string productCode)
|
||
|
{
|
||
|
string productType = "";
|
||
|
|
||
|
if (txtProductCode.Text.IndexOf("B9A") == 0)
|
||
|
{
|
||
|
productType = EnumGeter.ProductType.gujia.GetHashCode().ToString();
|
||
|
}
|
||
|
|
||
|
if (txtProductCode.Text.IndexOf("B9B") == 0)
|
||
|
{
|
||
|
productType = EnumGeter.ProductType.fengdao.GetHashCode().ToString();
|
||
|
}
|
||
|
|
||
|
if (txtProductCode.Text.IndexOf("B9C") == 0)
|
||
|
{
|
||
|
productType = EnumGeter.ProductType.HUDfengdao.GetHashCode().ToString();
|
||
|
}
|
||
|
if (txtProductCode.Text.IndexOf("FJC") == 0)
|
||
|
{
|
||
|
productType = EnumGeter.ProductType.qinangzhijia.GetHashCode().ToString();
|
||
|
}
|
||
|
|
||
|
return productType;
|
||
|
}
|
||
|
|
||
|
private void comMachine_SelectedIndexChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
txtProductCode.Focus();
|
||
|
}
|
||
|
}
|
||
|
}
|