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

3 years ago
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);
}
}
}
}