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

201 lines
6.0 KiB

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL;
using MESClassLibrary.DAL.ZPPlan;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
namespace MESClassLibrary.BLL.ZPPlan
{
public class ZPBomBLL
{
ZPBomDAL da=new ZPBomDAL();
BasicBLL<tb_ZPBom> db=new BasicBLL<tb_ZPBom>();
public DataTable IsMath(string stationNo, string partNo1, string partNo2,int step)
{
try
{
return da.IsMath(stationNo, partNo1, partNo2, step);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchPartAndMould(string stationNo, string partNo1, string mould)
{
try
{
return da.SearchPartAndMould(stationNo, partNo1, mould);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public string SearchStepInfo(string page, string pagesize, string partNo1, string partNo2)
{
try
{
return da.SearchStepInfo(page, pagesize, partNo1, partNo2);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
return "";
}
}
public bool AddInfo(tb_ZPBom md)
{
try
{
var list = db.SearchAllInfo().Where(p =>
p.StationID == md.StationID && p.ProductID1 == md.ProductID1 && p.ProductID2 == md.ProductID2)
.ToList();
if (list.Count > 0)
{
return false;
}
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool UpdateInfo(tb_ZPBom md)
{
try
{
var list = db.SearchAllInfo().Where(p => p.StationID == md.StationID && p.ProductID1 == md.ProductID1 && p.ProductID2 == md.ProductID2 && p.ID!=md.ID).ToList();//判断是否有重复数据
if (list.Count > 0)
{
return false;
}
//初始化要更新的字段
string[] proNames = new string[7];
proNames[0] = "StationID";
proNames[1] = "ProductID1";
proNames[2] = "ProductID2";
//proNames[3] = "IsHigh";
proNames[3] = "MouldNo";
proNames[4] = "Step";
proNames[5] = "IsScanCode";
proNames[6] = "IsPhoto";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool DeleteInfo(tb_ZPBom md)
{
try
{
return db.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public string QueryForStep(string stationID, string productID)
{
try
{
var info = db.SearchAllInfo().Where(p => p.ProductID1.Equals(productID)).OrderByDescending(p => p.Step).FirstOrDefault();
//var info = db.SearchAllInfo().Where(p => p.StationID.Equals(stationID) && p.ProductID1.Equals(productID)).OrderByDescending(p => p.Step).FirstOrDefault();
if (info != null)
{
return (info.Step + 1).ToString();
}
else
{
return "1";
}
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return "";
}
}
public bool IsLast(string partNo, int step)
{
try
{
return da.IsLast(partNo, step);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable SearchStep(string partNo, string station)
{
try
{
return da.SearchStep(partNo, station);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchInfoByStep(string station, string partNo, int step)
{
try
{
return da.SearchInfoByStep(station, partNo, step);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public int SearchBeforeStepCount( string partNo, int step)
{
try
{
return da.SearchBeforeStepCount( partNo, step);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return 0;
}
}
}
}