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

274 lines
13 KiB

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using QM.Common;
using QMAPP.FJC.Entity;
using QMAPP.FJC.Entity.Basic;
using QMAPP.FJC.Entity.Operation;
using QMAPP.ServicesAgent;
using QMAPP.WinForm.Common;
using QMAPP.Entity;
namespace QMAPP.WinForm.Forms.Injection
{
/// <summary>
/// 模块编号:M12-2
/// 作 用:注塑条码打印
/// 作 者:王庆男
/// 编写日期:2015年05月28日
///</summary>
public partial class InjectionMoldingPrintLotForm : Form
{
Product recorder = new Product();
/// <summary>
/// 新建
/// </summary>
public InjectionMoldingPrintLotForm()
{
InitializeComponent();
}
/// <summary>
/// 编辑
/// </summary>
/// <param name="pid"></param>
public InjectionMoldingPrintLotForm(string pid)
{
recorder.PID = pid;
InitializeComponent();
}
/// <summary>
/// 窗体加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Form_Load(object sender, EventArgs e)
{
#region 绑定下拉列表
BasicData basicData = new BasicData();
//加载注塑设备列表
this.comMachineCode.DataSource = basicData.GetMachineInfoList(new string[] { EnumGeter.ProcessType_M.Injection.GetHashCode().ToString() }, true);
this.comMachineCode.DisplayMember = "MACHINENAME";
this.comMachineCode.ValueMember = "MACHINECODDE";
//产品类型
ProductBasic searchModelList = new ProductBasic();
searchModelList.PRODUCTMAINTYPE = EnumGeter.PRODUCTMAINTYPE.zhusu.GetHashCode().ToString();
searchModelList.PRODUCTUNIT = EnumGeter.PRODUCTUNIT.SINGLE.GetHashCode().ToString();
this.comProType.DataSource = basicData.GetProductBasicList(searchModelList, true);
this.comProType.DisplayMember = "PRODUCTNAME";
this.comProType.ValueMember = "PRODUCTTYPE";
#endregion
//加工日期
this.dtpDate.Text = DateTime.Now.ToString();
#region 编辑
//判断是否为编辑加载编辑数据
if (string.IsNullOrEmpty(recorder.PID) == false)
{
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
recorder = agent.InvokeServiceFunction<Product>(B9BasicService.ProductBLL_Get.ToString(), recorder);
}
#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;
}
int proNum = 0;
if (int.TryParse(this.txtNum.Text, out proNum))
{
for (int i = 0; i < proNum; i++)
{
#region 加载保存信息
Product product = new Product();
ProductBasic basic = this.comProType.SelectedItem as ProductBasic;
MachineInfo machine = this.comMachineCode.SelectedItem as MachineInfo;
string proCode = "";
if (basic.PRODUCTTYPE.Equals(EnumGeter.ProductType.gujia.GetHashCode().ToString()))
{
proCode = "B9A";
product.CURRENTPROCESS = EnumGeter.ProcessType.huoyanjiagong.GetHashCode().ToString();//需要读取该类别最后的一道工序
}
else if (basic.PRODUCTTYPE.Equals(EnumGeter.ProductType.qinangzhijia.GetHashCode().ToString()))
{
proCode = "FJC";
product.CURRENTPROCESS = EnumGeter.ProcessType.hongwaihanjie.GetHashCode().ToString();//需要读取该类别最后的一道工序
}
else if (basic.PRODUCTTYPE.Equals(EnumGeter.ProductType.fengdao.GetHashCode().ToString()))
{
proCode = "B9B";
product.CURRENTPROCESS = EnumGeter.ProcessType.maojie.GetHashCode().ToString();//需要读取该类别最后的一道工序
}
else if (basic.PRODUCTTYPE.Equals(EnumGeter.ProductType.HUDfengdao.GetHashCode().ToString()))
{
proCode = "B9C";
product.CURRENTPROCESS = EnumGeter.ProcessType.zongchengzhuangpei.GetHashCode().ToString();//需要读取该类别最后的一道工序
}
else if (basic.PRODUCTTYPE.Equals(EnumGeter.ProductType.kaiguanzhijia.GetHashCode().ToString()))
{
proCode = "B9E";
product.CURRENTPROCESS = EnumGeter.ProcessType.chaoshengbohanjie.GetHashCode().ToString();//需要读取该类别最后的一道工序
}
if (basic.PRODUCTTYPE.Equals(EnumGeter.ProductType.qinangzhijia.GetHashCode().ToString()))
{
if (string.IsNullOrEmpty(this.dtpDate.Text.Trim()))
{
proCode += DateTime.Now.ToString("yyMMddHHmmss");
}
else
{
proCode += Convert.ToDateTime(this.dtpDate.Text.Trim()).ToString("yyMMddHHmmss");
}
proCode += ClientContext.LoginInfo.EmployeeNo;
proCode += machine.MACHINENUM;
proCode += Convert.ToDateTime(DateTime.Now).ToString("ff"); ;//获取流水已经精确到秒了还要流水?
}
else
{
if (string.IsNullOrEmpty(this.dtpDate.Text.Trim()))
{
proCode += DateTime.Now.ToString("yyMMddHHmm");
}
else
{
proCode += Convert.ToDateTime(this.dtpDate.Text.Trim()).ToString("yyMMddHHmm");
}
proCode += machine.MACHINENUM;
proCode += this.comOpereator.SelectedValue;
proCode += DateTime.Now.ToString("ssff"); ;//获取流水已经精确到秒了还要流水?
}
System.Threading.Thread.Sleep(100);
product.PRODUCTTYPE = basic.PRODUCTTYPE;
product.PRODUCTCODE = proCode;//需要生成条码
#endregion
if (this.checkBox1.Checked)
{
//骨架注塑条码规则,列如条码号B9A14081403301664950,其中B9A表示骨架注塑,140814表示日期,0330表示时间精确到秒,1表示机器号,66表示操作员号,4950表示流水号。
//气囊支架注塑条码规则,列如条码号B9D14081403301664950,其中B9D表示气囊支架注塑,140814表示日期,0330表示时间精确到秒,1表示机器号,66表示操作员号,4950表示流水号。
//开关支架包装盒条码规则:例如2015060908012511,其中2015表示年,06表示月,09表示日期,08表示小时,01表示分钟,25表示秒,11表示操作者号。
//风道注塑条码规则,例如条码号B9B14081403301664950,其中B9B表示风道注塑,140814表示日期,0330表示时间精确到分钟,1表示机器号,66表示操作员号,4950表示流水号。
//HUD风道注塑条码规则,例如条码号B9C14081403301664950,其中B9C表示HUD风道注塑,140814表示日期,0330表示时间精确到分钟,1表示机器号,66表示操作员号,4950表示流水号。
product.MACHINECODDE = machine.MACHINECODDE;//暂时用这个码
product.MACHINENAME = machine.MACHINENAME;
product.PRODUCESHIFTNAME = ClientContext.produceShift.PRODUCESHIFTNAME;//班组
product.PRODUCESHIFTTCODE = ClientContext.produceShift.PRODUCESHIFTTCODE;//班组
product.PRODUCTTYPE = basic.PRODUCTTYPE;
product.STATUS = EnumGeter.PRODUCTSTAUTS.QUALIFIED.GetHashCode().ToString();
product.PRODUCELINE = EnumGeter.PRODUCELINE.B9.ToString();
product.OUTFLAG = EnumGeter.PRODUCTOUTFLAG.INLIBRARY.GetHashCode().ToString();
product.USINGSTATE = EnumGeter.PRODUCTUSESTATE.UNUSED.GetHashCode().ToString();
product.CAPACITY = 1;
product.USINGCOUNT = 0;
product.PRODUCTSOURCE = EnumGeter.PRODUCTSOURCE.SELFMADE.GetHashCode().ToString();
#region 保存
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
DataResult<int> result;//判断是否成功
if (string.IsNullOrEmpty(product.PID) == true)
{
result = agent.InvokeServiceFunction<DataResult<int>>(B9BasicService.ProductBLL_Insert.ToString(), product);
}
else
{
result = agent.InvokeServiceFunction<DataResult<int>>(B9BasicService.ProductBLL_Update.ToString(), product);
}
if (!result.IsSuccess)
{
MessageBox.Show(result.Msg);
return;
}
#endregion
}
//打印条码
//打印条码
QM.Assist.LabelInfo ll = new QM.Assist.LabelInfo();
ll.BarCode = proCode + ",*" + proCode + "*";
QM.Assist.PrintUtil.LabelList2.Add(ll);
}
QM.Assist.PrintUtil pu = new QM.Assist.PrintUtil();
pu.PrintLabel2(System.Configuration.ConfigurationManager.AppSettings["proPath"].ToString
(), System.Configuration.ConfigurationManager.AppSettings[(this.comProType.SelectedItem as ProductBasic).PRODUCTTYPE + "temPath"].ToString
(), System.Configuration.ConfigurationManager.AppSettings[(this.comProType.SelectedItem as ProductBasic).PRODUCTTYPE + "dataPath"].ToString
());
MessageBox.Show("成功!");
}
}
/// <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.comMachineCode.SelectedValue == null || this.comMachineCode.SelectedValue == string.Empty)
{
strMessage += Resource1.SlushMachineNullValidate + "\r\n";
}
//产品类别
if (this.comProType.SelectedValue == null || this.comProType.SelectedValue == string.Empty)
{
strMessage += Resource1.ProductTypeNullValidate + "\r\n";
}
return strMessage;
#endregion
}
private void comProType_SelectedIndexChanged(object sender, EventArgs e)
{
//加载操作人
BasicData basicData = new BasicData();
if (this.comProType.SelectedValue != null && !string.IsNullOrEmpty(this.comProType.SelectedValue.ToString()))
{
this.comOpereator.DataSource = basicData.GetOperatorInfoList(this.comProType.SelectedValue.ToString(), true); ;
this.comOpereator.DisplayMember = "OPERATOR";
this.comOpereator.ValueMember = "OPERATORCODE";
}
}
}
}