using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QM.Account;
using DCS.Common;
using Model;
using QM.Assist;
using DCS.Place;
using QMAPP.FJC.Entity.Operation;
using QMAPP.Entity;
using QMAPP.MD.Entity;
using QMAPP.FJC.Entity.Basic;
using QMAPP.FJC.Entity.TianJin;
using QMAPP.ServicesAgent;
using QMAPP.MD.Entity.TianJin;
namespace QMAPP.WinForm.Forms.TianJin
{
///
/// 工位终端FIS发货效验功能
/// 创建时间:2012-11-12
/// 创 建 人:pxbibm
/// H1:modified by sun g.q. on 20130330
/// 1)隐藏了rb_hx 和rb_dx,全部根据pFisType判断,生产线的设置使用按钮进行设置;
/// 2)增加 CreatePastecardNo(String lineNo)代替CreatePastecardNo(),贴车单流水号,根据生产线代码生成;
/// 3)校准功能进行了bug修改;
/// 4)20190325移植了成都DCS发运功能,同时保留原有发运,校验信息通过零件规则表判断//gzf。
/// 5)20190325成都存在东西厂情况,且未来要货可能都混线生产,现场操作者要讲求快速切换发货,将单选按钮恢复,且用此过滤发货计划。--gzf
///
public partial class TJFrmPlace : Form
{
#region 常量
private const string DISPLAY_NAME = "工位终端";
private DataTable dt = null;
private DataTable dtmat = null;
private DataTable dtpro = null;
private BindingSource bs;
private bool setRedBackgroudFlag = false;//设置第一次设置背景颜色校验标识
//获取服务代理
QMAPP.ServicesAgent.ServiceAgent _agent = ClientContext.GetServiceAgent();
List _barcodeRules = null;
public delegate void myMethodDelegate();
private string PlaceFirstPositionType = string.Empty;
private string _TJFYPrintName = string.Empty; //打印机名称
#endregion
#region 变量
public string a = "1";
DateTime _dt = DateTime.Now;
//2016-01-07 增加车架的1号位置的扫描校验
private string placeFirstPosition = ""; //1号码标识
private DateTime placeFirstPositionTime = DateTime.MinValue;//获取1号码的时间
int BarcodeTime = 10000;
///
/// 指令二次确认
///
string _CMDConfirm = "";
public string WORKCENTER_CODE = "";//工作重心参数
public string ProMaterial = "";//扫描产品物料信息
#endregion
#region 界面初始化
public TJFrmPlace()
{
InitializeComponent();
PlaceFirstPositionType = System.Configuration.ConfigurationManager.AppSettings["PlaceFirstPositionType"].ToString();
//_barcodeRules = _agent.InvokeServiceFunction>("BarcodeRulesBLL_GetListForSend");
_barcodeRules = _agent.InvokeServiceFunction>(B9BasicService.BarcodeRulesBLL_GetAllList.ToString());
_TJFYPrintName = GetAppConfigValue("FYPrintName"); //查找所有 需要自动填充的工位
}
#endregion
#region 绑定DataGridView
///
/// 绑定DataGridView
///
private DataTable BindDataGridView()
{
#region
return null;
#endregion
}
#endregion
#region 字段
//主键
private string strFiskey;
//大众顺序号
private string strvwseq;
//位置
private string strmouldcode;
//车身号
private string strkin;
//底盘号
private string strvin;
//零件号
private string strprodno;
//总成描述
private string strcarsetdesc_cn;
//上线时间
private string strcp5a;
//车型
private string strlineno;
//扫描状态
private string strscanstat;
int nfindex = 0;
//int ncsindex = 0;
//int rowindex = 0;
///
/// NF贴车单明细列表
///
List nflist = null;
///
/// NCS贴车单明细列表
///
List ncslist = null;
///
/// NF贴车单主键
///
string nfpastcardkey = "";
///
/// 当前guidview行号
///
int dgvrowindex = 0;
///
/// 正确的声音文件路径
///
private string okSoundPath = null;
public string pFisType = "";
///
/// 错误的声音文件路径
///
private string errorSoundPath = null;
#endregion
#region FIS数据列Post
///
/// FIS数据列Post
///
///
///
private void dgvMATChange_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
#region
try
{
if (dgvMATChange.Rows.Count > 0)
{
e.Graphics.DrawString((e.RowIndex + 1).ToString(), dgvMATChange.RowHeadersDefaultCellStyle.Font,
new SolidBrush(dgvMATChange.RowHeadersDefaultCellStyle.ForeColor),
e.RowBounds.Location.X + 15, e.RowBounds.Y + 5);
}
}
catch (Exception ex)
{
//MessageBox.Show(ex.Message);
lberror.Text = ex.Message;
}
#endregion
}
#endregion
#region 获取混线,单线FIS数据
///
/// 获取混线,单线FIS数据
///
///
public void GetInitData()
{
#region
try
{
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
DataTable tbl = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.TJFrmPlaceBLL_GetList.ToString(), pFisType, WORKCENTER_CODE);
tbl.AcceptChanges();
DataTable tbz = new DataTable();
if (tbl.Rows.Count <= 0)
{
DataTable dt = (DataTable)dgvMATChange.DataSource;
if (dt != null)
{
dt.Rows.Clear();
}
}
else
{
dgvMATChange.DataSource = tbl;
}
setRedBackgroudFlag = false;
SetRowColor();
computenfncs();
}
catch (Exception ex)
{
//MessageBox.Show(ex.Message);
lberror.Text = ex.Message;
}
finally
{
}
#endregion
}
#endregion
#region 获取EPasteDetailsCard数据
///
///
///
public void GetInitData2()
{
try
{
dgvNF.DataSource = new List();
nfpastecard = null;
nflist = null;
nfindex = 0;
dgvrowindex = 0;
setRedBackgroudFlag = false;
}
catch (Exception ex)
{
//MessageBox.Show(ex.Message);
lberror.Text = ex.Message;
}
finally
{
}
}
#endregion
#region 设置FIS数据颜色
///
/// 设置FIS数据颜色
///
private void SetRowColor()
{
if (setRedBackgroudFlag == true)
{
//return;
}
//底盘号
int vinNumber = 0;
int lastVinNumber = 0;
int num = 0;
int defaultNum = Convert.ToInt32(QMAPP.WinForm.Common.LocalSetting.Settings["ShowDataCount", "4"]);
for (int i = 0; i < this.dgvMATChange.Rows.Count; i++)
{
vinNumber = Convert.ToInt32(dgvMATChange.Rows[i].Cells["REQUESTID"].Value.ToString());
//vinNumber = Convert.ToInt32(dgvMATChange.Rows[i].Cells["PID"].Value.ToString());
//2016-01-21 wangqingnan 如果行变色则不重新刷颜色
var fispid = dgvMATChange.Rows[i].Cells[PID.Name].Value.ToString();
if (nflist != null && nflist.Exists(p => p.FIS_KEY == fispid))
{
this.dgvMATChange.Rows[i].Cells[clscanstate.Name].Value = "1";
}
//if (this.dgvMATChange.Rows[i].Cells[clscanstate.Name].Value.ToString() == "1")
//{
// this.dgvMATChange.Rows[i].DefaultCellStyle.BackColor = Color.White;
// continue;
//}
//2016-01-21 wangqingnan 如果行变色则不重新刷颜色
//int defaultNum = Convert.ToInt32(QM.Config.CustomConfig.GetItem("ShowDataCount"));
if (num == 0)
{
this.dgvMATChange.Rows[i].DefaultCellStyle.BackColor = Color.Yellow;
if ((i + 1) % defaultNum == 0)
{
num = 1;
}
}
else
{
this.dgvMATChange.Rows[i].DefaultCellStyle.BackColor = Color.YellowGreen;
if ((i + 1) % defaultNum == 0)
{
num = 0;
}
}
//2016-10-31 闫永刚 如果出现该底盘号与上一条底盘号间断的情况,
//设置当前底盘号的颜色为红色
if (lastVinNumber > 0)
{
if ((vinNumber - lastVinNumber) > 1)
{
this.dgvMATChange.Rows[i - 1].DefaultCellStyle.BackColor = Color.Red;
this.dgvMATChange.Rows[i].DefaultCellStyle.BackColor = Color.Red;
setRedBackgroudFlag = true;
}
}
lastVinNumber = vinNumber;
}
if (dgvMATChange.RowCount > 0)
{
dgvMATChange.FirstDisplayedScrollingRowIndex = nfindex - nfindex % 4;
}
dgvMATChange.Refresh();
dgvMATChange.ClearSelection();
txtCode.Focus();
}
#endregion
#region 处理扫描条码框设置焦点
///
/// 处理扫描条码框设置焦点
///
private void ArragetxtCode()
{
txtCode.Text = string.Empty;
//Activates the control.
txtCode.Select();
//Sets input focus to the control.
txtCode.Focus();
}
#endregion
#region 加载画面
///
/// 加载画面
///
///
///
private void FrmElevateRequest_Load(object sender, EventArgs e)
{
try
{
timeRefew.Enabled = true;
//UserBuffer.Interval = CtlApp.GetInterval(QM.Convvvvvvvvvvvn'n'n'n'n'n'n'n'n'n'n'n'n'n'n'n'n'n'nfig.CustomConfig.GetItem("RefreshTime"));
UserBuffer.Interval = CtlApp.GetInterval(QMAPP.WinForm.Common.LocalSetting.Settings["RefreshTime","20"]);
timeRefew.Interval = UserBuffer.Interval;
//BarcodeTime = int.Parse(QM.Config.CustomConfig.GetItem("BarcodeTime"));
//BarcodeTime = int.Parse(QMAPP.WinForm.Common.LocalSetting.Settings["BarcodeTime","1"]);
okSoundPath = System.Configuration.ConfigurationManager.AppSettings["SaveFilePath"] + "Sound\\" + PlaySoundConst.strSoundOk;
errorSoundPath = System.Configuration.ConfigurationManager.AppSettings["SaveFilePath"] + "Sound\\" + PlaySoundConst.strSoundNg;
//隐藏了rb_hx 和rb_dx,全部根据pFisType判断,生产线的设置使用按钮进行设置;
//pFisType = "01";
//pFisType = QM.Config.CustomConfig.GetItem("FlashProCode");
//pFisType = QMAPP.WinForm.Common.LocalSetting.Settings["FlashProCode","01"];
pFisType = QMAPP.WinForm.Common.LocalSetting.Settings["FlashProCode", ""];
if (!string.IsNullOrEmpty(pFisType))
{
if (pFisType.Equals("01"))
{
rb_hx.Checked = true;
}
else if(pFisType.Equals("02"))
{
rb_dx.Checked = true;
}
else if (pFisType.Equals("03"))
{
ra_hx.Checked = true;
}
else
{
ra_dx.Checked = true;
}
}
//发运信息直接用单选按钮过滤,工作中心字段用作打印功能格式使用
//WORKCENTER_CODE = QMAPP.WinForm.Common.LocalSetting.Settings["PlantNameConfig", ""];
WORKCENTER_CODE = "IPFY" + pFisType;
//发运框设置
InitContainer();
GetInitData();
//SetShowData();
//computenfncs();//lable1原有copy代码 这个功能注释掉了 崔法宝-20170905调整
dgvMATChange.ClearSelection();
dgvNF.AutoGenerateColumns = false;
SetPastNOConfirm(0);
GetLastPastCard();
//lblLastPastNO.Text = "";
}
catch (Exception ex)
{
//MessageBox.Show(ex.Message);
lberror.Text = ex.Message;
}
finally
{
ArragetxtCode();
dgvMATChange.ClearSelection();
}
}
#endregion
#region 获取上一条发运单信息
///
/// 获取上一条发运单信息
///
private void GetLastPastCard()
{
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
var lastpastcard= agent.InvokeServiceFunction("TJFrmPlaceBLL_GetLastPastCard", pFisType);
if (lastpastcard != null)
{
lblLastPastNO.Text = lastpastcard.PASTECARDNO;
}
}
#endregion
#region 设置贴车单确认状态
///
/// 设置贴车单确认状态
///
/// 0:未确认 1:确认OK 2:确认失败
private void SetPastNOConfirm(int state)
{
switch (state)
{
case 0:
{
pbPastNoConfirmed.Enabled = false;
pbPastNoConfirmed.Image = global::QMAPP.WinForm.Resource1.help;
break;
}
case 1:
{
pbPastNoConfirmed.Enabled = true;
pbPastNoConfirmed.Image = global::QMAPP.WinForm.Resource1.ok;
break;
}
case 2:
{
pbPastNoConfirmed.Enabled = false;
pbPastNoConfirmed.Image = global::QMAPP.WinForm.Resource1.cancel;
break;
}
default:
{
pbPastNoConfirmed.Enabled = false;
pbPastNoConfirmed.Image = global::QMAPP.WinForm.Resource1.stop;
break;
}
}
}
#endregion
#region 贴车单查询功能
///
/// 贴车单查询功能
///
///
///
private void btnSearch_Click(object sender, EventArgs e)
{
TJFrmItemList frm = new TJFrmItemList();
frm.ShowDialog();
txtCode.Focus();
}
#endregion
#region 实现效验功能
///
/// 实现效验功能
///
///
///
private void btnJZ_Click(object sender, EventArgs e)
{
try
{
if (MessageBox.Show("您确定要挂起当前计划吗吗?", "挂起提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
if (nfindex > 0)
{
MessageBox.Show("发运已开始扫描无法进行计划挂起!", "挂起提示");
return;
}
List ids = new List();
foreach (System.Windows.Forms.DataGridViewRow row in dgvMATChange.SelectedRows)
{
//var SS = row..DataBoundItem;
var pid = row.Cells["PID"].Value.ToString();
var state = row.Cells["STATE"].Value.ToString();
if (int.Equals(state, 1))
{
MessageBox.Show("只可挂起未扫描的计划!");
return;
}
ids.Add(pid);
}
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.TJFrmPlaceBLL_UpdateWorkOrderState.ToString(), ids);
GetInitData();
//_agent.InvokeServiceFunction(B9IPCService.WorkOrderBLL_CancelSuspend.ToString(), ids);
//if (dgvMATChange.Rows.Count > 0)
//{
// int i = dgvMATChange.CurrentRow.Index;
// string strvwseq = dgvMATChange.Rows[i].Cells["REQUESTID"].Value.ToString();
// //上线时间
// string strCP5A = dgvMATChange.Rows[i].Cells["CP5A"].Value.ToString();
// //BllFisOrder bllFisOrder = new BllFisOrder();
// //bllFisOrder.UpdateFisOrder(strvwseq, strCP5A);
// QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
// agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_UpdateFisOrder.ToString(), strvwseq, strCP5A, WORKCENTER_CODE);
// GetInitData();
//}
}
}
catch (Exception ex)
{
}
finally
{
txtCode.Focus();
}
}
#endregion
#region 获取FIS数据
///
/// 获取FIS数据
///
///
///
private void btnGetFisData_Click(object sender, EventArgs e)
{
if (dgvNF.Rows.Count == 0)
{
GetInitData();
//computenfncs();
}
}
#endregion
#region 手动刷新
///
/// 手动刷新
///
///
///
private void btnRef_Click(object sender, EventArgs e)
{
GetInitData();
}
#endregion
#region 创建贴车单号
//EPasteCard nfpastecard = null;
///
/// 创建贴车单号
/// 贴车单号的规则生成贴车单号,格式为“FB”(2位)+日期(8位,20121008)+流水号(4位);
///
///
private string CreatePastecardNo()
{
#region
//BllFisOrder bllFisOrder = new BllFisOrder();
string strdate = DateTime.Now.ToString("yyyyMMdd");
// DataTable tbl = bllFisOrder.GetPastecardNo(DateTime.Now.ToShortDateString());
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
DataTable tbl = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetPastecardNo.ToString(), DateTime.Now.ToShortDateString());
string strindex = tbl.Rows[0][0].ToString().PadLeft(4, '0');
string pastecardno = string.Format("FB{0}{1}", strdate, strindex);
return pastecardno;
#endregion
}
#endregion
#region 创建贴车单号(外来)
///
/// 创建贴车单号
/// 贴车单号的规则生成贴车单号,格式为“生产线代码”(2位)+日期(8位,20121008)+流水号(4位);
/// 20190329--贴车单号的规则生成贴车单号,格式为“生产线代码”(工作中心)+日期(8位,20121008)+流水号(4位)
///
///
private string CreatePastecardNo(String lineNo)
{
#region
String prefix = lineNo;
//BllFisOrder bllFisOrder = new BllFisOrder();
//2016-10-30闫永刚获取贴车单号修改
// DataTable dt = bllFisOrder.GetPastecardIndex();
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
//DataTable dt = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetPastecardIndex.ToString());
DataTable dt = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetDaspssteCarIndexByPlanName.ToString(), prefix);
string PASTECARDNO = "";
string OLD_PASTECARDNO = "";
string NEW_PASTECARDNO = "";
if (dt.Rows.Count == 0)
{
PASTECARDNO =lineNo+ DateTime.Now.ToString("yyyyMMdd") + "0001";
nfpastecard.PASTECARDNO = PASTECARDNO;
int delResult = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_InsertDaspssteCarIndexByPlanName.ToString(), nfpastecard);
}
else
{
foreach (DataRow dr in dt.Rows)
{
//OLD_PASTECARDNO = dr["PASTECARDNO"].ToString();
//int Addvalue = Convert.ToInt32(OLD_PASTECARDNO.Substring(OLD_PASTECARDNO.Length - 1, 1)) + 1;
//NEW_PASTECARDNO = OLD_PASTECARDNO.Substring(lineNo.Length, OLD_PASTECARDNO.Length - lineNo.Length - 1) + Addvalue.ToString();
//20190314
PASTECARDNO = dr["PASTECARDNO"].ToString();
if ((Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString().Length < 4)
{
int num = 4 - (Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString().Length;
string value = (Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString();
string sumValue = "";
for (var i = 0; i < num; i++)
{
sumValue = sumValue + "0";
}
if (PASTECARDNO.Substring(lineNo.Length, PASTECARDNO.Length - lineNo.Length - 4).ToString() == DateTime.Now.ToString("yyyyMMdd"))
{
PASTECARDNO = PASTECARDNO.Substring(lineNo.Length, PASTECARDNO.Length - lineNo.Length - 4) + sumValue + value;
}
else
{
PASTECARDNO = DateTime.Now.ToString("yyyyMMdd") + "0001";
}
}
else
{
if (PASTECARDNO.Substring(lineNo.Length, 8).ToString() == DateTime.Now.ToString("yyyyMMdd"))
{
PASTECARDNO = PASTECARDNO.Substring(lineNo.Length, PASTECARDNO.Length - lineNo.Length - 2) + (Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString();
}
else
{
PASTECARDNO = DateTime.Now.ToString("yyyyMMdd") + "0001";
}
}
//nfpastecard.PASTECARDNO = PASTECARDNO;
//nfpastecard.OPERATOR = ClientContext.LoginInfo.UserName.ToString();
}
PASTECARDNO = lineNo + PASTECARDNO;
}
return PASTECARDNO;
#region XXX
//string pasteCardIndex = "";
//DateTime updateTime;
//foreach (DataRow dr in dt.Rows)
//{
// string lineNoRow = dr["PASTECARDNO"].ToString().Substring(0, 2);
// if (lineNo == lineNoRow)
// {
// pasteCardIndex = dr["PASTECARDNO"].ToString();
// updateTime = Convert.ToDateTime(dr["PASTECARDDATE"]);
// }
//}
//string strdate = DateTime.Now.ToString("yyyyMMdd");
//string strindex = "";
//if (pasteCardIndex.Substring(2, 8) == strdate)
//{
// strindex = (Convert.ToInt32(pasteCardIndex.Substring(10, 4)) + 1).ToString().PadLeft(4, '0');
//}
//else
//{
// strindex = "0001";
//}
//原来获取贴车单方式
//string strdate = DateTime.Now.ToString("yyyyMMdd");
//DataTable tbl = bllFisOrder.GetPastecardNo(DateTime.Now.ToShortDateString(), prefix);
//string strindex = tbl.Rows[0][0].ToString().PadLeft(4, '0');
//string pastecardno = string.Format("{0}{1}{2}", prefix, strdate, strindex);
//return pastecardno;
#endregion
#endregion
}
#endregion
#region 删除已经打印过的贴车单FIS列表
///
/// 删除已经打印过的贴车单FIS列表
///
///
///
private void DGVRemoveRow(List pnflist, ref List pnflist2)
{
#region
if (pnflist2 != null)
{
for (int rowindex = 0; rowindex < pnflist2.Count; rowindex++)
{
string tempfiskey2 = pnflist2[rowindex].FIS_KEY;
for (int rowindex1 = 0; rowindex1 < dgvMATChange.Rows.Count; rowindex1++)
{
string tempFiskey1 = dgvMATChange.Rows[rowindex1].Cells["clFiskey"].Value.ToString();
if (tempFiskey1 == tempfiskey2)
{
DataGridViewCellStyle ds = new DataGridViewCellStyle();
ds.BackColor = Color.Green;
this.dgvMATChange.Rows[rowindex1].DefaultCellStyle = ds;
//当删除了满6个的记录后,另一个数据集的行号需要重新排列。
dgvMATChange.Rows[rowindex1].Cells[clscanstate.Name].Value = "1";
pnflist2[rowindex].DGVROWINDEX = rowindex1;
break;
}
}
}
}
#endregion
}
#endregion
#region NF贴车单手动打印功能
///
/// NF贴车单手动打印功能
///
///
///
private void btnPrint_NF_Click(object sender, EventArgs e)
{
#region
bool isprint = false;
try
{
if (nflist != null)
{
if (MessageBox.Show("您确定要提交并且打印数据吗?", "信息提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
//当点击了确定,则会执行删除操作
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
DataTable tbl = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.TJFrmPlaceBLL_GetDaspssteCarIndexByPlanName.ToString());
if (tbl.Rows.Count > 0)
{
nfpastecard.PASTECARDNO = tbl.Rows[0][0].ToString();
}
else
{
MessageBox.Show("无法打印!");
}
EFailLog log = new EFailLog();
log.TID = Guid.NewGuid().ToString();
log.FCT_DATE = DateTime.Now;
log.FCT_NO = nfpastecard.PASTE_CARD_KEY;
log.FCT_OPER = UserBuffer.UserCode;
log.FCT_OPERTYPE = 1;
log.FCT_REASON = "NF手动打印贴车单操作";
nfpastecard.FailLog = log;
string strprodtype = "";
//#region "隐藏了rb_hx 和rb_dx,全部根据pFisType判断,生产线的设置使用按钮进行设置"
if (pFisType == "01")
{
strprodtype = "( 左 )";
}
else if (pFisType == "02")
{
strprodtype = "( 右 )";
}
else if (pFisType == "03")
{
strprodtype = "( 前 )";
}
else if (pFisType == "04")
{
strprodtype = "( 后 )";
}
//提交数据处理
foreach (DataRow dr in tbl.Rows)
{
string PASTECARDNO = dr["PASTECARDNO"].ToString();
if (PASTECARDNO.Substring(2, 8).ToString() == DateTime.Now.ToString("yyyyMMdd"))
{
if ((Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString().Length < 4)
{
int num = 4 - (Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString().Length;
string value = (Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString();
string sumValue = "";
for (var i = 0; i < num; i++)
{
sumValue = sumValue + "0";
}
if (PASTECARDNO.Substring(2, PASTECARDNO.Length - 6).ToString() == DateTime.Now.ToString("yyyyMMdd"))
{
PASTECARDNO = PASTECARDNO.Substring(2, PASTECARDNO.Length - 6) + sumValue + value;
}
else
{
PASTECARDNO = DateTime.Now.ToString("yyyyMMdd") + "0001";
}
}
else
{
if (PASTECARDNO.Substring(2, PASTECARDNO.Length - 6).ToString() == DateTime.Now.ToString("yyyyMMdd"))
{
PASTECARDNO = PASTECARDNO.Substring(2, PASTECARDNO.Length - 6) + (Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString();
}
else
{
PASTECARDNO = DateTime.Now.ToString("yyyyMMdd") + "0001";
}
}
}
else
{
PASTECARDNO = DateTime.Now.ToString("yyyyMMdd") + "0001";
}
nfpastecard.PASTECARDNO = PASTECARDNO;
nfpastecard.OPERATOR = ClientContext.LoginInfo.UserName.ToString();
// nfpastecard.
}
int rowindex = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.TJFrmPlaceBLL_AddNewPasteCard.ToString(), nfpastecard);
// 打印处理
TJFrmCarCardPrintShow frm = new TJFrmCarCardPrintShow(nfpastecard, strprodtype, "手动");
frm.Owner = this;
frm.ShowDialog();
isprint = frm.isprint;
}
}
else
{
MessageBox.Show("无打印数据!");
}
}
catch (Exception ex)
{
}
finally
{
if (isprint)
{
nflist = null;
txtCode.Focus();
//2016-01-07 增加1号位校验 - 清空1号位
this.placeFirstPosition = "";
this.placeFirstPositionTime = DateTime.MinValue;
//2016-01-07 增加1号位校验
}
}
#endregion
}
#endregion
#region 打印1号位的条码
///
/// 打印1号位的条码
///
///
///
private void btnFirstPlace_Click(object sender, EventArgs e)
{
this.dgvMATChange.Rows[0].DefaultCellStyle.BackColor = Color.White;
#region 打印
DCS.Common.PrintCode printFun = new DCS.Common.PrintCode();
//执行打印
printFun.PinrtFirstPlaceHU();
#endregion
}
#endregion
#region 判断当前扫描过的数据集合中是否有相同条码
TJEPasteCard ncspastecard = null;
///
/// 判断当前扫描过的数据集合中是否有相同条码
/// 与右侧列表中校验,条码是否扫描过
///
/// 扫描的条码
private bool CheckDataSet(string strbarcode)
{
String teshucode = getTeShuBarcode(barcodeidentification);
if (nfpastecard != null)
{
foreach (TJEPasteDetailsCard pe in nfpastecard.DetailsCardlist)
{
if (teshucode == strbarcode)
{
continue;
}
if (strbarcode == pe.SANBARCODE)
{
Alert("条码重复:已扫描过的条码,不可以重复扫描。");
ArragetxtCode();
return false;
}
}
}
if (ncspastecard != null)
{
foreach (TJEPasteDetailsCard pe2 in ncspastecard.DetailsCardlist)
{
if (teshucode == strbarcode)
{
continue;
}
if (strbarcode == pe2.SANBARCODE)
{
Alert("条码重复:已扫描过的条码,不可以重复扫描。");
ArragetxtCode();
return false;
}
}
}
return true;
}
#endregion
#region 创建NF的贴车单以及明细(外来件)
///
/// 创建NF的贴车单以及明细(NF开头)
///
private void CreateNFPaste__()
{
#region
if (nfindex == 0)
{
nflist = new List();
nfpastcardkey = Guid.NewGuid().ToString();
nfpastecard = new TJEPasteCard();
nfpastecard.DetailsCardlist = new List();
nfpastecard.PASTE_CARD_KEY = nfpastcardkey;
//nfpastecard.PLANTNAME = WORKCENTER_CODE.ToString();
nfpastecard.PASTECARDNO = "";
nfpastecard.PRODUCTIONNAME = pFisType;
nfpastecard.PASTECARDDATE = DateTime.Now.ToString();
nfpastecard.OPERATOR = UserBuffer.UserCode;
nfpastecard.CREATETIME = DateTime.Now.ToString();
}
TJEPasteDetailsCard pastdetail = new TJEPasteDetailsCard();
pastdetail.PASTEDETAILED_CARD_KEY = Guid.NewGuid().ToString();
pastdetail.FIS_KEY = strFiskey;
pastdetail.PASTE_CARD_KEY = nfpastcardkey;
pastdetail.SANBARCODE = txtCode.Text.ToString();
pastdetail.SCANDATE = DateTime.Now.ToString();
pastdetail.PRODNO = strprodno;
pastdetail.CARSETDESC_CN = strcarsetdesc_cn;
pastdetail.VIN = strvin;
pastdetail.VWSEQ = strvwseq;
pastdetail.CP5A = strcp5a;
pastdetail.DGVROWINDEX = dgvrowindex;
pastdetail.LINENO = strlineno;
nfpastecard.DetailsCardlist.Add(pastdetail);
nflist.Add(pastdetail);
dgvNF.DataMember = null;
dgvNF.DataSource = nflist;
strprodno = "";
nfindex++;
int setdefaultSum = Convert.ToInt32(QMAPP.WinForm.Common.LocalSetting.Settings["ShowDataCount", ""]);
if (nfindex == setdefaultSum)
{
EFailLog log = new EFailLog();
log.TID = Guid.NewGuid().ToString();
log.FCT_DATE = DateTime.Now;
log.FCT_NO = nfpastecard.PASTE_CARD_KEY;
log.FCT_OPER = UserBuffer.UserCode;
log.FCT_OPERTYPE = 1;
log.FCT_REASON = "NF贴车单自动打印操作";
//nfpastecard.PLANTNAME = WORKCENTER_CODE.ToString();
nfpastecard.OPERATOR = ClientContext.LoginInfo.UserName.ToString();
nfpastecard.PASTECARDNO = CreatePastecardNo(WORKCENTER_CODE.ToString());
nfpastecard.DetailsCardlist = nflist;
nfpastecard.FailLog = log;
nfindex = 0;
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
int rowindex = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.TJFrmPlaceBLL_AddNewPasteCard.ToString(), nfpastecard);
//BllFisOrder bllFisOrder = new BllFisOrder();
//int rowindex = bllFisOrder.AddPasteCard(nfpastecard);
TJPrintPasteCard prin = new TJPrintPasteCard();
string strprodtype = "";
//#region "隐藏了rb_hx 和rb_dx,全部根据pFisType判断,生产线的设置使用按钮进行设置"
if (pFisType == "01")
{
strprodtype = "( 左 )";
}
else if (pFisType == "02")
{
strprodtype = "( 右 )";
}
else if (pFisType == "03")
{
strprodtype = "( 前 )";
}
else if (pFisType == "04")
{
strprodtype = "( 后 )";
}
prin.Print(rowindex, nfpastecard, strprodtype);
ClearContainer();
GetInitData();
DGVRemoveRow(nflist, ref ncslist);
dgvNF.DataSource = new List();
nfpastecard = null;
nflist = null;
nfindex = 0;
dgvrowindex = 0;
computenfncs();
GetLastPastCard();
SetPastNOConfirm(0);
//2016-01-07 增加1号位校验 - 清空1号位
this.placeFirstPosition = "";
this.placeFirstPositionTime = DateTime.MinValue;
//2016-01-07 增加1号位校验
}
#endregion
}
#endregion
#region 计算NF,NCS数量----每条产线的数量
///
/// 计算NF,NCS数量
///
private void computenfncs()
{
//BindingSource bin = (BindingSource)dgvMATChange.DataSource;
//DataTable tbl = (DataTable)dgvMATChange.DataSource;
//DataRow[] nfrows = tbl.Select("LINENO='NF'");
//DataRow[] ncsrows = tbl.Select("LINENO='NCS'");
//DataRow[] ncsnfrows = tbl.Select("LINENO='NCSNF'");
//DataRow[] ncsgprows = tbl.Select("LINENO='NCSGP'");
//lblCount.Text = "NCS: " + ncsrows.Length + " NF: " + nfrows.Length + " NCSNF: " + ncsnfrows.Length + " NCSGP: " + ncsgprows.Length;
}
#endregion
private void Alert(string message, bool openConfirmDialog = true)
{
PlaySound.PlaySounds.Play(@errorSoundPath);
lberror.Text = message;
if (openConfirmDialog
&& string.Equals(QMAPP.WinForm.Common.LocalSetting.Settings["AlertConfirmEnable", "0"], "1"))
{
Common.frmAlertConfirm alertconfirm = new Common.frmAlertConfirm(message, "85010800");
alertconfirm.StartPosition = FormStartPosition.CenterScreen;
alertconfirm.ShowDialog();
}
}
#region 与FIS数据匹配
///
/// 与FIS数据匹配
///
private void FISDataCompare(string Code,string MATERIAL_CODE,string MOULD_CODE)
{
int temprowindex = 0;
int nflistCount = 0;
if (nflist != null && nflist.Count > 0)
{
nflistCount = nflist.Count;
}
int ncslistCount = 0;
if (ncslist != null && ncslist.Count > 0)
{
ncslistCount = ncslist.Count;
}
temprowindex = nflistCount + ncslistCount;
strprodno = dgvMATChange.Rows[temprowindex].Cells["MATERIAL_CODE"].Value.ToString();
string pstrprodcno = strprodno;
string strmoulecode = dgvMATChange.Rows[temprowindex].Cells["MOULD_CODE"].Value.ToString();
// Getmoulecodecode(strmoulecode);
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
//2.判断成品
//Product statusRuslt = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetProductByAssembleCode.ToString(), Code);
if (strmoulecode != MOULD_CODE)
{
SetContainerItem(nfindex, false);
Alert("扫描的成品位置与计划位置不符!");
txtCode.Text = "";
txtCode.Focus();
return;
}
if (MATERIAL_CODE != pstrprodcno)
{
SetContainerItem(nfindex, false);
Alert("扫描的成品零件号与计划零件号不符!");
txtCode.Text = "";
txtCode.Focus();
return;
}
DataTable tblbarcode = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.TJFrmPlaceBLL_ExistBarcode.ToString(), BarcodeTime, Code);
if (tblbarcode.Rows.Count == 0)
{
for (; temprowindex < dgvMATChange.Rows.Count; temprowindex++)
{
//主键
strFiskey = dgvMATChange.Rows[temprowindex].Cells["PID"].Value.ToString();
//大众顺序号
strvwseq = dgvMATChange.Rows[temprowindex].Cells["REQUESTID"].Value.ToString();
//位置
strmouldcode = dgvMATChange.Rows[temprowindex].Cells["MOULD_CODE"].Value.ToString();
//零件号
strprodno = dgvMATChange.Rows[temprowindex].Cells["MATERIAL_CODE"].Value.ToString();
//总成描述
strcarsetdesc_cn = dgvMATChange.Rows[temprowindex].Cells["MATERIAL_NAME"].Value.ToString();
//车型
strlineno = dgvMATChange.Rows[temprowindex].Cells["LINENO"].Value.ToString();
strvin = Code;
//扫描状态
strscanstat = dgvMATChange.Rows[temprowindex].Cells["STATE"].Value.ToString();
dgvrowindex = temprowindex;
if (strscanstat == "0")
{
strprodno = strprodno.ToString().Trim();
pstrprodcno = pstrprodcno.ToString().Trim();
//if (strprodno == pstrprodcno)
if (pstrprodcno.ToUpper().Replace(".", "").Contains(strprodno.ToUpper().Replace(".", "")))
{
this.dgvMATChange.Rows[temprowindex].DefaultCellStyle.BackColor = Color.White;
dgvMATChange.Rows[temprowindex].Cells["STATE"].Value = "1";
temprowindex = dgvMATChange.Rows.Count;
}
else
{
SetContainerItem(nfindex, false);
Alert("条码错误:条码的零件号与FIS队列零件号不符合。");
return;
}
}
else
{
SetContainerItem(nfindex, false);
Alert("条码错误:条码已扫描或车型不符合。");
return;
}
}
}
else
{
Alert("扫描条码重复,请重新扫描。");
return;
}
CreateNFPaste(Code); //创建NF的贴车单以及明细
SetContainerItem(nfindex, true);
if (dgvMATChange.RowCount > 0)
{
dgvMATChange.FirstDisplayedScrollingRowIndex = nfindex - nfindex % 4;
}
lberror.Text = "";
}
#endregion
#region 扫描条码时触发事件
/////
///// 扫描条码时触发事件
/////
/////
///// 崔法宝20170906
private void txtCode_KeyDown(object sender, KeyEventArgs e)
{
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
string inputstring = "";
try
{
if (e.KeyCode != Keys.Enter)
{
return;
}
inputstring = txtCode.Text.ToUpper();
this.lberror.Text = null;
if (inputstring.Substring(0, 4) == "FYJH")
{
//数量
int defaultNum = Convert.ToInt32(QMAPP.WinForm.Common.LocalSetting.Settings["ShowDataCount"]);
DialogResult dr = MessageBox.Show("是否确认创建计划?", "提示");
if (dr == DialogResult.OK)
{
//物料
var mach = inputstring.Substring(4, inputstring.Length - 4);
var plan = new TJOrderPlan();
plan.PLAN_DATE = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
plan.QTY = defaultNum/2;
if (mach.Substring(0, 3) == "770")
plan.LINENO = "770B";
else if(mach.Substring(0, 3) == "018")
plan.LINENO = "018D";
else if(mach.Substring(0, 3) == "493")
plan.LINENO = "493D";
if (plan.LINENO == "770B")
{
foreach (var s in "R,F".Split(','))
{
plan.PID = Guid.NewGuid().ToString();
plan.MATERIAL_CODE = mach.Substring(0, mach.Length - 1) + s + mach.Substring(mach.Length - 1, 1);
foreach (var rule in _barcodeRules)
{
if (System.Text.RegularExpressions.Regex.IsMatch(plan.MATERIAL_CODE + "1", rule.REGEX))
{
plan.MATERIAL_CODE = rule.MATERIAL_CODE;
}
}
var RESULT = agent.InvokeServiceFunction>("TJDoorPlankPlanBLL_Insert", plan);
if (RESULT.IsSuccess == true)
{
agent.InvokeServiceFunction>("TJDoorPlankPlanBLL_PutOut", plan.PID);
}
}
}
else
{
foreach (var s in "L,R".Split(','))
{
plan.PID = Guid.NewGuid().ToString();
//plan.MATERIAL_CODE = mach.Substring(0, 4)+"-"+ mach.Substring(4,3)+"-" + mach.Substring(mach.Length - 1, 1) + s;
plan.MATERIAL_CODE = mach.Substring(0, mach.Length - 1) + mach.Substring(mach.Length - 1, 1) + s;
foreach (var rule in _barcodeRules)
{
if (System.Text.RegularExpressions.Regex.IsMatch(plan.MATERIAL_CODE + "1", rule.REGEX))
{
plan.MATERIAL_CODE = rule.MATERIAL_CODE;
}
}
var RESULT = agent.InvokeServiceFunction>("TJDoorPlankPlanBLL_Insert", plan);
if (RESULT.IsSuccess == true)
{
agent.InvokeServiceFunction>("TJDoorPlankPlanBLL_PutOut", plan.PID);
}
}
}
txtCode.Text = "";
txtCode.Focus();
return;
}
else
{
txtCode.Text = "";
txtCode.Focus();
return;
}
}
#region 一号位校验是否扫描校验
//2016-01-07 增加1号位校验
if (this.dgvNF.Rows.Count == 0) //第一个码必须先扫描1号位
{
string placeCode = txtCode.Text.Trim();
if (placeCode.Equals(System.Configuration.ConfigurationManager.AppSettings["PlaceFirstPositionCode"].ToString()))
{
this.placeFirstPosition = placeCode;
this.placeFirstPositionTime = DateTime.Now;
this.txtCode.Text = "";
//处理条码扫描文本框
ArragetxtCode();
return;
}
}
#endregion
#region 请先扫描1号位
if (string.IsNullOrEmpty(this.placeFirstPosition))
{
this.placeFirstPosition = "";
this.txtCode.Text = "";
lberror.Text = "请先扫描1号位!";
return;
}
#endregion
#region 计划外发运
if (inputstring.Equals("FIRSTPOSITIONTYPE"))
{
if (PlaceFirstPositionType == "False")
{
PlaceFirstPositionType = "True";
lberror.Text = "关闭验证!";
}
else
{
PlaceFirstPositionType = "False";
lberror.Text = "打开验证!";
}
this.txtCode.Text = "";
//处理条码扫描文本框
ArragetxtCode();
return;
}
//inputstring += DateTime.Now.ToString("yyyyMMddHHmmssfff");
if (PlaceFirstPositionType == "True")
{
#region 校验是否有重复的扫过的条码
if (dgvNF.Rows.Count > 0)
{
for (var i = 0; i < dgvNF.Rows.Count; i++)
{
if (dgvNF.Rows[i].Cells[CODE_NF.Name].Value.ToString().ToUpper() == inputstring)
{
SetContainerItem(nfindex+1, false);
Alert("该条码已扫描!");
txtCode.Text = "";
txtCode.Focus();
return;
}
}
}
string msgs = "";
//CheckDataBase(inputstring,ref msgs); //检查T_PP_TJFY_WORKORDER 是否存在条码记录
//if (!string.IsNullOrEmpty(msgs))
//{
// Alert("该条码已扫描!");
// txtCode.Text = "";
// txtCode.Focus();
// return;
//}
foreach (var rule in _barcodeRules)
{
if (System.Text.RegularExpressions.Regex.IsMatch(inputstring, rule.REGEX))
{
strprodno = rule.MATERIAL_CODE;
strmouldcode = rule.REMARK;
strcarsetdesc_cn = rule.MATERIAL_TYPE;
}
}
List tbl = agent.InvokeServiceFunction>(QMAPP.ServicesAgent.FrmPlaceManage.TJDoorPlankPlanBLL_GetListMachine.ToString(), strprodno);
if (tbl.Count == 1)
strcarsetdesc_cn = tbl[0].MATERIALNAME;
strvin = inputstring;
CreateNFPaste(inputstring); //创建NF的贴车单以及明细
//CreateNFPaste__();
SetContainerItem(nfindex, true); //变更右下角位置颜色
txtCode.Text = "";
txtCode.Focus();
return;
#endregion
}
#endregion
#region fis区是否有记录
if (dgvMATChange.Rows.Count == 0)
{
Alert("当前没有发运计划,请先下计划后再扫描!");
ArragetxtCode();
return;
}
#endregion
#region FIS区域数据全部扫描完成,请获取数据后再扫描
if (dgvNF.Rows.Count >= dgvMATChange.Rows.Count)
{
Alert("当前计划数据全部扫描完成,请下达计划后再扫描!");
ArragetxtCode();
return;
}
#endregion
#region 校验位计算
if (txtCode.Text.StartsWith("052"))
{
string codepart = txtCode.Text.Substring(0, txtCode.Text.Length - 1).ToUpper();
string checksum = txtCode.Text.Substring(txtCode.Text.Length-1,1).ToUpper();
if (!string.Equals(checksum, CalculateChecksum(codepart)))
{
Alert("条码错误:总成条码校验位错误!");
ArragetxtCode();
return;
}
}
#endregion
#region 判断扫描条形码是否存在 获取扫描条码
string Code = txtCode.Text.Trim().ToUpper();
#region 校验是否有重复的扫过的条码
if (dgvNF.Rows.Count > 0)
{
for (var i = 0; i < dgvNF.Rows.Count; i++)
{
if (dgvNF.Rows[i].Cells[CODE_NF.Name].Value.ToString().ToUpper() == Code)
{
SetContainerItem(nfindex + 1, false);
Alert("该条码已扫描!");
txtCode.Text = "";
txtCode.Focus();
return;
}
}
}
#region 底盘号间隔校验
//2016-10-31 闫永刚
int scanSum = dgvNF.Rows.Count;
int lastvinNumber = 0;
int vinNumber = 0;
if (scanSum > 0)
{
lastvinNumber = Convert.ToInt32(dgvMATChange.Rows[scanSum - 1].Cells["REQUESTID"].Value.ToString());
vinNumber = Convert.ToInt32(dgvMATChange.Rows[scanSum].Cells["REQUESTID"].Value.ToString());
}
//if ((vinNumber - lastvinNumber) > 1)
//{
// var dresult = MessageBox.Show("出现顺序号间隔,是否继续发货?", "提示", MessageBoxButtons.YesNo);
// if (dresult == DialogResult.No)
// {
// ArragetxtCode();
// return;
// }
//}
#endregion
#region 判断当前扫描过的数据集合中是否有相同条码
//判断当前扫描过的数据集合中是否有相同条码
string msg = "";
//CheckDataBase(Code,ref msg);
//if (!string.IsNullOrEmpty(msg))
//{
// Alert("该条码已扫描!");
// txtCode.Text = "";
// txtCode.Focus();
// return;
//}
#endregion
#endregion
//规则
bool signal = false;
string MOULD_CODE = "";
foreach (var rule in _barcodeRules)
{
if (System.Text.RegularExpressions.Regex.IsMatch(Code, rule.REGEX))
{
signal = true;
ProMaterial = rule.MATERIAL_CODE;
MOULD_CODE = rule.REMARK;
}
}
if (signal != false)
{
#region 校验是否有重复的扫过的条码
//------------------校验是否有重复的扫过的条码------
if (dgvNF.Rows.Count > 0)
{
for (var i = 0; i < dgvNF.Rows.Count; i++)
{
if (dgvNF.Rows[i].Cells[CODE_NF.Name].Value.ToString() == Code)
{
SetContainerItem(nfindex + 1, false);
Alert("该条码已扫描!");
txtCode.Text = "";
txtCode.Focus();
return;
}
}
}
//-------------------------End-----------
#endregion
#region 4.与FIS数据匹配
//4.与FIS数据匹配 匹配到计划后 开始生成贴车单
FISDataCompare(Code, ProMaterial, MOULD_CODE);
#endregion
}
else
{
Alert("条码正则未查询到零件号!");
txtCode.Text = "";
txtCode.Focus();
return;
}
#endregion
#region 处理条码扫描文本框
ArragetxtCode();
#endregion
txtCode.Text = "";
txtCode.Focus();
}
catch (Exception ex)
{
//MessageBox.Show(ex.Message);
lberror.Text = ex.Message;
}
finally
{
if (!string.IsNullOrWhiteSpace(inputstring))
WriteLog.WriteShipmentLog(string.Format("{0}\t{1}\t{2}", DateTime.Now, inputstring, lberror.Text));
dgvMATChange.ClearSelection();
}
}
#endregion
#region 执行CMD码
///
/// 执行CMD码
///
private void ExcuteCMDCode()
{
string cmd = txtCode.Text.Trim().Split(':')[1];
switch (cmd)
{
case "CLOSECART"://强制提交
{
CloseCart(cmd);
break;
}
case "RESETCART"://重扫器具
{
ResetCart();
break;
}
case "FORCESCAN"://强制扫描
{
ForceScan(cmd);
break;
}
default:
{
Alert("未知指令!",false);
_CMDConfirm = "";
break;
}
}
}
#endregion
#region 强制扫描 将下一次扫描的物料验证
///
/// 强制扫描 将下一次扫描的物料验证
///
///
private void ForceScan(string cmd)
{
if (_CMDConfirm == cmd)//指令二次确认
{
//CreatePaste();
lberror.Text = "";
_CMDConfirm = "";
}
else
{
Alert("确定要提交此贴车单?请再次扫描指令码确认。");
_CMDConfirm = cmd;
}
}
#endregion
#region 手动提交贴车单-在器具未满情况下使用
///
/// 手动提交贴车单-在器具未满情况下使用
///
///
private void CloseCart(string cmd)
{
if (!btnCloseCart.Enabled)
{
Alert("您没有进行此操作的权限!", false);
_CMDConfirm = "";
return;
}
if (nflist == null)
{
Alert("需要至少扫描一件产品才能提交贴车单!",false);
_CMDConfirm = "";
return;
}
if (_CMDConfirm == cmd)//指令二次确认
{
lberror.Text = "";
_CMDConfirm = "";
CreatePaste();
}
else
{
Alert("确定要提交此贴车单?请再次扫描指令码确认。",false);
_CMDConfirm = cmd;
}
}
#endregion
#region 根据条码标识查询零件信息(无用)
///
/// 根据条码标识查询零件信息
///
///
private DataTable GetSparepartsinfo(string strbarcode)
{
//根据条码前3位去零件表查询条码标识查找零件号。包括的数据有052、NF1、NF2、NF3、NF4。车型,指NF或NCS。
// BllFisOrder bllFisOrder = new BllFisOrder();
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
//----------2015-02-10 王丹丹 修改(条码规则变更,所以查询零件号的条件也变更)----------------
if (strbarcode.Substring(0, 3) != "052")
{
//如果前3位不是"052",截取条码前3位进行查询
//return bllFisOrder.GetSparepartsinfo(strbarcode.Substring(0, 3));
return agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetSparepartsinfo.ToString(), strbarcode.Substring(0, 3));
}
else
{
//如果前3位是"052",截取条码前8位进行查询
//return bllFisOrder.GetSparepartsinfo(strbarcode.Substring(0, 8));
return agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetSparepartsinfo.ToString(), strbarcode.Substring(0, 8));
}
//--------------------------------------------------------------------------------------------
}
#endregion
#region 判断数据库中是否有相同的条码
//条码标识
string barcodeidentification = "";
///
/// 判断数据库中是否有相同的条码
///
/// 扫描条码
private void CheckDataBase(string strbarcode,ref string messages)
{
var messagess = "";
barcodeidentification = "";
//特殊条码,当丢失条码或者条码损坏时,扫描一个特殊条码
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
DataTable tblbarcode = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.TJFrmPlaceBLL_ExistBarcode.ToString(), BarcodeTime, strbarcode);
if (tblbarcode.Rows.Count > 0)
{
messagess = "扫描条码重复,请重新扫描。";
Alert("扫描条码重复,请重新扫描。");
}
messages = messagess;
}
#endregion
#region 光标聚焦
///
/// 光标聚焦
///
///
///
private void txtCode_Leave(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(txtCode.Text))
{
txtCode.Focus();
}
}
#endregion
#region 获取FIS发货数据的当前行
///
/// 获取FIS发货数据的当前行
///
private void GetCruentFisData(string pstrbarcode, string pstrprodcno, string ptemplineno, TJEPasteCard pnfpascard, TJEPasteCard pncspascard)
{
#region
if (dgvMATChange.Rows.Count != 0)
{
//if (ptemplineno == "NCS")
//{
// if (ncslist == null)
// {
// DGVCurrontRow(pstrprodcno, ptemplineno, 0);
// }
// else
// {
// int rowcount = ncslist.Count;
// int temprowindex = ncslist[rowcount - 1].DGVROWINDEX + 1;
// DGVCurrontRow(pstrprodcno, ptemplineno, temprowindex);
// }
//}
//if (ptemplineno == "NF")
//{
// if (nflist == null)
// {
// DGVCurrontRow(pstrprodcno, ptemplineno, 0);
// }
// else
// {
// int rowcount = nflist.Count;
// int temprowindex = nflist[rowcount - 1].DGVROWINDEX + 1;
// DGVCurrontRow(pstrprodcno, ptemplineno, temprowindex);
// }
//}
if (nflist == null)
{
DGVCurrontRow(pstrprodcno, ptemplineno, 0);
}
else
{
int rowcount = nflist.Count;
int temprowindex = nflist[rowcount - 1].DGVROWINDEX + 1;
DGVCurrontRow(pstrprodcno, ptemplineno, temprowindex);
}
}
#endregion
}
#endregion
#region 根据零件号,车型获取当前要发货的FIS信息(外来件)
///
/// 根据零件号,车型获取当前要发货的FIS信息
///
///
///
///
private void DGVCurrontRow(string pstrprodcno, string ptemplineno, int rowindex)
{
#region
for (; rowindex < dgvMATChange.Rows.Count; rowindex++)
{
//主键
//strFiskey = dgvMATChange.Rows[rowindex].Cells["clFiskey"].Value.ToString();
strFiskey = dgvMATChange.Rows[rowindex].Cells["PID"].Value.ToString();
//大众顺序号
strvwseq = dgvMATChange.Rows[rowindex].Cells["REQUESTID"].Value.ToString();
//零件号
strprodno = dgvMATChange.Rows[rowindex].Cells["PRODNO"].Value.ToString();
//总成描述
strcarsetdesc_cn = dgvMATChange.Rows[rowindex].Cells["CARSETDESC_CN"].Value.ToString();
//上线时间
strcp5a = dgvMATChange.Rows[rowindex].Cells["CP5A"].Value.ToString();
//车型
strlineno = dgvMATChange.Rows[rowindex].Cells["LINENO"].Value.ToString();
//车身号
strkin = dgvMATChange.Rows[rowindex].Cells["KIN"].Value.ToString();
//底盘号
strvin = dgvMATChange.Rows[rowindex].Cells["VIN"].Value.ToString();
//扫描状态
strscanstat = dgvMATChange.Rows[rowindex].Cells[clscanstate.Name].Value.ToString();
dgvrowindex = rowindex;
if (strscanstat == "0" )//&& strlineno == ptemplineno
{
strprodno = strprodno.ToString().Trim();
pstrprodcno = pstrprodcno.ToString().Trim();
//if (strprodno == pstrprodcno)
if (pstrprodcno.ToUpper().Replace(".", "").Contains(strprodno.ToUpper().Replace(".", "")))
{
//2016-01-21 wangqingnan 如果行变色则不重新刷颜色
//DataGridViewCellStyle ds = new DataGridViewCellStyle();
//ds.BackColor = Color.White;
//this.dgvMATChange.Rows[rowindex].DefaultCellStyle = ds;
this.dgvMATChange.Rows[rowindex].DefaultCellStyle.BackColor = Color.White;
//2016-01-21 wangqingnan 如果行变色则不重新刷颜色
dgvMATChange.Rows[rowindex].Cells[clscanstate.Name].Value = "1";
break;
}
else
{
Alert("条码错误:条码的零件号与FIS队列零件号不符合。");
break;
}
}
else
{
Alert("条码错误:条码已扫描或车型不符合。");
break;
}
}
#endregion
}
#endregion
#region 创建NF的贴车单以及明细(vw371)
TJEPasteCard nfpastecard = null;
///
/// 创建NF的贴车单以及明细
///
private void CreateNFPaste(string barcode)
{
#region
if (nfindex == 0)
{
nflist = new List();
nfpastcardkey = Guid.NewGuid().ToString();
nfpastecard = new TJEPasteCard();
nfpastecard.DetailsCardlist = new List();
nfpastecard.PASTE_CARD_KEY = nfpastcardkey;
nfpastecard.PASTECARDNO = "";
nfpastecard.PRODUCTIONNAME = "DPFY" + pFisType;
nfpastecard.PASTECARDDATE = DateTime.Now.ToString();
nfpastecard.OPERATOR = UserBuffer.UserCode;
nfpastecard.CREATETIME = DateTime.Now.ToString();
nfpastecard.PLANTNAME = "DPFY"+pFisType.ToString();
}
TJEPasteDetailsCard pastdetail = new TJEPasteDetailsCard();
pastdetail.PASTEDETAILED_CARD_KEY = Guid.NewGuid().ToString();
pastdetail.FIS_KEY = strFiskey;
pastdetail.PASTE_CARD_KEY = nfpastcardkey;
//为扫描记录关联产品主键 张鹏 2018-3-8
pastdetail.SANBARCODE = barcode;// txtCode.Text.ToString();
//pastdetail.PRODUCT_PID = product.PID;
pastdetail.SCANDATE = DateTime.Now.ToString();
pastdetail.PRODNO = strprodno;
pastdetail.CARSETDESC_CN = strcarsetdesc_cn;
pastdetail.VIN = strvin;
pastdetail.VWSEQ = strvwseq;
//pastdetail.CP5A = strcp5a;
//pastdetail.KIN = strkin;
pastdetail.DGVROWINDEX = dgvrowindex;
pastdetail.LINENO = strvin.Substring(0,3);
pastdetail.MOULDCODE = strmouldcode;
string strprodtype = "";
if (pFisType == "01")
{
strprodtype = "( 左 )";
}
else if (pFisType == "02")
{
strprodtype = "( 右 )";
}
else if (pFisType == "03")
{
strprodtype = "( 前 )";
}
else if (pFisType == "04")
{
strprodtype = "( 后 )";
}
if (strvin.Substring(0, 3) == "770")
nfpastecard.MbConfig = strvin.Substring(3, 3);
else
nfpastecard.MbConfig = strvin.Substring(4, 3);
nfpastecard.MbOrientation = strprodtype;
nfpastecard.CreateTime = DateTime.Now.ToString("yyyy年MM月dd日 HH:mm");
nfpastecard.DetailsCardlist.Add(pastdetail);
nflist.Add(pastdetail);
dgvNF.DataMember = null;
dgvNF.DataSource = nflist;
strprodno = "";
nfindex++;
//int setdefaultSum = Convert.ToInt32(QM.Config.CustomConfig.GetItem("ShowDataCount"));
int setdefaultSum = Convert.ToInt32(QMAPP.WinForm.Common.LocalSetting.Settings["ShowDataCount",""]);
if (nfindex == setdefaultSum)
{
EFailLog log = new EFailLog();
log.TID = Guid.NewGuid().ToString();
log.FCT_DATE = DateTime.Now;
log.FCT_NO = nfpastecard.PASTE_CARD_KEY;
log.FCT_OPER = UserBuffer.UserCode;
log.FCT_OPERTYPE = 1;
log.FCT_REASON = "NF贴车单自动打印操作";
nfpastecard.DetailsCardlist = nflist;
nfpastecard.FailLog = log;
nfindex = 0;
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
DataTable tbl = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.TJFrmPlaceBLL_GetDaspssteCarIndexByPlanName.ToString(), nfpastecard.PLANTNAME.ToString());
if (tbl.Rows.Count == 0)
{
nfpastecard.PASTECARDNO = nfpastecard.PLANTNAME + DateTime.Now.ToString("yyyyMMdd") + "0001";
int delResult = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.TJFrmPlaceBLL_InsertDaspssteCarIndexByPlanName.ToString(), nfpastecard);
}
else
{
foreach (DataRow dr in tbl.Rows)
{
string PASTECARDNO = dr["PASTECARDNO"].ToString();
string PLANTNAME = dr["PLANTNAME"].ToString();
if ((Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString().Length < 4)
{
int num = 4 - (Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString().Length;
string value = (Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString();
string sumValue = "";
for (var i = 0; i < num; i++)
{
sumValue = sumValue + "0";
}
if (PASTECARDNO.Substring(PLANTNAME.Length, PASTECARDNO.Length - PLANTNAME.Length - 4).ToString() == DateTime.Now.ToString("yyyyMMdd"))
{
PASTECARDNO = PASTECARDNO.Substring(PLANTNAME.Length, PASTECARDNO.Length - PLANTNAME.Length - 4) + sumValue + value;
}
else
{
PASTECARDNO = DateTime.Now.ToString("yyyyMMdd") + "0001";
}
}
else
{
if (PASTECARDNO.Substring(PLANTNAME.Length, PASTECARDNO.Length - PLANTNAME.Length - 4).ToString() == DateTime.Now.ToString("yyyyMMdd"))
{
PASTECARDNO = PASTECARDNO.Substring(PLANTNAME.Length, PASTECARDNO.Length - PLANTNAME.Length - 4) + (Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString();
}
else
{
PASTECARDNO = DateTime.Now.ToString("yyyyMMdd") + "0001";
}
}
nfpastecard.PASTECARDNO = PLANTNAME + PASTECARDNO;
nfpastecard.OPERATOR = ClientContext.LoginInfo.UserName.ToString();
}
}
int rowindex = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.TJFrmPlaceBLL_AddNewPasteCard.ToString(), nfpastecard, setdefaultSum);
Print();//手动提交打印功能
ClearContainer();
GetInitData();
DGVRemoveRow(nflist, ref ncslist);
dgvNF.DataSource = new List();
nfpastecard = null;
nflist = null;
nfindex = 0;
dgvrowindex = 0;
//computenfncs();
//2016-01-07 增加1号位校验 - 清空1号位
//this.placeFirstPosition = "";
//this.placeFirstPositionTime = DateTime.MinValue;
//2016-01-07 增加1号位校验
GetLastPastCard();
SetPastNOConfirm(0);
}
#endregion
}
#endregion
#region 创建贴车单(不满车提交)
///
/// 创建贴车单(不满车提交)
///
private void CreatePaste()
{
if (nflist == null)
{
Alert("无数据,请先按FIS顺序扫描产品!",false);
return;
}
EFailLog log = new EFailLog();
log.TID = Guid.NewGuid().ToString();
log.FCT_DATE = DateTime.Now;
log.FCT_NO = nfpastecard.PASTE_CARD_KEY;
log.FCT_OPER = UserBuffer.UserCode;
log.FCT_OPERTYPE = 1;
log.FCT_REASON = "NF贴车单自动打印操作";
nfpastecard.DetailsCardlist = nflist;
nfpastecard.FailLog = log;
nfindex = 0;
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
DataTable tbl = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.TJFrmPlaceBLL_GetDaspssteCarIndexByPlanName.ToString(), nfpastecard.PLANTNAME.ToString());
if (tbl.Rows.Count == 0)
{
nfpastecard.PASTECARDNO = DateTime.Now.ToString("yyyyMMdd") + "0001";
int delResult = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.TJFrmPlaceBLL_InsertDaspssteCarIndexByPlanName.ToString(), nfpastecard);
}
else
{
foreach (DataRow dr in tbl.Rows)
{
string PASTECARDNO = dr["PASTECARDNO"].ToString();
string PLANTNAME = dr["PLANTNAME"].ToString();
if ((Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString().Length < 4)
{
int num = 4 - (Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString().Length;
string value = (Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString();
string sumValue = "";
for (var i = 0; i < num; i++)
{
sumValue = sumValue + "0";
}
string ii = PASTECARDNO.Substring(PLANTNAME.Length, 8).ToString();
if (PASTECARDNO.Substring(PLANTNAME.Length, 8).ToString() == DateTime.Now.ToString("yyyyMMdd"))
{
PASTECARDNO = PLANTNAME + PASTECARDNO.Substring(PLANTNAME.Length - PLANTNAME.Length, 6) + sumValue + value;
}
else
{
PASTECARDNO = PLANTNAME + DateTime.Now.ToString("yyyyMMdd") + "0001";
}
}
else
{
if (PASTECARDNO.Substring(2, PASTECARDNO.Length - 6).ToString() == DateTime.Now.ToString("yyyyMMdd"))
{
PASTECARDNO = PASTECARDNO.Substring(2, PASTECARDNO.Length - 6) + (Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString();
}
else
{
PASTECARDNO = DateTime.Now.ToString("yyyyMMdd") + "0001";
}
}
nfpastecard.PASTECARDNO = PASTECARDNO;
nfpastecard.OPERATOR = ClientContext.LoginInfo.UserName.ToString();
}
}
int setdefaultSum = Convert.ToInt32(QMAPP.WinForm.Common.LocalSetting.Settings["ShowDataCount", ""]);
int rowindex = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.TJFrmPlaceBLL_AddNewPasteCard.ToString(), nfpastecard, setdefaultSum);
Print();//手动提交打印功能
ClearContainer();
GetInitData();
DGVRemoveRow(nflist, ref ncslist);
dgvNF.DataSource = new List();
nfpastecard = null;
nflist = null;
nfindex = 0;
dgvrowindex = 0;
GetLastPastCard();
SetPastNOConfirm(0);
}
#endregion
#region 打印功能
///
/// 打印功能
///
private void Print()
{
int PrintDisable = Convert.ToInt32(QMAPP.WinForm.Common.LocalSetting.Settings["PrintDisable", "1"]);
if (PrintDisable == 1)
{
lberror.Text = "贴车单打印已禁用!";
return;
}
TJPrintPasteCard prin = new TJPrintPasteCard();
string strprodtype = "";
if (pFisType == "01")
{
strprodtype = "( 左 )";
}
else if (pFisType == "02")
{
strprodtype = "( 右 )";
}
else if (pFisType == "03")
{
strprodtype = "( 前 )";
}
else if (pFisType == "04")
{
strprodtype = "( 后 )";
}
DataTable dt = new DataTable();
dt.Columns.Add("ROWINDEX");
dt.Columns.Add("VWSEQ");
dt.Columns.Add("VIN");
dt.Columns.Add("PRODNO");
dt.Columns.Add("CARSETDESCCN");
dt.Columns.Add("PASTECARDNO");
dt.Columns.Add("SCANDATE");
dt.Columns.Add("CP5A");
dt.Columns.Add("PRODUCTIONNAME");
dt.Columns.Add("LINENO");
dt.Columns.Add("MbConfig");
dt.Columns.Add("MbOrientation");
dt.Columns.Add("CreateTime");
int index = 1;
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
//DataTable tbl = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetPastecardDeatis.ToString());
DataTable tbl = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.TJFrmPlaceBLL_GetPascardDetailsByPid.ToString(), nfpastecard.PASTE_CARD_KEY);
//index = Convert.ToInt32(tbl.Rows[0][0].ToString());
for (var i = 0; i < tbl.Rows.Count; i++)
{
DataRow ncsdr = dt.NewRow();
ncsdr["ROWINDEX"] = index.ToString(); ;
ncsdr["VWSEQ"] = tbl.Rows[i]["VWSEQ"].ToString();
ncsdr["VIN"] = tbl.Rows[i]["VIN"].ToString();
ncsdr["PRODNO"] = tbl.Rows[i]["PRODNO"].ToString();
ncsdr["CP5A"] = tbl.Rows[i]["CP5A"].ToString(); //门板位置
for(var a = 0;a< dgvNF.Rows.Count;a++)
{
if (dgvNF.Rows[a].Cells[CODE_NF.Name].Value.ToString().ToUpper() == tbl.Rows[i]["VIN"].ToString())
{
var sssss = dgvNF.Rows[a].Cells[CARSETDESC_CN_NF.Name].Value.ToString();
ncsdr["CARSETDESCCN"] = sssss;
}
}
//ncsdr["CARSETDESCCN"] = tbl.Rows[i]["CARSETDESC_CN"].ToString();
ncsdr["PASTECARDNO"] = tbl.Rows[i]["PASTECARDNO"].ToString();
ncsdr["SCANDATE"] = DateTime.Now.ToString();
ncsdr["PRODUCTIONNAME"] = strprodtype;
ncsdr["LINENO"] = tbl.Rows[i]["LINENO"].ToString();
if (strvin.Substring(0, 3) == "770")
ncsdr["MbConfig"] = strvin.Substring(3, 3);
else
ncsdr["MbConfig"] = strvin.Substring(4, 3);
ncsdr["MbOrientation"]= strprodtype;
ncsdr["CreateTime"] = DateTime.Now.ToString("yyyy年MM月dd日 HH:mm");
dt.Rows.Add(ncsdr);
index++;
}
if (!string.IsNullOrEmpty(_TJFYPrintName))
{
System.Drawing.Printing.PrintDocument doc = new System.Drawing.Printing.PrintDocument();
doc.PrinterSettings.PrinterName = _TJFYPrintName;
prin.Print(dt, _TJFYPrintName);
lberror.Text = "贴车单已打印;";
}
else
{
prin.Print(dt);
lberror.Text = "贴车单已打印;";
}
#region 针对贴车单上的条码进行出库操作
var nor = string.Empty;
for (var i = 0; i < tbl.Rows.Count; i++)
{
if (string.IsNullOrEmpty(nor))
nor += tbl.Rows[i]["VIN"].ToString() + ",";
else
{
if (!nor.Contains(tbl.Rows[i]["VIN"].ToString()))
{
var count = agent.InvokeServiceFunction>("StorageBLL_SelectCount", tbl.Rows[i]["VIN"].ToString());
//如果条码未入库,先进行入库操作
if (count.Result <= 0)
{
Storage pi = new Storage();
pi.ProductCode = tbl.Rows[i]["VIN"].ToString();
pi.InStorageType = "发运入库";
agent.InvokeServiceFunction>("StorageBLL_Insert", pi);
}
var storage = new Storage();
storage.ProductCode = tbl.Rows[i]["VIN"].ToString();
storage.OutStorageType = "发运出库";
var result = agent.InvokeServiceFunction("StorageBLL_Update", storage);
if (!result.IsSuccess)
{
lberror.Text += tbl.Rows[i]["VIN"].ToString() + "出库失败;原因:" + result.Msg; ;
}
}
}
}
#endregion
}
#endregion
#region 定时刷新数据
///
/// 定时刷新数据
///
///
///
private void timeRefew_Tick(object sender, EventArgs e)
{
//if (dgvNF.Rows.Count == 0)
//{
GetInitData();
//}
}
#endregion
#region 扫描件状态框动作
///
///
///
public void InitContainer()
{
tpContainer.Controls.Clear();
tpContainer.RowStyles.Clear();
tpContainer.ColumnStyles.Clear();
int defaultNum = Convert.ToInt32(QMAPP.WinForm.Common.LocalSetting.Settings["ShowDataCount", "6"]);
int rowcount = Convert.ToInt32(QMAPP.WinForm.Common.LocalSetting.Settings["RowCount", "2"]);
tpContainer.RowCount = rowcount;
tpContainer.ColumnCount = defaultNum / rowcount + (defaultNum % rowcount > 0 ? 1 : 0);
for (int i = 0; i < tpContainer.RowCount; i++)
{
if (i == 0)
{
tpContainer.RowStyles.Add(new RowStyle(SizeType.Percent, 50));
}
else
{
tpContainer.RowStyles.Add(new RowStyle(SizeType.Percent, 50));
}
}
for (int i = 0; i < tpContainer.ColumnCount; i++)
{
tpContainer.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50));
for (int j = 0; j < tpContainer.RowCount; j++)
{
Label lblItem = new Label();
lblItem.Text = (i + j * tpContainer.ColumnCount + 1).ToString();
lblItem.Font = new Font("微软雅黑", 24, FontStyle.Bold);
lblItem.Dock = DockStyle.Fill;
lblItem.TextAlign = ContentAlignment.MiddleCenter;
tpContainer.Controls.Add(lblItem, i, j);
}
}
//for (int i = 0; i < tpContainer.ColumnCount; i++)
//{
// tpContainer.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50));
// for (int j = 0; j < tpContainer.RowCount; j++)
// {
// Label lblItem = new Label();
// lblItem.Text = (i*rowcount+j+ 1).ToString();
// lblItem.Font = new Font("微软雅黑", 24, FontStyle.Bold);
// lblItem.Dock = DockStyle.Fill;
// lblItem.TextAlign = ContentAlignment.MiddleCenter;
// tpContainer.Controls.Add(lblItem, i, j);
// }
//}
for (int i = 0; i < nfindex; i++)
{
SetContainerItem(i, true);
}
}
///
///
///
///
///
public void SetContainerItem(int itemindex, bool result)
{
if (itemindex == 0)
return;
if (itemindex == 1)
{
var label = tpContainer.GetControlFromPosition(0, 0) as Label;
label.BackColor = result ? Color.Lime : Color.Red;
}
else
{
itemindex = itemindex - 1;
var columnindex = itemindex / (tpContainer.ColumnCount);
var rowindex = itemindex % (tpContainer.ColumnCount);
var label = tpContainer.GetControlFromPosition(rowindex, columnindex) as Label;
if (label != null)
{
label.BackColor = result ? Color.Lime : Color.Red;
}
}
}
///
///
///
public void ClearContainer()
{
foreach (var ctrl in tpContainer.Controls)
{
var label = ctrl as Label;
if (label != null)
{
label.BackColor = tpContainer.BackColor;
}
}
}
#endregion
#region 重新扫描
///
/// 重新扫描
///
///
///
private void btnResetCart_Click(object sender, EventArgs e)
{
ResetCart();
}
private void ResetCart()
{
if (!btnResetCart.Enabled)
{
lberror.Text = "您无权执行此操作!";
}
nflist = null;
nfindex = 0;
ClearContainer();
GetInitData();
//DGVRemoveRow(nflist, ref ncslist);
dgvNF.DataSource = new List();
nfpastecard = null;
dgvrowindex = 0;
if (dgvMATChange.RowCount > 0)
{
dgvMATChange.FirstDisplayedScrollingRowIndex = nfindex - nfindex % 4;
}
}
#endregion
#region 混线单选按钮
///
/// 混线单选按钮
///
///
///
//int signal = 0;
private void rb_hx_CheckedChanged(object sender, EventArgs e)
{
if (dgvNF.Rows.Count > 0)
{
lberror.Text = "已扫描数据区不为空,重置或者扫描整车后才能切换生产线!";
return;
}
lberror.Text = "";
QMAPP.WinForm.Common.LocalSetting.Settings["FlashProCode"]= "01";
//混
pFisType = "01";
WORKCENTER_CODE = "IPFY01";
GetInitData();
GetLastPastCard();
}
///
/// 右侧门板
///
///
///
private void rb_dx_CheckedChanged(object sender, EventArgs e)
{
if (dgvNF.Rows.Count > 0)
{
lberror.Text = "已扫描数据区不为空,重置或者扫描整车后才能切换生产线!";
return;
}
lberror.Text = "";
QMAPP.WinForm.Common.LocalSetting.Settings["FlashProCode"] = "01";
//混
pFisType = "02";
WORKCENTER_CODE = "IPFY02";
GetInitData();
GetLastPastCard();
}
///
/// 018前门
///
///
///
private void ra_hx_CheckedChanged(object sender, EventArgs e)
{
if (dgvNF.Rows.Count > 0)
{
lberror.Text = "已扫描数据区不为空,重置或者扫描整车后才能切换生产线!";
return;
}
lberror.Text = "";
QMAPP.WinForm.Common.LocalSetting.Settings["FlashProCode"] = "03";
//混
pFisType = "03";
WORKCENTER_CODE = "IPFY03";
GetInitData();
GetLastPastCard();
}
///
/// 018后门
///
///
///
private void ra_dx_CheckedChanged(object sender, EventArgs e)
{
if (dgvNF.Rows.Count > 0)
{
lberror.Text = "已扫描数据区不为空,重置或者扫描整车后才能切换生产线!";
return;
}
lberror.Text = "";
QMAPP.WinForm.Common.LocalSetting.Settings["FlashProCode"] = "04";
//混
pFisType = "04";
WORKCENTER_CODE = "IPFY04";
GetInitData();
GetLastPastCard();
}
#endregion
#region 工作中心设置按钮
///
/// 工作中心设置按钮
///
///
///
private void btnLineSetting_Click(object sender, EventArgs e)
{
TJfrmLineSetting frm = new TJfrmLineSetting();
frm.Owner = this;
frm.ShowDialog();
txtCode.Focus();
}
#endregion
#region 贴车单顺序校正按钮
///
/// 贴车单顺序校正按钮
///
///
///
private void btnResetIndex_Click(object sender, EventArgs e)
{
TJResetSendIndexForm form = new TJResetSendIndexForm();
form.ShowDialog();
txtCode.Focus();
}
#endregion
#region 设置容器容量
///
/// 设置容器容量
///
///
///
private void btnSetDatagroupType_Click(object sender, EventArgs e)
{
TJDefaultDataSetNum window = new TJDefaultDataSetNum();
window.Owner = this;
window.Show();
}
#endregion
///
///
///
///
///
private void FrmPlace_Activated(object sender, EventArgs e)
{
SetRowColor();
}
///
///
///
///
///
private string getTeShuBarcode(String str)
{
return str + " 4XR#" + DateTime.Now.ToString("MMddHH") + "#";
}
#region 不满车打印贴车单
///
/// 不满车打印贴车单
///
///
///
private void btnCloseCart_Click(object sender, EventArgs e)
{
lberror.Text = "";
_CMDConfirm = "";
CreatePaste();
}
#endregion
public static string CalculateChecksum(string barcode)
{
string chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%";
int sum = 0;
foreach (var c in barcode)
{
sum += chars.IndexOf(c);
}
int rem = sum % chars.Length;
return chars[rem].ToString();
}
///
/// 位置名称转换code
///
///
///
public static string Getmoulecodecode(string Name)
{
switch (Name)
{
case "左前":
return "LF";
case "左后":
return "LR";
case "右前":
return "RF";
case "右后":
return "RR";
default:
break;
}
return "";
}
///
/// 查找配置表
///
///
public string GetAppConfigValue(string pConfigCode)
{
var AppConfig = _agent.InvokeServiceFunction(B9IPCService.AppConfigBLL_Get.ToString(), pConfigCode);
if (AppConfig != null)
return AppConfig.Value;
else
return null;
}
}
}