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.
327 lines
13 KiB
327 lines
13 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Windows.Forms;
|
|
using QM.Common;
|
|
using QMAPP.FJC.Entity;
|
|
using QMAPP.FJC.Entity.Basic;
|
|
using QMAPP.FJC.Entity.Injection;
|
|
using QMAPP.ServicesAgent;
|
|
using QMAPP.WinForm.Common;
|
|
using QMAPP.Entity;
|
|
namespace QMAPP.WinForm.Forms.Injection
|
|
{
|
|
/// <summary>
|
|
/// 模块编号:M11-1
|
|
/// 作 用:投料记录
|
|
/// 作 者:王庆男
|
|
/// 编写日期:2015年05月26日
|
|
///</summary>
|
|
public partial class SlushMoldingEditForm : Form
|
|
{
|
|
InjectionRecorder recorder = new InjectionRecorder();//编辑保存实体
|
|
List<MachineInfo> machineList = new List<MachineInfo>();
|
|
|
|
/// <summary>
|
|
/// 新建
|
|
/// </summary>
|
|
public SlushMoldingEditForm()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 编辑
|
|
/// </summary>
|
|
/// <param name="pid"></param>
|
|
public SlushMoldingEditForm(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();
|
|
//加载是否有条码列表
|
|
//this.comIsHadNo.Items.Add(new ListItem("1", "有"));
|
|
//this.comIsHadNo.Items.Add(new ListItem("0", "无"));
|
|
|
|
//this.comIsHadNo.SelectedIndex = 0;
|
|
//设置焦点
|
|
this.ActiveControl = this.comMaterialCode;
|
|
this.comMaterialCode.Focus();
|
|
//this.txtMaterialCode.Visible = false;
|
|
//加载搪塑设备列表
|
|
this.comMachineCode.DisplayMember = "MACHINENAME";
|
|
this.comMachineCode.ValueMember = "MACHINECODDE";
|
|
machineList= basicData.GetMachineInfoList(new string[] { EnumGeter.ProcessType_M.Slush.GetHashCode().ToString() }, true);
|
|
this.comMachineCode.DataSource = machineList;
|
|
|
|
//加载物料列表
|
|
this.comMaterialCode.DataSource = basicData.GetMaterielInfoList("RAW_SLUSH", true);
|
|
this.comMaterialCode.DisplayMember = "MATERIAL_NAME";
|
|
this.comMaterialCode.ValueMember = "MATERIAL_CODE";
|
|
//加载操作人列表
|
|
this.comOpreator.DataSource = basicData.GetOperatorInfoList(EnumGeter.ProcessType.tangsu.GetHashCode().ToString(), true); ;
|
|
this.comOpreator.DisplayMember = "OPERATOR";
|
|
this.comOpreator.ValueMember = "PID";
|
|
//加载入料口列表
|
|
///this.comInjectionTerminal.DataSource = itemList;
|
|
this.comInjectionTerminal.DisplayMember = "Value";
|
|
this.comInjectionTerminal.ValueMember = "Key";
|
|
#endregion
|
|
|
|
#region 加载编辑
|
|
//判断是否为编辑加载编辑数据
|
|
if (string.IsNullOrEmpty(recorder.PID) == false)
|
|
{
|
|
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
|
|
recorder = agent.InvokeServiceFunction<InjectionRecorder>(B9BasicService.InjectionRecorderBLL_Get.ToString(), recorder);
|
|
//一定是存在的物料
|
|
//this.comIsHadNo.SelectedIndex = 0;
|
|
//this.txtMaterialCode.Visible = false;
|
|
this.comMaterialCode.Visible = true;
|
|
//this.txtMaterialCode.Text = "";
|
|
//窗口赋值
|
|
this.comMachineCode.SelectedValue = recorder.MACHINECODDE;
|
|
this.comMaterialCode.SelectedValue = recorder.MATERIALCODE;
|
|
this.comInjectionTerminal.SelectedIndex = recorder.INJECTIONTERMINAL;
|
|
this.comOpreator.SelectedValue = recorder.CREATEUSER.Trim();
|
|
this.txtMeterialWeight.Text = recorder.METERIALWEIGHT.ToString("0");
|
|
this.txtMaterialBatch.Text = recorder.MATERIALBATCH;
|
|
this.tbxPackageNo.Text = recorder.PACKAGENO;
|
|
txtRAWTYPE.Text = recorder.MATERIALTYPE;
|
|
dtpOperateDate.ValueX = recorder.MAKEDATE;
|
|
}
|
|
else
|
|
{
|
|
dtpOperateDate.ValueX = DateTime.Now;
|
|
}
|
|
#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 加载保存信息
|
|
//判断是否有物料号
|
|
//if (this.comIsHadNo.SelectedItem.ToString().Equals("无"))//无
|
|
//{
|
|
// recorder.MATERIALCODE = this.txtMaterialCode.Text;//因为如果不存在物料条码只扫描的话根本不知道物料名称所以必须先去基础信息维护物料号
|
|
//}
|
|
//else//有
|
|
//{
|
|
recorder.MATERIALCODE = this.comMaterialCode.SelectedValue.ToString();
|
|
//}
|
|
|
|
//原材料信息
|
|
var mateial = (this.comMaterialCode.DataSource as List<MD.Entity.Material>).Where(m => m.MATERIAL_CODE == recorder.MATERIALCODE);
|
|
MD.Entity.Material materielInfo = mateial.First();
|
|
recorder.MATERIALNAME = materielInfo.MATERIAL_NAME;
|
|
recorder.MATERIALTYPE = txtRAWTYPE.Text;
|
|
//工序类别
|
|
recorder.PROCESSTYPE = EnumGeter.ProcessType.tangsu.GetHashCode().ToString();
|
|
//获取设备信息
|
|
MachineInfo machineInfo = this.comMachineCode.SelectedItem as MachineInfo;
|
|
recorder.MACHINECODDE = machineInfo.MACHINECODDE;
|
|
recorder.MACHINENAME = machineInfo.MACHINENAME;
|
|
//设备类别
|
|
recorder.MACHINETYPE = EnumGeter.MACHINETYPE.tangsu.GetHashCode().ToString();
|
|
//投料信息
|
|
//ListItem item = this.comInjectionTerminal.SelectedItem as ListItem;
|
|
//List<string> list = item.Value.Split('-').ToList<string>();
|
|
recorder.INJECTIONTERMINAL = this.comInjectionTerminal.SelectedIndex;
|
|
//recorder.INJECTIONINDEX = Convert.ToInt32(list[0]);
|
|
//重量
|
|
recorder.METERIALWEIGHT = Convert.ToDecimal(this.txtMeterialWeight.Text);
|
|
//批次
|
|
recorder.MATERIALBATCH = this.txtMaterialBatch.Text.Trim().ToUpper();
|
|
recorder.PRODUCELINE = EnumGeter.PRODUCELINE.B9.ToString();
|
|
//操作人
|
|
recorder.CREATEUSER = this.comOpreator.SelectedValue.ToString().Trim();
|
|
recorder.PRODUCESHIFTNAME = ClientContext.produceShift.PRODUCESHIFTNAME;//班组
|
|
recorder.PRODUCESHIFTTCODE = ClientContext.produceShift.PRODUCESHIFTTCODE;//班组
|
|
recorder.PACKAGENO = tbxPackageNo.Text.Trim().ToUpper();
|
|
|
|
recorder.MAKEDATE = dtpOperateDate.Value;
|
|
|
|
#endregion
|
|
|
|
#region 保存
|
|
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
|
|
DataResult<int> result;//判断是否成功
|
|
if (string.IsNullOrEmpty(recorder.PID) == true)
|
|
{
|
|
result = agent.InvokeServiceFunction<DataResult<int>>(B9BasicService.InjectionRecorderBLL_Insert.ToString(), recorder);
|
|
}
|
|
else
|
|
{
|
|
result = agent.InvokeServiceFunction<DataResult<int>>(B9BasicService.InjectionRecorderBLL_Update.ToString(), recorder);
|
|
}
|
|
//保存成功
|
|
MessageBox.Show(result.Msg);
|
|
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>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void comIsHadNo_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
//if (this.comIsHadNo.SelectedItem.ToString().Equals("无"))
|
|
//{
|
|
// this.txtMaterialCode.Visible = true;
|
|
// this.comMaterialCode.Visible = false;
|
|
// this.comMaterialCode.SelectedItem = null;
|
|
// this.ActiveControl = this.txtMaterialCode;
|
|
// this.txtMaterialCode.Focus();//落入光标
|
|
//}
|
|
//else
|
|
//{
|
|
// this.txtMaterialCode.Visible = false;
|
|
// this.comMaterialCode.Visible = true;
|
|
// this.txtMaterialCode.Text = "";
|
|
//}
|
|
}
|
|
|
|
///<summary>
|
|
///错误检测
|
|
///</summary>
|
|
///<returns></returns>
|
|
private string ErrorCheck()
|
|
{
|
|
#region
|
|
string strMessage = "";
|
|
//物料号
|
|
if (this.comMaterialCode.Text.Trim() == string.Empty || this.comMaterialCode.SelectedValue == string.Empty)
|
|
{
|
|
strMessage += Resource1.MaterialCodeNullValidate + "\r\n";
|
|
}
|
|
//else
|
|
//{
|
|
// if (this.comIsHadNo.SelectedItem.ToString().Equals("无"))
|
|
// {
|
|
// var mateial = (this.comMaterialCode.DataSource as List<Materiel>).Where(m => m.MATERIALNO == this.txtMaterialCode.Text.Trim());
|
|
// if (mateial.Count() <= 0)
|
|
// {
|
|
// strMessage += Resource1.MaterialCodeExsitValidate + "\r\n";
|
|
// }
|
|
// }
|
|
//}
|
|
//入料口
|
|
if (this.txtRAWTYPE.Text.Trim() == string.Empty)
|
|
{
|
|
strMessage += "粉料类型不能为空" + "\r\n";
|
|
}
|
|
//设备
|
|
if (this.comMachineCode.SelectedValue == null || this.comMachineCode.SelectedValue == string.Empty)
|
|
{
|
|
strMessage += Resource1.SlushMachineNullValidate + "\r\n";
|
|
}
|
|
//入料口
|
|
if (this.comInjectionTerminal.SelectedValue == null || this.comInjectionTerminal.SelectedValue == string.Empty)
|
|
{
|
|
strMessage += Resource1.InjectionTerminalNullValidate + "\r\n";
|
|
}
|
|
//重量
|
|
if (this.txtMeterialWeight.Text == string.Empty)
|
|
{
|
|
strMessage += Resource1.MeterialWeightNullValidate + "\r\n";
|
|
}
|
|
else
|
|
{
|
|
if (SysValidate.IsDecimal(txtMeterialWeight.Text.Trim()) == false)
|
|
{
|
|
strMessage += Resource1.MeterialWeightFormatValidate + "\r\n";
|
|
}
|
|
}
|
|
//操作人
|
|
if (this.comOpreator.SelectedValue == null || this.comOpreator.SelectedValue == string.Empty)
|
|
{
|
|
strMessage += Resource1.OpreatorNullValidate+ "\r\n";
|
|
}
|
|
//批次
|
|
if (this.txtMaterialBatch.Text == string.Empty)
|
|
{
|
|
strMessage += Resource1.MaterialBatchNullValidate + "\r\n";
|
|
}
|
|
|
|
if (tbxPackageNo.Text == string.Empty)
|
|
{
|
|
strMessage += "料包号不能为空!";
|
|
}
|
|
return strMessage;
|
|
#endregion
|
|
}
|
|
|
|
|
|
|
|
private void comMaterialCode_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
if (this.comMaterialCode.SelectedValue != null && this.comMaterialCode.SelectedValue != string.Empty)
|
|
{
|
|
this.txtMeterialWeight.Text = (this.comMaterialCode.SelectedItem as MD.Entity.Material).WEIGHT.ToString();
|
|
}
|
|
}
|
|
|
|
private void comMachineCode_SelectedValueChanged(object sender, EventArgs e)
|
|
{
|
|
List<ListItem> list = new List<ListItem>();
|
|
//comInjectionTerminal.DataSource = list;
|
|
MachineInfo machine = comMachineCode.SelectedItem as MachineInfo;
|
|
if (machine != null && string.IsNullOrEmpty(machine.MACHINECODDE) == false)
|
|
{
|
|
List<string> portList = machine.MATERAILPORT.Split(',').ToList<string>();
|
|
//List<string> indeList = machine.MATERAILINDEX.Split(',').ToList<string>();
|
|
//foreach (var indexvalue in indeList)
|
|
//{
|
|
foreach (var port in portList)
|
|
{
|
|
|
|
list.Add(new ListItem(port, port + "号料箱"));
|
|
}
|
|
//}
|
|
list.Insert(0, new ListItem("", ""));
|
|
comInjectionTerminal.DataSource = list;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|