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.
827 lines
32 KiB
827 lines
32 KiB
5 months ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.ComponentModel;
|
||
|
using System.Configuration;
|
||
|
using System.Data;
|
||
|
using System.Data.SqlClient;
|
||
|
using System.Drawing;
|
||
|
using System.Linq;
|
||
|
using System.Reflection;
|
||
|
using System.Text;
|
||
|
using System.Threading;
|
||
|
using System.Windows.Forms;
|
||
|
using DBUtility;
|
||
|
using gregn6Lib;
|
||
|
using MESClassLibrary.BLL.Log;
|
||
|
using MESClassLibrary.BLL.Mistake247;
|
||
|
using MESClassLibrary.BLL.PunchAndWeld;
|
||
|
using PunchAndWeld.DataSouce;
|
||
|
using PunchAndWeld.WebReference;
|
||
|
|
||
|
namespace PunchAndWeld
|
||
|
{
|
||
|
public partial class FrmDoorSill : Form
|
||
|
{
|
||
|
PunchAdressBLL bll = new PunchAdressBLL();
|
||
|
public bool IsChangeBox = false;
|
||
|
public bool IsPass = false;
|
||
|
private string IsHigh = "1";
|
||
|
|
||
|
private GridppReport Report = new GridppReport();
|
||
|
private string oneBarCode = "";
|
||
|
string[] partNo1=new string[10];
|
||
|
string zcPartNo = "", planID = "", zcPartName="",zcHigh="" ,sn;
|
||
|
|
||
|
string stationNo = "", stationId = "";
|
||
|
|
||
|
public FrmDoorSill()
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
}
|
||
|
|
||
|
private void FrmDoorSill_Load(object sender, EventArgs e)
|
||
|
{
|
||
|
stationNo = ConfigurationManager.AppSettings["StationNo"];
|
||
|
label1.Text = ProScreenFunc.GetStation(stationNo);
|
||
|
stationId = ProScreenFunc.GetStationId(stationNo);
|
||
|
Control.CheckForIllegalCrossThreadCalls = false;
|
||
|
|
||
|
Thread t = new Thread(new ThreadStart(TimeGo));
|
||
|
t.Start();
|
||
|
textBox4.Visible = false;
|
||
|
textBox2.TabIndex = 0;
|
||
|
textBox2.Select();
|
||
|
if (ConfigurationManager.AppSettings["IsHaveVisual"] == "1")
|
||
|
{
|
||
|
SqlStart();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void TimeGo()
|
||
|
{
|
||
|
System.Timers.Timer timer = new System.Timers.Timer();
|
||
|
timer.Interval = 10;
|
||
|
timer.Enabled = true;
|
||
|
timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Tick);
|
||
|
}
|
||
|
|
||
|
private void timer_Tick(object sender, EventArgs e)
|
||
|
{
|
||
|
label9.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||
|
Thread.Sleep(500);
|
||
|
}
|
||
|
|
||
|
private void textBox2_KeyDown(object sender, KeyEventArgs e)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
if (e.KeyCode == Keys.Enter)
|
||
|
{
|
||
|
if (string.IsNullOrWhiteSpace(textBox2.Text.Trim()))
|
||
|
{
|
||
|
MessageBox.Show("订单号不能为空!", "提示", MessageBoxButtons.OK);
|
||
|
textBox2.SelectAll();
|
||
|
textBox2.Focus();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (InitList()) return;
|
||
|
|
||
|
InitProduct();
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private bool InitList()
|
||
|
{
|
||
|
Plan247BLL bll = new Plan247BLL();
|
||
|
int a = 0;
|
||
|
this.listView1.Items.Clear();
|
||
|
|
||
|
//DataTable dt = bll.SearhByOrderNo(textBox2.Text.Trim());
|
||
|
DataTable dt = ProScreenFunc.GetPlanInfoByOrderNo(textBox2.Text.Trim());
|
||
|
if (dt != null && dt.Rows.Count > 0)
|
||
|
{
|
||
|
|
||
|
|
||
|
partNo1 = new string[dt.Rows.Count];
|
||
|
for (int i = 0; i < dt.Rows.Count; i++)
|
||
|
{
|
||
|
if (Convert.ToInt32(dt.Rows[i]["IsFinish"].ToString()) == 1)
|
||
|
{
|
||
|
a += 1;
|
||
|
if (a == dt.Rows.Count)
|
||
|
{
|
||
|
MessageBox.Show("订单已完成,请扫描其他订单!", "提示", MessageBoxButtons.OK);
|
||
|
textBox2.Focus();
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
partNo1[i] = dt.Rows[i]["PartNo"].ToString();
|
||
|
ListViewItem lvi = new ListViewItem(dt.Rows[i]["OrderNo"].ToString());
|
||
|
lvi.SubItems.Add(dt.Rows[i]["PartNo"].ToString()); //后面添加的Item都为SubItems ,即为子项
|
||
|
lvi.SubItems.Add(dt.Rows[i]["OrderCount"].ToString());
|
||
|
lvi.SubItems.Add(dt.Rows[i]["ProductName"].ToString());
|
||
|
//lvi.SubItems.Add(dt.Rows[i]["CompleteCount"].ToString());
|
||
|
listView1.Items.Add(lvi);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
MessageBox.Show("订单号不存在,请重新扫描!", "提示", MessageBoxButtons.OK);
|
||
|
textBox2.SelectAll();
|
||
|
textBox2.Focus();
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
private void textBox1_KeyDown(object sender, KeyEventArgs e)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
if (e.KeyCode == Keys.Enter)
|
||
|
{
|
||
|
if (string.IsNullOrWhiteSpace(textBox1.Text))
|
||
|
{
|
||
|
MessageBox.Show("请扫描订单号!", "提示", MessageBoxButtons.OK);
|
||
|
textBox2.SelectAll();
|
||
|
textBox2.Focus();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
|
||
|
if (ConfigurationManager.AppSettings["IsHaveVisual"] == "1")
|
||
|
{
|
||
|
if (ProScreenFunc.HaveNotPrint(stationId))
|
||
|
{
|
||
|
MessageBox.Show("存在未打印标签的产品,不允许扫描!");
|
||
|
textBox1.SelectAll();
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
CheckPartAndProduct();
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void CheckPartAndProduct()
|
||
|
{
|
||
|
textBox1.SelectAll();
|
||
|
string barcode = textBox1.Text.Trim();
|
||
|
|
||
|
if (barcode.Contains("."))
|
||
|
{
|
||
|
barcode = ProScreenFunc.UniteBarCodeToOne(barcode);
|
||
|
|
||
|
}
|
||
|
oneBarCode = barcode;
|
||
|
|
||
|
|
||
|
|
||
|
if (ProScreenFunc.HaveScan(barcode))
|
||
|
{
|
||
|
DialogResult result = MessageBox.Show("条码为" + barcode + "的蒙皮已经冲孔,是否重新冲孔?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
|
||
|
if (result == DialogResult.OK)
|
||
|
{
|
||
|
FrmPassWord pass = new FrmPassWord();
|
||
|
pass.OkBtnClick += (arg1) =>
|
||
|
{
|
||
|
if (!string.IsNullOrEmpty(arg1) &&
|
||
|
arg1.ToLower() == ConfigurationManager.AppSettings["password"].ToLower())
|
||
|
{
|
||
|
pass.Close();
|
||
|
|
||
|
ScanBarcode(barcode);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
MessageBox.Show("密码错误,请重新输入!", "提示", MessageBoxButtons.OK);
|
||
|
}
|
||
|
};
|
||
|
pass.ShowDialog();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
ScanBarcode(barcode);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void ScanBarcode(string barcode)
|
||
|
{
|
||
|
//string productID1 = textBox1.Tag.ToString().Trim();
|
||
|
string productID1 = "";
|
||
|
string productID2 = "";
|
||
|
zcPartNo = "";
|
||
|
productID1 = "";
|
||
|
zcPartName = "";
|
||
|
zcHigh = "";
|
||
|
|
||
|
string[] codeSpecial = { "2200000057", "2200000058" };
|
||
|
//string[] codeSpecial = ProScreenFunc.GetSpecialStockNo();
|
||
|
string code = barcode.Substring(0, 10);
|
||
|
if (codeSpecial.Contains(code))
|
||
|
{
|
||
|
productID2 = ProScreenFunc.GetProductID(code, "");
|
||
|
//AfterScanBarcode(barcode, productID2, productID1, this.Tag.ToString().Trim());
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (barcode.Substring(0, 2) != "22")
|
||
|
{
|
||
|
string[] codeSpecial1 = ProScreenFunc.GetSpecialStockNo();
|
||
|
string code1 = barcode.Substring(0, 10);
|
||
|
if (codeSpecial1.Contains(code1))
|
||
|
{
|
||
|
productID2 = ProScreenFunc.GetProductID(code, "");
|
||
|
//AfterScanBarcode(barcode, productID2, productID1, this.Tag.ToString().Trim());
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
productID2 = ProScreenFunc.GetProductID(barcode);
|
||
|
if (string.IsNullOrWhiteSpace(productID2))
|
||
|
{
|
||
|
string stockNo = barcode.Substring(0, 10);
|
||
|
productID2 = ProScreenFunc.GetProductID(stockNo, "");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
bool isScan = ProScreenFunc.IsScan(barcode);
|
||
|
|
||
|
DataTable dt1 = ProScreenFunc.GetZCPartInfo(productID2, stationNo);
|
||
|
if (dt1 != null && dt1.Rows.Count > 0)
|
||
|
{
|
||
|
for (int i = 0; i < dt1.Rows.Count; i++)
|
||
|
{
|
||
|
if (stationNo == "ZP75" ||stationNo == "ZP76")
|
||
|
{
|
||
|
if (isScan && dt1.Rows[i]["IsHigh"].ToString() == "1")
|
||
|
{
|
||
|
zcPartNo = dt1.Rows[i]["PartNo"].ToString();
|
||
|
productID1 = dt1.Rows[i]["ProductID"].ToString();
|
||
|
zcPartName = dt1.Rows[i]["ProductName"].ToString();
|
||
|
zcHigh = "高配";
|
||
|
}
|
||
|
|
||
|
if (!isScan && dt1.Rows[i]["IsHigh"].ToString() == "0")
|
||
|
{
|
||
|
zcPartNo = dt1.Rows[i]["PartNo"].ToString();
|
||
|
productID1 = dt1.Rows[i]["ProductID"].ToString();
|
||
|
zcPartName = dt1.Rows[i]["ProductName"].ToString();
|
||
|
zcHigh = "低配";
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
zcPartNo = dt1.Rows[i]["PartNo"].ToString();
|
||
|
productID1 = dt1.Rows[i]["ProductID"].ToString();
|
||
|
zcPartName = dt1.Rows[i]["ProductName"].ToString();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
if (!((System.Collections.IList)partNo1).Contains(zcPartNo))
|
||
|
{
|
||
|
MessageBox.Show("订单中无此计划,请检查后再扫描");
|
||
|
textBox1.Text = "";
|
||
|
textBox1.Focus();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
|
||
|
ScanAll.ScanResult = false;
|
||
|
|
||
|
//OtherPart parts = ProScreenFunc.HaveOtherPart(label1.Text.Trim(), productID1);
|
||
|
OtherPart parts = ProScreenFunc.HaveOtherPart(label1.Text.Trim(), productID1);
|
||
|
if ((parts != null) && ((!string.IsNullOrWhiteSpace(parts.productID3)) || (!string.IsNullOrWhiteSpace(parts.productID4)) || (!string.IsNullOrWhiteSpace(parts.productID5))))
|
||
|
{
|
||
|
FrmProScreen3 frm3 = new FrmProScreen3(parts);
|
||
|
frm3.ShowDialog();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
ScanAll.ScanResult = true;
|
||
|
}
|
||
|
|
||
|
|
||
|
if (ScanAll.ScanResult)
|
||
|
{
|
||
|
planID = ProScreenFunc.GetPlanIDByOrderNo(textBox2.Text.Trim(), zcPartNo);
|
||
|
if (ConfigurationManager.AppSettings["IsHaveVisual"] != "1")
|
||
|
{
|
||
|
AfterScanBarcode(barcode, zcPartNo, productID2, productID1, planID,stationId);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
ProScreenFunc.SavePartAndProduct(barcode, productID2, productID1, textBox2.Text.Trim(), textBox2.Text.Trim().Substring(0, 1) + "班", planID,stationId, ConfigurationManager.AppSettings["StationDescription"]);
|
||
|
ProScreenFunc.SaveZcCode(barcode, zcPartNo);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void AfterScanBarcode(string barcode,string zcPartNo, string productID2, string productID1, string planID,string stationId)
|
||
|
{
|
||
|
if ((IsChangeBox == true && IsPass) || (IsChangeBox == false))
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
DateTime time = DateTime.Now;
|
||
|
string tmp = ProScreenFunc.SerialNo(zcPartNo, time.ToString("yyMMdd"));
|
||
|
if (tmp == "")
|
||
|
{
|
||
|
sn =
|
||
|
zcPartNo + "." + time.ToString("yyMMdd") + ".000001";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
sn = tmp.Substring(0, tmp.Length - 6) +
|
||
|
(int.Parse(tmp.Substring(tmp.Length - 6, 6)) + 1).ToString()
|
||
|
.PadLeft(6, '0');
|
||
|
}
|
||
|
}
|
||
|
catch (Exception e)
|
||
|
{
|
||
|
MessageBox.Show("连接数据库超时!");
|
||
|
return;
|
||
|
}
|
||
|
#region 调WMS接口
|
||
|
|
||
|
try
|
||
|
{
|
||
|
LogHelper.WriteSysLogBase("条码号:" + barcode + "工位:" + label1.Text.Trim() + ",一码到底调用WMS接口", MethodBase.GetCurrentMethod().Name);
|
||
|
|
||
|
string stockNo = "";
|
||
|
string batchNo = "";
|
||
|
string partNo = "";
|
||
|
ProScreenFunc.GetCode(barcode, out stockNo, out batchNo, out partNo);
|
||
|
|
||
|
partNo = zcPartNo;
|
||
|
batchNo = DateTime.Now.ToString("yyyyMMdd");
|
||
|
|
||
|
WMSWebService webService = new WMSWebService();
|
||
|
webService.Url = ConfigurationManager.AppSettings["WMSWebServiceURL"].ToString();
|
||
|
|
||
|
if (webService.WMSInterfaceStockIn(barcode, partNo, batchNo, 1))
|
||
|
{
|
||
|
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteErrLogBase("工位:" + label1.Text.Trim() + ",一码到底调用WMS接口:" + ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 存储
|
||
|
|
||
|
if (ProScreenFunc.SavePartAndProduct1(barcode, productID2, productID1, textBox2.Text.Trim(), textBox2.Text.Trim().Substring(0, 1) + "班", planID, sn,stationId, ConfigurationManager.AppSettings["StationDescription"])<=0)
|
||
|
{
|
||
|
MessageBox.Show("连接数据库失败!");
|
||
|
return;
|
||
|
}
|
||
|
ProScreenFunc.SaveZcCode(barcode, zcPartNo);
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 完成数量+1
|
||
|
|
||
|
//bll.UpdateCount(zcPartNo, textBox2.Text.Trim());
|
||
|
ProScreenFunc.AddCompleteCount(planID);
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 打印标签
|
||
|
|
||
|
try
|
||
|
{
|
||
|
if (ConfigurationManager.AppSettings["PrintEnable"].ToString().ToLower() == "true")
|
||
|
{
|
||
|
string path = "";
|
||
|
if (zcPartNo.Contains("A2477900588-"))
|
||
|
{
|
||
|
path = Application.StartupPath + @"\aaa1.grf";
|
||
|
Report.Initialize += new _IGridppReportEvents_InitializeEventHandler(ReportInitialize1);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
path = Application.StartupPath + @"\aaa.grf";
|
||
|
Report.Initialize += new _IGridppReportEvents_InitializeEventHandler(ReportInitialize);
|
||
|
}
|
||
|
|
||
|
Report.Register("");
|
||
|
Report.LoadFromFile(path);
|
||
|
|
||
|
//Report.DesignPaperOrientation = GRPaperOrientation.grpoLandscape;
|
||
|
//report.PrintPreview(true);
|
||
|
Report.Print(false);
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
InitProduct();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
MessageBox.Show("雷达支架不匹配");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void ReportInitialize()
|
||
|
{
|
||
|
|
||
|
Report.ParameterByName("SerialNo").Value = sn;
|
||
|
Report.ParameterByName("oneBarCode").Value = oneBarCode;
|
||
|
Report.ParameterByName("zcPartNo").Value = zcPartNo;
|
||
|
Report.ParameterByName("zcName").Value = zcPartName;
|
||
|
//Report.ParameterByName("zcHigh").Value = zcHigh; 214门槛用
|
||
|
}
|
||
|
|
||
|
private void ReportInitialize1()
|
||
|
{
|
||
|
string barcode = textBox1.Text.Trim();
|
||
|
if (barcode.Contains("."))
|
||
|
{
|
||
|
barcode = ProScreenFunc.UniteBarCodeToOne(barcode);
|
||
|
}
|
||
|
DateTime time = DateTime.Now;
|
||
|
if (zcPartNo.Contains("A2477900588-"))
|
||
|
{
|
||
|
Report.ParameterByName("Des").Value = "X247S";
|
||
|
}
|
||
|
if (zcPartNo.Contains("A2477900000-"))
|
||
|
{
|
||
|
Report.ParameterByName("Des").Value = "H247S";
|
||
|
}
|
||
|
Report.ParameterByName("PartNo").Value = zcPartNo;
|
||
|
Report.ParameterByName("PartName").Value = zcPartName;
|
||
|
Report.ParameterByName("BatchNo").Value = time.ToString("yyMMdd");
|
||
|
|
||
|
try
|
||
|
{
|
||
|
string tmp = ProScreenFunc.SerialNo(zcPartNo, time.ToString("yyMMdd"));
|
||
|
string sn = "";
|
||
|
if (tmp == "")
|
||
|
{
|
||
|
sn =
|
||
|
zcPartNo + "." + time.ToString("yyMMdd") + ".000001";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
sn = tmp.Substring(0, tmp.Length - 6) +
|
||
|
(int.Parse(tmp.Substring(tmp.Length - 6, 6)) + 1).ToString()
|
||
|
.PadLeft(6, '0');
|
||
|
}
|
||
|
Report.ParameterByName("SerialNo").Value = sn;
|
||
|
Report.ParameterByName("BarCode").Value = sn + ";24;2217;;.0;" + time.ToString("yyyy/MM/dd");
|
||
|
Report.ParameterByName("oneBarCode").Value = barcode;
|
||
|
}
|
||
|
catch (Exception e)
|
||
|
{
|
||
|
MessageBox.Show("连接数据库超时!");
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
private void InitProduct()
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
int a = 0;
|
||
|
this.listView2.Items.Clear();
|
||
|
|
||
|
DataTable dt = ProScreenFunc.GetPlanInfoByOrderNo(textBox2.Text.Trim());
|
||
|
if (dt != null && dt.Rows.Count > 0)
|
||
|
{
|
||
|
for (int i = 0; i < dt.Rows.Count; i++)
|
||
|
{
|
||
|
ListViewItem lvi = new ListViewItem(dt.Rows[i]["PartNo"].ToString());
|
||
|
if (dt.Rows[i]["PartNo"].ToString() == zcPartNo)
|
||
|
{
|
||
|
lvi.BackColor = Color.LimeGreen;
|
||
|
}
|
||
|
lvi.SubItems.Add(dt.Rows[i]["CompleteCount"].ToString());
|
||
|
listView2.Items.Add(lvi);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void label9_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
Environment.Exit(0);
|
||
|
}
|
||
|
|
||
|
private void button3_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
|
||
|
DialogResult result = MessageBox.Show("是否补打标签?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
|
||
|
if (result == DialogResult.OK)
|
||
|
{
|
||
|
FrmPassWord pass = new FrmPassWord();
|
||
|
pass.OkBtnClick += (arg1) =>
|
||
|
{
|
||
|
if (!string.IsNullOrEmpty(arg1) &&
|
||
|
arg1.ToLower() == ConfigurationManager.AppSettings["password"].ToLower())
|
||
|
{
|
||
|
pass.Close();
|
||
|
textBox4.Visible = true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
MessageBox.Show("密码错误,请重新输入!", "提示", MessageBoxButtons.OK);
|
||
|
return;
|
||
|
}
|
||
|
};
|
||
|
pass.ShowDialog();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
private void textBox4_KeyDown(object sender, KeyEventArgs e)
|
||
|
{
|
||
|
if (e.KeyCode == Keys.Enter)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string barcode = textBox4.Text.Trim();
|
||
|
if (barcode.Contains("."))
|
||
|
{
|
||
|
barcode = ProScreenFunc.UniteBarCodeToOne(barcode);
|
||
|
}
|
||
|
|
||
|
DataTable dtHg = ProScreenFunc.GetGh(barcode);
|
||
|
if (dtHg == null || dtHg.Rows.Count < 1)
|
||
|
{
|
||
|
MessageBox.Show("未装配,不能补打标签!");
|
||
|
textBox4_DoubleClick(sender, e);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
DataTable dtBl = ProScreenFunc.GetBl(barcode);
|
||
|
if (dtBl != null && dtBl.Rows.Count > 0)
|
||
|
{
|
||
|
DateTime hgTime = (DateTime)Tools.NumericParse.StringToDateTime("1900-01-01 00:00:00");
|
||
|
DataTable dtHG1 = ProScreenFunc.GetHG_New(barcode);
|
||
|
if (dtHG1 != null && dtHG1.Rows.Count > 0)
|
||
|
{
|
||
|
hgTime = (DateTime)Tools.NumericParse.StringToDateTime(dtHG1.Rows[0]["CreateTime"].ToString());
|
||
|
}
|
||
|
|
||
|
DateTime blTime = (DateTime)Tools.NumericParse.StringToDateTime(dtBl.Rows[0]["createTime"].ToString());
|
||
|
if (DateTime.Compare(blTime, hgTime) > 0)
|
||
|
{
|
||
|
MessageBox.Show("产品不良,不能补打标签!");
|
||
|
textBox4_DoubleClick(sender, e);
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
LogSysBLL.AddInfo("条码:" + barcode + "补打标签", MethodBase.GetCurrentMethod());
|
||
|
string zcID = dtHg.Rows[0]["ZcID"].ToString();
|
||
|
string zcSn = dtHg.Rows[0]["SerialNo"].ToString();
|
||
|
ZcPrintLabel zl = ProScreenFunc.GetZcPrintLabel(zcID);
|
||
|
if (zl != null && zl.zcPartNo != null && zl.zcName != null)
|
||
|
{
|
||
|
if (ConfigurationManager.AppSettings["PrintEnable"].ToString().ToLower() == "true")
|
||
|
{
|
||
|
if (zl.zcPartNo.Contains("A2477900588-") || zl.zcPartNo.Contains("A2477900000-"))
|
||
|
{
|
||
|
string path = System.Windows.Forms.Application.StartupPath + @"\aaa1.grf";
|
||
|
|
||
|
GridppReport Report2 = new GridppReport();
|
||
|
Report2.Register("");
|
||
|
Report2.LoadFromFile(path);
|
||
|
if (zl.zcPartNo.Contains("A2477900588-"))
|
||
|
{
|
||
|
Report2.ParameterByName("Des").Value = "X247S";
|
||
|
}
|
||
|
if (zl.zcPartNo.Contains("A2477900000-"))
|
||
|
{
|
||
|
Report2.ParameterByName("Des").Value = "H247S";
|
||
|
}
|
||
|
Report2.ParameterByName("PartNo").Value = zl.zcPartNo;
|
||
|
Report2.ParameterByName("PartName").Value = zl.zcName;
|
||
|
string sn = dtHg.Rows[0]["SerialNo"].ToString();
|
||
|
Report2.ParameterByName("SerialNo").Value = sn;
|
||
|
string[] tmp = sn.Split('.');
|
||
|
Report2.ParameterByName("BarCode").Value = sn + ";24;2217;;.0;" + tmp[1];
|
||
|
Report2.ParameterByName("oneBarCode").Value = barcode;
|
||
|
Report2.ParameterByName("BatchNo").Value = tmp[1];
|
||
|
Report2.Print(false);
|
||
|
textBox4.SelectAll();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
string path = System.Windows.Forms.Application.StartupPath + @"\aaa.grf";
|
||
|
|
||
|
GridppReport Report1 = new GridppReport();
|
||
|
Report1.Register("");
|
||
|
Report1.LoadFromFile(path);
|
||
|
Report1.ParameterByName("oneBarCode").Value = barcode;
|
||
|
|
||
|
Report1.ParameterByName("zcPartNo").Value = zl.zcPartNo;
|
||
|
Report1.ParameterByName("SerialNo").Value = zcSn;
|
||
|
Report1.ParameterByName("zcName").Value = zl.zcName;
|
||
|
Report1.Print(false);
|
||
|
textBox4.SelectAll();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
MessageBox.Show("根据总成号找不到对应名称,请维护基础数据!");
|
||
|
textBox4_DoubleClick(sender, e);
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
|
||
|
textBox4_DoubleClick(sender, e);
|
||
|
}
|
||
|
}
|
||
|
else if (e.KeyCode == Keys.Escape)
|
||
|
{
|
||
|
textBox4_DoubleClick(sender, e);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void textBox4_DoubleClick(object sender, EventArgs e)
|
||
|
{
|
||
|
textBox4.Text = "";
|
||
|
textBox4.Visible = false;
|
||
|
}
|
||
|
|
||
|
private void SqlStart()
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
SqlDependency.Start(SqlHelper.SqlConnString);
|
||
|
SqlDependencyWatch();
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void SqlDependencyWatch()
|
||
|
{
|
||
|
string sSQL = "SELECT [ToVisual] FROM [dbo].[tb_Punch_Code_Record]";
|
||
|
|
||
|
using (SqlConnection connection = new SqlConnection(SqlHelper.SqlConnString))
|
||
|
{
|
||
|
using (SqlCommand command = new SqlCommand(sSQL, connection))
|
||
|
{
|
||
|
command.CommandType = CommandType.Text;
|
||
|
connection.Open();
|
||
|
SqlDependency dependency = new SqlDependency(command);
|
||
|
dependency.OnChange += new OnChangeEventHandler(SQLTableOnChange);
|
||
|
SqlDataReader sdr = command.ExecuteReader();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void SQLTableOnChange(object sender, SqlNotificationEventArgs e)
|
||
|
{
|
||
|
SqlDependencyWatch();
|
||
|
AfterScanBarcode1();
|
||
|
}
|
||
|
|
||
|
private void AfterScanBarcode1()
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string ID = "", barcode = "", productID2 = "", productID1 = "";
|
||
|
DataTable dt1 = ProScreenFunc.HavePrint(stationId);
|
||
|
if (dt1 != null && dt1.Rows.Count > 0)
|
||
|
{
|
||
|
//if (dt1.Rows[0]["PlanID"].ToString() != base.Tag.ToString().Trim())
|
||
|
//{
|
||
|
// MessageBox.Show("产品和计划不匹配");
|
||
|
// return;
|
||
|
//}
|
||
|
//else
|
||
|
//{
|
||
|
ID = dt1.Rows[0]["ID"].ToString();
|
||
|
barcode = dt1.Rows[0]["barcode"].ToString();
|
||
|
oneBarCode = barcode;
|
||
|
|
||
|
//productID2 = dt1.Rows[0]["BcpID"].ToString();
|
||
|
//productID1 = dt1.Rows[0]["ZcID"].ToString();
|
||
|
zcPartNo = dt1.Rows[0]["PartNo"].ToString();
|
||
|
zcPartName = dt1.Rows[0]["ProductName"].ToString();
|
||
|
planID = dt1.Rows[0]["PlanID"].ToString();
|
||
|
//}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
this.Invoke((EventHandler) (delegate
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
LogHelper.WriteSysLogBase("条码号:" + barcode + "工位:" + label1.Text.Trim() + ",一码到底调用WMS接口", MethodBase.GetCurrentMethod().Name);
|
||
|
|
||
|
string stockNo = "";
|
||
|
string batchNo = "";
|
||
|
string partNo = "";
|
||
|
ProScreenFunc.GetCode(barcode, out stockNo, out batchNo, out partNo);
|
||
|
|
||
|
partNo = zcPartNo;
|
||
|
batchNo = DateTime.Now.ToString("yyyyMMdd");
|
||
|
|
||
|
WMSWebService webService = new WMSWebService();
|
||
|
webService.Url = ConfigurationManager.AppSettings["WMSWebServiceURL"].ToString();
|
||
|
|
||
|
webService.WMSInterfaceStockIn(barcode, partNo, batchNo, 1);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteErrLogBase("工位:" + label1.Text.Trim() + ",一码到底调用WMS接口:" + ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
}
|
||
|
|
||
|
ProScreenFunc.AddCompleteCount(planID);
|
||
|
|
||
|
|
||
|
try
|
||
|
{
|
||
|
if (ConfigurationManager.AppSettings["PrintEnable"].ToString().ToLower() == "true")
|
||
|
{
|
||
|
string path = "";
|
||
|
if (zcPartNo.Contains("A2477900588-"))
|
||
|
{
|
||
|
path = Application.StartupPath + @"\aaa1.grf";
|
||
|
Report.Initialize += new _IGridppReportEvents_InitializeEventHandler(ReportInitialize1);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
path = Application.StartupPath + @"\aaa.grf";
|
||
|
Report.Initialize += new _IGridppReportEvents_InitializeEventHandler(ReportInitialize);
|
||
|
}
|
||
|
|
||
|
Report.Register("");
|
||
|
Report.LoadFromFile(path);
|
||
|
|
||
|
Report.Print(false);
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
|
||
|
ProScreenFunc.UpdatePrintTime(ID);
|
||
|
|
||
|
|
||
|
InitProduct();
|
||
|
}));
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|