10 changed files with 669 additions and 18 deletions
@ -0,0 +1,281 @@ |
|||
using MESClassLibrary.BLL.Log; |
|||
using MESClassLibrary.EFModel; |
|||
using MESClassLibrary.Model; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Data; |
|||
using System.Linq; |
|||
using System.Reflection; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using MESClassLibrary.DAL.BasicInfo; |
|||
|
|||
namespace MESClassLibrary.BLL.BasicInfo |
|||
{ |
|||
public class Bom_MKBLL |
|||
{ |
|||
BasicBLL<tb_Bom_MK> db = new BasicBLL<tb_Bom_MK>(); |
|||
|
|||
/// <summary>
|
|||
/// 新增信息
|
|||
/// </summary>
|
|||
/// <param name="md"></param>
|
|||
/// <returns></returns>
|
|||
public bool AddInfo(tb_Bom_MK md) |
|||
{ |
|||
try |
|||
{ |
|||
var list = db.SearchInfoByKey("PartNo1", md.PartNo1);//判断是否有重复数据
|
|||
if (list != null) |
|||
{ |
|||
//if (list.Where(p => p.BomID != md.BomID).Count() > 0)
|
|||
//{
|
|||
// return false;
|
|||
//}
|
|||
|
|||
} |
|||
|
|||
return db.AddInfo(md); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); |
|||
return false; |
|||
} |
|||
|
|||
} |
|||
/// <summary>
|
|||
/// 修改信息
|
|||
/// </summary>
|
|||
/// <param name="md"></param>
|
|||
/// <returns></returns>
|
|||
public bool UpdateInfo(tb_Bom_MK md) |
|||
{ |
|||
try |
|||
{ |
|||
var list = db.SearchAllInfo().Where(p => p.PartNo1 == md.PartNo1 && p.BomID != md.BomID).ToList();//判断是否有重复数据
|
|||
//if (list.Count > 0)
|
|||
//{
|
|||
// return false;
|
|||
//}
|
|||
|
|||
//初始化要更新的字段
|
|||
string[] proNames = new string[2]; |
|||
proNames[0] = "PartNo1"; |
|||
proNames[1] = "PartNo2"; |
|||
|
|||
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
|
|||
//如果没有初始化必填字段,更新会报错
|
|||
|
|||
|
|||
return db.UpdateInfo(md, proNames); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); |
|||
return false; |
|||
} |
|||
|
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 删除信息
|
|||
/// </summary>
|
|||
/// <param name="md"></param>
|
|||
/// <param name="flag"></param>
|
|||
/// <returns></returns>
|
|||
public bool DeleteInfo(tb_Bom_MK md) |
|||
{ |
|||
try |
|||
{ |
|||
return db.DelInfo(md); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); |
|||
return false; |
|||
} |
|||
|
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 查询全部信息分页
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
public string SearchInfoAll(string page, string pagesize, string partNo1, string partNo2, string placeName) |
|||
{ |
|||
try |
|||
{ |
|||
|
|||
string jsonStr = "[]"; |
|||
int total = 0;//总行数
|
|||
List<tb_Bom_MK> list = db.SearchAllInfo(); |
|||
|
|||
if (!String.IsNullOrEmpty(partNo1)) |
|||
{ |
|||
list = list.Where(p => p.PartNo1 != null && p.PartNo1.Contains(partNo1)).ToList(); |
|||
} |
|||
|
|||
if (!String.IsNullOrEmpty(partNo2)) |
|||
{ |
|||
list = list.Where(p => p.PartNo2 != null && p.PartNo2.Contains(partNo2) ).ToList(); |
|||
} |
|||
|
|||
if (!String.IsNullOrEmpty(placeName)) |
|||
{ |
|||
list = list.Where(p => p.PlaceName != null && p.PlaceName.Contains(placeName)).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(); |
|||
|
|||
List<Bom_MKModel> modelList = new List<Bom_MKModel>(); |
|||
BasicBLL<tb_Product> s_db = new BasicBLL<tb_Product>(); |
|||
var s_list = s_db.SearchAllInfo(); |
|||
|
|||
foreach (var item in list) |
|||
{ |
|||
Bom_MKModel dm = Tool.Mapper<Bom_MKModel, tb_Bom_MK>(item); |
|||
var info = s_list.FirstOrDefault(p => p.PartNo == item.PartNo1); |
|||
if (info != null) |
|||
{ |
|||
dm.ProductName1 = info.ProductName; |
|||
} |
|||
|
|||
var info2 = s_list.FirstOrDefault(p => p.PartNo == item.PartNo2); |
|||
if (info2 != null) |
|||
{ |
|||
dm.ProductName2 = info2.ProductName; |
|||
} |
|||
|
|||
modelList.Add(dm); |
|||
} |
|||
|
|||
|
|||
JsonDataModel<Bom_MKModel> md = new JsonDataModel<Bom_MKModel>(); |
|||
md.total = total.ToString(); |
|||
md.rows = modelList; |
|||
jsonStr = JSONTools.ScriptSerialize<JsonDataModel<Bom_MKModel>>(md); |
|||
} |
|||
return jsonStr; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); |
|||
return null; |
|||
} |
|||
|
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 查询全部信息
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
public List<tb_Bom_MK> SearchAll() |
|||
{ |
|||
try |
|||
{ |
|||
var s_list = db.SearchAllInfo().ToList(); |
|||
return s_list; |
|||
} |
|||
catch (Exception) |
|||
{ |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 根据ID查询信息
|
|||
/// </summary>
|
|||
/// <param name="id"></param>
|
|||
/// <returns></returns>
|
|||
public tb_Bom_MK SearchInfoByID(string id) |
|||
{ |
|||
try |
|||
{ |
|||
return db.SearchInfoByID(id); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); |
|||
return null; |
|||
} |
|||
|
|||
} |
|||
|
|||
public DataTable SearchBom(string PartNo) |
|||
{ |
|||
BomDAL dal = new BomDAL(); |
|||
try |
|||
{ |
|||
return dal.SearchBom(PartNo); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
public DataTable Search(string partNo1, string partNo2) |
|||
{ |
|||
BomDAL dal = new BomDAL(); |
|||
try |
|||
{ |
|||
return dal.Search(partNo1, partNo2); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
public bool AddInfo(Bom_MKModel md) |
|||
{ |
|||
Bom_MKDAL dal = new Bom_MKDAL(); |
|||
try |
|||
{ |
|||
return dal.AddInfo(md); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
public bool updateInfo(Bom_MKModel md) |
|||
{ |
|||
Bom_MKDAL dal = new Bom_MKDAL(); |
|||
try |
|||
{ |
|||
return dal.updateInfo(md); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
public bool DelInfo(Bom_MKModel md) |
|||
{ |
|||
Bom_MKDAL dal = new Bom_MKDAL(); |
|||
try |
|||
{ |
|||
return dal.DelInfo(md); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
@ -0,0 +1,150 @@ |
|||
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 MESClassLibrary.BLL.Log; |
|||
using MESClassLibrary.Model; |
|||
|
|||
namespace MESClassLibrary.DAL.BasicInfo |
|||
{ |
|||
public class Bom_MKDAL |
|||
{ |
|||
public DataTable SearchBom(string PartNo) |
|||
{ |
|||
try |
|||
{ |
|||
string sql = @"SELECT dbo.tb_Product.ProductName, dbo.tb_ProductType.ProductTypeName, dbo.tb_ProductType.ProductTypeNo,
|
|||
dbo.tb_Product.PartNo, dbo.tb_Bom.PartNo2, dbo.tb_Product.StockNo |
|||
FROM dbo.tb_Bom RIGHT OUTER JOIN |
|||
dbo.tb_Product ON dbo.tb_Bom.PartNo1 = dbo.tb_Product.PartNo LEFT OUTER JOIN |
|||
dbo.tb_ProductType ON dbo.tb_Product.ProductTypeID = dbo.tb_ProductType.ProductTypeID |
|||
WHERE PartNo=@PartNo";
|
|||
|
|||
SqlParameter[] param = new SqlParameter[1]; |
|||
param[0] = new SqlParameter("@PartNo", SqlDbType.VarChar); |
|||
param[0].Value = PartNo; |
|||
|
|||
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0]; |
|||
|
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
public DataTable Search(string partNo1, string partNo2) |
|||
{ |
|||
try |
|||
{ |
|||
string sql = "select * from tb_Bom where PartNo1=@partNo1,PartNo2=@partNo2"; |
|||
|
|||
SqlParameter[] param = new SqlParameter[2]; |
|||
param[0] = new SqlParameter("@@partNo1", SqlDbType.VarChar); |
|||
param[0].Value = partNo1; |
|||
|
|||
param[1] = new SqlParameter("@@partNo2", SqlDbType.VarChar); |
|||
param[1].Value = partNo2; |
|||
|
|||
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0]; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
public bool AddInfo(Bom_MKModel md) |
|||
{ |
|||
string sql = ""; |
|||
SqlParameter[] param = null; |
|||
|
|||
try |
|||
{ |
|||
sql = "insert into tb_Bom(ID,,PartNo1,PartNo2) values(@ID,@partNo1,@partNo2)"; |
|||
|
|||
param = new SqlParameter[3]; |
|||
param[0] = new SqlParameter("@ID", SqlDbType.VarChar); |
|||
param[0].Value = md.BomID; |
|||
|
|||
param[1] = new SqlParameter("@partNo1", SqlDbType.VarChar); |
|||
param[1].Value = md.PartNo1; |
|||
|
|||
param[2] = new SqlParameter("@partNo2", SqlDbType.VarChar); |
|||
param[2].Value = md.PartNo2; |
|||
|
|||
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param); |
|||
|
|||
return true; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
public bool updateInfo(Bom_MKModel md) |
|||
{ |
|||
string sql = ""; |
|||
SqlParameter[] param = null; |
|||
|
|||
try |
|||
{ |
|||
sql = "update tb_Bom set PartNo2=@partNo2 where PartNo1=@partNo1"; |
|||
|
|||
param = new SqlParameter[2]; |
|||
|
|||
param[0] = new SqlParameter("@partNo1", SqlDbType.VarChar); |
|||
param[0].Value = md.PartNo1; |
|||
|
|||
param[1] = new SqlParameter("@partNo2", SqlDbType.VarChar); |
|||
param[1].Value = md.PartNo2; |
|||
|
|||
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param); |
|||
|
|||
return true; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
public bool DelInfo(Bom_MKModel md) |
|||
{ |
|||
string sql = ""; |
|||
SqlParameter[] param = null; |
|||
|
|||
try |
|||
{ |
|||
sql = "delete from tb_Bom where PartNo1=@partNo1 and PartNo2=@partNo2 "; |
|||
|
|||
param = new SqlParameter[2]; |
|||
|
|||
param[0] = new SqlParameter("@partNo1", SqlDbType.VarChar); |
|||
param[0].Value = md.PartNo1; |
|||
|
|||
param[1] = new SqlParameter("@partNo2", SqlDbType.VarChar); |
|||
param[1].Value = md.PartNo2; |
|||
|
|||
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param); |
|||
|
|||
return true; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
@ -0,0 +1,26 @@ |
|||
//------------------------------------------------------------------------------
|
|||
// <auto-generated>
|
|||
// 此代码已从模板生成。
|
|||
//
|
|||
// 手动更改此文件可能导致应用程序出现意外的行为。
|
|||
// 如果重新生成代码,将覆盖对此文件的手动更改。
|
|||
// </auto-generated>
|
|||
//------------------------------------------------------------------------------
|
|||
|
|||
namespace MESClassLibrary.EFModel |
|||
{ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
|
|||
public partial class tb_Bom_MK |
|||
{ |
|||
public int BomID { get; set; } |
|||
public string PartNo1 { get; set; } |
|||
public string PartNo2 { get; set; } |
|||
public string UserID { get; set; } |
|||
public Nullable<bool> IsChecked { get; set; } |
|||
public string PlaceName { get; set; } |
|||
public Nullable<int> IsPartAssemble { get; set; } |
|||
public string StationNo { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,16 @@ |
|||
using MESClassLibrary.EFModel; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace MESClassLibrary.Model |
|||
{ |
|||
public class Bom_MKModel : tb_Bom_MK |
|||
{ |
|||
public string ProductName1 { get; set; } |
|||
|
|||
public string ProductName2 { get; set; } |
|||
} |
|||
} |
Loading…
Reference in new issue