一厂MES,含注塑,喷涂,冲孔
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.
 
 
 
 
 

223 lines
7.8 KiB

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using DBUtility;
using PaintingPC.Model;
namespace PaintingPC
{
public class Function1
{
/// <summary>
/// 查询在悬挂链上的条码
/// </summary>
/// <returns></returns>
public static DataTable GetOnChainBarCode()
{
DataTable res = new DataTable();
try
{
string sql = @"select * from tb_ChainUp where flag =0 order by CreateTime asc";
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
}
catch (Exception ex)
{
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
}
return res;
}
public static DataTable GetDownInfo()
{
DataTable res = new DataTable();
try
{
string sql = @"SELECT COUNT(*) AS sum,carType,color FROM dbo.tb_ChainDown
WHERE boxNum IS NULL OR boxNum =''
GROUP BY carType,color";
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
}
catch (Exception ex)
{
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
}
return res;
}
public static DataTable PackCount(string carType, string color)
{
DataTable res = new DataTable();
try
{
string sql = @"SELECT * FROM dbo.tb_Product
WHERE ProductName='" + carType + "' and ColorName='"+ color+"'";
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
}
catch (Exception ex)
{
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
}
return res;
}
public static DataTable GetBarCodeInfo(string barcode)
{
DataTable res = new DataTable();
try
{
string sql = @"select * from tb_ChainUp where barcode='" + barcode + "'";
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
}
catch (Exception ex)
{
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
}
return res;
}
/// <summary>
/// 查看该产品是否已打包
/// </summary>
/// <param name="barcode"></param>
/// <returns></returns>
public static DataTable isPack(string barcode)
{
DataTable res = new DataTable();
try
{
string sql = @"SELECT * FROM dbo.tb_ChainDown
WHERE barcode ='"+ barcode+"' and boxNum IS NULL OR boxNum =''";
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
}
catch (Exception ex)
{
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
}
return res;
}
/// <summary>
/// 根据二维码查找对应的一维码
/// </summary>
/// <param name="twoBarcode"></param>
/// <returns></returns>
public static DataTable oneBarcode(string twoBarcode)
{
DataTable res = new DataTable();
try
{
string sql = @"SELECT top 1 * FROM v_Code where BarCode='" + twoBarcode + "' and IsDel =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 GetNotPack(string barcode)
{
DataTable res = new DataTable();
try
{
string sql = @"SELECT count(*) as aa FROM dbo.tb_ChainDown
WHERE boxNum IS NULL OR boxNum ='' and barcode SUBSTRING(barcode,1,10)='"+ barcode.Substring(0,10)+"'" ;
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
}
catch (Exception ex)
{
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
}
return res;
}
public static DataTable GetProductInfo(string productname,string color)
{
DataTable res = new DataTable();
try
{
string sql = @"SELECT * FROM dbo.tb_Product WHERE ProductName='" + productname + "' and ColorName='"+ color +"'";
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
}
catch (Exception ex)
{
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
}
return res;
}
public static DataTable GetPackNo(string partNo)
{
DataTable res = new DataTable();
try
{
string sql = @"SELECT top 1 * FROM tb_PaintBox WHERE boxNum like '%" + partNo + "%' and flag=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 int InsertPaintInfo(PaintBoxModel md)
{
int res = 0;
try
{
string sql = @"insert into tb_PaintBox(ID,boxNum,partNo,PackCount,flag) values (@ID,@boxNum,@partNo,@PackCount,@flag)";
SqlParameter[] param=new SqlParameter[5];
param[0] = new SqlParameter("@ID", SqlDbType.VarChar);
param[0].Value = md.ID;
param[1] = new SqlParameter("@boxNum", SqlDbType.VarChar);
param[1].Value = md.boxNum;
param[2] = new SqlParameter("@partNo", SqlDbType.VarChar);
param[2].Value = md.partNo;
param[3] = new SqlParameter("@PackCount", SqlDbType.Int);
param[3].Value = md.PackCount;
param[4] = new SqlParameter("@flag", SqlDbType.Int);
param[4].Value = md.flag;
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, param);
return res;
}
catch (Exception ex)
{
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
return res;
}
}
public static int delChaimUp(string barCode)
{
int res = 0;
try
{
string sql = @"update tb_ChainUp set flag=2 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;
}
}
}
}