一厂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.

549 lines
16 KiB

2 months ago
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL;
2 months ago
using MESClassLibrary.DAL.BasicInfo;
using MESClassLibrary.DAL.Injection;
2 months ago
using MESClassLibrary.Model;
namespace MESClassLibrary.BLL.BasicInfo
{
public class BarCodeBLL
{
private BarCodeDAl db = new BarCodeDAl();
private WmsDAL wmsDal = new WmsDAL();
private BadInjectionDAL badDb = new BadInjectionDAL();
2 months ago
public DataTable SearchInfoByStock(string StockNo)
{
try
{
return db.SearchInfoByStock(StockNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
throw ex;
//return null;
}
}
public DataTable SearchInfoByPartNo(string partNo)
{
try
{
return db.SearchInfoByPartNo(partNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
throw ex;
}
}
public DataTable SearchInfoByPartNo1(string partNo)
{
try
{
return db.SearchInfoByPartNo1(partNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
throw ex;
//return null;
}
}
public DataTable searchBarCode(string barcode, int flag)
{
try
{
return db.searchBarCode(barcode, flag);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool Add_Info(BarCodeModel md)
{
try
{
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool Add_Info_New(BarCodeModel md,string tableName)
{
try
{
return db.AddInfoNew(md,tableName);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool Add_Info_New(LocalDBService local, BarCodeModel md, string tableName)
{
try
{
return db.AddInfoNew(md, tableName);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
2 months ago
public DataTable SearchInfo(string stationNo)
{
try
{
return db.SearchInfo(stationNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchInfoAll()
{
try
{
return db.SearchInfoAll();
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchBarCode()
{
try
{
return db.SearchBarCode();
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchBarCodeByOne(string OneBarCode)
{
try
{
return db.SearchBarCodeByOne(OneBarCode);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchBarCodeByTwo(string BarCode)
{
try
{
return db.SearchBarCodeByTwo(BarCode);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchSerialNoByBarCode(string Code)
{
try
{
return db.SearchSerialNoByBarCode(Code);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchSerialNoByBarCodeNew(string Code,string tableName)
{
try
{
return db.SearchSerialNoByBarCodeNew(Code, tableName);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
throw ex;
//return null;
}
}
public DataTable SearchSerialNoByBarCodeNew1(string Code)
{
try
{
return db.SearchSerialNoByBarCodeNew1(Code);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchInfoByBarCode(string BarCode)
{
try
{
return db.SearchInfoByBarCode(BarCode);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchInfoByBarCodeNew(string BarCode,string tableName)
{
try
{
return db.SearchInfoByBarCodeNew(BarCode, tableName);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool Update_Info(BarCodeModel md)
{
try
{
return db.UpdateInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool DelBarCode(BarCodeModel md)
{
try
{
return db.DelBarCode(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool DelBarCode_New(BarCodeModel md,string tableName)
{
try
{
return db.DelBarCode_New(md,tableName);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 条码删除 --wms中间表未读数据,删除中间表,tb_barcode中IsDel=1
/// </summary>
/// <param name="barCode"></param>
/// <param name="tableName"></param>
/// <returns></returns>
public string DelBarCode(string barCode, string tableName)
{
LocalDBService localDB = new LocalDBService(SqlHelper.GetConnSting());
try
{
localDB.BeginTrans();
bool wms = wmsDal.DeleteInterface(localDB, barCode);
if (wms == false)
{
throw new Exception($"条码在wms库已报工,无法删除!");
}
db.DelBarCode(localDB, barCode, tableName);
localDB.Commit();
return "";
}
catch (Exception ex)
{
if (localDB != null)
{
localDB.Rollback();
}
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return ex.Message;
}
finally
{
if (localDB != null)
{
localDB.EndTrans();
}
}
}
2 months ago
public DataTable SearchBoxIsNull(string partNo, string StationID, string tableName, string ProductNature)
{
try
{
return db.SearchBoxIsNull(partNo, StationID, tableName, ProductNature);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable IsHave(string partNo, string StationID, string tableName)
{
try
{
return db.IsHave(partNo, StationID, tableName);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 箱码中单个条码替换
/// </summary>
/// <param name="tableName"></param>
/// <param name="boxCode"></param>
/// <param name="oldID"></param>
/// <param name="newID"></param>
/// <param name="model"></param>
/// <returns></returns>
public bool BarCodeReplace(string oldtableName, string newtableName, string boxCode,string oldID,string newID,string newOneBarCode,string newBarCode, BadInjectionModel model)
{
LocalDBService localDB = new LocalDBService(SqlHelper.GetConnSting());
try
{
localDB.BeginTrans();
db.UpdateBoxNoByID(localDB, newtableName, boxCode, newID);
db.UpdateBoxNoNull(localDB, oldtableName, oldID);
badDb.AddInfo(localDB, model);
//删除旧的条码
wmsDal.DeleteRecord(localDB, boxCode, model.OneBarCode, model.BarCode);
//保存新条码
wmsDal.AddRecord(localDB, boxCode, newOneBarCode, newBarCode,"0", model.Desc,"");
localDB.Commit();
return true;
}
catch (Exception ex)
{
if(localDB != null)
{
localDB.Rollback();
}
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
finally
{
if (localDB != null)
{
localDB.EndTrans();
}
}
}
2 months ago
public bool UpdateBoxNo(string tableName, string boxNo, string partNo)
{
try
{
return db.UpdateBoxNo(tableName, boxNo, partNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
2 months ago
public DataTable SearchCountByBox(string boxNo, string tableName)
{
try
{
return db.SearchCountByBox(boxNo, tableName);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool UpdateIsBad(string tableName, string onebarcode, string barcode)
{
try
{
return db.UpdateIsBad(tableName, onebarcode, barcode);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool UpdateIsBad(LocalDBService localDB, string tableName, string onebarcode, string barcode)
{
return db.UpdateIsBad(localDB,tableName, onebarcode, barcode);
}
public bool UpdateIsBadByBoxCode(string tableName, string boxNo)
{
try
{
return db.UpdateIsBadByBoxCode(tableName, boxNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool UpdateIsBadByBoxCode(LocalDBService localDB, string tableName, string boxNo)
{
try
{
return db.UpdateIsBadByBoxCode(localDB,tableName, boxNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
2 months ago
public DataTable SearchBarCode(string boxNo, string tableName, string row)
{
try
{
DataTable dt = null;
if (string.IsNullOrEmpty(tableName))
{
dt = db.SearchInfoByBox(boxNo);
}
else
{
dt = db.SearchBarCode(boxNo, tableName, row);
}
return dt;
2 months ago
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchBarCodeByWhere(string whereStr, string tableName, string row)
{
try
{
return db.SearchBarCodeByWhere(whereStr, tableName, row);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
2 months ago
public bool updateProductNature(string tableName, string barcode)
{
try
{
return db.updateProductNature(tableName, barcode);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable SeachInfoByOne(string barCode, string tableName,int flag)
{
try
{
return db.SeachInfoByOne(barCode, tableName, flag);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public string LastBarCode(string tableName)
{
try
{
return db.LastBarCode(tableName);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return "";
}
}
public bool IsExist(string barCode)
{
try
{
return db.IsExist(barCode);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
return false;
}
}
}
}