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

279 lines
10 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>
/// 模块编号:M12-1
/// 作 用:投料记录
/// 作 者:王庆男
/// 编写日期:2015年06月08日
///</summary>
public partial class PouringMoldingEditForm : Form
{
InjectionRecorder recorder = new InjectionRecorder();//编辑保存实体
/// <summary>
/// 新建
/// </summary>
public PouringMoldingEditForm()
{
InitializeComponent();
}
/// <summary>
/// 编辑
/// </summary>
/// <param name="pid"></param>
public PouringMoldingEditForm(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.comMachineCode.DataSource = basicData.GetMachineInfoList(new string[] { EnumGeter.ProcessType_M.Foaming.GetHashCode().ToString() }, true);
this.comMachineCode.DisplayMember = "MACHINENAME";
this.comMachineCode.ValueMember = "MACHINECODDE";
if (comMachineCode.Items.Count > 0)
this.comMachineCode.SelectedIndex = 0;
//if (ClientContext.MachineInfo != null)
//{
// this.comMachineCode.SelectedValue = ClientContext.MachineInfo.MACHINECODDE;
//}
//else
//{
// this.comMachineCode.SelectedIndex = 0;
//}
//this.comMachineCode.SelectedValue = ClientContext.MachineInfo.MACHINECODDE;//默认当前设备
//加载物料列表
this.comMaterialCode.DataSource = basicData.GetMaterielInfoList("RAW_FOAM", true);
this.comMaterialCode.DisplayMember = "MATERIAL_NAME";
this.comMaterialCode.ValueMember = "MATERIAL_CODE";
//加载操作人列表
this.comOpreator.DataSource = basicData.GetOperatorInfoList(EnumGeter.ProcessType.jiaozhu.GetHashCode().ToString(), true); ;
this.comOpreator.DisplayMember = "OPERATOR";
this.comOpreator.ValueMember = "PID";
#endregion
#region 加载编辑
//判断是否为编辑加载编辑数据
if (string.IsNullOrEmpty(recorder.PID) == false)
{
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
recorder = agent.InvokeServiceFunction<InjectionRecorder>(B9BasicService.InjectionRecorderBLL_Get.ToString(), recorder);
//窗口赋值
this.comMaterialCode.SelectedValue = recorder.MATERIALCODE;
this.comMachineCode.SelectedValue = recorder.MACHINECODDE;
this.txtMeterialWeight.Text = recorder.METERIALWEIGHT.ToString("0");
this.comOpreator.SelectedValue = recorder.CREATEUSER.Trim();
this.txtMaterialBatch.Text = recorder.MATERIALBATCH;
this.dtpOperateDate.ValueX = recorder.MAKEDATE;
dtpCreateUserLimit.ValueX = recorder.VALIDDATE;
this.txtPackageNo.Text = recorder.PACKAGENO;
}
else
{
this.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 加载保存信息
recorder.MATERIALCODE = this.comMaterialCode.SelectedValue.ToString();
//原材料信息
var mateial = (this.comMaterialCode.DataSource as List<MD.Entity.Material>).Where(m => m.MATERIAL_CODE == recorder.MATERIALCODE);
if (mateial.Count() > 0)
{
MD.Entity.Material materielInfo = mateial.First();
recorder.MATERIALNAME = materielInfo.MATERIAL_NAME;
recorder.MATERIALTYPE = materielInfo.MATERIAL_TYPE_NAME;
recorder.LIMITTIME = 1;
}
//获取设备信息
MachineInfo machineInfo = this.comMachineCode.SelectedItem as MachineInfo;
recorder.MACHINECODDE = machineInfo.MACHINECODDE;
recorder.MACHINENAME = machineInfo.MACHINENAME;
recorder.MACHINETYPE = EnumGeter.MACHINETYPE.jiaozhu.GetHashCode().ToString();
//工序类别
recorder.PROCESSTYPE = EnumGeter.ProcessType.jiaozhu.GetHashCode().ToString();
//重量
recorder.METERIALWEIGHT = Convert.ToInt32(this.txtMeterialWeight.Text);
//批次
recorder.MATERIALBATCH = this.txtMaterialBatch.Text;
recorder.PRODUCELINE = EnumGeter.PRODUCELINE.B9.ToString();
//生产日期
recorder.MAKEDATE = dtpOperateDate.Value;
recorder.VALIDDATE = dtpCreateUserLimit.Value;
recorder.PACKAGENO = txtPackageNo.Text;
//操作人
recorder.CREATEUSER = this.comOpreator.SelectedValue.ToString().Trim();
recorder.PRODUCESHIFTNAME = ClientContext.produceShift.PRODUCESHIFTNAME;//班组
recorder.PRODUCESHIFTTCODE = ClientContext.produceShift.PRODUCESHIFTTCODE;//班组
#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>
///<returns></returns>
private string ErrorCheck()
{
#region 校验
string strMessage = "";
//物料号
if (this.comMaterialCode.SelectedValue == string.Empty)
{
strMessage += Resource1.MaterialCodeNullValidate + "\r\n";
}
//设备
if (this.comMachineCode.SelectedValue == null || this.comMachineCode.SelectedValue == string.Empty)
{
strMessage += Resource1.InjectionMachineNullValidate + "\r\n";
}
//批次
if (this.txtMaterialBatch.Text == string.Empty)
{
strMessage += Resource1.MaterialBatchNullValidate + "\r\n";
}
//批次
if (this.txtPackageNo.Text == string.Empty)
{
strMessage += "料桶号不能为空!" + "\r\n";
}
//重量
if (this.txtMeterialWeight.Text == string.Empty)
{
strMessage += Resource1.MeterialWeightNullValidate + "\r\n";
}
else
{
if (SysValidate.IsInt(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.dtpCreateUserLimit.ValueX == null)
{
strMessage += "有效日期不能为空!" + "\r\n";
}
if (this.dtpCreateUserLimit.Value < DateTime.Now)
{
strMessage += Resource1.BeyondLimitTime + "\r\n";
}
//投料时间
if (this.dtpOperateDate.ValueX == null)
{
strMessage += "投料时间不能为空!" + "\r\n";
}
//if (this.dtpCreateUserLimit.ValueX < this.dtpCreateUserStart.ValueX)
//{
// strMessage += "生产日期不能早于有效日期!" + "\r\n";
//}
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();
}
}
}
}