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.
182 lines
8.2 KiB
182 lines
8.2 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.PunchAndWeld;
|
|
using MESClassLibrary.EFModel;
|
|
using MESClassLibrary.Model;
|
|
|
|
namespace MESClassLibrary.BLL.PunchAndWeld
|
|
{
|
|
public class PunchAndStationBLL
|
|
{
|
|
BasicBLL<tb_PunchAndStation> db = new BasicBLL<tb_PunchAndStation>();
|
|
|
|
public bool AddInfo(tb_PunchAndStation md)
|
|
{
|
|
try
|
|
{
|
|
BBMPTEntities ef = new BBMPTEntities();
|
|
List<tb_PunchAndStation> list1 = ef.tb_PunchAndStation.Where(p =>
|
|
p.StationID == md.StationID && p.ProductID1 == md.ProductID1 && p.ProductID2 == md.ProductID2)
|
|
.ToList();
|
|
|
|
if (list1 != null)
|
|
{
|
|
if (list1.Count() > 0)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return db.AddInfo(md);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
public string SearchInfoAll(string page, string pagesize, string partNo1)
|
|
{
|
|
try
|
|
{
|
|
string jsonStr = "[]";
|
|
int total = 0;//总行数
|
|
List<PunchAndStationModel1> list = new List<PunchAndStationModel1>();
|
|
|
|
string sql = @"SELECT dbo.tb_PunchAndStation.ID, dbo.tb_Station.StationNo, tb_Product_1.PartNo AS PartNo1,
|
|
tb_Product_1.ProductName AS ProductName1, tb_Product_2.PartNo AS PartNo2,
|
|
tb_Product_2.ProductName AS ProductName2, tb_Product_3.PartNo AS PartNo3,
|
|
tb_Product_3.ProductName AS ProductName3, tb_Product_4.PartNo AS PartNo4,
|
|
tb_Product_4.ProductName AS ProductName4, dbo.tb_Product.PartNo AS PartNo5,
|
|
dbo.tb_Product.ProductName AS ProductName5
|
|
FROM dbo.tb_Product AS tb_Product_3 RIGHT OUTER JOIN
|
|
dbo.tb_PunchAndStation LEFT OUTER JOIN
|
|
dbo.tb_Product ON dbo.tb_PunchAndStation.ProductID5 = dbo.tb_Product.ProductID LEFT OUTER JOIN
|
|
dbo.tb_Product AS tb_Product_4 ON dbo.tb_PunchAndStation.ProductID4 = tb_Product_4.ProductID ON
|
|
tb_Product_3.ProductID = dbo.tb_PunchAndStation.ProductID3 LEFT OUTER JOIN
|
|
dbo.tb_Product AS tb_Product_2 ON dbo.tb_PunchAndStation.ProductID2 = tb_Product_2.ProductID LEFT OUTER JOIN
|
|
dbo.tb_Station ON dbo.tb_PunchAndStation.StationID = dbo.tb_Station.StationID LEFT OUTER JOIN
|
|
dbo.tb_Product AS tb_Product_1 ON dbo.tb_PunchAndStation.ProductID1 = tb_Product_1.ProductID where 1=1";
|
|
|
|
if (!string.IsNullOrWhiteSpace(partNo1))
|
|
{
|
|
sql += " And tb_Product_1.PartNo like '%" + partNo1 + "%' ";
|
|
}
|
|
|
|
DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql).Tables[0];
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
list = Tool.ConvertTo<PunchAndStationModel1>(dt).ToList();
|
|
}
|
|
|
|
if (list.Count > 0)
|
|
{
|
|
total = list.Count;
|
|
|
|
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
|
|
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
|
|
|
|
JsonDataModel<PunchAndStationModel1> md = new JsonDataModel<PunchAndStationModel1>();
|
|
md.total = total.ToString();
|
|
md.rows = list;
|
|
jsonStr = JSONTools.ScriptSerialize<JsonDataModel<PunchAndStationModel1>>(md);
|
|
}
|
|
return jsonStr;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
return null;
|
|
}
|
|
|
|
}
|
|
|
|
public bool UpdateInfo(tb_PunchAndStation md)
|
|
{
|
|
try
|
|
{
|
|
List<PunchAndStationModel> list = new List<PunchAndStationModel>();
|
|
|
|
string sql = @"SELECT dbo.tb_PunchAndStation.ID, dbo.tb_Station.StationNo, tb_Product_1.PartNo AS PartNo1,
|
|
tb_Product_1.ProductName AS ProductName1, tb_Product_2.PartNo AS PartNo2,
|
|
tb_Product_2.ProductName AS ProductName2, tb_Product_3.PartNo AS PartNo3,
|
|
tb_Product_3.ProductName AS ProductName3, tb_Product_4.PartNo AS PartNo4,
|
|
tb_Product_4.ProductName AS ProductName4, dbo.tb_Product.PartNo AS PartNo5,
|
|
dbo.tb_Product.ProductName AS ProductName5,dbo.tb_PunchAndStation.ProductID1,
|
|
dbo.tb_PunchAndStation.ProductID2,dbo.tb_PunchAndStation.ProductID3,
|
|
dbo.tb_PunchAndStation.ProductID4,dbo.tb_PunchAndStation.ProductID5
|
|
FROM dbo.tb_Product AS tb_Product_3 RIGHT OUTER JOIN
|
|
dbo.tb_PunchAndStation LEFT OUTER JOIN
|
|
dbo.tb_Product ON dbo.tb_PunchAndStation.ProductID5 = dbo.tb_Product.ProductID LEFT OUTER JOIN
|
|
dbo.tb_Product AS tb_Product_4 ON dbo.tb_PunchAndStation.ProductID4 = tb_Product_4.ProductID ON
|
|
tb_Product_3.ProductID = dbo.tb_PunchAndStation.ProductID3 LEFT OUTER JOIN
|
|
dbo.tb_Product AS tb_Product_2 ON dbo.tb_PunchAndStation.ProductID2 = tb_Product_2.ProductID LEFT OUTER JOIN
|
|
dbo.tb_Station ON dbo.tb_PunchAndStation.StationID = dbo.tb_Station.StationID LEFT OUTER JOIN
|
|
dbo.tb_Product AS tb_Product_1 ON dbo.tb_PunchAndStation.ProductID1 = tb_Product_1.ProductID where 1=1 and
|
|
ProductID1='"+md.ProductID1+"' and ProductID2='"+md.ProductID2+"' and ProductID3='"+md.ProductID3+"' and ProductID4='"+md.ProductID4 +"' and ProductID5='"+md.ProductID5+"' and ID <> '"+ md.ID+"' ";
|
|
|
|
DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql).Tables[0];
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
//初始化要更新的字段
|
|
string[] proNames = new string[6];
|
|
proNames[0] = "StationID";
|
|
proNames[1] = "ProductID1";
|
|
proNames[2] = "ProductID2";
|
|
proNames[3] = "ProductID3";
|
|
proNames[4] = "ProductID4";
|
|
proNames[5] = "ProductID5";
|
|
|
|
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
|
|
//如果没有初始化必填字段,更新会报错
|
|
|
|
return db.UpdateInfo(md, proNames);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
public bool DeleteInfo(tb_PunchAndStation md)
|
|
{
|
|
try
|
|
{
|
|
return db.DelInfo(md);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
public DataTable IsMath(string partNo1, string partNo2)
|
|
{
|
|
try
|
|
{
|
|
PunchAndStationDAL da=new PunchAndStationDAL();
|
|
return da.IsMath(partNo1, partNo2);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|