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

334 lines
13 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.Basic;
using QMAPP.FJC.Entity.Operation;
using QMAPP.FJC.Entity.SendPlan;
using QMAPP.ServicesAgent;
using QMAPP.WinForm.Common;
using QMFrameWork.Common.Serialization;
using QMFrameWork.Data;
using QMAPP.FJC.Entity;
using QMAPP.Entity;
namespace QMAPP.WinForm.Forms.SendPlan
{
/// <summary>
/// 搪塑条码打印
/// </summary>
public partial class SendPlanPrintForm : Form
{
List<Main> mainList = new List<Main>();
string typeSelected = "";
public SendPlanPrintForm()
{
InitializeComponent();
}
#region 窗体载入
private void Form_Load(object sender, EventArgs e)
{
BasicData basicData = new BasicData();
//初始化控件属性
this.DGView.AutoGenerateColumns = false;
////加载料架列表
this.comType.DataSource = basicData.GetMaterialShelfTypeList("",true);
this.comType.DisplayMember = "MARERIALSHELFTYPENAME";
this.comType.ValueMember = "PID";
}
#endregion
/// <summary>
/// 打印
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tsbPrint_Click(object sender, EventArgs e)
{
string barCode = "";
PrintBarCode(barCode);
}
/// <summary>
/// 打印条码
/// </summary>
/// <param name="barCode"></param>
private void PrintBarCode(string barCode)
{
string xmlPath = @"E:\富维江森\代码\B9\APPB9\QMAPP.WinForm\XMLResources\SendInfo.xml";
BarcodeLib.BarCodeGenerate generate = new BarcodeLib.BarCodeGenerate(xmlPath);
generate.PrintBarCode(barCode);
}
/// <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 comType_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.mainList.Count > 0 && !this.typeSelected.Equals(this.comType.SelectedValue))
{
if (MessageBox.Show(Resource1.SendInfoHadProduct, Resource1.ConfirmTitle, MessageBoxButtons.OKCancel) == DialogResult.OK)
{
MaterialShelfType type = this.comType.SelectedItem as MaterialShelfType;
this.lblCounts.Text = type.CAPACITY.ToString();
this.typeSelected = type.PID;
this.mainList.Clear();
this.DGView.DataSource = new List<Main>();
}
else
{
this.comType.SelectedValue = this.typeSelected;
}
}
else
{
MaterialShelfType type = this.comType.SelectedItem as MaterialShelfType;
this.lblCounts.Text = type.CAPACITY.ToString();
this.typeSelected = type.PID;
}
}
/// <summary>
/// 扫码枪或者点击增加方法
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ValidateAndAddCode(string proCode)
{
if (this.comType.SelectedValue == null)
{
MessageBox.Show(Resource1.SendInfoSelect);
return;
}
if (string.IsNullOrEmpty(this.lblCounts.Text.Trim()))
{
MessageBox.Show(Resource1.SendInfoNotNull);
return;
}
if (this.mainList.Count >= Convert.ToInt32(this.lblCounts.Text.Trim()))
{
MessageBox.Show(Resource1.SendInfoWasFull);
return;
}
if (!string.IsNullOrEmpty(proCode))
{
//首先判断是否在列表中存在
if (this.mainList.FindAll(m => m.EPIDERMISCODE == proCode).Count > 0 || this.mainList.FindAll(m => m.SKELETONCODE == proCode).Count > 0)
{
MessageBox.Show(this.txtCode.Text + Resource1.SendInfoWasHad);
return;
}
#region 获取零件信息
Main searchModel = new Main();
searchModel.publicCode = proCode;
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
List<Main> list = agent.InvokeServiceFunction<List<Main>>(B9IPCService.MainBLL_GetAllList.ToString(), searchModel);
if (list.Count <= 0)//是否存在该零件
{
MessageBox.Show(this.txtCode.Text +Resource1.SendInfoNotFoundCode);
return;
}
Main model = list[0];
#endregion
#region 判断零件状态
if (!model.STATUS.Equals(EnumGeter.PRODUCTSTAUTS.QUALIFIED.GetHashCode().ToString()))//合格
{
if (model.STATUS.Equals(EnumGeter.PRODUCTSTAUTS.REPAIR.GetHashCode().ToString()))//合格
{
MessageBox.Show(this.txtCode.Text +Resource1.SendInfoRepaired);
return;
}
else
{
MessageBox.Show(this.txtCode.Text + Resource1.SendInfoWadBad);
return;
}
}
//是否已出库
if (EnumGeter.OUTFLAG.INWAREHOUSE.GetHashCode().ToString().Equals(model.OUTFLAG) ==false)
{
MessageBox.Show(this.txtCode.Text + Resource1.SendInfoNotOk);
return;
}
//是否已完成
if (EnumGeter.COMPLETEFLAG.COMPLETED.GetHashCode().ToString().Equals(model.COMPLETEFLAG) == false)
{
MessageBox.Show(this.txtCode.Text + "该本体正在加工中,未完成");
return;
}
#endregion
#region 判断零件属性是否与料架属性匹配
//获取该产品的属性
//ProductAttribute attribute = new ProductAttribute();
//attribute.MPPID = model.EID;
//List<ProductAttribute> listAttribute = agent.InvokeServiceFunction<List<ProductAttribute>>(B9BasicService.ProductAttributeBLL_GetAllList.ToString(), attribute);
//if (listAttribute.Count <= 0)
//{
// MessageBox.Show(Resource1.SendInfoCantFind);
// return;
//}
//attribute = listAttribute[0];
//判断是否与料架属性匹配
MaterialShelfType type = this.comType.SelectedItem as MaterialShelfType;
//判断产品类别type.PRODUCTTYPE;
if (!type.VERSION.Equals(model.HB))
{
MessageBox.Show(this.txtCode.Text + Resource1.SendInfoNotFIt);
return;
}
if (!type.COLORCODE.Equals(model.COLOR))
{
MessageBox.Show(this.txtCode.Text + Resource1.SendInfoColorNotFit);
return;
}
#endregion
//添加到零件列表
mainList.Add(model);
this.DGView.DataSource = new List<Main>();
this.DGView.DataSource = mainList;
this.txtCode.Text = "";
if (mainList.Count.ToString().Equals(this.lblCounts.Text.Trim()))//判断是否装满
{
if (MessageBox.Show(Resource1.SendInfoReadySend, Resource1.ConfirmTitle, MessageBoxButtons.OKCancel) == DialogResult.OK)
{
SaveInfo();
}
}
}
}
/// <summary>
/// 保存发运方法
/// </summary>
public void SaveInfo()
{
if (mainList.Count <= 0)
{
MessageBox.Show(Resource1.SendInfoNotProduct);
return;
}
SendPlanInfo sendPlanInfo = new SendPlanInfo();
sendPlanInfo.SENDCODE = DateTime.Now.ToString("yyyyMMddHHmmss"); //生成贴车单号
sendPlanInfo.PRODUCESHIFTNAME = ClientContext.produceShift.PRODUCESHIFTNAME;//班组
sendPlanInfo.PRODUCESHIFTTCODE = ClientContext.produceShift.PRODUCESHIFTTCODE;//班组
sendPlanInfo.COUNT = mainList.Count;
sendPlanInfo.PRODUCELINE = EnumGeter.PRODUCELINE.B9.ToString();
//获取当前料架
MaterialShelfType type = this.comType.SelectedItem as MaterialShelfType;
sendPlanInfo.SPID = type.PID;
sendPlanInfo.MARERIALSHELFTYPECODE = type.MARERIALSHELFTYPECODE;
sendPlanInfo.MARERIALSHELFTYPENAME = type.MARERIALSHELFTYPENAME;
sendPlanInfo.PRODUCTTYPE = type.PRODUCTTYPE;
sendPlanInfo.VERSION = type.VERSION;
sendPlanInfo.COLORCODE = type.COLORCODE;
sendPlanInfo.mainList = this.mainList;
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
DataResult<int> result = agent.InvokeServiceFunction<DataResult<int>>(B9IPCService.SendPlanInfoBLL_InsertAndUpdateMain.ToString(), sendPlanInfo);
MessageBox.Show(result.Msg);
//保存成功
if (result.IsSuccess)
{
this.mainList.Clear();
this.DGView.DataSource = new List<Main>();
}
}
/// <summary>
/// 添加条码
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void stbAdd_Click(object sender, EventArgs e)
{
ValidateAndAddCode(this.txtCode.Text.Trim());
this.txtCode.Text = "";
}
/// <summary>
/// 保存条码
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tsbSave_Click(object sender, EventArgs e)
{
SaveInfo();
this.DialogResult = System.Windows.Forms.DialogResult.OK;
}
/// <summary>
/// 删除选中条码
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void stbDelete_Click(object sender, EventArgs e)
{
if (this.DGView.SelectedRows.Count > 0)
{
string selectKey = this.DGView.SelectedRows[0].Cells["Pid"].Value.ToString();
this.mainList.RemoveAll(m => m.PID == selectKey);
this.DGView.DataSource = new List<Main>();
this.DGView.DataSource = this.mainList;
}
}
/// <summary>
/// 打开查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tsbSearch_Click(object sender, EventArgs e)
{
SendPlanSearchForm form = new SendPlanSearchForm();
form.MdiParent = this.ParentForm;
form.Show();
}
/// <summary>
/// 回车事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void SendPlanPrintForm_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)//如果输入的是回车键
{
this.stbAdd_Click(sender, e);//触发button事件
}
}
private void txtCode_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
this.stbAdd_Click(sender, e);
}
}
}
}