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.
3591 lines
147 KiB
3591 lines
147 KiB
using DBUtility;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using MESClassLibrary.BLL.Log;
|
|
using MESClassLibrary.EFModel;
|
|
using System.Xml;
|
|
using static System.Windows.Forms.AxHost;
|
|
|
|
namespace PunchAndWeld.DataSouce
|
|
{
|
|
public class ProScreenFunc
|
|
{
|
|
public static DataTable GetResDataTable(string sql)
|
|
{
|
|
DataTable res = new DataTable();
|
|
try
|
|
{
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public static DataTable GetProScreen(string stationNo)
|
|
{
|
|
DataTable res = new DataTable();
|
|
try
|
|
{
|
|
string sql = @"
|
|
select top 1 a.ID, d.[Des], a.OrderNo, a.PartNo,b.ProductName,a.OrderCount,a.CompleteCount,a.BadCount, c.ProductID1, c.ProductID2, b.IsHigh
|
|
from tb_Plan_Punch a
|
|
left join tb_Product b
|
|
on a.PartNo = b.PartNo
|
|
left join tb_PunchAndStation c
|
|
on b.ProductID = c.ProductID1
|
|
left join tb_Station d
|
|
on c.StationID = d.StationID
|
|
where d.StationNo = '" + stationNo +@"'
|
|
and IsFinish = 1
|
|
order by CreateTime desc
|
|
";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (res == null || res.Rows.Count < 1)
|
|
{
|
|
sql = @"
|
|
select top 1 a.ID, d.[Des], a.OrderNo, a.PartNo,b.ProductName,a.OrderCount,a.CompleteCount,a.BadCount, c.ProductID1, c.ProductID2, b.IsHigh
|
|
from tb_Plan_Punch a
|
|
left join tb_Product b
|
|
on a.PartNo = b.PartNo
|
|
left join tb_PunchAndStation c
|
|
on b.ProductID = c.ProductID1
|
|
left join tb_Station d
|
|
on c.StationID = d.StationID
|
|
where d.StationNo = '" + stationNo + @"'
|
|
and IsFinish = 0
|
|
order by CreateTime desc
|
|
";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
if (res == null || res.Rows.Count < 1)
|
|
{
|
|
sql = @"
|
|
select top 1 a.ID, d.[Des], a.OrderNo, a.PartNo,b.ProductName,a.OrderCount,a.CompleteCount,a.BadCount, c.ProductID1, c.ProductID2, b.IsHigh
|
|
from tb_Plan_Punch a
|
|
left join tb_Product b
|
|
on a.PartNo = b.PartNo
|
|
left join tb_PunchAndStation c
|
|
on b.ProductID = c.ProductID1
|
|
left join tb_Station d
|
|
on c.StationID = d.StationID
|
|
where d.StationNo = '" + stationNo + @"'
|
|
and IsFinish = 2
|
|
order by CreateTime desc
|
|
";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static DataTable GetProScreenPlan(string id, string stationNo, string plan)
|
|
{
|
|
DataTable res = new DataTable();
|
|
try
|
|
{
|
|
if (plan == "下一计划")
|
|
{
|
|
#region 查询当前计划时间
|
|
|
|
string time = "";
|
|
string sql;
|
|
string sqll = @" select CreateTime from tb_Plan_Punch where ID = '" + id + @"' ";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sqll, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
time = dt.Rows[0][0].ToString();
|
|
time = Tools.NumericParse.StringToDateTime(time).Value.AddSeconds(1).ToString("yyyy-MM-dd HH:mm:ss");
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 查询下一计划
|
|
DateTime dtime = DateTime.Now;
|
|
DateTime.TryParse(time, out dtime);
|
|
sql = @"
|
|
select top 1 a.ID, d.[Des], a.OrderNo, a.PartNo,b.ProductName,a.OrderCount,a.CompleteCount,a.BadCount, c.ProductID1, c.ProductID2, b.IsHigh
|
|
from tb_Plan_Punch a
|
|
left join tb_Product b
|
|
on a.PartNo = b.PartNo
|
|
left join tb_PunchAndStation c
|
|
on b.ProductID = c.ProductID1
|
|
left join tb_Station d
|
|
on c.StationID = d.StationID
|
|
where d.StationNo = '" + stationNo + @"'
|
|
and IsFinish <> 3
|
|
and a.CreateTime > '" + dtime.ToString("yyyy-MM-dd HH:mm:ss") + @"'
|
|
order by CreateTime asc
|
|
";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
|
|
#endregion
|
|
}
|
|
else if (plan == "上一计划")
|
|
{
|
|
#region 查询当前计划时间
|
|
|
|
string time = "";
|
|
string sql;
|
|
string sqll = @" select CreateTime from tb_Plan_Punch where ID = '" + id + @"' ";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sqll, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
time = dt.Rows[0][0].ToString();
|
|
//time = Tools.NumericParse.StringToDateTime(time).Value.AddSeconds(-1).ToString("yyyy-MM-dd HH:mm:ss");
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 查询上一计划
|
|
DateTime dtime = DateTime.Now;
|
|
DateTime.TryParse(time, out dtime);
|
|
|
|
sql = @"
|
|
select top 1 a.ID, d.[Des], a.OrderNo, a.PartNo,b.ProductName,a.OrderCount,a.CompleteCount,a.BadCount, c.ProductID1, c.ProductID2, b.IsHigh
|
|
from tb_Plan_Punch a
|
|
left join tb_Product b
|
|
on a.PartNo = b.PartNo
|
|
left join tb_PunchAndStation c
|
|
on b.ProductID = c.ProductID1
|
|
left join tb_Station d
|
|
on c.StationID = d.StationID
|
|
where d.StationNo = '" + stationNo + @"'
|
|
and IsFinish <> 3
|
|
and a.CreateTime < '" + dtime.ToString("yyyy-MM-dd HH:mm:ss") + @"'
|
|
order by CreateTime desc
|
|
";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
|
|
#endregion
|
|
|
|
}
|
|
else if (plan == "当前计划")
|
|
{
|
|
string sql = @"
|
|
select a.ID, d.[Des], a.OrderNo, a.PartNo,b.ProductName,a.OrderCount,a.CompleteCount,a.BadCount, c.ProductID1, c.ProductID2, b.IsHigh
|
|
from tb_Plan_Punch a
|
|
left join tb_Product b
|
|
on a.PartNo = b.PartNo
|
|
left join tb_PunchAndStation c
|
|
on b.ProductID = c.ProductID1
|
|
left join tb_Station d
|
|
on c.StationID = d.StationID
|
|
where a.ID='"+ id +@"'
|
|
";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static void GetCode(string code, out string stockNo, out string batchNo, out string partNo)
|
|
{
|
|
|
|
stockNo = "";
|
|
batchNo = "";
|
|
partNo = "";
|
|
try
|
|
{
|
|
if (code.Contains(".") == false)
|
|
{
|
|
//一维码
|
|
if (code.Length > 9)
|
|
{
|
|
stockNo = code.Substring(0, 10);
|
|
batchNo = code.Substring(10, 6);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//二维码
|
|
string[] strs = code.Split(';');
|
|
if (strs.Length > 0)
|
|
{
|
|
string str = strs[0];
|
|
string[] props = str.Split('.');
|
|
if (props.Length >= 2)
|
|
{
|
|
partNo = props[0];
|
|
batchNo = props[1];
|
|
}
|
|
}
|
|
}
|
|
LogHelper.WriteSysLogBase("[入参]:code=" + code + "; [出参:]stockNo=" + stockNo + ",batchNo=" + batchNo + ",partNo=" + partNo, MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogManager(ex);
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
}
|
|
|
|
public static string GetProductID(string barcode)
|
|
{
|
|
string res = "";
|
|
try
|
|
{
|
|
LogHelper.WriteSysLogBase("[一码到底]扫入条码:"+barcode, MethodBase.GetCurrentMethod().Name);
|
|
|
|
barcode = UniteBarCodeToOne(barcode);
|
|
string sql = @" select ProductID
|
|
from tb_Product
|
|
where partNo = ( select top 1 paintCode from tb_StockIn where barcode = '" + barcode + @"' ) ";
|
|
object aa = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (aa != null)
|
|
res = aa.ToString();
|
|
else
|
|
{
|
|
string sql1 = @" select top 1 productInfo
|
|
from tb_InspectResult
|
|
where barcode = '"+ barcode +@"'
|
|
order by createtime desc ";
|
|
object bb = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql1, null);
|
|
if (bb != null)
|
|
{
|
|
string color = "";
|
|
string colorInfo = bb.ToString();
|
|
string[] colors = colorInfo.Split(',');
|
|
if (colors.Length >= 2)
|
|
{
|
|
color = colors[2];
|
|
|
|
string sql2 = @" select partNo from tb_Product where stockNo = '" + barcode.Substring(0, 10) + @"' ";
|
|
object cc = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql2, null);
|
|
if (cc != null)
|
|
{
|
|
string partNo = cc.ToString();
|
|
string paintCode = partNo.Replace("-P","") + "-" + color;
|
|
string sql3 = @" select ProductID
|
|
from tb_Product
|
|
where partNo = '" + paintCode + @"' ";
|
|
object dd = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql3, null);
|
|
if (dd != null)
|
|
{
|
|
res = dd.ToString();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
string partNo = "",stockNo="";
|
|
|
|
if (barcode.Contains('/'))
|
|
{
|
|
string[] aastr = barcode.Split('/');
|
|
partNo = aastr[0];
|
|
}
|
|
else if (barcode.Contains('.'))
|
|
{
|
|
string[] aastr = barcode.Split('.');
|
|
partNo = aastr[0];
|
|
}
|
|
else if (barcode.Length==20)
|
|
{
|
|
stockNo = barcode.Substring(0, 10);
|
|
}
|
|
else
|
|
{
|
|
partNo = barcode;
|
|
}
|
|
|
|
string sql3 = "";
|
|
if (partNo != "")
|
|
{
|
|
sql3 = @"select ProductID
|
|
from tb_Product
|
|
where partNo = '" + partNo + @"'";
|
|
}
|
|
else
|
|
{
|
|
sql3 = @"select ProductID
|
|
from tb_Product
|
|
where StockNo = '" + stockNo + @"'";
|
|
}
|
|
|
|
object dd = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql3, null);
|
|
if (dd != null)
|
|
{
|
|
res = dd.ToString();
|
|
}
|
|
}
|
|
}
|
|
LogHelper.WriteSysLogBase("[一码到底]传出ProductID2:" + res, MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static string GetProductID(string stockNo, string partNo)
|
|
{
|
|
string res = "";
|
|
try
|
|
{
|
|
string sql = " select ProductID from tb_Product where StockNo = '" + stockNo + "' or PartNo = '" + partNo + "' ";
|
|
object aa = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (aa != null)
|
|
{
|
|
res = aa.ToString();
|
|
}
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static string GetProductIDByPartNo(string partNo)
|
|
{
|
|
string res = "";
|
|
try
|
|
{
|
|
string sql = " select ProductID from tb_Product where PartNo = '" + partNo + "' ";
|
|
object aa = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (aa != null)
|
|
{
|
|
res = aa.ToString();
|
|
}
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static string TransToBarCodeOne(string barcode)
|
|
{
|
|
string res = barcode;
|
|
try
|
|
{
|
|
string sql = @"
|
|
SELECT TOP 1 OneBarCode FROM tb_BarCode WHERE BarCode = '" + barcode + @"'
|
|
";
|
|
object aa = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (aa != null)
|
|
{
|
|
res = aa.ToString();
|
|
}
|
|
else
|
|
{
|
|
string sql2 = @" SELECT TOP 1 OneBarCode FROM [10.60.101.60].[BBMPT1].[dbo].[v_Code] where BarCode = '" + barcode + @"' ";
|
|
object bb = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql2, null);
|
|
if (bb != null)
|
|
{
|
|
res = bb.ToString();
|
|
}
|
|
}
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
public static string UniteBarCodeToOne(string barcode)
|
|
{
|
|
string res = barcode;
|
|
if (!string.IsNullOrWhiteSpace(barcode))
|
|
{
|
|
if (barcode.Contains("."))
|
|
{
|
|
res = TransToBarCodeOne(barcode);
|
|
}
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static bool CheckPartAndProduct(string pid1, string pid2)
|
|
{
|
|
bool res = false;
|
|
try
|
|
{
|
|
string sql = @" select * from tb_PunchAndStation where ProductID1 = '" + pid1 + @"' and ProductID2 = '"+ pid2 +@"' ";
|
|
DataTable dt = ProScreenFunc.GetResDataTable(sql);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = true;
|
|
}
|
|
else
|
|
{
|
|
res = false;
|
|
}
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static int AddCompleteCount(string ID)
|
|
{
|
|
int res = 0;
|
|
try
|
|
{
|
|
string sql = " update tb_Plan_Punch set CompleteCount = CompleteCount + 1 where ID = '"+ ID +"' ";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static int SubCompleteCount(string ID)
|
|
{
|
|
int res = 0;
|
|
try
|
|
{
|
|
string sql = " update tb_Plan_Punch set CompleteCount = CompleteCount - 1 where ID = '" + ID + "' ";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static int AddBadCount(string ID)
|
|
{
|
|
int res = 0;
|
|
try
|
|
{
|
|
string sql = " update tb_Plan_Punch set BadCount = BadCount + 1 where ID = '" + ID + "' ";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static int SubBadCount(string ID)
|
|
{
|
|
int res = 0;
|
|
try
|
|
{
|
|
string sql = " update tb_Plan_Punch set BadCount = BadCount - 1 where ID = '" + ID + "' ";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static void SetPlanComplete(string ID)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"declare @a int;
|
|
declare @b int;
|
|
declare @ID varchar(50);
|
|
set @ID = '"+ ID +@"';
|
|
set @a = (select orderCount from tb_Plan_Punch where ID = @ID);
|
|
set @b = (select CompleteCount from tb_Plan_Punch where ID = @ID);
|
|
if @a <= @b
|
|
begin update tb_Plan_Punch set IsFinish = 3 where ID = @ID
|
|
end;";
|
|
SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
}
|
|
|
|
public static bool CheckPlanCompleted(string ID)
|
|
{
|
|
bool res = false;
|
|
try
|
|
{
|
|
string sql = @"
|
|
select IsFinish from tb_Plan_Punch where ID = '"+ ID +@"'
|
|
";
|
|
object aa = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (aa != null)
|
|
{
|
|
string bb = aa.ToString();
|
|
if (bb == "3")
|
|
{
|
|
res = true;
|
|
}
|
|
else
|
|
{
|
|
res = false;
|
|
}
|
|
}
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static int SavePartAndProduct(string barcode, string BcpID, string ZcID, string OrderNo, string WorkClass, string planID,string stationId,string description)
|
|
{
|
|
int res = 0;
|
|
try
|
|
{
|
|
string sql = @"
|
|
INSERT INTO [dbo].[tb_Punch_Code_Record]
|
|
([ID]
|
|
,[barcode]
|
|
,[BcpID]
|
|
,[ZcID]
|
|
,[OrderNo]
|
|
,[WorkClass]
|
|
,[CreateTime], PlanID,StationId,StationDescription)
|
|
VALUES
|
|
((select newid())
|
|
,'" + barcode + @"'
|
|
,'" + BcpID +@"'
|
|
,'" + ZcID + @"'
|
|
,'" + OrderNo + @"'
|
|
,'" + WorkClass + @"'
|
|
,(select getdate()), '" + planID + @"','"+ stationId + @"','"+ description + @"')
|
|
";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static int SavePartAndProduct1(string barcode, string BcpID, string ZcID, string OrderNo, string WorkClass, string planID, string SerialNo,string stationID,string description)
|
|
{
|
|
int res = 0;
|
|
try
|
|
{
|
|
string sql = @"
|
|
INSERT INTO [dbo].[tb_Punch_Code_Record]
|
|
([ID]
|
|
,[barcode]
|
|
,[BcpID]
|
|
,[ZcID]
|
|
,[OrderNo]
|
|
,[WorkClass]
|
|
,[CreateTime], PlanID,SerialNo,StationId,StationDescription)
|
|
VALUES
|
|
((select newid())
|
|
,'" + barcode + @"'
|
|
,'" + BcpID + @"'
|
|
,'" + ZcID + @"'
|
|
,'" + OrderNo + @"'
|
|
,'" + WorkClass + @"'
|
|
,(select getdate()), '" + planID + @"','" + SerialNo + @"','"+ stationID + @"','"+ description + @"')
|
|
";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static int SavePartAndProduct2(string barcode, string BcpID, string ZcID, string OrderNo, string WorkClass, string planID, string SerialNo,string stationId, string description)
|
|
{
|
|
int res = 0;
|
|
try
|
|
{
|
|
string sql = @"
|
|
INSERT INTO [dbo].[tb_Punch_Code_Record]
|
|
([ID]
|
|
,[barcode]
|
|
,[BcpID]
|
|
,[ZcID]
|
|
,[OrderNo]
|
|
,[WorkClass]
|
|
,[CreateTime], PlanID,SerialNo,StationId,StationDescription)
|
|
VALUES
|
|
((select newid())
|
|
,'" + barcode + @"'
|
|
,'" + BcpID + @"'
|
|
,'" + ZcID + @"'
|
|
,'" + OrderNo + @"'
|
|
,'" + WorkClass + @"'
|
|
,(select getdate()), '" + planID + @"','" + SerialNo + @"','"+ stationId + @"','"+ description + @"')
|
|
";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static int CompleteQty(string stationId)
|
|
{
|
|
int res = 0;
|
|
try
|
|
{
|
|
string time1 = DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00";
|
|
string time2 = DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59";
|
|
string sql= @"select count(ID) as qty from tb_Punch_Code_Record WITH(NOLOCK) where StationId='" + stationId + @"' and CreateTime between '"+ time1+@"' and '"+ time2 +@"'";
|
|
DataTable dt= SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt!=null && dt.Rows.Count>0)
|
|
{
|
|
res = int.Parse(dt.Rows[0]["qty"].ToString());
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static int SavePartAndProductBF(string barcode, string BcpID, string ZcID, string OrderNo, string WorkClass, string planID)
|
|
{
|
|
int res = 0;
|
|
try
|
|
{
|
|
string sql = @"
|
|
INSERT INTO [dbo].[tb_Punch_Code_Record_BF]
|
|
([ID]
|
|
,[barcode]
|
|
,[BcpID]
|
|
,[ZcID]
|
|
,[OrderNo]
|
|
,[WorkClass]
|
|
,[CreateTime], PlanID)
|
|
VALUES
|
|
((select newid())
|
|
,'" + barcode + @"'
|
|
,'" + BcpID + @"'
|
|
,'" + ZcID + @"'
|
|
,'" + OrderNo + @"'
|
|
,'" + WorkClass + @"'
|
|
,(select getdate()), '" + planID + @"')
|
|
";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static DataTable QueryPlanDetail(string starttime, string endtime, string stationNo)
|
|
{
|
|
DataTable res = new DataTable();
|
|
try
|
|
{
|
|
string sql = @"
|
|
select * from
|
|
(
|
|
select a.IsFinish, a.OrderNo, a.PartNo,b.ProductName,a.OrderCount,a.CompleteCount,a.BadCount,a.CreateTime,a.ID
|
|
from tb_Plan_Punch a
|
|
left join tb_Product b
|
|
on a.PartNo = b.PartNo
|
|
left join tb_PunchAndStation c
|
|
on b.ProductID = c.ProductID1
|
|
left join tb_Station d
|
|
on c.StationID = d.StationID
|
|
where a.CreateTime >= '" + starttime + @" 00:00:00' and a.CreateTime <= '" + endtime + @" 23:59:59'
|
|
and c.stationID = ( select StationID from tb_Station where StationNo = '" + stationNo + @"' )
|
|
and IsFinish <> 3
|
|
) bb
|
|
order by CreateTime
|
|
";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static string GetStation(string stationNo)
|
|
{
|
|
string res = "";
|
|
try
|
|
{
|
|
string sql = @" select [des] from tb_Station where StationNo = '"+ stationNo +@"' ";
|
|
object aa = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (aa != null)
|
|
{
|
|
res = aa.ToString();
|
|
}
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static string GetStationId(string stationNo)
|
|
{
|
|
string res = "";
|
|
try
|
|
{
|
|
string sql = @" select StationID from tb_Station where StationNo = '" + stationNo + @"' ";
|
|
object aa = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (aa != null)
|
|
{
|
|
res = aa.ToString();
|
|
}
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static int SaveZcCode(string barcode, string partNo)
|
|
{
|
|
int res = 0;
|
|
try
|
|
{
|
|
barcode = UniteBarCodeToOne(barcode);
|
|
string sql = @" update tb_StockIn set ZcCode = '" + partNo + "' where barcode = '"+ barcode +"' ";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static OtherPart HaveOtherPart(string stationNo, string productID1)
|
|
{
|
|
OtherPart res = new OtherPart();
|
|
res.productID3 = "";
|
|
res.productID4 = "";
|
|
res.productID5 = "";
|
|
try
|
|
{
|
|
string sql = @"
|
|
select top 1 [ProductID3]
|
|
,[ProductID4]
|
|
,[ProductID5]
|
|
,[ProductID9]
|
|
,[ProductID10]
|
|
,[ProductID11]
|
|
from tb_PunchAndStation
|
|
where StationID = ( select StationID from tb_Station where StationNo = '" + stationNo +@"' )
|
|
and ProductID1 = '" + productID1 + @"'
|
|
order by CreateTine desc
|
|
";
|
|
DataTable dt = ProScreenFunc.GetResDataTable(sql);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res.productID3 = dt.Rows[0]["ProductID3"].ToString();
|
|
res.productID4 = dt.Rows[0]["ProductID4"].ToString();
|
|
res.productID5 = dt.Rows[0]["ProductID5"].ToString();
|
|
res.productID6 = dt.Rows[0]["ProductID9"].ToString();
|
|
res.productID7 = dt.Rows[0]["ProductID10"].ToString();
|
|
res.productID8 = dt.Rows[0]["ProductID11"].ToString();
|
|
}
|
|
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static bool HaveScan(string barcode)
|
|
{
|
|
bool res = false;
|
|
try
|
|
{
|
|
string sql = "";
|
|
if (barcode.Substring(0, 2) != "22")
|
|
{
|
|
sql = @"
|
|
select *
|
|
from tb_Punch_Code_Record
|
|
where barcode = '" + barcode + @"'
|
|
";
|
|
}
|
|
else
|
|
{
|
|
if (barcode.Substring(0, 10) == "2200000057" || barcode.Substring(0, 10) == "2200000058")
|
|
{
|
|
sql = @"
|
|
select *
|
|
from tb_Punch_Code_Record
|
|
where barcode = '" + barcode + @"'
|
|
";
|
|
}
|
|
else
|
|
{
|
|
sql = @" select * from tb_StockIn where barcode = '" + barcode + "' and ZcCode is not null";
|
|
}
|
|
}
|
|
DataTable dt = ProScreenFunc.GetResDataTable(sql);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = true;
|
|
}
|
|
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
|
|
public static bool IsBad(string barcode)
|
|
{
|
|
bool res = false;
|
|
try
|
|
{
|
|
string sql = "";
|
|
|
|
sql = @"
|
|
select top 1 *
|
|
from tb_Punch_Code_Record2
|
|
where barcode = '" + barcode + @"' order by createtime DESC
|
|
";
|
|
DataTable dt = ProScreenFunc.GetResDataTable(sql);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
if (dt.Rows[0]["isOK"].ToString() == "0")
|
|
{
|
|
res = true;
|
|
}
|
|
else
|
|
{
|
|
res = false;
|
|
}
|
|
}
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static string GetPartNoByStockNo(string stockNo)
|
|
{
|
|
string res = "";
|
|
try
|
|
{
|
|
string sql = " select partNo from tb_Product where StockNo = '" + stockNo + "' ";
|
|
object aa = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (aa != null)
|
|
{
|
|
res = aa.ToString();
|
|
}
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static string GetPlanIDByBarcode(string barcode)
|
|
{
|
|
string res = "";
|
|
try
|
|
{
|
|
string sql = @"
|
|
select top 1 PlanID from tb_Punch_Code_Record where barcode = '" + barcode + @"' order by CreateTime desc
|
|
";
|
|
object aa = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (aa != null)
|
|
{
|
|
res = aa.ToString();
|
|
}
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static DataTable GetProScreenByPlanID(string planID)
|
|
{
|
|
DataTable res = new DataTable();
|
|
try
|
|
{
|
|
string sql = @"
|
|
select top 1 a.ID, d.[Des], a.OrderNo, a.PartNo,b.ProductName,a.OrderCount,a.CompleteCount,a.BadCount, c.ProductID1, c.ProductID2
|
|
from tb_Plan_Punch a
|
|
left join tb_Product b
|
|
on a.PartNo = b.PartNo
|
|
left join tb_PunchAndStation c
|
|
on b.ProductID = c.ProductID1
|
|
left join tb_Station d
|
|
on c.StationID = d.StationID
|
|
where a.ID = '" + planID + @"'
|
|
";
|
|
res = ProScreenFunc.GetResDataTable(sql);
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static int SaveRecord2(string barcode, string isOK, string planID)
|
|
{
|
|
int res = 0;
|
|
try
|
|
{
|
|
string sql = @"
|
|
INSERT INTO tb_Punch_Code_Record2
|
|
([ID]
|
|
,[barcode]
|
|
,[isOK]
|
|
,[planID]
|
|
,[createtime])
|
|
VALUES
|
|
((select newid())
|
|
,'" + barcode + @"'
|
|
,'" + isOK + @"'
|
|
,'" + planID + @"'
|
|
,(select getdate()))
|
|
";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static string[] GetSpecialStockNo()
|
|
{
|
|
string[] res = {""};
|
|
try
|
|
{
|
|
string sql = @" select SpecialStockNo from tb_SpcialStockNo ";
|
|
DataTable dt = ProScreenFunc.GetResDataTable(sql);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = new string[dt.Rows.Count];
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
res[i] = dt.Rows[i][0].ToString().Trim();
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static string[] GetSpcialNotFacStockNo()
|
|
{
|
|
string[] res = { "" };
|
|
try
|
|
{
|
|
string sql = @" select NotFacStockNo from tb_SpcialNotFacStockNo ";
|
|
DataTable dt = ProScreenFunc.GetResDataTable(sql);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = new string[dt.Rows.Count];
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
res[i] = dt.Rows[i][0].ToString().Trim();
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static string GetZcPartNo(string barcode)
|
|
{
|
|
string res = "";
|
|
try
|
|
{
|
|
string sql = " select * from tb_Punch_Code_Record where barcode = '"+ barcode +"' ";
|
|
DataTable dt = ProScreenFunc.GetResDataTable(sql);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = "";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
return "";
|
|
}
|
|
|
|
public static bool IsYaoYanBlack(string barcode)
|
|
{
|
|
bool res = false;
|
|
try
|
|
{
|
|
string sql = @"
|
|
SELECT *
|
|
FROM [BBMPT].[dbo].[tb_InspectResult]
|
|
where barcode = '"+ barcode +@"'
|
|
and productInfo like '曜岩黑%'
|
|
";
|
|
DataTable dt = ProScreenFunc.GetResDataTable(sql);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = true;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static bool IsFBC(string code, string text)
|
|
{
|
|
bool res = false;
|
|
try
|
|
{
|
|
if ((code.Contains("57") && text.Contains("0540-9197")) || (code.Contains("58") && text.Contains("0640-9197")) || (code.Contains("1230003138") && text.Contains("A2476904100")) || (code.Contains("1230003139") && text.Contains("A2476904200")))
|
|
{
|
|
res = true;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static bool HaveInspect(string barcode)
|
|
{
|
|
bool res = false;
|
|
try
|
|
{
|
|
string sql = " select * from tb_InspectResult where barcode = '"+ barcode +"' ";
|
|
DataTable dt = ProScreenFunc.GetResDataTable(sql);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = true;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static string GetCompleteCount(string ID)
|
|
{
|
|
string res = "0";
|
|
try
|
|
{
|
|
string sql = @"
|
|
select CompleteCount
|
|
from tb_Plan_Punch WITH(NOLOCK)
|
|
where ID = '" + ID + @"'
|
|
";
|
|
object aa = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (aa != null)
|
|
{
|
|
res = aa.ToString();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static bool CanScan(string injectionPlanID)
|
|
{
|
|
bool res = true;
|
|
try
|
|
{
|
|
string sql = @" select CompleteCount,OrderCount from tb_Plan_Punch WITH (NOLOCK) where ID = '" + injectionPlanID + "' ";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
int compCount = Tools.NumericParse.StringToInt(dt.Rows[0]["CompleteCount"].ToString());
|
|
int planCount = Tools.NumericParse.StringToInt(dt.Rows[0]["OrderCount"].ToString());
|
|
if (compCount >= planCount)
|
|
{
|
|
res = false;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static bool HaveNotPrint(string stationId)
|
|
{
|
|
bool res = false;
|
|
try
|
|
{
|
|
string sql = @" SELECT ID from dbo.tb_Punch_Code_Record
|
|
where dbo.tb_Punch_Code_Record.StationId='" + stationId + @"'
|
|
and (isnull(ToVisual,1) =1 OR ISNULL(PrintTime,'') ='')";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = true;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static DataTable NotPrintBarCode(string stationId)
|
|
{
|
|
string sql = @" SELECT top 1 barcode from dbo.tb_Punch_Code_Record
|
|
where dbo.tb_Punch_Code_Record.StationId='" + stationId + @"'
|
|
and (isnull(ToVisual,1) =1 OR ISNULL(PrintTime,'') ='')
|
|
ORDER BY CreateTime DESC ";
|
|
return SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
|
|
public static DataTable GetGh(string barcode)
|
|
{
|
|
DataTable res = new DataTable();
|
|
try
|
|
{
|
|
string sql = @"
|
|
select top 1 * from tb_Punch_Code_Record WITH (NOLOCK) where barcode = '" + barcode + @"' order by CreateTime desc
|
|
";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static DataTable GetBl(string barcode)
|
|
{
|
|
DataTable res = new DataTable();
|
|
try
|
|
{
|
|
string sql = @"
|
|
select top 1 *
|
|
from tb_Punch_Code_Record2 WITH (NOLOCK)
|
|
where barcode = '" + barcode + @"'
|
|
and isOK = '0'
|
|
order by createtime desc
|
|
";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static DataTable GetHG_New(string barcode)
|
|
{
|
|
DataTable res = new DataTable();
|
|
try
|
|
{
|
|
string sql = @"
|
|
select top 1 *
|
|
from tb_Punch_Code_Record2 WITH (NOLOCK)
|
|
where barcode = '" + barcode + @"'
|
|
and isOK = '1'
|
|
order by createtime desc
|
|
";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static ZcPrintLabel GetZcPrintLabel(string zcID)
|
|
{
|
|
ZcPrintLabel zl = new ZcPrintLabel();
|
|
try
|
|
{
|
|
string sql = @"
|
|
select *
|
|
from tb_Product
|
|
where ProductID = '" + zcID + @"'
|
|
";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
zl.zcPartNo = dt.Rows[0]["PartNo"].ToString();
|
|
zl.zcName = dt.Rows[0]["ProductName"].ToString();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
return zl;
|
|
}
|
|
|
|
public static string GetPaintCode(string barcode)
|
|
{
|
|
string res = "0";
|
|
try
|
|
{
|
|
string sql = @"
|
|
select top 1 paintCode from tb_StockIn where barcode = '" + barcode + @"' order by createTime desc
|
|
";
|
|
object aa = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (aa != null)
|
|
{
|
|
res = aa.ToString();
|
|
}
|
|
else
|
|
{
|
|
string sql1 = @"select top 1 productInfo from tb_InspectResult where barcode = '" + barcode + @"' ORDER BY createTime DESC";
|
|
object aa1 = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql1, null);
|
|
if (aa1 != null)
|
|
{
|
|
string productInfo = aa1.ToString();
|
|
if (!string.IsNullOrEmpty(productInfo))
|
|
{
|
|
string[] bb = productInfo.Split(',');
|
|
string color = bb[2];
|
|
|
|
string stockNo = "";
|
|
string batchNo = "";
|
|
string partNo = "";
|
|
GetCode(barcode, out stockNo, out batchNo, out partNo);
|
|
|
|
res = partNo + "-" + color;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static DateTime GetPlanTime(string planID)
|
|
{
|
|
DateTime res = new DateTime();
|
|
try
|
|
{
|
|
string sql = @"
|
|
select CreateTime from tb_Plan_Punch where ID = '" + planID + @"'
|
|
";
|
|
object aa = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (aa != null)
|
|
{
|
|
res = Convert.ToDateTime(aa);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static DataTable HavePrint(string stationId)
|
|
{
|
|
DataTable dt = null;
|
|
try
|
|
{
|
|
// string sql = @"select top 1 r.*,s.StationNo from [dbo].[tb_Punch_Code_Record] r
|
|
// LEFT JOIN dbo.tb_PunchAndStation p
|
|
// ON r.ZcID=p.ProductID1
|
|
// LEFT JOIN dbo.tb_Station s
|
|
// ON p.StationID=s.StationID
|
|
// WHERE r.ToVisual=0 and isNull(r.PrintTime,'')=''
|
|
// AND s.StationNo='" + stationNo + @"' order by ID";
|
|
|
|
// string sql = @"SELECT TOP (1) r.ID, r.barcode, r.BcpID, r.ZcID, r.OrderNo, r.WorkClass, r.CreateTime, r.PlanID, r.SerialNo, r.ToVisual,
|
|
// r.FinishTime, r.PrintTime, r.IsCheck, s.StationNo, dbo.tb_Product.PartNo, dbo.tb_Product.ProductName
|
|
//FROM dbo.tb_Punch_Code_Record AS r LEFT OUTER JOIN
|
|
// dbo.tb_Product ON r.ZcID = dbo.tb_Product.ProductID LEFT OUTER JOIN
|
|
// dbo.tb_PunchAndStation AS p ON r.ZcID = p.ProductID1 LEFT OUTER JOIN
|
|
// dbo.tb_Station AS s ON p.StationID = s.StationID
|
|
// WHERE r.ToVisual=1 and isNull(r.PrintTime,'')=''
|
|
// AND s.StationNo='" + stationNo + @"' order by r.CreateTime";
|
|
//string sql =
|
|
// "select top 1 * from [dbo].[tb_Punch_Code_Record] where ToVisual=0 and isNull(PrintTime,'')='' order by ID ";
|
|
|
|
|
|
|
|
//string sql = @"SELECT TOP (1) r.ID, r.barcode, r.BcpID, r.ZcID, r.OrderNo, r.WorkClass, r.CreateTime, r.PlanID, r.SerialNo, r.ToVisual,
|
|
// r.FinishTime, r.PrintTime, r.IsCheck, s.StationNo, dbo.tb_Product.PartNo, dbo.tb_Product.ProductName
|
|
// FROM dbo.tb_Punch_Code_Record AS r LEFT OUTER JOIN
|
|
// dbo.tb_Product ON r.ZcID = dbo.tb_Product.ProductID LEFT OUTER JOIN
|
|
// dbo.tb_PunchAndStation AS p ON r.ZcID = p.ProductID1 LEFT OUTER JOIN
|
|
// dbo.tb_Station AS s ON p.StationID = s.StationID
|
|
// WHERE (r.ToVisual=0 or isNull(r.PrintTime,'')='')
|
|
// AND s.StationNo='" + stationNo + @"' order by r.CreateTime desc";
|
|
|
|
string sql = @"SELECT TOP (1) r.ID, r.barcode, r.BcpID, r.ZcID, r.PlanID, r.SerialNo, r.ToVisual,
|
|
dbo.tb_Product.PartNo, dbo.tb_Product.ProductName
|
|
FROM dbo.tb_Punch_Code_Record AS r LEFT OUTER JOIN
|
|
dbo.tb_Product ON r.ZcID = dbo.tb_Product.ProductID
|
|
WHERE (r.ToVisual=0 and isNull(r.PrintTime,'')='')
|
|
AND r.StationId='" + stationId + @"' order by r.CreateTime desc";
|
|
|
|
dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
|
|
return dt;
|
|
}
|
|
|
|
public static int UpdatePrintTime(string ID)
|
|
{
|
|
int res = 0;
|
|
try
|
|
{
|
|
string sql = @"
|
|
update tb_Punch_Code_Record
|
|
set PrintTime=(select getdate())
|
|
where ID='"+ID+@"'
|
|
";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static string SerialNo(string partNo, string batch)
|
|
{
|
|
string res = "";
|
|
try
|
|
{
|
|
string temp_no = partNo + "." + batch;
|
|
string sql = @"select top 1 SerialNo from tb_Punch_Code_Record where SerialNo like '" + temp_no +
|
|
@"%' order by CreateTime desc";
|
|
object dt=SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null)
|
|
{
|
|
res = dt.ToString();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
throw ex;
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static bool IsPunch(string barCode,string stationNo)
|
|
{
|
|
bool res = false;
|
|
|
|
try
|
|
{
|
|
string sql = @"
|
|
SELECT dbo.tb_Punch_Code_Record.ID
|
|
FROM dbo.tb_Station RIGHT OUTER JOIN
|
|
dbo.tb_PunchAndStation ON dbo.tb_Station.StationID = dbo.tb_PunchAndStation.StationID RIGHT OUTER JOIN
|
|
dbo.tb_Punch_Code_Record ON dbo.tb_PunchAndStation.ProductID1 = dbo.tb_Punch_Code_Record.ZcID
|
|
where dbo.tb_Punch_Code_Record.barcode='" + barCode + @"' and dbo.tb_Station.StationNo='"+ stationNo+@"'
|
|
";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = true;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static string GetPartNoByID(string id)
|
|
{
|
|
string res = "";
|
|
try
|
|
{
|
|
string sql = @"select PartNo from tb_Product where ProductID ='"+ id +@"'";
|
|
object dt = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null)
|
|
{
|
|
res = dt.ToString();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static string GetPartNameByStock(string stockNo)
|
|
{
|
|
string res = "";
|
|
try
|
|
{
|
|
string sql = @"select ProductName from tb_Product where StockNo ='" + stockNo + @"'";
|
|
object dt = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null)
|
|
{
|
|
res = dt.ToString();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static bool IsPack(string barCode)
|
|
{
|
|
bool res = false;
|
|
try
|
|
{
|
|
string sql = @"select ID from tb_Box_Record with (nolock) where BarCode='"+ barCode +@"' ";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = true;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static DataTable ZCInfo(string barCode)
|
|
{
|
|
DataTable res = null;
|
|
|
|
try
|
|
{
|
|
string sql = @"SELECT isnull(dbo.tb_Product.PackQty,0) as PackCount, dbo.tb_Product.ProductName, dbo.tb_Product.PartNo
|
|
FROM dbo.tb_Punch_Code_Record with (nolock) LEFT OUTER JOIN
|
|
dbo.tb_Product ON dbo.tb_Punch_Code_Record.ZcID = dbo.tb_Product.ProductID
|
|
where dbo.tb_Punch_Code_Record.barcode='" + barCode +@"'";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static string boxNo(string barCode)
|
|
{
|
|
string res = "";
|
|
|
|
try
|
|
{
|
|
string sql = @"SELECT TOP 1 dbo.tb_Box_WheelBrow.BoxNo
|
|
FROM dbo.tb_Product LEFT OUTER JOIN
|
|
dbo.tb_Box_WheelBrow ON dbo.tb_Product.PartNo = dbo.tb_Box_WheelBrow.PartNo RIGHT OUTER JOIN
|
|
dbo.tb_Punch_Code_Record ON dbo.tb_Product.ProductID = dbo.tb_Punch_Code_Record.ZcID
|
|
where dbo.tb_Punch_Code_Record.barcode='"+ barCode+@"'
|
|
order by dbo.tb_Box_WheelBrow.CreateTime desc";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = dt.Rows[0]["BoxNo"].ToString();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static int HavePackCount(string boxNo)
|
|
{
|
|
int res = 0;
|
|
|
|
try
|
|
{
|
|
string sql= @"select count(ID) as aa from dbo.tb_Box_Record with (nolock) where BoxNo='"+ boxNo + @"'";
|
|
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = int.Parse(dt.Rows[0]["aa"].ToString());
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static int AddBoxInfo(string boxNo, int flag, string partNo, string partName, string batch,
|
|
string validity, string validityDate)
|
|
{
|
|
int res = 0;
|
|
|
|
try
|
|
{
|
|
string sql = @" insert into tb_Box_WheelBrow (BoxNo,Flag,PartNo,PartName,BatchNo,Validity,ValidityDate) values('"+ boxNo +@"',
|
|
"+flag +@",'"+ partNo + @"','" + partName + @"','" + batch + @"','" + validity + @"','" + validityDate + @"')";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static int AddPackInfo(string barCode, string boxNo)
|
|
{
|
|
int res = 0;
|
|
|
|
try
|
|
{
|
|
string sql = @"insert into tb_Box_Record (BarCode,BoxNo) values('" + barCode + @"','" + boxNo + @"')";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static DataTable IsExsit(string boxNo)
|
|
{
|
|
DataTable res = null;
|
|
|
|
try
|
|
{
|
|
string sql = @"select top 1 * from tb_Box_WheelBrow with (nolock) where BoxNo='" + boxNo + @"' order by CreateTime desc";
|
|
res= SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static DataTable PackSum(string stationNo)
|
|
{
|
|
DataTable res = null;
|
|
try
|
|
{
|
|
string sql = "";
|
|
if (stationNo == "ZP79" )
|
|
{
|
|
sql = @"SELECT COUNT(r.ID) AS qty
|
|
,r.BoxNo
|
|
,p.PartNo
|
|
,p.ProductName
|
|
FROM tb_Box_Record r WITH (NOLOCK)
|
|
LEFT OUTER JOIN dbo.tb_Product p
|
|
ON SUBSTRING(r.BoxNo,0,CHARINDEX('.',r.BoxNo))=p.PartNo
|
|
where p.PartNo in ('A2548850000','A2548850200','A2548850400','A2548850600')
|
|
GROUP BY BoxNo,PartNo,ProductName
|
|
HAVING COUNT(r.ID)<54";
|
|
}
|
|
|
|
if (stationNo == "ZP63")
|
|
{
|
|
sql = @"SELECT COUNT(r.ID) AS qty
|
|
,r.BoxNo
|
|
,p.PartNo
|
|
,p.ProductName
|
|
FROM tb_Box_Record r WITH (NOLOCK)
|
|
LEFT OUTER JOIN dbo.tb_Product p
|
|
ON SUBSTRING(r.BoxNo,0,CHARINDEX('.',r.BoxNo))=p.PartNo
|
|
where p.PartNo like 'A2548805702-%' OR p.PartNo like 'A2548805802-%' OR p.PartNo like 'A2548809402-%' OR p.PartNo like 'A2548809502-%'
|
|
GROUP BY BoxNo,PartNo,ProductName
|
|
HAVING COUNT(r.ID)<54
|
|
UNION
|
|
SELECT COUNT(r.ID) AS qty
|
|
,r.BoxNo
|
|
,p.PartNo
|
|
,p.ProductName
|
|
FROM tb_Box_Record r WITH (NOLOCK)
|
|
LEFT OUTER JOIN dbo.tb_Product p
|
|
ON SUBSTRING(r.BoxNo,0,CHARINDEX('.',r.BoxNo))=p.PartNo
|
|
where p.PartNo IN( 'A2948806000' ,'A2948805900','A2948808202','A2948808102')
|
|
GROUP BY BoxNo,PartNo,ProductName
|
|
HAVING COUNT(r.ID)<16";
|
|
}
|
|
if (stationNo == "ZP78")
|
|
{
|
|
sql = @"SELECT COUNT(r.ID) AS qty
|
|
,r.BoxNo
|
|
,p.PartNo
|
|
,p.ProductName
|
|
FROM tb_Box_Record r WITH (NOLOCK)
|
|
LEFT OUTER JOIN dbo.tb_Product p
|
|
ON SUBSTRING(r.BoxNo,0,CHARINDEX('.',r.BoxNo))=p.PartNo
|
|
where p.PartNo like 'A2548809402-%' OR p.PartNo like 'A2548809502-%'
|
|
GROUP BY BoxNo,PartNo,ProductName
|
|
HAVING COUNT(r.ID)<54
|
|
UNION
|
|
SELECT COUNT(r.ID) AS qty
|
|
,r.BoxNo
|
|
,p.PartNo
|
|
,p.ProductName
|
|
FROM tb_Box_Record r WITH (NOLOCK)
|
|
LEFT OUTER JOIN dbo.tb_Product p
|
|
ON SUBSTRING(r.BoxNo,0,CHARINDEX('.',r.BoxNo))=p.PartNo
|
|
where p.PartNo IN( 'A2948808202' ,'A2948808102')
|
|
GROUP BY BoxNo,PartNo,ProductName
|
|
HAVING COUNT(r.ID)<16";
|
|
}
|
|
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static DataTable PackList(string boxNo)
|
|
{
|
|
DataTable res = null;
|
|
|
|
try
|
|
{
|
|
string sql = @"select * from tb_Box_Record with (nolock) where BoxNo='" + boxNo + @"' order by CreateTime desc";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static DataTable NotPackList(string stationNo)
|
|
{
|
|
DataTable res = null;
|
|
|
|
try
|
|
{
|
|
string sql = @"SELECT dbo.tb_Punch_Code_Record.barcode
|
|
FROM dbo.tb_Punch_Code_Record WITH (NOLOCK) LEFT OUTER JOIN
|
|
dbo.tb_PunchAndStation ON dbo.tb_Punch_Code_Record.ZcID = dbo.tb_PunchAndStation.ProductID1 LEFT OUTER JOIN
|
|
dbo.tb_Station ON dbo.tb_PunchAndStation.StationID = dbo.tb_Station.StationID
|
|
WHERE dbo.tb_Station.StationNo='"+ stationNo +@"'
|
|
AND dbo.tb_Punch_Code_Record.barcode NOT IN(SELECT barcode FROM dbo.tb_Box_Record WITH (NOLOCK))";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static string barCode(string serialNo)
|
|
{
|
|
string res = "";
|
|
try
|
|
{
|
|
string sql = @"select top 1 barcode from tb_Punch_Code_Record WHERE SerialNo='" + serialNo + @"' order by CreateTime desc ";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = dt.Rows[0]["barcode"].ToString();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
public static bool IsScan(string barCode)
|
|
{
|
|
bool res = false;
|
|
|
|
try
|
|
{
|
|
string sql = @"select ID from tb_ScanRecord_Laser where BarCode='" + barCode + @"'";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = true;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
public static bool IsScanNew(string barCode,string tableName)
|
|
{
|
|
bool res = false;
|
|
|
|
try
|
|
{
|
|
string sql = $@"select ID from tb_ScanRecord_Laser where BarCode='" + barCode + "' union all select ID from tb_ScanRecord_LaserL where BarCode='" + barCode + "'";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = true;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
public static bool IsBarCodeExsit214(string barCode)
|
|
{
|
|
return ProScreenFunc.SjBarCodeIsInStockIn(barCode);
|
|
//bool res = false;
|
|
|
|
//try
|
|
//{
|
|
// string sql = $@"select ID from tb_StockIn where BarCode='" + barCode + @"'";
|
|
// DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
// if (dt != null && dt.Rows.Count > 0)
|
|
// {
|
|
// res = true;
|
|
// }
|
|
//}
|
|
//catch (Exception ex)
|
|
//{
|
|
// LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
//}
|
|
|
|
//return res;
|
|
}
|
|
public static DataTable GetScanRecord_Lasers(DateTime timeFr,DateTime timeTo,string barCode)
|
|
{
|
|
bool res = false;
|
|
|
|
try
|
|
{
|
|
string whereStr = $"ScanTime>='{timeFr}' and ScanTime<='{timeTo}'";
|
|
if(!string.IsNullOrEmpty(barCode))
|
|
{
|
|
whereStr = whereStr + $" and BarCode='{barCode}'";
|
|
}
|
|
string sql = $@"select BarCode,ScanTime,LeftOrRight,MCode,'高' as Cfg from tb_ScanRecord_Laser where {whereStr}
|
|
union all select BarCode,ScanTime,LeftOrRight,MCode,'低' as Cfg from tb_ScanRecord_LaserL where {whereStr}";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
return dt;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public static int AddScanRecord(string barCode)
|
|
{
|
|
int res = 0;
|
|
|
|
try
|
|
{
|
|
string sql = @"insert into tb_ScanRecord_Laser(BarCode) values('" + barCode + @"')";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
public static int AddScanRecordNew(string barCode,string partCode,string leftOrright,string tableName)
|
|
{
|
|
int res = 0;
|
|
|
|
try
|
|
{
|
|
string sql = $@"insert into {tableName}(BarCode,LeftOrRight,MCode) values('{barCode}','{leftOrright}','{partCode}')";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static string GetScanCountByClass(string workClass)
|
|
{
|
|
string res = "0";
|
|
try
|
|
{
|
|
string t1 = "",t2="";
|
|
|
|
if (workClass == "白班")
|
|
{
|
|
t1 = DateTime.Now.ToString("yyyy-MM-dd") + " 07:30:00";
|
|
t2 = DateTime.Now.ToString("yyyy-MM-dd") + " 19:29:59";
|
|
}
|
|
else
|
|
{
|
|
if (DateTime.Now.Hour <= 23)
|
|
{
|
|
t1 = DateTime.Now.ToString("yyyy-MM-dd") + " 19:30:00";
|
|
t2 = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") + " 07:29:59";
|
|
}
|
|
else if (DateTime.Now.Hour >= 0 && DateTime.Now.Hour <8)
|
|
{
|
|
t1 = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + " 19:30:00";
|
|
t2 = DateTime.Now.ToString("yyyy-MM-dd") + " 07:29:59";
|
|
}
|
|
}
|
|
string sql = @"select Count(ID) as qty from tb_ScanRecord_Laser where ScanTime between '" + t1 + @"' and '" +
|
|
t2 + @"' ";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = dt.Rows[0]["qty"].ToString();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static DataTable GetScanRecord(string workClass)
|
|
{
|
|
DataTable res = null;
|
|
try
|
|
{
|
|
//string t1 = DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00";
|
|
//string t2 = DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59";
|
|
|
|
string t1 = "", t2 = "";
|
|
|
|
if (workClass == "白班")
|
|
{
|
|
t1 = DateTime.Now.ToString("yyyy-MM-dd") + " 07:30:00";
|
|
t2 = DateTime.Now.ToString("yyyy-MM-dd") + " 19:29:59";
|
|
}
|
|
else
|
|
{
|
|
if (DateTime.Now.Hour <= 23)
|
|
{
|
|
t1 = DateTime.Now.ToString("yyyy-MM-dd") + " 19:30:00";
|
|
t2 = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") + " 07:29:59";
|
|
}
|
|
else if (DateTime.Now.Hour >= 0 && DateTime.Now.Hour < 8)
|
|
{
|
|
t1 = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + " 19:30:00";
|
|
t2 = DateTime.Now.ToString("yyyy-MM-dd") + " 07:29:59";
|
|
}
|
|
}
|
|
|
|
string sql = @"select BarCode,ScanTime from tb_ScanRecord_Laser where ScanTime between '" + t1 + @"' and '" +
|
|
t2 + @"' order by ID desc";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static DataTable GetZCPartInfo(string partID, string stationNo)
|
|
{
|
|
DataTable res = new DataTable();
|
|
|
|
try
|
|
{
|
|
string sql = @"SELECT dbo.tb_Product.PartNo,dbo.tb_Product.ProductID,dbo.tb_Product.ProductName,dbo.tb_Product.IsHigh
|
|
FROM dbo.tb_PunchAndStation LEFT OUTER JOIN
|
|
dbo.tb_Product ON dbo.tb_PunchAndStation.ProductID1 = dbo.tb_Product.ProductID LEFT OUTER JOIN
|
|
dbo.tb_Station ON dbo.tb_PunchAndStation.StationID = dbo.tb_Station.StationID
|
|
where dbo.tb_PunchAndStation.ProductID2='" + partID + @"' and dbo.tb_Station.StationNo='"+ stationNo +@"'";
|
|
res= SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static DataTable GetPlanInfoByOrderNo(string orderNo)
|
|
{
|
|
DataTable res=new DataTable();
|
|
|
|
try
|
|
{
|
|
string sql = @"SELECT dbo.tb_Product.ProductName, dbo.tb_Plan_Punch.OrderNo, dbo.tb_Plan_Punch.PartNo,
|
|
dbo.tb_Plan_Punch.OrderCount,dbo.tb_Plan_Punch.IsFinish,dbo.tb_Plan_Punch.CompleteCount
|
|
FROM dbo.tb_Plan_Punch LEFT OUTER JOIN
|
|
dbo.tb_Product ON dbo.tb_Plan_Punch.PartNo = dbo.tb_Product.PartNo where dbo.tb_Plan_Punch.OrderNo='" + orderNo +@"'";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static string GetPlanIDByOrderNo(string orderNo, string partNo)
|
|
{
|
|
string res = "";
|
|
|
|
try
|
|
{
|
|
string sql = @"SELECT top 1 ID FROM dbo.tb_Plan_Punch where OrderNo='" + orderNo + @"' and PartNo='" +
|
|
partNo + @"' and IsFinish <> 1
|
|
order by CreateTime ";
|
|
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = dt.Rows[0]["ID"].ToString();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static DataTable DetailOrderNo(string orderNo)
|
|
{
|
|
DataTable res = new DataTable();
|
|
|
|
try
|
|
{
|
|
string sql = @"SELECT dbo.tb_Plan_Punch.Item, dbo.tb_Plan_Punch.PartNo, dbo.tb_Product.ProductName,
|
|
dbo.tb_Plan_Punch.OrderCount
|
|
FROM dbo.tb_Plan_Punch LEFT OUTER JOIN
|
|
dbo.tb_Product ON dbo.tb_Plan_Punch.PartNo = dbo.tb_Product.PartNo
|
|
where dbo.tb_Plan_Punch.OrderNo='" + orderNo + @"' order by dbo.tb_Plan_Punch.Item";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static DataTable GetOtherPart(string stationNo, string partNo)
|
|
{
|
|
DataTable res = null;
|
|
|
|
try
|
|
{
|
|
string sql = @"IF OBJECT_ID('TEMPDB..#a') IS NOT NULL
|
|
DROP TABLE #a
|
|
create table #a (PartNo nvarchar(100),PartName nvarchar(100),IsCheck nvarchar(10),Qty nvarchar(10))
|
|
|
|
INSERT INTO #a( PartNo,PartName, IsCheck,Qty )
|
|
SELECT p2.PartNo ,p2.ProductName ,'是','1' FROM dbo.tb_PunchAndStation ps
|
|
LEFT OUTER JOIN dbo.tb_Station s ON ps.StationID=s.StationID
|
|
LEFT OUTER JOIN dbo.tb_Product p1 ON ps.ProductID1=p1.ProductID
|
|
LEFT OUTER JOIN dbo.tb_Product p2 ON ps.ProductID2=p2.ProductID
|
|
WHERE s.StationNo='" + stationNo + @"' AND p1.PartNo='" + partNo + @"'
|
|
INSERT INTO #a( PartNo,PartName, IsCheck,Qty )
|
|
SELECT p2.PartNo ,p2.ProductName ,'是',Qty3 FROM dbo.tb_PunchAndStation ps
|
|
LEFT OUTER JOIN dbo.tb_Station s ON ps.StationID=s.StationID
|
|
LEFT OUTER JOIN dbo.tb_Product p1 ON ps.ProductID1=p1.ProductID
|
|
LEFT OUTER JOIN dbo.tb_Product p2 ON ps.ProductID3=p2.ProductID
|
|
WHERE s.StationNo='" + stationNo + @"' AND p1.PartNo='" + partNo + @"'
|
|
INSERT INTO #a( PartNo,PartName, IsCheck,Qty )
|
|
SELECT p2.PartNo ,p2.ProductName ,'是',Qty4 FROM dbo.tb_PunchAndStation ps
|
|
LEFT OUTER JOIN dbo.tb_Station s ON ps.StationID=s.StationID
|
|
LEFT OUTER JOIN dbo.tb_Product p1 ON ps.ProductID1=p1.ProductID
|
|
LEFT OUTER JOIN dbo.tb_Product p2 ON ps.ProductID4=p2.ProductID
|
|
WHERE s.StationNo='" + stationNo + @"' AND p1.PartNo='" + partNo + @"'
|
|
INSERT INTO #a( PartNo,PartName, IsCheck,Qty )
|
|
SELECT p2.PartNo ,p2.ProductName ,'是',Qty5 FROM dbo.tb_PunchAndStation ps
|
|
LEFT OUTER JOIN dbo.tb_Station s ON ps.StationID=s.StationID
|
|
LEFT OUTER JOIN dbo.tb_Product p1 ON ps.ProductID1=p1.ProductID
|
|
LEFT OUTER JOIN dbo.tb_Product p2 ON ps.ProductID5=p2.ProductID
|
|
WHERE s.StationNo='" + stationNo + @"' AND p1.PartNo='" + partNo + @"'
|
|
|
|
INSERT INTO #a( PartNo,PartName, IsCheck,Qty )
|
|
SELECT p2.PartNo ,p2.ProductName ,'是',Qty9 FROM dbo.tb_PunchAndStation ps
|
|
LEFT OUTER JOIN dbo.tb_Station s ON ps.StationID=s.StationID
|
|
LEFT OUTER JOIN dbo.tb_Product p1 ON ps.ProductID1=p1.ProductID
|
|
LEFT OUTER JOIN dbo.tb_Product p2 ON ps.ProductID9=p2.ProductID
|
|
WHERE s.StationNo='" + stationNo + @"' AND p1.PartNo='" + partNo + @"'
|
|
INSERT INTO #a( PartNo,PartName, IsCheck,Qty )
|
|
SELECT p2.PartNo ,p2.ProductName ,'是',Qty10 FROM dbo.tb_PunchAndStation ps
|
|
LEFT OUTER JOIN dbo.tb_Station s ON ps.StationID=s.StationID
|
|
LEFT OUTER JOIN dbo.tb_Product p1 ON ps.ProductID1=p1.ProductID
|
|
LEFT OUTER JOIN dbo.tb_Product p2 ON ps.ProductID10=p2.ProductID
|
|
WHERE s.StationNo='" + stationNo + @"' AND p1.PartNo='" + partNo + @"'
|
|
INSERT INTO #a( PartNo,PartName, IsCheck,Qty )
|
|
SELECT p2.PartNo ,p2.ProductName ,'是',Qty11 FROM dbo.tb_PunchAndStation ps
|
|
LEFT OUTER JOIN dbo.tb_Station s ON ps.StationID=s.StationID
|
|
LEFT OUTER JOIN dbo.tb_Product p1 ON ps.ProductID1=p1.ProductID
|
|
LEFT OUTER JOIN dbo.tb_Product p2 ON ps.ProductID11=p2.ProductID
|
|
WHERE s.StationNo='" + stationNo + @"' AND p1.PartNo='" + partNo + @"'
|
|
|
|
INSERT INTO #a( PartNo,PartName, IsCheck,Qty )
|
|
SELECT p2.PartNo ,p2.ProductName ,'',Qty6 FROM dbo.tb_PunchAndStation ps
|
|
LEFT OUTER JOIN dbo.tb_Station s ON ps.StationID=s.StationID
|
|
LEFT OUTER JOIN dbo.tb_Product p1 ON ps.ProductID1=p1.ProductID
|
|
LEFT OUTER JOIN dbo.tb_Product p2 ON ps.ProductID6=p2.ProductID
|
|
WHERE s.StationNo='" + stationNo + @"' AND p1.PartNo='" + partNo + @"'
|
|
INSERT INTO #a( PartNo,PartName, IsCheck ,Qty)
|
|
SELECT p2.PartNo ,p2.ProductName ,'' ,Qty7 FROM dbo.tb_PunchAndStation ps
|
|
LEFT OUTER JOIN dbo.tb_Station s ON ps.StationID=s.StationID
|
|
LEFT OUTER JOIN dbo.tb_Product p1 ON ps.ProductID1=p1.ProductID
|
|
LEFT OUTER JOIN dbo.tb_Product p2 ON ps.ProductID7=p2.ProductID
|
|
WHERE s.StationNo='" + stationNo + @"' AND p1.PartNo='" + partNo + @"'
|
|
INSERT INTO #a( PartNo,PartName, IsCheck,Qty )
|
|
SELECT p2.PartNo ,p2.ProductName ,'',Qty8 FROM dbo.tb_PunchAndStation ps
|
|
LEFT OUTER JOIN dbo.tb_Station s ON ps.StationID=s.StationID
|
|
LEFT OUTER JOIN dbo.tb_Product p1 ON ps.ProductID1=p1.ProductID
|
|
LEFT OUTER JOIN dbo.tb_Product p2 ON ps.ProductID8=p2.ProductID
|
|
WHERE s.StationNo='" + stationNo + @"' AND p1.PartNo='" + partNo + @"'
|
|
|
|
INSERT INTO #a( PartNo,PartName, IsCheck,Qty )
|
|
SELECT p2.PartNo ,p2.ProductName ,'',Qty12 FROM dbo.tb_PunchAndStation ps
|
|
LEFT OUTER JOIN dbo.tb_Station s ON ps.StationID=s.StationID
|
|
LEFT OUTER JOIN dbo.tb_Product p1 ON ps.ProductID1=p1.ProductID
|
|
LEFT OUTER JOIN dbo.tb_Product p2 ON ps.ProductID12=p2.ProductID
|
|
WHERE s.StationNo='" + stationNo + @"' AND p1.PartNo='" + partNo + @"'
|
|
INSERT INTO #a( PartNo,PartName, IsCheck ,Qty)
|
|
SELECT p2.PartNo ,p2.ProductName ,'' ,Qty13 FROM dbo.tb_PunchAndStation ps
|
|
LEFT OUTER JOIN dbo.tb_Station s ON ps.StationID=s.StationID
|
|
LEFT OUTER JOIN dbo.tb_Product p1 ON ps.ProductID1=p1.ProductID
|
|
LEFT OUTER JOIN dbo.tb_Product p2 ON ps.ProductID13=p2.ProductID
|
|
WHERE s.StationNo='" + stationNo + @"' AND p1.PartNo='" + partNo + @"'
|
|
INSERT INTO #a( PartNo,PartName, IsCheck,Qty )
|
|
SELECT p2.PartNo ,p2.ProductName ,'',Qty14 FROM dbo.tb_PunchAndStation ps
|
|
LEFT OUTER JOIN dbo.tb_Station s ON ps.StationID=s.StationID
|
|
LEFT OUTER JOIN dbo.tb_Product p1 ON ps.ProductID1=p1.ProductID
|
|
LEFT OUTER JOIN dbo.tb_Product p2 ON ps.ProductID14=p2.ProductID
|
|
WHERE s.StationNo='" + stationNo + @"' AND p1.PartNo='" + partNo + @"'
|
|
|
|
SELECT * FROM #a where isnull(PartNo,'')<>''";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static int SavePartAndProduct_New(string barcode, string BcpID, string ZcID, string OrderNo, string WorkClass, string planID, string SerialNo, string barCode1, string barCode2, string barCode3, string barCode4, string barCode5, string barCode6,string stationId,string description)
|
|
{
|
|
int res = 0;
|
|
try
|
|
{
|
|
string sql = @"
|
|
INSERT INTO [dbo].[tb_Punch_Code_Record]
|
|
([ID]
|
|
,[barcode]
|
|
,[BcpID]
|
|
,[ZcID]
|
|
,[OrderNo]
|
|
,[WorkClass]
|
|
,[CreateTime], PlanID,SerialNo
|
|
,barCode1,barCode2,barCode3
|
|
,barCode4,barCode5,barCode6,StationId,StationDescription)
|
|
VALUES
|
|
((select newid())
|
|
,'" + barcode + @"'
|
|
,'" + BcpID + @"'
|
|
,'" + ZcID + @"'
|
|
,'" + OrderNo + @"'
|
|
,'" + WorkClass + @"'
|
|
,(select getdate()), '" + planID + @"','" + SerialNo + @"'
|
|
,'" + barCode1 + @"','" + barCode2 + @"','" + barCode3 + @"'
|
|
,'" + barCode4 + @"','" + barCode5 + @"','" + barCode6 + @"','"+ stationId +@"','"+ description +"@')";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static bool IsNeedVisual(string partNo)
|
|
{
|
|
bool res = false;
|
|
try
|
|
{
|
|
string sql = @"select ID from tb_SpecialVisual where SpecialPartNo='"+ partNo +@"'";
|
|
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = true;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static int AddCompleteCountAndFinish(string ID)
|
|
{
|
|
int res = 0;
|
|
try
|
|
{
|
|
string sql = " update tb_Plan_Punch set CompleteCount = CompleteCount + 1 where ID = '" + ID + "' ";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
|
|
string sql2 = " select OrderCount,CompleteCount from tb_Plan_Punch where ID = '" + ID + "' ";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql2, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
if (int.Parse(dt.Rows[0]["CompleteCount"].ToString()) >=
|
|
int.Parse(dt.Rows[0]["OrderCount"].ToString()))
|
|
{
|
|
string sql1 = " update tb_Plan_Punch set IsFinish = 3 where ID = '" + ID + "' ";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql1, null);
|
|
}
|
|
}
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static string SearchIdByBarCode(string barCode)
|
|
{
|
|
string res = "";
|
|
try
|
|
{
|
|
string sql = @"
|
|
select top 1 ID from tb_Punch_Code_Record
|
|
where barcode ='" + barCode+ @"'
|
|
order by CreateTime desc
|
|
";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = dt.Rows[0]["ID"].ToString();
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static bool IsHigh(string zcPartNo)
|
|
{
|
|
bool res = false;
|
|
|
|
try
|
|
{
|
|
string sql = @"
|
|
select IsHigh from tb_Product where PartNo='" + zcPartNo + @"'";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = dt.Rows[0]["IsHigh"].ToString() == "1" ? true : false;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static int AddDel(string barCode)
|
|
{
|
|
int res = 0;
|
|
try
|
|
{
|
|
string sql =
|
|
@"insert into tb_Punch_Code_Record_Del select top 1 * from tb_Punch_Code_Record WITH (NOLOCK) where barcode = '" +
|
|
barCode + @"' order by CreateTime desc;
|
|
DELETE FROM tb_Punch_Code_Record WHERE ID=(select top 1 ID from tb_Punch_Code_Record WITH (NOLOCK) where barcode = '" +
|
|
barCode + @"' order by CreateTime DESC)";
|
|
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static DataTable DelInfoByBarCode(string barCode)
|
|
{
|
|
DataTable res = null;
|
|
|
|
try
|
|
{
|
|
string sql = @"select top 1 * from tb_Punch_Code_Record_Del WITH (NOLOCK) where barcode = '" +
|
|
barCode + @"' order by CreateTime desc";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static int VisualRetest(string stationNo)
|
|
{
|
|
int res = 0;
|
|
try
|
|
{
|
|
string sql = @"UPDATE dbo.tb_Punch_Code_Record SET ToVisual=1 ,PrintTime = NULL
|
|
WHERE id=(
|
|
SELECT TOP 1 r.ID
|
|
FROM dbo.tb_SpecialVisual LEFT OUTER JOIN
|
|
dbo.tb_Product ON dbo.tb_SpecialVisual.SpecialPartNo = dbo.tb_Product.PartNo RIGHT OUTER JOIN
|
|
dbo.tb_Punch_Code_Record AS r ON dbo.tb_Product.ProductID = r.ZcID LEFT OUTER JOIN
|
|
dbo.tb_PunchAndStation AS p ON r.ZcID = p.ProductID1 LEFT OUTER JOIN
|
|
dbo.tb_Station AS s ON p.StationID = s.StationID
|
|
WHERE dbo.tb_SpecialVisual.SpecialPartNo IS NOT NULL
|
|
AND r.ToVisual=0
|
|
AND s.StationNo='" + stationNo + @"'
|
|
ORDER by r.CreateTime DESC)";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
|
|
return res;
|
|
}
|
|
}
|
|
public static DataTable GetProScreen_1(string stationId)
|
|
{
|
|
DataTable res = new DataTable();
|
|
try
|
|
{
|
|
string sql = @"
|
|
SELECT a.*,b.ProductName,b.IsHigh,b.ProductID,s.Des Des1
|
|
FROM [BBMPT].[dbo].[tb_Plan_Punch_214] a
|
|
LEFT OUTER JOIN dbo.tb_Product b ON a.PartNo=b.PartNo
|
|
LEFT OUTER JOIN dbo.tb_Station s ON a.StationId=s.StationID
|
|
WHERE a.StationId='" + stationId + @"' AND IsFinish=1
|
|
order by CreateTime desc
|
|
";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (res == null || res.Rows.Count < 1)
|
|
{
|
|
sql = @"
|
|
SELECT a.*,b.ProductName,b.IsHigh,b.ProductID,s.Des
|
|
FROM [BBMPT].[dbo].[tb_Plan_Punch_214] a
|
|
LEFT OUTER JOIN dbo.tb_Product b ON a.PartNo=b.PartNo
|
|
LEFT OUTER JOIN dbo.tb_Station s ON a.StationId=s.StationID
|
|
WHERE a.StationId='" + stationId + @"' AND IsFinish=0
|
|
order by CreateTime desc
|
|
";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
if (res == null || res.Rows.Count < 1)
|
|
{
|
|
sql = @"
|
|
SELECT a.*,b.ProductName,b.IsHigh,b.ProductID,s.Des
|
|
FROM [BBMPT].[dbo].[tb_Plan_Punch_214] a
|
|
LEFT OUTER JOIN dbo.tb_Product b ON a.PartNo=b.PartNo
|
|
LEFT OUTER JOIN dbo.tb_Station s ON a.StationId=s.StationID
|
|
WHERE a.StationId='" + stationId + @"' AND IsFinish=2
|
|
order by CreateTime desc
|
|
";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static DataTable GetProScreenPlan_1(string id, string stationNo, string plan)
|
|
{
|
|
DataTable res = new DataTable();
|
|
try
|
|
{
|
|
if (plan == "下一计划")
|
|
{
|
|
#region 查询当前计划时间
|
|
|
|
string time = "";
|
|
string sql;
|
|
string sqll = @" select CreateTime from tb_Plan_Punch_214 where ID = '" + id + @"' ";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sqll, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
time = dt.Rows[0][0].ToString();
|
|
time = Tools.NumericParse.StringToDateTime(time).Value.AddSeconds(1).ToString("yyyy-MM-dd HH:mm:ss");
|
|
}
|
|
#endregion
|
|
|
|
#region 查询下一计划
|
|
DateTime dtime = DateTime.Now;
|
|
DateTime.TryParse(time, out dtime);
|
|
|
|
//sql = @"
|
|
// SELECT a.*,b.ProductName,b.IsHigh,b.ProductID,s.Des
|
|
// FROM tb_Plan_Punch_214 a
|
|
// LEFT OUTER JOIN dbo.tb_Product b ON a.PartNo=b.PartNo
|
|
// LEFT OUTER JOIN dbo.tb_Station s ON a.StationId=s.StationID
|
|
// WHERE s.StationNo = '" + stationNo + @"'
|
|
// and a.IsFinish <> 3
|
|
// and a.CreateTime > '" + time + @"'
|
|
// order by a.CreateTime asc
|
|
// ";
|
|
sql = @"
|
|
SELECT a.*,b.ProductName,b.IsHigh,b.ProductID,s.Des
|
|
FROM tb_Plan_Punch_214 a
|
|
LEFT OUTER JOIN dbo.tb_Product b ON a.PartNo=b.PartNo
|
|
LEFT OUTER JOIN dbo.tb_Station s ON a.StationId=s.StationID
|
|
WHERE s.StationNo = '" + stationNo + @"'
|
|
and a.IsFinish <> 3
|
|
and a.CreateTime > '" + dtime.ToString("yyyy-MM-dd HH:mm:ss") + @"'
|
|
order by a.CreateTime asc
|
|
";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
|
|
#endregion
|
|
}
|
|
else if (plan == "上一计划")
|
|
{
|
|
#region 查询当前计划时间
|
|
|
|
string time = "";
|
|
string sql;
|
|
string sqll = @" select CreateTime from tb_Plan_Punch_214 where ID = '" + id + @"' ";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sqll, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
time = dt.Rows[0][0].ToString();
|
|
}
|
|
|
|
LogHelper.WriteLog($" 语句3:{sqll}, 连接字符串:{SqlHelper.SqlConnString}");
|
|
#endregion
|
|
|
|
#region 查询上一计划
|
|
|
|
DateTime dtime = DateTime.Now;
|
|
DateTime.TryParse(time, out dtime);
|
|
|
|
sql = @"
|
|
SELECT a.*,b.ProductName,b.IsHigh,b.ProductID,s.Des
|
|
FROM tb_Plan_Punch_214 a
|
|
LEFT OUTER JOIN dbo.tb_Product b ON a.PartNo=b.PartNo
|
|
LEFT OUTER JOIN dbo.tb_Station s ON a.StationId=s.StationID
|
|
WHERE s.StationNo = '" + stationNo + @"'
|
|
and a.IsFinish <> 3
|
|
and a.CreateTime < '" + dtime.ToString("yyyy-MM-dd HH:mm:ss") + @"'
|
|
order by a.CreateTime desc
|
|
";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
else if (plan == "当前计划")
|
|
{
|
|
string sql = @"
|
|
SELECT a.*,b.ProductName,b.IsHigh,b.ProductID,s.Des
|
|
FROM tb_Plan_Punch_214 a
|
|
LEFT OUTER JOIN dbo.tb_Product b ON a.PartNo=b.PartNo
|
|
LEFT OUTER JOIN dbo.tb_Station s ON a.StationId=s.StationID
|
|
where a.ID='" + id + @"'
|
|
";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static DataTable QueryPlanDetail_1(string starttime, string endtime, string stationNo)
|
|
{
|
|
DataTable res = new DataTable();
|
|
try
|
|
{
|
|
string sql = @"
|
|
SELECT a.ID,a.OrderNo,a.PartNo,a.OrderCount,a.CompleteCount,a.BadCount,a.IsFinish,b.ProductName
|
|
FROM tb_Plan_Punch_214 a
|
|
LEFT OUTER JOIN dbo.tb_Product b ON a.PartNo=b.PartNo
|
|
LEFT OUTER JOIN dbo.tb_Station s ON a.StationId=s.StationID
|
|
WHERE s.StationNo= '"+ stationNo +@"'
|
|
and IsFinish <> 3
|
|
order by CreateTime
|
|
";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static DataTable HavePrint_1(string stationId)
|
|
{
|
|
DataTable dt = null;
|
|
try
|
|
{
|
|
string sql = @"SELECT top 1 p.PartNo,r.*,p.ProductName
|
|
FROM tb_Punch_Code_Record_DoorSill_214 r WITH(NOLOCK)
|
|
LEFT OUTER JOIN dbo.tb_Product p ON r.ZcID=p.ProductID
|
|
WHERE (r.ToVisual=0 and isNull(r.PrintTime,'')='')
|
|
AND r.StationId='" + stationId + @"'
|
|
order by r.CreateTime desc";
|
|
|
|
dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
|
|
return dt;
|
|
}
|
|
|
|
public static int UpdateVisualFlag(string stationId)
|
|
{
|
|
int res = 0;
|
|
|
|
try
|
|
{
|
|
string sql = @" update tb_Punch_Code_Record_DoorSill_214 set ToVisual=0 ,FinishTime=(select getdate()) where id =(SELECT top 1 ID
|
|
FROM tb_Punch_Code_Record_DoorSill_214 r WITH(NOLOCK)
|
|
WHERE r.StationId = '" + stationId + @"' and isNull(r.PrintTime,'')=''
|
|
order by r.CreateTime desc)";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static bool HaveScan_1(string barcode)
|
|
{
|
|
bool res = false;
|
|
try
|
|
{
|
|
string sql = "";
|
|
if (barcode.Substring(0, 2) != "22")
|
|
{
|
|
sql = @"
|
|
select *
|
|
from tb_Punch_Code_Record_DoorSill_214
|
|
where barcode = '" + barcode + @"'
|
|
";
|
|
}
|
|
else
|
|
{
|
|
if (barcode.Substring(0, 10) == "2200000057" || barcode.Substring(0, 10) == "2200000058")
|
|
{
|
|
sql = @"
|
|
select *
|
|
from tb_Punch_Code_Record_DoorSill_214
|
|
where barcode = '" + barcode + @"'
|
|
";
|
|
}
|
|
else
|
|
{
|
|
sql = @" select * from tb_StockIn where barcode = '" + barcode + "' and ZcCode is not null";
|
|
}
|
|
}
|
|
DataTable dt = ProScreenFunc.GetResDataTable(sql);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = true;
|
|
}
|
|
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static OtherPart HaveOtherPart_1(string stationId, string productID1)
|
|
{
|
|
OtherPart res = new OtherPart();
|
|
|
|
try
|
|
{
|
|
string sql = @"
|
|
select top 1 [ProductID3]
|
|
,Qty3
|
|
,[ProductID4]
|
|
,Qty4
|
|
,[ProductID5]
|
|
,Qty5
|
|
,[ProductID9]
|
|
,Qty9
|
|
,[ProductID10]
|
|
,Qty10
|
|
,[ProductID11]
|
|
,Qty11
|
|
from tb_PunchAndStation
|
|
where StationID = '"+ stationId +@"'
|
|
and ProductID1 = '" + productID1 + @"'
|
|
order by CreateTine desc
|
|
";
|
|
DataTable dt = ProScreenFunc.GetResDataTable(sql);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res.productID3 = dt.Rows[0]["ProductID3"].ToString();
|
|
res.productID4 = dt.Rows[0]["ProductID4"].ToString();
|
|
res.productID5 = dt.Rows[0]["ProductID5"].ToString();
|
|
res.productID6 = dt.Rows[0]["ProductID9"].ToString();
|
|
res.productID7 = dt.Rows[0]["ProductID10"].ToString();
|
|
res.productID8 = dt.Rows[0]["ProductID11"].ToString();
|
|
res.qty3 = dt.Rows[0]["Qty3"].ToString();
|
|
res.qty4 = dt.Rows[0]["Qty4"].ToString();
|
|
res.qty5 = dt.Rows[0]["Qty5"].ToString();
|
|
res.qty6 = dt.Rows[0]["Qty9"].ToString();
|
|
res.qty7 = dt.Rows[0]["Qty10"].ToString();
|
|
res.qty8 = dt.Rows[0]["Qty11"].ToString();
|
|
}
|
|
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static bool IsUsing(string barCode,string columeName)
|
|
{
|
|
bool res = false;
|
|
|
|
try
|
|
{
|
|
string sql = @"select ID from tb_Punch_Code_Record_DoorSill_214 WITH(NOLOCK)
|
|
where " + columeName + " like '%" + barCode + @"%'";
|
|
DataTable dt= ProScreenFunc.GetResDataTable(sql);
|
|
if (dt!=null && dt.Rows.Count>0)
|
|
{
|
|
res = true;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static int SavePartAndProduct_1(string barcode, string BcpID, string ZcID, string OrderNo, string WorkClass, string planID, string SerialNo, string barCode1, string barCode2, string barCode3, string barCode4, string barCode5, string barCode6,string stationId,int isIndia)
|
|
{
|
|
int res = 0;
|
|
try
|
|
{
|
|
string sql = @"
|
|
INSERT INTO [dbo].[tb_Punch_Code_Record_DoorSill_214]
|
|
([ID]
|
|
,[barcode]
|
|
,[BcpID]
|
|
,[ZcID]
|
|
,[OrderNo]
|
|
,[WorkClass]
|
|
,[CreateTime], PlanID,SerialNo
|
|
,barCode1,barCode2,barCode3
|
|
,barCode4,barCode5,barCode6,StationId,IsIndia)
|
|
VALUES
|
|
((select newid())
|
|
,'" + barcode + @"'
|
|
,'" + BcpID + @"'
|
|
,'" + ZcID + @"'
|
|
,'" + OrderNo + @"'
|
|
,'" + WorkClass + @"'
|
|
,(select getdate()), '" + planID + @"','" + SerialNo + @"'
|
|
,'" + barCode1 + @"','" + barCode2 + @"','" + barCode3 + @"'
|
|
,'" + barCode4 + @"','" + barCode5 + @"','" + barCode6 + @"','" + stationId + @"',"+ isIndia+@")
|
|
";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static string SearchIdByBarCode_1(string barCode)
|
|
{
|
|
string res = "";
|
|
try
|
|
{
|
|
string sql = @"
|
|
select top 1 ID from tb_Punch_Code_Record_DoorSill_214
|
|
where barcode ='" + barCode + @"'
|
|
order by CreateTime desc
|
|
";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = dt.Rows[0]["ID"].ToString();
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static int UpdatePrintTime_1(string ID)
|
|
{
|
|
int res = 0;
|
|
try
|
|
{
|
|
string sql = @"
|
|
update tb_Punch_Code_Record_DoorSill_214
|
|
set PrintTime=(select getdate())
|
|
where ID='" + ID + @"'
|
|
";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static DataTable GetProScreenByPlanID_1(string planId)
|
|
{
|
|
DataTable res = new DataTable();
|
|
try
|
|
{
|
|
string sql = @"
|
|
select a.ID, b.[Des], a.OrderNo, a.PartNo,b.ProductName,a.OrderCount,a.CompleteCount,a.BadCount, c.ProductID1, c.ProductID2
|
|
from tb_Plan_Punch_214 a
|
|
left join tb_Product b
|
|
on a.PartNo = b.PartNo
|
|
left join tb_PunchAndStation c
|
|
on b.ProductID = c.ProductID1
|
|
where a.ID = '" + planId + @"'
|
|
";
|
|
res = ProScreenFunc.GetResDataTable(sql);
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static string SerialNo_1(string partNo, string batch)
|
|
{
|
|
string res = "";
|
|
try
|
|
{
|
|
string temp_no = partNo + "." + batch;
|
|
string sql = @"select top 1 SerialNo from tb_Punch_Code_Record_DoorSill_214 where SerialNo like '" + temp_no +
|
|
@"%' order by CreateTime desc";
|
|
object dt = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null)
|
|
{
|
|
res = dt.ToString();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
throw ex;
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static bool CheckPlanCompleted_1(string Id)
|
|
{
|
|
bool res = false;
|
|
try
|
|
{
|
|
string sql = @"
|
|
select IsFinish from tb_Plan_Punch_214 where ID = '" + Id + @"'
|
|
";
|
|
object aa = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (aa != null)
|
|
{
|
|
string bb = aa.ToString();
|
|
if (bb == "3")
|
|
{
|
|
res = true;
|
|
}
|
|
else
|
|
{
|
|
res = false;
|
|
}
|
|
}
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static string GetCompleteCount_1(string Id)
|
|
{
|
|
string res = "0";
|
|
try
|
|
{
|
|
string sql = @"
|
|
select CompleteCount
|
|
from tb_Plan_Punch_214 WITH(NOLOCK)
|
|
where ID = '" + Id + @"'
|
|
";
|
|
object aa = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (aa != null)
|
|
{
|
|
res = aa.ToString();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static int AddCompleteCountAndFinish_1(string Id)
|
|
{
|
|
int res = 0;
|
|
try
|
|
{
|
|
string sql = " update tb_Plan_Punch_214 set CompleteCount = CompleteCount + 1 where ID = '" + Id + "' ";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
|
|
string sql2 = " select OrderCount,CompleteCount from tb_Plan_Punch_214 where ID = '" + Id + "' ";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql2, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
if (int.Parse(dt.Rows[0]["CompleteCount"].ToString()) >=
|
|
int.Parse(dt.Rows[0]["OrderCount"].ToString()))
|
|
{
|
|
string sql1 = " update tb_Plan_Punch_214 set IsFinish = 3 where ID = '" + Id + "' ";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql1, null);
|
|
}
|
|
}
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static DataTable GetZp(string barcode)
|
|
{
|
|
DataTable res = new DataTable();
|
|
try
|
|
{
|
|
string sql = @"
|
|
select top 1 * from tb_Punch_Code_Record_DoorSill_214 WITH (NOLOCK)
|
|
where barcode = '" + barcode + @"' order by CreateTime desc
|
|
";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static int UpdateFlag(string barCode,int flag)
|
|
{
|
|
int res = 0;
|
|
try
|
|
{
|
|
string sql = @"update tb_Punch_Code_Record_DoorSill_214 set Flag=" + flag + " where barcode='" + barCode + @"'";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static int AddBadCount_1(string ID)
|
|
{
|
|
int res = 0;
|
|
try
|
|
{
|
|
string sql = " update tb_Plan_Punch_214 set BadCount = BadCount + 1,CompleteCount = CompleteCount - 1 where ID = '" + ID + "' ";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static int VisualReset_1(string stationId)
|
|
{
|
|
int res = 0;
|
|
try
|
|
{
|
|
string sql = @"UPDATE tb_Punch_Code_Record_DoorSill_214 SET ToVisual=1 ,PrintTime = NULL
|
|
WHERE id=(
|
|
SELECT TOP 1 r.ID
|
|
FROM dbo.tb_SpecialVisual LEFT OUTER JOIN
|
|
dbo.tb_Product ON dbo.tb_SpecialVisual.SpecialPartNo = dbo.tb_Product.PartNo RIGHT OUTER JOIN
|
|
dbo.tb_Punch_Code_Record_DoorSill_214 AS r ON dbo.tb_Product.ProductID = r.ZcID LEFT OUTER JOIN
|
|
dbo.tb_PunchAndStation AS p ON r.ZcID = p.ProductID1
|
|
WHERE dbo.tb_SpecialVisual.SpecialPartNo IS NOT NULL
|
|
AND r.ToVisual=0
|
|
AND r.StationId='"+ stationId + @"'
|
|
ORDER by r.CreateTime DESC)";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static bool CheckPartAndProduct_1(string pid1, string pid2,string stationId)
|
|
{
|
|
bool res = false;
|
|
try
|
|
{
|
|
string sql = @" select * from tb_PunchAndStation where ProductID1 = '" + pid1 + @"' and ProductID2 = '" + pid2 + @"' and StationID='"+ stationId + @"' ";
|
|
DataTable dt = ProScreenFunc.GetResDataTable(sql);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = true;
|
|
}
|
|
else
|
|
{
|
|
res = false;
|
|
}
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static int UpdateSignal(int isHigh,int state,int isFinish)
|
|
{
|
|
int res = 0;
|
|
|
|
try
|
|
{
|
|
string sql = @"update tb_Signal set IsHigh="+ isHigh +@", State=" + state + @",IsFinish=" + isFinish;
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static int UpdateWriteDone()
|
|
{
|
|
int res = 0;
|
|
|
|
try
|
|
{
|
|
string sql = @"update tb_Signal set IsFinish=2";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static int VisualState()
|
|
{
|
|
int res = 0;
|
|
|
|
try
|
|
{
|
|
string sql = @"select State from tb_Signal";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = Convert.ToInt32(dt.Rows[0]["State"].ToString());
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static DataTable GetSignal()
|
|
{
|
|
DataTable res = null;
|
|
|
|
try
|
|
{
|
|
string sql = @"select IsHigh,State,IsFinish from tb_Signal with(NOLOCK)";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
}
|
|
return res;
|
|
}
|
|
public static bool CheckDeviceNo(string deviceNo,string stationId)
|
|
{
|
|
bool res = false;
|
|
|
|
try
|
|
{
|
|
string sql = @"select ID from tb_PunchAndStation where DeviceNo='" + deviceNo + @"' and StationID='" + stationId + @"'";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = true;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static string SumByPartNo(string orderNo,string zcPartNo)
|
|
{
|
|
string res = "0";
|
|
|
|
try
|
|
{
|
|
string sql = @"SELECT Count(ID) as sum
|
|
FROM dbo.tb_Punch_Code_Record LEFT OUTER JOIN
|
|
dbo.tb_Product ON dbo.tb_Punch_Code_Record.ZcID = dbo.tb_Product.ProductID
|
|
where dbo.tb_Punch_Code_Record.OrderNo='" + orderNo + @"' and dbo.tb_Product.PartNo ='" + zcPartNo + @"'";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = dt.Rows[0]["sum"].ToString();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static string PlanCountByPartNo(string orderNo, string zcPartNo)
|
|
{
|
|
string res = "0";
|
|
|
|
try
|
|
{
|
|
string sql = @"SELECT dbo.tb_Plan_Punch.OrderCount
|
|
FROM dbo.tb_Plan_Punch INNER JOIN
|
|
dbo.tb_Product ON dbo.tb_Plan_Punch.PartNo = dbo.tb_Product.PartNo
|
|
where tb_Plan_Punch.OrderNo='" + orderNo + @"' and dbo.tb_Product.PartNo ='" + zcPartNo + @"'";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = dt.Rows[0]["OrderCount"].ToString();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static DataTable ZcPartNo(string partNo2)
|
|
{
|
|
DataTable res = null;
|
|
|
|
try
|
|
{
|
|
string sql = @"SELECT p1.PartNo,p1.ProductName
|
|
FROM dbo.tb_Product AS p2 RIGHT OUTER JOIN
|
|
dbo.tb_PunchAndStation ON p2.ProductID = dbo.tb_PunchAndStation.ProductID2 LEFT OUTER JOIN
|
|
dbo.tb_Product AS p1 ON dbo.tb_PunchAndStation.ProductID1 = p1.ProductID
|
|
where p2.PartNo='" + partNo2 +@"'";
|
|
return SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
//if (dt != null && dt.Rows.Count > 0)
|
|
//{
|
|
// res = dt.Rows[0]["PartNo"].ToString();
|
|
//}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static bool IsCheck(string deviceNo, string partNo2)
|
|
{
|
|
bool res = false;
|
|
|
|
try
|
|
{
|
|
string sql = @"SELECT ID
|
|
FROM dbo.tb_PunchAndStation LEFT OUTER JOIN
|
|
dbo.tb_Product AS p1 ON dbo.tb_PunchAndStation.ProductID2 = p1.ProductID
|
|
where p1.PartNo='" + partNo2 + @"' and dbo.tb_PunchAndStation.DeviceNo='" + deviceNo + @"'";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = true;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static int AddAssembly(Assembly1 md)
|
|
{
|
|
int res = 0;
|
|
|
|
try
|
|
{
|
|
string sql =
|
|
@"insert into tb_Assembly_254 (ID,PartNo,PartName,BatchNo,Color,PartType,TapeBatchNo,Validity,ValidityDate,Des,Flag,BarCode) values
|
|
(@ID,@PartNo,@PartName,@BatchNo,@Color,@PartType,@TapeBatchNo,@Validity,@ValidityDate,@Des,@Flag,@BarCode)";
|
|
|
|
#region 参数
|
|
|
|
SqlParameter[] param = new SqlParameter[12];
|
|
|
|
param[0] = new SqlParameter("@ID", SqlDbType.VarChar);
|
|
param[0].Value = md.ID;
|
|
|
|
param[1] = new SqlParameter("@PartNo", SqlDbType.VarChar);
|
|
param[1].Value = md.PartNo;
|
|
|
|
param[2] = new SqlParameter("@PartName", SqlDbType.VarChar);
|
|
param[2].Value = md.PartName;
|
|
|
|
param[3] = new SqlParameter("@BatchNo", SqlDbType.VarChar);
|
|
param[3].Value = md.BatchNo;
|
|
|
|
param[4] = new SqlParameter("@Color", SqlDbType.VarChar);
|
|
param[4].Value = md.Color;
|
|
|
|
//param[5] = new SqlParameter("@ColorNo", SqlDbType.VarChar);
|
|
//param[5].Value = md.ColorNo;
|
|
|
|
param[5] = new SqlParameter("@PartType", SqlDbType.VarChar);
|
|
param[5].Value = md.PartType;
|
|
|
|
param[6] = new SqlParameter("@TapeBatchNo", SqlDbType.VarChar);
|
|
param[6].Value = md.TapeBatchNo;
|
|
|
|
param[7] = new SqlParameter("@Validity", SqlDbType.VarChar);
|
|
param[7].Value = md.Validity;
|
|
|
|
param[8] = new SqlParameter("@ValidityDate", SqlDbType.VarChar);
|
|
param[8].Value = md.ValidityDate;
|
|
|
|
param[9] = new SqlParameter("@Des", SqlDbType.VarChar);
|
|
param[9].Value = md.Des;
|
|
|
|
param[10] = new SqlParameter("@Flag", SqlDbType.Int);
|
|
param[10].Value = md.Flag;
|
|
|
|
param[11] = new SqlParameter("@BarCode", SqlDbType.VarChar);
|
|
param[11].Value = md.BarCode;
|
|
|
|
#endregion
|
|
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, param);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static int UpdateAssembly(Assembly1 md)
|
|
{
|
|
int res = 0;
|
|
|
|
try
|
|
{
|
|
string sql = @"update tb_Assembly_254 set PrintTime=@PrintTime where BarCode=@BarCode";
|
|
|
|
#region 参数
|
|
|
|
SqlParameter[] param = new SqlParameter[13];
|
|
|
|
param[0] = new SqlParameter("@PrintTime", SqlDbType.DateTime);
|
|
param[0].Value = md.PrintTime;
|
|
|
|
param[1] = new SqlParameter("@BarCode", SqlDbType.VarChar);
|
|
param[1].Value = md.BarCode;
|
|
|
|
#endregion
|
|
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, param);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static string LastNo(string partNo)
|
|
{
|
|
string res = "";
|
|
|
|
try
|
|
{
|
|
string sql = @"select top 1 PartNo from tb_Assembly_254 where PartNo like '" + partNo +
|
|
@"%' and Flag=0 order by CreateTime desc";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = dt.Rows[0]["PartNo"].ToString();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static DataTable AssemblyInfo(string barCode)
|
|
{
|
|
DataTable res = null;
|
|
|
|
try
|
|
{
|
|
string sql = @"select top 1 * from tb_Assembly_254 where BarCode='"+ barCode +@"' order by CreateTime desc";
|
|
|
|
return SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
|
|
}
|
|
|
|
return res;
|
|
}
|
|
public static string[] GetSpecialHybrid()
|
|
{
|
|
string[] res = { "" };
|
|
try
|
|
{
|
|
string sql = @" select SpecialPartNo from tb_SpecialHybrid ";
|
|
DataTable dt = ProScreenFunc.GetResDataTable(sql);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = new string[dt.Rows.Count];
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
res[i] = dt.Rows[i][0].ToString().Trim();
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static DataTable GetProductInfo1(string productId2,string stationId)
|
|
{
|
|
DataTable res = null;
|
|
try
|
|
{
|
|
string sql = @"SELECT dbo.tb_Product.PartNo, dbo.tb_PunchAndStation.ProductID1, dbo.tb_Product.IsHigh, dbo.tb_Product.ProductName
|
|
FROM dbo.tb_PunchAndStation LEFT OUTER JOIN
|
|
dbo.tb_Product ON dbo.tb_PunchAndStation.ProductID1 = dbo.tb_Product.ProductID where tb_PunchAndStation.ProductID2='" + productId2 +
|
|
@"' and tb_PunchAndStation.StationID='" + stationId + @"'";
|
|
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static string StockZcCode(string barCode)
|
|
{
|
|
string res = "";
|
|
|
|
try
|
|
{
|
|
string sql = @"select [ZcCode] from [tb_StockIn] where [barcode]='" + barCode + @"'";
|
|
|
|
DataTable dt = ProScreenFunc.GetResDataTable(sql);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = dt.Rows[0][0].ToString().Trim();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static int SaveToWmsRecord(string barCode)
|
|
{
|
|
int res = 0;
|
|
try
|
|
{
|
|
string sql = @"
|
|
insert into tb_ToWmsRecord(BarCode) values('"+ barCode +@"')
|
|
";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static bool IsToWms(string barCode)
|
|
{
|
|
bool res = false;
|
|
try
|
|
{
|
|
string sql = @"
|
|
select Id from tb_ToWmsRecord where BarCode='" + barCode + @"'
|
|
";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = true;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
|
|
}
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 漆件码是否在喷涂下线 --用于冲孔扫塑件码验证 非注塑码默认为true
|
|
/// </summary>
|
|
/// <param name="sjBarCode"></param>
|
|
/// <returns></returns>
|
|
public static bool SjBarCodeIsInStockIn(string sjBarCode)
|
|
{
|
|
DataTable res = null;
|
|
if (string.IsNullOrEmpty(sjBarCode))
|
|
{
|
|
return true;
|
|
}
|
|
else if(sjBarCode.Length !=20)
|
|
{
|
|
//不是注塑码,直接通过.
|
|
return true;
|
|
}
|
|
else if (sjBarCode.Contains("."))
|
|
{
|
|
//零件号条码,不涉及一码到底,直接返回true
|
|
return true;
|
|
}
|
|
try
|
|
{
|
|
string sql = @"select top 1 * from [tb_StockIn] where [barcode]='" + sjBarCode + @"' order by createtime desc ";
|
|
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (res.Rows.Count == 0)
|
|
return false;
|
|
|
|
if( res.Rows[0]["pass"].ToString() =="0") //最近检测不合格
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public class OtherPart
|
|
{
|
|
public string productID3 { get; set; }
|
|
|
|
public string qty3 { get; set; }
|
|
|
|
public string productID4 { get; set; }
|
|
|
|
public string qty4 { get; set; }
|
|
|
|
public string productID5 { get; set; }
|
|
|
|
public string qty5 { get; set; }
|
|
|
|
public string productID6 { get; set; }
|
|
|
|
public string qty6 { get; set; }
|
|
|
|
public string productID7 { get; set; }
|
|
|
|
public string qty7 { get; set; }
|
|
|
|
public string productID8 { get; set; }
|
|
|
|
public string qty8 { get; set; }
|
|
|
|
}
|
|
|
|
public static class ScanAll
|
|
{
|
|
public static bool ScanResult;
|
|
public static string barCode1;
|
|
public static string barCode2;
|
|
public static string barCode3;
|
|
public static string barCode4;
|
|
public static string barCode5;
|
|
public static string barCode6;
|
|
public static string partNo1;
|
|
public static string partNo2;
|
|
public static string partNo3;
|
|
public static string partNo4;
|
|
public static string partNo5;
|
|
public static string partNo6;
|
|
}
|
|
|
|
public class ZcPrintLabel
|
|
{
|
|
public string zcPartNo { get; set; }
|
|
public string zcName { get; set; }
|
|
}
|
|
|
|
public class Assembly1
|
|
{
|
|
public string ID { get; set; }
|
|
|
|
public string PartNo { get; set; }
|
|
|
|
public string PartName { get; set; }
|
|
|
|
public string BatchNo { get; set; }
|
|
|
|
public string Color { get; set; }
|
|
|
|
public string ColorNo { get; set; }
|
|
|
|
public string PartType { get; set; }
|
|
|
|
public string TapeBatchNo { get; set; }
|
|
|
|
public string Validity { get; set; }
|
|
|
|
public string ValidityDate { get; set; }
|
|
|
|
public DateTime PrintTime { get; set; }
|
|
|
|
public string Des { get; set; }
|
|
|
|
public int Flag { get; set; }
|
|
|
|
public string BarCode { get; set; }
|
|
}
|
|
}
|
|
|