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.
 
 
 
 

1025 lines
38 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Stone.Common;
using Stone.Entity;
using mshtml;
using System.IO;
using Gm_WMS.DataAccess.DataService;
namespace Stone.WinModule.AssembleAdmin
{
public partial class frmViewAssemblyNew : Form
{
#region 属性和构造函数
private string AGVNo = MyAppconfig.ReadValue("AGV编号");
private string WSNo = MyAppconfig.ReadValue("装配工位编号"); //第7工位时使用
private string PackageGroupName = MyAppconfig.ReadValue("JIS扫描打印类型");
private int BomShowCount = Convert.ToInt32(MyAppconfig.ReadValue("装配零件信息显示行数"));
private int BomKeyCount = Convert.ToInt32(MyAppconfig.ReadValue("关键零件校验显示行数"));
private Entity_t_JIS_Seq5000 t_JIS_Seq5000 = new Entity_t_JIS_Seq5000();
private Entity_t_JIS_Seq5000_ReOrder t_JIS_Seq5000_ReOrder = new Entity_t_JIS_Seq5000_ReOrder();
private Entity_t_JIS_Bom t_JIS_Bom = new Entity_t_JIS_Bom();
private Entity_t_JIS_Line t_JIS_Line = new Entity_t_JIS_Line();
private LocalDBService db = new LocalDBService();
private IHTMLDocument3 doc3 = null;
public frmViewAssemblyNew()
{
InitializeComponent();
}
private void frmViewAssemblyNew_Load(object sender, EventArgs e)
{
try
{
InitHtml();
Control.CheckForIllegalCrossThreadCalls = false;
string filename = Application.StartupPath + "\\html\\" + MyAppconfig.ReadValue("新装配看板模板");
this.webBrowser1.Navigate(filename);
if (AGVNo == "") //当不在AGV小车上的时候,显示插单按钮
{
this.btnInsert.Visible = true;
this.btnInsert.Visible = true;
}
this.btnUp.Visible = false;
this.btnNext.Visible = false;
}
catch (Exception ex)
{
MyMessageBox.ShowMessagePop(ex.Message);
}
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
try
{
IHTMLDocument2 doc2 = (IHTMLDocument2)this.webBrowser1.Document.DomDocument;
doc3 = (IHTMLDocument3)doc2;
timer1.Interval = Convert.ToInt32(MyAppconfig.ReadValue("看板刷新时间"));
timer1.Enabled = true;
timer2.Enabled = true;
if (AGVNo != "")
{
doc3.getElementById("lblAssyStationName").innerHTML = AGVNo;
}
else
{
doc3.getElementById("lblAssyStationName").innerHTML = WSNo;
}
}
catch (Exception ex)
{
MyMessageBox.ShowMessagePop(ex.Message);
}
}
private void frmViewAssemblyNew_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
this.Close();
}
}
#endregion
#region 初始化html模块
private string html_tb1 = "";
private string html_tb2 = "";
private string html_tb3 = "";
private void InitHtml()
{
string path = Application.StartupPath + "\\html";
html_tb1 = ReadFile(path + "\\10_tb1.html");
html_tb2 = ReadFile(path + "\\10_tb2.html");
html_tb3 = ReadFile(path + "\\10_tb3.html");
}
#endregion
#region 数据刷新
private DataSet dsLine = null;
private void timer1_Tick(object sender, EventArgs e)
{
timer1.Enabled = false;
this.Update();
try
{
UpdateWeb();
}
catch (Exception ex)
{
MyMessageBox.ShowMessagePop(ex.Message);
}
finally
{
timer1.Enabled = true;
}
}
private void timer2_Tick(object sender, EventArgs e)
{
try
{
if (!this.txtBarCode.Focused)
{
this.txtBarCode.Focus();
this.txtBarCode.SelectAll();
}
doc3.getElementById("lblTimer").innerHTML = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
catch (Exception ex)
{
MyMessageBox.ShowMessagePop(ex.Message);
}
}
private void UpdateWeb()
{
if (UpdateData())
{
//GetBomKey();
string html_tb1_show = GetData_tb1();
string html_tb2_show = GetData_tb2();
doc3.getElementById("tb1").innerHTML = html_tb1_show;
doc3.getElementById("tb2").innerHTML = html_tb2_show;
Update_tb3();
}
}
private void Update_tb3()
{
string html_tb3_show = GetData_tb3();
doc3.getElementById("tb3").innerHTML = html_tb3_show;
}
private bool UpdateData()
{
DataSet dsTemp = null;
if (AGVNo != "")
{
dsTemp = t_JIS_Line.GetData("top 1 *", "[AGVNo]='" + AGVNo + "'", "[ID] asc");
}
else
{
dsTemp = t_JIS_Line.GetData("top 1 *", "[WSNo]='" + WSNo + "'", "[ID] asc");
}
if (dsTemp.Tables[0].Rows.Count > 0)
{
if (dsLine == null)
{
dsLine = dsTemp.Copy();
return true;
}
else
{
if (dsLine.Tables[0].Rows.Count == 0)
{
dsLine = dsTemp.Copy();
return true;
}
else
{
if (AGVNo != "")//AGVNo不为空的时候,就按WSNo的变化来刷新数据
{
if (dsLine.Tables[0].Rows[0]["WSNo"].ToString() != dsTemp.Tables[0].Rows[0]["WSNo"].ToString())
{
dsLine = dsTemp.Copy();
return true;
}
else
{
return false;
}
}
else //AGVNo为空的时候,就按JisID的变化来刷新数据
{
if (dsLine.Tables[0].Rows[0]["JisID"].ToString() != dsTemp.Tables[0].Rows[0]["JisID"].ToString())
{
dsLine = dsTemp.Copy();
return true;
}
else
{
return false;
}
}
}
}
}
else
{
dsLine = dsTemp.Copy();
return true;
}
}
private string GetData_tb1()
{
string ret = html_tb1;
if (dsLine.Tables[0].Rows.Count > 0)
{
string IsInsert = dsLine.Tables[0].Rows[0]["IsInsert"].ToString();
if (IsInsert != "")
{
if (IsInsert == "1")
{
ret = ret.Replace("{tb1_rows1_col1}", "<font color=red>" + dsLine.Tables[0].Rows[0]["CheckSequence"].ToString() + "</font>");
ret = ret.Replace("{tb1_rows1_col2}", "<font color=red>" + dsLine.Tables[0].Rows[0]["WSNo"].ToString() + "</font>");
ret = ret.Replace("{tb1_rows1_col3}", "<font color=red>" + dsLine.Tables[0].Rows[0]["OrderNumber"].ToString() + "</font>");
ret = ret.Replace("{tb1_rows1_col4}", "<font color=red>" + dsLine.Tables[0].Rows[0]["Variant"].ToString() + "</font>");
ret = ret.Replace("{tb1_rows1_col5}", "<font color=red>" + dsLine.Tables[0].Rows[0]["PartColor"].ToString() + "</font>");
ret = ret.Replace("{tb1_rows1_col6}", "<font color=red>" + "&nbsp;" + "</font>");
ret = ret.Replace("{tb1_rows1_col7}", "<font color=red>" + "&nbsp;" + "</font>");
ret = ret.Replace("{tb1_rows1_col8}", "<font color=red>" + Convert.ToDateTime(dsLine.Tables[0].Rows[0]["SwetTime"].ToString()).ToString("HH:mm:ss") + "</font>");
}
else
{
ret = ret.Replace("{tb1_rows1_col1}", dsLine.Tables[0].Rows[0]["CheckSequence"].ToString());
ret = ret.Replace("{tb1_rows1_col2}", dsLine.Tables[0].Rows[0]["WSNo"].ToString());
ret = ret.Replace("{tb1_rows1_col3}", dsLine.Tables[0].Rows[0]["OrderNumber"].ToString());
ret = ret.Replace("{tb1_rows1_col4}", dsLine.Tables[0].Rows[0]["Variant"].ToString());
ret = ret.Replace("{tb1_rows1_col5}", dsLine.Tables[0].Rows[0]["PartColor"].ToString());
ret = ret.Replace("{tb1_rows1_col6}", "&nbsp;");
ret = ret.Replace("{tb1_rows1_col7}", "&nbsp;");
ret = ret.Replace("{tb1_rows1_col8}", Convert.ToDateTime(dsLine.Tables[0].Rows[0]["SwetTime"].ToString()).ToString("HH:mm:ss"));
}
}
else
{
ret = ret.Replace("{tb1_rows1_col1}", "&nbsp;");
ret = ret.Replace("{tb1_rows1_col2}", "&nbsp;");
ret = ret.Replace("{tb1_rows1_col3}", "&nbsp;");
ret = ret.Replace("{tb1_rows1_col4}", "&nbsp;");
ret = ret.Replace("{tb1_rows1_col5}", "&nbsp;");
ret = ret.Replace("{tb1_rows1_col6}", "&nbsp;");
ret = ret.Replace("{tb1_rows1_col7}", "&nbsp;");
ret = ret.Replace("{tb1_rows1_col8}", "&nbsp;");
}
}
else
{
ret = ret.Replace("{tb1_rows1_col1}", "&nbsp;");
ret = ret.Replace("{tb1_rows1_col2}", "&nbsp;");
ret = ret.Replace("{tb1_rows1_col3}", "&nbsp;");
ret = ret.Replace("{tb1_rows1_col4}", "&nbsp;");
ret = ret.Replace("{tb1_rows1_col5}", "&nbsp;");
ret = ret.Replace("{tb1_rows1_col6}", "&nbsp;");
ret = ret.Replace("{tb1_rows1_col7}", "&nbsp;");
ret = ret.Replace("{tb1_rows1_col8}", "&nbsp;");
}
return ret;
}
private string GetData_tb2()
{
string ret = html_tb2;
if (dsLine.Tables[0].Rows.Count > 0)
{
DataSet dsTod = null;
if (WSNo == "WS07")
{
dsTod = t_JIS_Bom.GetData("[OrderNumber]='" + dsLine.Tables[0].Rows[0]["OrderNumber"].ToString() + "' and [PackageGroupName]='" + PackageGroupName + "'");
}
else
{
dsTod = t_JIS_Bom.GetData("[OrderNumber]='" + dsLine.Tables[0].Rows[0]["OrderNumber"].ToString() + "' and [StationCode]='" + dsLine.Tables[0].Rows[0]["WSNo"].ToString() + "' and [PackageGroupName]='" + PackageGroupName + "'");
}
for (int i = 1; i <= BomShowCount; i++)
{
ret = (i - 1) < dsTod.Tables[0].Rows.Count ? ret.Replace("{tb2_rows" + i + "_col1}", i + "") : ret.Replace("{tb2_rows" + i + "_col1}", "&nbsp;");
ret = (i - 1) < dsTod.Tables[0].Rows.Count ? ret.Replace("{tb2_rows" + i + "_col2}", dsTod.Tables[0].Rows[i - 1]["partNumber"].ToString()) : ret.Replace("{tb2_rows" + i + "_col2}", "&nbsp;");
ret = (i - 1) < dsTod.Tables[0].Rows.Count ? ret.Replace("{tb2_rows" + i + "_col3}", dsTod.Tables[0].Rows[i - 1]["quantity"].ToString()) : ret.Replace("{tb2_rows" + i + "_col3}", "&nbsp;");
ret = (i - 1) < dsTod.Tables[0].Rows.Count ? ret.Replace("{tb2_rows" + i + "_col4}", dsTod.Tables[0].Rows[i - 1]["description"].ToString()) : ret.Replace("{tb2_rows" + i + "_col4}", "&nbsp;");
}
}
else
{
for (int i = 1; i <= BomShowCount; i++)
{
ret = ret.Replace("{tb2_rows" + i + "_col1}", "&nbsp;");
ret = ret.Replace("{tb2_rows" + i + "_col2}", "&nbsp;");
ret = ret.Replace("{tb2_rows" + i + "_col3}", "&nbsp;");
ret = ret.Replace("{tb2_rows" + i + "_col4}", "&nbsp;");
}
}
return ret;
}
private string GetData_tb3()
{
string ret = html_tb3;
if (dsLine.Tables[0].Rows.Count > 0)
{
DataSet dsTod = null;
if (WSNo == "WS07")
{
dsTod = t_JIS_Bom.GetData("[OrderNumber]='" + dsLine.Tables[0].Rows[0]["OrderNumber"].ToString() + "' and [IsKey]=1 and [PackageGroupName]='" + PackageGroupName + "'");
}
else
{
dsTod = t_JIS_Bom.GetData("[OrderNumber]='" + dsLine.Tables[0].Rows[0]["OrderNumber"].ToString() + "' and [IsKey]=1 and [StationCode]='" + dsLine.Tables[0].Rows[0]["WSNo"].ToString() + "' and [PackageGroupName]='" + PackageGroupName + "'");
}
for (int i = 1; i <= BomShowCount; i++)
{
ret = (i - 1) < dsTod.Tables[0].Rows.Count ? ret.Replace("{tb3_rows" + i + "_col1}", dsTod.Tables[0].Rows[i - 1]["description"].ToString()) : ret.Replace("{tb3_rows" + i + "_col1}", "&nbsp;");
ret = (i - 1) < dsTod.Tables[0].Rows.Count ? ret.Replace("{tb3_rows" + i + "_col2}", dsTod.Tables[0].Rows[i - 1]["barcodeCode"].ToString()) : ret.Replace("{tb3_rows" + i + "_col2}", "&nbsp;");
ret = (i - 1) < dsTod.Tables[0].Rows.Count ? ret.Replace("{tb3_rows" + i + "_col3}", get_scan_image(Convert.ToBoolean(dsTod.Tables[0].Rows[i - 1]["IsScan"]))) : ret.Replace("{tb3_rows" + i + "_col3}", "&nbsp;");
}
}
else
{
for (int i = 1; i <= BomShowCount; i++)
{
ret = ret.Replace("{tb3_rows" + i + "_col1}", "&nbsp;");
ret = ret.Replace("{tb3_rows" + i + "_col2}", "&nbsp;");
ret = ret.Replace("{tb3_rows" + i + "_col3}", "&nbsp;");
}
}
return ret;
}
#endregion
#region 扫描条码处理
private void txtBarCode_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
try
{
string BarCode = this.txtBarCode.Text.Trim().ToUpper();
if (BarCode == "") return;
//扫描的是订单条码
if (BarCode.Length == 7)
{
BarCode = BarCode + "1";
if (AGVNo != "")
{
if (dsLine == null) return;
if (dsLine.Tables[0].Rows.Count == 0)
{
BarCodeScanWS01(BarCode);
}
else
{
//if (dsLine.Tables[0].Rows[0]["WSNo"].ToString().ToUpper() == "WS03")
//{
// BarCodeScanWS03(BarCode);
//}
throw new Exception("请扫描领料单");
}
}
else if (WSNo == "WS07")
{
BarCodeScanWS07(BarCode);
}
else //其他工位(比如后保、左右门槛条)
{
BarCodeScanBWS(BarCode);
}
}
else
{
if (BarCode.ToUpper().Substring(0, 2) == "PL")
{
try
{
BarCode = BarCode.Replace("PL", "") + "1";
if (dsLine.Tables[0].Rows.Count == 0)
throw new Exception("当前没有装配数据,当前没有装配数据当前没有装配数据当前没有装配数据当前没有装配数据当前没有装配数据当前没有装配数据");
if (dsLine.Tables[0].Rows[0]["WSNo"].ToString().ToUpper() == "WS03")
{
BarCodeScanWS03(BarCode);
}
if (dsLine.Tables[0].Rows[0]["WSNo"].ToString().ToUpper() == "WS07")
{
BarCodeScanWS07_01(BarCode);
}
}
catch (Exception exmsg)
{
frmMessageBox frm = new frmMessageBox();
frm.lblState.Text = exmsg.Message;
frm.ShowDialog();
frm.Dispose();
}
}
else
{
//扫描的是关键件的条码
DataSet dsBom = t_JIS_Bom.GetData("[IsKey]=1 and [barcodeCode]='" + BarCode + "' and [PackageGroupName]='" + PackageGroupName + "'");
if (dsBom.Tables[0].Rows.Count > 0)
{
t_JIS_Bom.Edit("[IsScan]=1", "[ID]=" + dsBom.Tables[0].Rows[0]["ID"].ToString());
}
else
{
throw new Exception("关键件条码 " + BarCode + " 不存在");
}
Update_tb3();
}
}
this.txtBarCode.Text = "";
}
catch (Exception ex)
{
MyMessageBox.ShowMessagePop(ex.Message);
}
finally
{
this.txtBarCode.Focus();
this.txtBarCode.SelectAll();
}
}
}
//1号工位扫描订单(把订单和AGV小车进行绑定)
private void BarCodeScanWS01(string BarCode)
{
if (t_JIS_Line.GetData("[AGVNo]='" + AGVNo + "'").Tables[0].Rows.Count > 0) throw new Exception(AGVNo + " 已经有产品在配置,不能再放产品");
if (t_JIS_Line.GetData("[OrderNumber]='" + BarCode + "' and [PackageGroupName]='" + PackageGroupName + "'").Tables[0].Rows.Count > 0) throw new Exception(BarCode + " 已经在线上装配了,不能重复扫描");
bool isReOrder = false;
DataSet dsJis = t_JIS_Seq5000_ReOrder.GetData("top 1 *", "[OrderNumber]='" + BarCode + "' and [PackageGroupName]='" + PackageGroupName + "'", "[SwetTime] desc, [CallOffNumber] desc");
if (dsJis.Tables[0].Rows.Count == 0)
{
dsJis = t_JIS_Seq5000.GetData("top 1 *", "[OrderNumber]='" + BarCode + "' and [PackageGroupName]='" + PackageGroupName + "'", "[SwetTime] desc, [CallOffNumber] desc");
if (dsJis.Tables[0].Rows.Count == 0) throw new Exception(BarCode + " 在系统中不存在");
}else{
isReOrder = true;
}
if (Convert.ToInt32(dsJis.Tables[0].Rows[0]["IsAssemble"]) == 1) throw new Exception(BarCode + " 已经装配过了");
if (Convert.ToInt32(dsJis.Tables[0].Rows[0]["IsTransport"]) == 0) throw new Exception(BarCode + " 还未打印扫描");
LocalDBService db = null;
try
{
db = new LocalDBService();
db.BeginTrans();
Entity_t_JIS_Line t_line = new Entity_t_JIS_Line(db);
DataRow drNew = t_line.Table.NewRow();
drNew["JisID"] = dsJis.Tables[0].Rows[0]["ID"];
drNew["AGVNo"] = AGVNo;
drNew["WSNo"] = "WS01"; //默认为WS01号工位
drNew["OrderNumber"] = BarCode;
drNew["CheckSequence"] = dsJis.Tables[0].Rows[0]["CheckSequence"].ToString();
drNew["SwetTime"] = dsJis.Tables[0].Rows[0]["SwetTime"];
drNew["PackageGroupName"] = dsJis.Tables[0].Rows[0]["PackageGroupName"].ToString();
drNew["PartColor"] = dsJis.Tables[0].Rows[0]["PartColor"].ToString();
drNew["Variant"] = dsJis.Tables[0].Rows[0]["Variant"].ToString();
drNew["IsInsert"] = dsJis.Tables[0].Rows[0]["IsInsert"].ToString();
drNew["IsReOrder"] = isReOrder ? 1 : 0;
t_line.Add(drNew);
//删除20天之前的数据
string sql = "delete from t_JIS_Bom where AddTime < dateadd(day,-20,getdate())";
db.Exec_NonQuery(sql);
new Entity_t_JIS_Bom(db).Del("[orderNumber]='" + dsJis.Tables[0].Rows[0]["orderNumber"].ToString() + "'");
sql = @"
insert into t_JIS_Bom([orderNumber], [partNumber], [quantity], [description], [StationCode], [IsKey], [barcodeCode], [PackageGroupName])
select [orderNumber], [partNumber], [quantity], [description], [StationCode], [IsKey], [barcodeCode], [PackageGroupName] from v_JIS_Tod
where orderNumber='{0}' and [partsFamily]='{1}' and [supplyGroup]='{2}'
";
if (isReOrder)
{
sql = @"
insert into t_JIS_Bom([orderNumber], [partNumber], [quantity], [description], [StationCode], [IsKey], [barcodeCode], [PackageGroupName])
select [orderNumber], [partNumber], [quantity], [description], [StationCode], [IsKey], [barcodeCode], [PackageGroupName] from v_JIS_Tod_ReOrder
where orderNumber='{0}' and [partsFamily]='{1}' and [supplyGroup]='{2}'
";
}
object[] obj = new object[3];
obj[0] = dsJis.Tables[0].Rows[0]["orderNumber"].ToString();
obj[1] = dsJis.Tables[0].Rows[0]["partsFamily"].ToString();
obj[2] = dsJis.Tables[0].Rows[0]["supplyGroup"].ToString();
sql = string.Format(sql, obj);
db.Exec_NonQuery(sql);
Entity_OrderInfoDown OrderInfoDown = new Entity_OrderInfoDown(db);
DataRow drDown = OrderInfoDown.Table.NewRow();
drDown["OrderNo"] = dsJis.Tables[0].Rows[0]["orderNumber"].ToString();
drDown["AGVNo"] = AGVNo;
drDown["OrderNo"] = dsJis.Tables[0].Rows[0]["orderNumber"].ToString();
drDown["PartType"] = dsJis.Tables[0].Rows[0]["PackageGroupName"].ToString();
drDown["WS01"] = 1;
drDown["WS02"] = new Entity_t_JIS_Bom(db).GetData("[orderNumber]='" + dsJis.Tables[0].Rows[0]["orderNumber"].ToString() + "' and [PackageGroupName]='" + PackageGroupName + "' and partNumber in(select Code from t_AssyPart)").Tables[0].Rows.Count > 0 ? 0 : 1;
drDown["WS03"] = 1;
drDown["WS04"] = 1;
drDown["WS05"] = 1;
drDown["WS06"] = 1;
drDown["WS07"] = 1;
OrderInfoDown.Add(drDown);
db.Commit();
}
catch (Exception ex)
{
if (db != null) db.Rollback();
throw ex;
}
finally
{
db.EndTrans();
}
UpdateWeb();
}
//除了前保的其他工位扫描
private void BarCodeScanBWS(string BarCode)
{
if (t_JIS_Line.GetData("[WSNo]='" + WSNo + "' and [PackageGroupName]='" + PackageGroupName + "'").Tables[0].Rows.Count > 0)
{
t_JIS_Line.Del("[WSNo]='" + WSNo + "' and [PackageGroupName]='" + PackageGroupName + "'");
}
bool isReOrder = false;
DataSet dsJis = t_JIS_Seq5000_ReOrder.GetData("top 1 *", "[OrderNumber]='" + BarCode + "' and [PackageGroupName]='" + PackageGroupName + "'", "[SwetTime] desc, [CallOffNumber] desc");
if (dsJis.Tables[0].Rows.Count == 0)
{
dsJis = t_JIS_Seq5000.GetData("top 1 *", "[OrderNumber]='" + BarCode + "' and [PackageGroupName]='" + PackageGroupName + "'", "[SwetTime] desc, [CallOffNumber] desc");
if (dsJis.Tables[0].Rows.Count == 0) throw new Exception(BarCode + " 在系统中不存在");
}
else
{
isReOrder = true;
}
if (Convert.ToInt32(dsJis.Tables[0].Rows[0]["IsAssemble"]) == 1) throw new Exception(BarCode + " 已经装配过了");
if (Convert.ToInt32(dsJis.Tables[0].Rows[0]["IsTransport"]) == 0) throw new Exception(BarCode + " 还未打印扫描");
LocalDBService db = null;
try
{
db = new LocalDBService();
db.BeginTrans();
Entity_t_JIS_Line t_line = new Entity_t_JIS_Line(db);
DataRow drNew = t_line.Table.NewRow();
drNew["JisID"] = dsJis.Tables[0].Rows[0]["ID"];
drNew["AGVNo"] = "";
drNew["WSNo"] = WSNo;
drNew["OrderNumber"] = BarCode;
drNew["CheckSequence"] = dsJis.Tables[0].Rows[0]["CheckSequence"].ToString();
drNew["SwetTime"] = dsJis.Tables[0].Rows[0]["SwetTime"];
drNew["PackageGroupName"] = dsJis.Tables[0].Rows[0]["PackageGroupName"].ToString();
drNew["PartColor"] = dsJis.Tables[0].Rows[0]["PartColor"].ToString();
drNew["Variant"] = dsJis.Tables[0].Rows[0]["Variant"].ToString();
drNew["IsInsert"] = dsJis.Tables[0].Rows[0]["IsInsert"].ToString();
t_line.Add(drNew);
new Entity_t_JIS_Bom(db).Del("[orderNumber]='" + dsJis.Tables[0].Rows[0]["orderNumber"].ToString() + "' and [PackageGroupName]='" + PackageGroupName + "' and [StationCode]='" + WSNo + "'");
string sql = @"
insert into t_JIS_Bom([orderNumber], [partNumber], [quantity], [description], [StationCode], [IsKey], [barcodeCode], [PackageGroupName])
select [orderNumber], [partNumber], [quantity], [description], '{3}' as [StationCode], [IsKey], [barcodeCode], [PackageGroupName] from v_JIS_Tod
where orderNumber='{0}' and [partsFamily]='{1}' and [supplyGroup]='{2}' and [StationCode]='{3}'
";
if (isReOrder)
{
sql = @"
insert into t_JIS_Bom([orderNumber], [partNumber], [quantity], [description], [StationCode], [IsKey], [barcodeCode], [PackageGroupName])
select [orderNumber], [partNumber], [quantity], [description], '{3}' as [StationCode], [IsKey], [barcodeCode], [PackageGroupName] from v_JIS_Tod_ReOrder
where orderNumber='{0}' and [partsFamily]='{1}' and [supplyGroup]='{2}' and [StationCode]='{3}'
";
}
object[] obj = new object[4];
obj[0] = dsJis.Tables[0].Rows[0]["orderNumber"].ToString();
obj[1] = dsJis.Tables[0].Rows[0]["partsFamily"].ToString();
obj[2] = dsJis.Tables[0].Rows[0]["supplyGroup"].ToString();
obj[3] = WSNo;
sql = string.Format(sql, obj);
db.Exec_NonQuery(sql);
db.Commit();
}
catch (Exception ex)
{
if (db != null) db.Rollback();
throw ex;
}
finally
{
db.EndTrans();
}
UpdateWeb();
}
//3号工位扫描判断订单和装配订单是否一样
private void BarCodeScanWS03(string BarCode)
{
if (dsLine.Tables[0].Rows.Count == 0) throw new Exception("当前工位没有装配信息");
if (dsLine.Tables[0].Rows[0]["orderNumber"].ToString().Trim().ToUpper() != BarCode)
{
throw new Exception("扫描的订单号不正确,当前订单号:" + dsLine.Tables[0].Rows[0]["orderNumber"].ToString());
}
frmInfo.ShowTip( "[" + BarCode + "] 领料单校验成功");
}
private bool ScanWS07 = false;
private void BarCodeScanWS07_01(string BarCode)
{
if (dsLine.Tables[0].Rows.Count == 0) throw new Exception("当前工位没有装配信息");
if (dsLine.Tables[0].Rows[0]["orderNumber"].ToString().Trim().ToUpper() != BarCode)
{
throw new Exception("扫描的订单号不正确,当前订单号:" + dsLine.Tables[0].Rows[0]["orderNumber"].ToString());
}
frmInfo.ShowTip("[" + BarCode + "] 领料单校验成功");
ScanWS07 = true;
}
//第七工位装配完成后扫描,将状态设置为【装配完成】
private void BarCodeScanWS07(string BarCode)
{
LocalDBService db = null;
try
{
db = new LocalDBService();
db.BeginTrans();
if (dsLine.Tables[0].Rows.Count == 0)
throw new Exception("当前工位没有装配信息");
if (ScanWS07 == false) throw new Exception("请先扫描取料单");
if (dsLine.Tables[0].Rows[0]["orderNumber"].ToString().Trim().ToUpper() != BarCode)
throw new Exception("扫描的订单号不正确,当前订单号:" + dsLine.Tables[0].Rows[0]["orderNumber"].ToString());
//将订单设置为【装配完成】
if (Convert.ToInt32(dsLine.Tables[0].Rows[0]["IsReOrder"]) == 0)
{
new Entity_t_JIS_Seq5000(db).Edit("[IsAssemble]=1", "[ID]=" + dsLine.Tables[0].Rows[0]["JisID"].ToString());
}
else
{
new Entity_t_JIS_Seq5000_ReOrder(db).Edit("[IsAssemble]=1", "[ID]=" + dsLine.Tables[0].Rows[0]["JisID"].ToString());
}
//清除当前装配记录
new Entity_t_JIS_Line().Del("[ID]=" + dsLine.Tables[0].Rows[0]["ID"].ToString());
//删除临时缓存中的BOM清单
new Entity_t_JIS_Bom(db).Del("[orderNumber]='" + dsLine.Tables[0].Rows[0]["orderNumber"].ToString() + "' and [PackageGroupName]='" + PackageGroupName + "'");
ScanWS07 = false;
db.Commit();
}
catch (Exception ex)
{
if (db != null) db.Rollback();
throw ex;
}
finally
{
if (db != null) db.EndTrans();
}
}
#endregion
#region 按钮动作
//上一条
private void btnUp_Click(object sender, EventArgs e)
{
try
{
if (((Button)sender).Text == "完成")
{
//-1 -2 工位装配完成触发
string sql = @"
update t_StationLine set
JisID=0,
StationCode=null,
PartType=null,
ProductCode=null,
SEQ=null,
TRIMLEVEL=null,
VEHNO=null,
ColorName=null,
Electroniceye=null,
Foglight=null,
Taxi=null,
PBSOUT=null,
BomCode=null,
ALCCODE=null,
IsInsert=null
where [AGVNo]='{0}'
";
sql = string.Format(sql, AGVNo);
db.Exec_NonQuery(sql);
}
else
{
db.Exec_NonQuery("exec p_Up_Jis");
}
UpdateWeb();
}
catch (Exception ex)
{
MyMessageBox.ShowMessagePop(ex.Message);
}
}
//下一条
private void btnNext_Click(object sender, EventArgs e)
{
LocalDBService db = null;
try
{
db = new LocalDBService();
db.BeginTrans();
//db.Exec_NonQuery("exec p_Next_Jis " + JisID);
if (dsLine == null) throw new Exception("当前没有装配信息");
if (dsLine.Tables[0].Rows.Count == 0) throw new Exception("当前没有装配信息");
int JisID = Convert.ToInt32(dsLine.Tables[0].Rows[0]["JisID"]);
if (JisID == 0) throw new Exception("当前没有装配信息");
string _WSNO = dsLine.Tables[0].Rows[0]["WSNo"].ToString();
string _OrderNumber = dsLine.Tables[0].Rows[0]["OrderNumber"].ToString();
Entity_OrderInfoDown OrderInfoDown = new Entity_OrderInfoDown();
DataSet dsOrderInfoDown = OrderInfoDown.GetData("top 1 *", "[OrderNo]='60223051'", "[ID] desc");
//t_Line.Edit("[AGVNo]='', [WSNo]='WS07'", "[ID]=" + dtLine.Rows[0]["ID"].ToString());
db.Commit();
}
catch (Exception ex)
{
if (db != null) db.Rollback();
MyMessageBox.ShowMessagePop(ex.Message);
}
finally
{
db.EndTrans();
}
try
{
UpdateWeb();
}
catch (Exception ex)
{
MyMessageBox.ShowErrorMessage(ex.Message);
}
}
private void btnInsert_Click(object sender, EventArgs e)
{
try
{
if (dsLine == null) throw new Exception("当前没有装配信息");
if (dsLine.Tables[0].Rows.Count == 0) throw new Exception("当前没有装配信息");
int JisID = Convert.ToInt32(dsLine.Tables[0].Rows[0]["JisID"]);
if (JisID == 0) throw new Exception("当前没有装配信息");
if (MyMessageBox.ShowQuestion("是否要对订单[" + dsLine.Tables[0].Rows[0]["OrderNumber"].ToString() + "]进行插单?"))
{
EntityBase t_JIS_Seq5000 = new Entity_t_JIS_Seq5000();
if (Convert.ToInt32(dsLine.Tables[0].Rows[0]["IsReOrder"]) == 1) t_JIS_Seq5000 = new Entity_t_JIS_Seq5000_ReOrder();
t_JIS_Seq5000.Edit("[IsInsert]=1, [IsPrintAssemble]=0, [IsAssemble]=0, [IsTransport]=0", "[ID]=" + JisID);
t_JIS_Line.Del("[JisID]=" + JisID);
UpdateWeb();
}
}
catch (Exception ex)
{
MyMessageBox.ShowMessagePop(ex.Message);
}
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
#endregion
#region 私有函数
private string ReadFile(string filename)
{
string ret = "";
StreamReader sr = new StreamReader(filename, Encoding.Default);
ret = sr.ReadToEnd();
sr.Close();
return ret;
}
private string get_pz_image(string pz)
{
string ret = "";
if (pz == "高配")
{
ret = "<img src=\"images/l_red.png\" width=\"28\" height=\"28\" />";
}
else if (pz == "中配")
{
ret = "<img src=\"images/l_yellow.png\" width=\"28\" height=\"28\" />";
}
else if (pz == "低配")
{
ret = "<img src=\"images/l_green.png\" width=\"28\" height=\"28\" />";
}
return ret;
}
private string get_scan_image(bool IsScan)
{
string ret = "";
if (IsScan == false)
{
ret = "<img src=\"images/cancel.png\" width=\"28\" height=\"28\" />";
}
else
{
ret = "<img src=\"images/apply.png\" width=\"28\" height=\"28\" />";
}
return ret;
}
#endregion
private void btnClear_Click(object sender, EventArgs e)
{
try
{
if (dsLine == null) throw new Exception("当前没有装配信息");
if (dsLine.Tables[0].Rows.Count == 0) throw new Exception("当前没有装配信息");
int JisID = Convert.ToInt32(dsLine.Tables[0].Rows[0]["JisID"]);
if (JisID == 0) throw new Exception("当前没有装配信息");
if (MyMessageBox.ShowQuestion("是否要取消订单[" + dsLine.Tables[0].Rows[0]["OrderNumber"].ToString() + "]的装配?"))
{
t_JIS_Line.Del("[ID]=" + dsLine.Tables[0].Rows[0]["ID"].ToString());
}
}
catch (Exception ex)
{
MyMessageBox.ShowErrorMessage(ex.Message);
}
}
}
}