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.
344 lines
15 KiB
344 lines
15 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
using QMAPP.FJC.Entity;
|
|
using QMAPP.FJC.Entity.Operation;
|
|
using QMAPP.ServicesAgent;
|
|
using QMAPP.WinForm.Common;
|
|
using QMFrameWork.Common.Serialization;
|
|
using QMFrameWork.Data;
|
|
using QMAPP.FJC.Entity.Basic;
|
|
using QM.Common;
|
|
using QMAPP.Entity;
|
|
|
|
namespace QMAPP.WinForm.Forms.Injection
|
|
{
|
|
/// <summary>
|
|
/// 模块编号:M12-3
|
|
/// 作 用:注塑打包
|
|
/// 作 者:王庆男
|
|
/// 编写日期:2015年06月11日
|
|
///</summary>
|
|
public partial class ProductAddForm : Form
|
|
{
|
|
Product product = new Product();//编辑保存
|
|
Product searchModel = new Product();//查询条件
|
|
public ProductAddForm()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
#region 窗体载入
|
|
|
|
private void Form_Load(object sender, EventArgs e)
|
|
{
|
|
#region 绑定下拉列表
|
|
BasicData basicData = new BasicData();
|
|
//初始化控件属性
|
|
this.DGView.AutoGenerateColumns = false;
|
|
//加载操作人列表
|
|
this.comOperator.DataSource = basicData.GetOperatorInfoList(EnumGeter.MACHINETYPE.zhusu.GetHashCode().ToString(), true); ;
|
|
this.comOperator.DisplayMember = "OPERATOR";
|
|
this.comOperator.ValueMember = "OPERATORCODE";
|
|
|
|
//产品类型
|
|
ProductBasic searchModelList = new ProductBasic();
|
|
searchModelList.PRODUCTSOURCE = EnumGeter.PRODUCTSOURCE.OUTSOURCING.GetHashCode().ToString();
|
|
searchModelList.PRODUCTUNIT = EnumGeter.PRODUCTUNIT.SET.GetHashCode().ToString();
|
|
|
|
this.comProType.DataSource = basicData.GetProductBasicList(searchModelList, true);
|
|
this.comProType.DisplayMember = "PRODUCTNAME";
|
|
this.comProType.ValueMember = "PRODUCTTYPE";
|
|
|
|
this.comProTypeB.DataSource = basicData.GetProductBasicList(searchModelList, true);
|
|
this.comProTypeB.DisplayMember = "PRODUCTNAME";
|
|
this.comProTypeB.ValueMember = "PRODUCTTYPE";
|
|
#endregion
|
|
//初始化分页
|
|
this.pager1.Init();
|
|
//加载默认查询条件
|
|
SetSearchModel();
|
|
BindGirdData();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 绑定数据
|
|
|
|
private DataPage BindGirdData()
|
|
{
|
|
List<Product> recorders = null;//查询结果列表
|
|
DataPage dataPage = new DataPage();
|
|
//获取前台分页设置信息
|
|
dataPage = pager1.DataPage;
|
|
try
|
|
{
|
|
#region 服务查询
|
|
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
|
|
dataPage = agent.InvokeServiceFunction<DataPage>(B9BasicService.ProductBLL_GetList.ToString(), searchModel, dataPage);
|
|
recorders = JsonConvertHelper.GetDeserialize<List<Product>>(dataPage.Result.ToString());
|
|
#endregion
|
|
this.DGView.DataSource = recorders;
|
|
this.pager1.DataPage = dataPage;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
return dataPage;
|
|
}
|
|
|
|
#endregion
|
|
/// <summary>
|
|
/// 分页事件
|
|
/// </summary>
|
|
/// <param name="e"></param>
|
|
/// <returns></returns>
|
|
private DataPage pager1_EventPaging(Controls.EventPagingArg e)
|
|
{
|
|
return BindGirdData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void tsbSearch_Click(object sender, EventArgs e)
|
|
{
|
|
SetSearchModel();
|
|
this.pager1.Init();
|
|
BindGirdData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置查询条件
|
|
/// </summary>
|
|
private void SetSearchModel()
|
|
{
|
|
searchModel = new Product();
|
|
//searchModel.PRODUCTTYPES = string.Join(",", new int[] { EnumGeter.ProductType.gujia.GetHashCode(), EnumGeter.ProductType.qinangzhijia.GetHashCode(), EnumGeter.ProductType.kaiguanzhijia.GetHashCode(), EnumGeter.ProductType.fengdao.GetHashCode(), EnumGeter.ProductType.HUDfengdao.GetHashCode() });//设置零件条码表的零件类别
|
|
searchModel.PRODUCTSOURCE = EnumGeter.PRODUCTSOURCE.OUTSOURCING.GetHashCode().ToString();
|
|
//操作人
|
|
if (this.comOperator.SelectedValue != null && string.IsNullOrEmpty(this.comOperator.SelectedValue.ToString().Trim()) == false)
|
|
{
|
|
searchModel.MACHINECODDE = this.comOperator.SelectedValue.ToString().Trim();
|
|
}
|
|
//条码
|
|
if (string.IsNullOrEmpty(this.txtProductCode.Text.Trim()) == false)
|
|
{
|
|
searchModel.PRODUCTCODE = this.txtProductCode.Text.Trim();
|
|
}
|
|
//零件类别
|
|
if (this.comProTypeB.SelectedValue != null && string.IsNullOrEmpty(this.comProTypeB.SelectedValue.ToString()) == false)
|
|
{
|
|
searchModel.PRODUCTTYPE = this.comProTypeB.SelectedValue.ToString();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 行序号
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void DG_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
|
|
{
|
|
Rectangle rectangle = new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, this.DGView.RowHeadersWidth - 4, e.RowBounds.Height);
|
|
TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), new Font("宋体", 12, FontStyle.Bold), rectangle, this.DGView.RowHeadersDefaultCellStyle.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 零件类别联动事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void comProType_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
if (this.comProType.SelectedValue !=null && !string.IsNullOrEmpty(this.comProType.SelectedValue.ToString()))
|
|
{
|
|
ProductBasic basic = this.comProType.SelectedItem as ProductBasic;
|
|
this.lblCount.Text = basic.CAPATITY.ToString();
|
|
this.txtCount.Text = basic.CAPATITY.ToString();
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 打包
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void tsbAdd_Click(object sender, EventArgs e)
|
|
{
|
|
//窗体数据校验
|
|
string errorMessae = ErrorCheck();
|
|
if (errorMessae != "")
|
|
{
|
|
MessageBox.Show(errorMessae, Resource1.ConfirmTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
|
|
#region 加载保存信息
|
|
ProductBasic basic = this.comProType.SelectedItem as ProductBasic;
|
|
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.maojie.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();//需要读取该类别最后的一道工序
|
|
}
|
|
else if (basic.PRODUCTTYPE.Equals(EnumGeter.ProductType.geshan.GetHashCode().ToString()))
|
|
{
|
|
product.CURRENTPROCESS = EnumGeter.ProcessType.zongchengzhuangpei.GetHashCode().ToString();//需要读取该类别最后的一道工序
|
|
}
|
|
else if (basic.PRODUCTTYPE.Equals(EnumGeter.ProductType.qinangzhijia.GetHashCode().ToString()))
|
|
{
|
|
product.CURRENTPROCESS = EnumGeter.ProcessType.chaoshengbohanjie.GetHashCode().ToString();//需要读取该类别最后的一道工序
|
|
}
|
|
proCode += Convert.ToDateTime(DateTime.Now).ToString("yyMMddHHmmss");
|
|
//proCode += machine.MACHINECODDE;
|
|
//proCode += this.comOpereator.SelectedValue;
|
|
proCode += "";//获取流水已经精确到秒了还要流水?
|
|
|
|
product.PRODUCTTYPE = basic.PRODUCTTYPE;
|
|
product.PRODUCTCODE = this.txtCode.Text.Trim();//需要生成条码
|
|
//骨架注塑条码规则,列如条码号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 = ClientContext.MachineInfo.MACHINECODDE;//暂时用这个码
|
|
//product.MACHINENAME = ClientContext.MachineInfo.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.USING.GetHashCode().ToString();
|
|
product.CAPACITY = Convert.ToInt32(this.txtCount.Text);
|
|
product.PRODUCTSOURCE = EnumGeter.PRODUCTSOURCE.OUTSOURCING.GetHashCode().ToString();
|
|
product.USINGCOUNT = 0;
|
|
#endregion
|
|
|
|
#region 保存
|
|
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
|
|
DataResult<int> result;//判断是否成功
|
|
if (string.IsNullOrEmpty(product.PID) == true)
|
|
{
|
|
result = agent.InvokeServiceFunction<DataResult<int>>(B9BasicService.ProductBLL_InsertForBundle.ToString(), product);
|
|
}
|
|
else
|
|
{
|
|
result = agent.InvokeServiceFunction<DataResult<int>>(B9BasicService.ProductBLL_Update.ToString(), product);
|
|
}
|
|
MessageBox.Show(result.Msg);
|
|
//保存成功
|
|
if (result.IsSuccess)
|
|
{
|
|
product = new Product();
|
|
SetSearchModel();
|
|
this.pager1.Init();
|
|
BindGirdData();
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
/// <summary>
|
|
/// 编辑
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void tsbEdit_Click(object sender, EventArgs e)
|
|
{
|
|
if (this.DGView.SelectedRows.Count > 0)
|
|
{
|
|
//获取ID
|
|
string selectKey = this.DGView.SelectedRows[0].Cells["Pid"].Value.ToString();
|
|
Product searchModel = new Product();
|
|
searchModel.PID = selectKey;
|
|
//获取实体
|
|
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
|
|
product = agent.InvokeServiceFunction<Product>(B9BasicService.ProductBLL_Get.ToString(), searchModel);
|
|
//显示到界面
|
|
this.comProType.SelectedValue = product.PRODUCTTYPE;
|
|
this.txtCount.Text = product.CAPACITY.ToString();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void tsbDelete_Click(object sender, EventArgs e)
|
|
{
|
|
if (this.DGView.SelectedRows.Count <= 0)
|
|
return;
|
|
if (MessageBox.Show(Resource1.ConfirmDelete, Resource1.ConfirmTitle, MessageBoxButtons.OKCancel) != DialogResult.OK)
|
|
return;
|
|
#region 删除
|
|
string selectKey = this.DGView.SelectedRows[0].Cells["Pid"].Value.ToString();
|
|
//删除校验判断该投料批次号是否已经生产出产品,如果已生产出产品则不允许删除,如果不允许则弹出提示'该批次号物料已使用,不能删除!'
|
|
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
|
|
DataResult<int> result = agent.InvokeServiceFunction<DataResult<int>>(B9BasicService.ProductBLL_Delete.ToString(), selectKey);
|
|
MessageBox.Show(result.Msg);
|
|
if (result.IsSuccess)
|
|
{
|
|
BindGirdData();
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
|
|
///<summary>
|
|
///错误检测
|
|
///</summary>
|
|
///<returns></returns>
|
|
private string ErrorCheck()
|
|
{
|
|
#region
|
|
string strMessage = "";
|
|
//设备
|
|
if (this.comProType.SelectedValue == null || this.comProType.SelectedValue == string.Empty)
|
|
{
|
|
strMessage += Resource1.ProductTypeNullValidate + "\r\n";
|
|
}
|
|
//重量
|
|
if (this.txtCount.Text == string.Empty)
|
|
{
|
|
strMessage += Resource1.NumNullValidate + "\r\n";
|
|
}
|
|
else
|
|
{
|
|
if (SysValidate.IsInt(txtCount.Text.Trim()) == false)
|
|
{
|
|
strMessage += Resource1.NumFormatValidate + "\r\n";
|
|
}
|
|
}
|
|
return strMessage;
|
|
#endregion
|
|
}
|
|
}
|
|
}
|
|
|