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.
286 lines
10 KiB
286 lines
10 KiB
3 years ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Windows.Forms;
|
||
|
using QMAPP.ServicesAgent;
|
||
|
using QMAPP.WinForm.Common;
|
||
|
using QMAPP.Entity;
|
||
|
using QMAPP.MD.Entity.Bucket;
|
||
|
using System.Threading;
|
||
|
using Stone.WinModuleTransWare;
|
||
|
|
||
|
namespace QMAPP.WinForm.Forms.Injection
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 模块编号:M11-1
|
||
|
/// 作 用:投料记录
|
||
|
/// 作 者:王庆男
|
||
|
/// 编写日期:2015年05月26日
|
||
|
///</summary>
|
||
|
public partial class InjectionMoldingNEWEditForm : Form
|
||
|
{
|
||
|
RawMaterial recorder = new RawMaterial();//编辑保存实体
|
||
|
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
|
||
|
private bool IsCntinueSpeakMsg = true;
|
||
|
|
||
|
/// <summary>
|
||
|
/// 新建
|
||
|
/// </summary>
|
||
|
public InjectionMoldingNEWEditForm()
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 编辑
|
||
|
/// </summary>
|
||
|
/// <param name="pid"></param>
|
||
|
public InjectionMoldingNEWEditForm(string pid)
|
||
|
{
|
||
|
recorder.PID = pid;
|
||
|
InitializeComponent();
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 窗体加载
|
||
|
/// </summary>
|
||
|
/// <param name="sender"></param>
|
||
|
/// <param name="e"></param>
|
||
|
private void Form_Load(object sender, EventArgs e)
|
||
|
{
|
||
|
new KeyEvent().SetKeyToTxt(this);
|
||
|
#region 绑定下拉列表
|
||
|
BasicData basicData = new BasicData();
|
||
|
//加载是否有条码列表
|
||
|
//加载搪塑设备列表
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 加载编辑
|
||
|
//判断是否为编辑加载编辑数据
|
||
|
if (string.IsNullOrEmpty(recorder.PID) == false)
|
||
|
{
|
||
|
recorder = agent.InvokeServiceFunction<DataResult<RawMaterial>>(B9BasicService.RawMaterialBLL_Get.ToString(), recorder).Result;
|
||
|
//一定是存在的物料
|
||
|
this.txtPartCode.Text = recorder.PartCode;
|
||
|
this.txtBatchCode.Text = recorder.BatchCode;
|
||
|
this.txtSerialCode.Text = recorder.SerialCode;
|
||
|
this.txtBucketCode.Text = recorder.BucketCode;
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 窗体保存事件
|
||
|
/// </summary>
|
||
|
/// <param name="sender"></param>
|
||
|
/// <param name="e"></param>
|
||
|
private void tsbSave_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
//窗体数据校验
|
||
|
string errorMessae = ErrorCheck();
|
||
|
if (errorMessae != "")
|
||
|
{
|
||
|
MessageBox.Show(errorMessae, Resource1.ConfirmTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
#region 加载保存信息
|
||
|
|
||
|
recorder.PartCode = this.txtPartCode.Text.Trim();
|
||
|
recorder.BatchCode = this.txtBatchCode.Text.Trim();
|
||
|
recorder.SerialCode = this.txtSerialCode.Text.Trim();
|
||
|
recorder.BucketCode = this.txtBucketCode.Text.Trim();
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 保存
|
||
|
|
||
|
DataResult<int> result;//判断是否成功
|
||
|
if (string.IsNullOrEmpty(recorder.PID) == true)
|
||
|
{
|
||
|
result = agent.InvokeServiceFunction<DataResult<int>>(B9BasicService.RawMaterialBLL_Insert.ToString(), recorder);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
result = agent.InvokeServiceFunction<DataResult<int>>(B9BasicService.RawMaterialBLL_Update.ToString(), recorder);
|
||
|
}
|
||
|
//保存成功
|
||
|
if (result.IsSuccess)
|
||
|
{
|
||
|
this.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||
|
this.Close();
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 窗体关闭
|
||
|
/// </summary>
|
||
|
/// <param name="sender"></param>
|
||
|
/// <param name="e"></param>
|
||
|
private void tsbClose_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
this.Close();
|
||
|
}
|
||
|
|
||
|
///<summary>
|
||
|
///错误检测
|
||
|
///</summary>
|
||
|
///<returns></returns>
|
||
|
private string ErrorCheck()
|
||
|
{
|
||
|
#region 校验
|
||
|
string strMessage = "";
|
||
|
|
||
|
if (!string.IsNullOrEmpty(this.txtBucketCode.Text) && !string.IsNullOrEmpty(this.txtPartCode.Text))
|
||
|
{
|
||
|
var List = agent.InvokeServiceFunction<List<BucketMaterial>>(DictService.BucketMaterialBLL_GetBucketMaterialList.ToString(), new BucketMaterial() { BucketCode = this.txtBucketCode.Text });
|
||
|
if (List != null && List.Count > 0)
|
||
|
{
|
||
|
var count = 0;
|
||
|
foreach (var t in List)
|
||
|
{
|
||
|
if (System.Text.RegularExpressions.Regex.IsMatch(this.txtPartCode.Text, t.RawMaterial))
|
||
|
count++;
|
||
|
}
|
||
|
if (count == 0)
|
||
|
{
|
||
|
strMessage += this.txtBucketCode.Text + "原料上料错误 \r\n";
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//批次
|
||
|
if (this.txtBatchCode.Text == string.Empty)
|
||
|
{
|
||
|
strMessage += Resource1.MaterialBatchNullValidate + "\r\n";
|
||
|
}
|
||
|
|
||
|
//料筒
|
||
|
if (this.txtBucketCode.Text == string.Empty)
|
||
|
{
|
||
|
strMessage += "料筒不能为空\r\n";
|
||
|
}
|
||
|
|
||
|
//零件号
|
||
|
if (this.txtPartCode.Text == string.Empty)
|
||
|
{
|
||
|
strMessage += "零件号不能为空\r\n";
|
||
|
}
|
||
|
|
||
|
return strMessage;
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
private void PartCode_TextChanged(object sender, KeyEventArgs e)
|
||
|
{
|
||
|
if (e.KeyCode == Keys.Enter && (sender as TextBox).Name == "txtPartCode")
|
||
|
{
|
||
|
if (!string.IsNullOrEmpty(this.txtBucketCode.Text) && !string.IsNullOrEmpty(this.txtPartCode.Text))
|
||
|
{
|
||
|
var List = agent.InvokeServiceFunction<List<BucketMaterial>>(DictService.BucketMaterialBLL_GetBucketMaterialList.ToString(), new BucketMaterial() { BucketCode = this.txtBucketCode.Text });
|
||
|
if (List != null && List.Count > 0)
|
||
|
{
|
||
|
var count = 0;
|
||
|
foreach (var t in List)
|
||
|
{
|
||
|
if (this.txtPartCode.Text == t.RawMaterial)
|
||
|
count++;
|
||
|
|
||
|
}
|
||
|
if (count == 0)
|
||
|
{
|
||
|
IsCntinueSpeakMsg = true;
|
||
|
timer1.Enabled = true;
|
||
|
_Msg = this.txtBucketCode.Text + "号筒,原料上料错误";
|
||
|
InjectionMoldingPasswordForm psd = new InjectionMoldingPasswordForm(_Msg);
|
||
|
var result = psd.ShowDialog();
|
||
|
if (result.ToString() == "OK")
|
||
|
{
|
||
|
IsCntinueSpeakMsg = false;
|
||
|
txtPartCode.Focus();
|
||
|
this.txtPartCode.Text = "";
|
||
|
timer1.Enabled = false;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
txtBatchCode.Focus();
|
||
|
}
|
||
|
else
|
||
|
txtBatchCode.Focus();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
MessageBox.Show("请优先扫描料筒号", Resource1.ConfirmTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
|
txtBucketCode.Focus();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void BucketCode_TextChanged(object sender, KeyEventArgs e)
|
||
|
{
|
||
|
if (e.KeyCode == Keys.Enter && (sender as TextBox).Name == "txtBucketCode")
|
||
|
{
|
||
|
txtPartCode.Focus();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
private void BatchCode_TextChanged(object sender, KeyEventArgs e)
|
||
|
{
|
||
|
//MessageBox.Show(e.KeyValue.ToString());
|
||
|
if (e.KeyCode == Keys.Enter && (sender as TextBox).Name == "txtBatchCode")
|
||
|
{
|
||
|
var List = agent.InvokeServiceFunction<List<RawMaterial>>(DictService.RawMaterialBLL_GetListRaw.ToString(), new RawMaterial() { BucketCode = this.txtBucketCode.Text, PartCode = this.txtPartCode.Text });
|
||
|
if (List != null && List.Count > 0)
|
||
|
{
|
||
|
var list = List.Where(p=>p.BatchCode == this.txtBatchCode.Text);
|
||
|
if (list.Count() == 0)
|
||
|
{
|
||
|
string state = string.Empty;
|
||
|
IsCntinueSpeakMsg = true;
|
||
|
timer1.Enabled = true;
|
||
|
_Msg = this.txtBucketCode.Text + "号筒,批次号变更";
|
||
|
//弹出输入密码
|
||
|
InjectionMoldingPasswordForm psd = new InjectionMoldingPasswordForm(_Msg);
|
||
|
var result = psd.ShowDialog();
|
||
|
if (result.ToString() == "OK")
|
||
|
{
|
||
|
IsCntinueSpeakMsg = false;
|
||
|
timer1.Enabled = false;
|
||
|
txtSerialCode.Focus();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
this.txtBatchCode.Text = "";
|
||
|
IsCntinueSpeakMsg = false;
|
||
|
timer1.Enabled = false;
|
||
|
txtBatchCode.Focus();
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
txtSerialCode.Focus();
|
||
|
}
|
||
|
else
|
||
|
txtSerialCode.Focus();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
private string _Msg = String.Empty;
|
||
|
private void buttonRecord_Click()
|
||
|
{
|
||
|
if (IsCntinueSpeakMsg)
|
||
|
{
|
||
|
new Form1().Speek(_Msg);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void timer1_Tick(object sender, EventArgs e)
|
||
|
{
|
||
|
Thread thread = new Thread(buttonRecord_Click);
|
||
|
thread.Start();
|
||
|
}
|
||
|
}
|
||
|
}
|