192 lines
		
	
	
		
			5.1 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			192 lines
		
	
	
		
			5.1 KiB
		
	
	
	
		
			C#
		
	
	
	
| 
								 | 
							
								using Model;
							 | 
						|||
| 
								 | 
							
								using System;
							 | 
						|||
| 
								 | 
							
								using System.Collections;
							 | 
						|||
| 
								 | 
							
								using System.Collections.Generic;
							 | 
						|||
| 
								 | 
							
								using System.Linq;
							 | 
						|||
| 
								 | 
							
								using System.Text;
							 | 
						|||
| 
								 | 
							
								using System.Threading.Tasks;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								namespace BLL
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
									public class PMITrustManageItemService
							 | 
						|||
| 
								 | 
							
									{
							 | 
						|||
| 
								 | 
							
										public static Model.SGGLDB db = Funs.DB;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
										/// <summary>
							 | 
						|||
| 
								 | 
							
										/// 记录数
							 | 
						|||
| 
								 | 
							
										/// </summary>
							 | 
						|||
| 
								 | 
							
										private static int count
							 | 
						|||
| 
								 | 
							
										{
							 | 
						|||
| 
								 | 
							
											get;
							 | 
						|||
| 
								 | 
							
											set;
							 | 
						|||
| 
								 | 
							
										}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
										/// <summary>
							 | 
						|||
| 
								 | 
							
										/// 定义变量
							 | 
						|||
| 
								 | 
							
										/// </summary>
							 | 
						|||
| 
								 | 
							
										private static IQueryable<Model.PMI_TrustMangeItem> qq = from x in db.PMI_TrustMangeItem
							 | 
						|||
| 
								 | 
							
																								 orderby x.PMITrustItemID, x.PipelineNum
							 | 
						|||
| 
								 | 
							
																								 select x;
							 | 
						|||
| 
								 | 
							
										/// <summary>
							 | 
						|||
| 
								 | 
							
										/// 根据委托Id获取用于委托的焊口视图信息
							 | 
						|||
| 
								 | 
							
										/// </summary>
							 | 
						|||
| 
								 | 
							
										/// <param name="jot_id"></param>
							 | 
						|||
| 
								 | 
							
										/// <returns></returns>
							 | 
						|||
| 
								 | 
							
										public static List<Model.PMI_TrustMangeItem> GetView_PMI_TrustItemByCH_TrustID(string PMI_TrustID)
							 | 
						|||
| 
								 | 
							
										{
							 | 
						|||
| 
								 | 
							
											Model.SGGLDB db = Funs.DB;
							 | 
						|||
| 
								 | 
							
											var view = (from x in db.PMI_TrustMangeItem where x.PMITrustID == PMI_TrustID select x).ToList();
							 | 
						|||
| 
								 | 
							
											return view;
							 | 
						|||
| 
								 | 
							
										}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
										/// <summary>
							 | 
						|||
| 
								 | 
							
										/// 查找后返回集合增加到列表集团中
							 | 
						|||
| 
								 | 
							
										/// </summary>
							 | 
						|||
| 
								 | 
							
										/// <param name="hdItemsString"></param>
							 | 
						|||
| 
								 | 
							
										/// <returns></returns>
							 | 
						|||
| 
								 | 
							
										public static List<Model.PMI_TrustMangeItem> GetTrustAddItem(string hdItemsString)
							 | 
						|||
| 
								 | 
							
										{
							 | 
						|||
| 
								 | 
							
											List<Model.PMI_TrustMangeItem> returnViewMatch = new List<Model.PMI_TrustMangeItem>(); //= getWeldReportItem;
							 | 
						|||
| 
								 | 
							
											if (!string.IsNullOrEmpty(hdItemsString))
							 | 
						|||
| 
								 | 
							
											{
							 | 
						|||
| 
								 | 
							
												List<string> jotIds = Funs.GetStrListByStr(hdItemsString, '|');
							 | 
						|||
| 
								 | 
							
												returnViewMatch = (from x in Funs.DB.PMI_TrustMangeItem
							 | 
						|||
| 
								 | 
							
																   where jotIds.Contains(x.PMITrustItemID)
							 | 
						|||
| 
								 | 
							
																   select x).ToList();
							 | 
						|||
| 
								 | 
							
											}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
											return returnViewMatch;
							 | 
						|||
| 
								 | 
							
										}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
										/// <summary>
							 | 
						|||
| 
								 | 
							
										/// 获取分页列表
							 | 
						|||
| 
								 | 
							
										/// </summary>
							 | 
						|||
| 
								 | 
							
										/// <param name="startRowIndex"></param>
							 | 
						|||
| 
								 | 
							
										/// <param name="maximumRows"></param>
							 | 
						|||
| 
								 | 
							
										/// <returns></returns>
							 | 
						|||
| 
								 | 
							
										public static IEnumerable getListData(string projectId, string startTime, string endTime, string CH_TrustID, int startRowIndex, int maximumRows)
							 | 
						|||
| 
								 | 
							
										{
							 | 
						|||
| 
								 | 
							
											IQueryable<Model.PMI_TrustMangeItem> q = qq;
							 | 
						|||
| 
								 | 
							
											if (!string.IsNullOrEmpty(projectId))
							 | 
						|||
| 
								 | 
							
											{
							 | 
						|||
| 
								 | 
							
												q = q.Where(e => e.ProjectId == projectId);
							 | 
						|||
| 
								 | 
							
											}
							 | 
						|||
| 
								 | 
							
											if (!string.IsNullOrEmpty(CH_TrustID))
							 | 
						|||
| 
								 | 
							
											{
							 | 
						|||
| 
								 | 
							
												q = q.Where(e => e.PMITrustID.Contains(CH_TrustID));
							 | 
						|||
| 
								 | 
							
											}
							 | 
						|||
| 
								 | 
							
											count = q.Count();
							 | 
						|||
| 
								 | 
							
											if (count == 0)
							 | 
						|||
| 
								 | 
							
											{
							 | 
						|||
| 
								 | 
							
												return new object[] { "" };
							 | 
						|||
| 
								 | 
							
											}
							 | 
						|||
| 
								 | 
							
											return from x in q.Skip(startRowIndex).Take(maximumRows)
							 | 
						|||
| 
								 | 
							
												   select new
							 | 
						|||
| 
								 | 
							
												   {
							 | 
						|||
| 
								 | 
							
													   x.PMITrustItemID,
							 | 
						|||
| 
								 | 
							
													   x.MaterialId,
							 | 
						|||
| 
								 | 
							
													   x.PMITrustID,
							 | 
						|||
| 
								 | 
							
													   x.PipelineNum,
							 | 
						|||
| 
								 | 
							
													   x.PipelineName,
							 | 
						|||
| 
								 | 
							
													   x.QualityNum,
							 | 
						|||
| 
								 | 
							
													   x.LotNumber,
							 | 
						|||
| 
								 | 
							
													   x.PipeIineSpecs,
							 | 
						|||
| 
								 | 
							
													   x.PipelineMaterial,
							 | 
						|||
| 
								 | 
							
													   x.HotStatus,
							 | 
						|||
| 
								 | 
							
													   x.AcceptanceCriteria,
							 | 
						|||
| 
								 | 
							
													   x.SamplingNum,
							 | 
						|||
| 
								 | 
							
													   x.RemarkNum,
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
												   };
							 | 
						|||
| 
								 | 
							
										}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
										public static void upDataCH_TrustItem(string cH_TrustID, List<PMI_TrustMangeItem> trusts)
							 | 
						|||
| 
								 | 
							
										{
							 | 
						|||
| 
								 | 
							
											Model.SGGLDB db = Funs.DB;
							 | 
						|||
| 
								 | 
							
											var cH_Trust = from x in db.PMI_TrustMangeItem where x.PMITrustID == cH_TrustID select x;
							 | 
						|||
| 
								 | 
							
											List<PMI_TrustMangeItem> needRemove = new List<PMI_TrustMangeItem>();
							 | 
						|||
| 
								 | 
							
											if (cH_Trust != null)//
							 | 
						|||
| 
								 | 
							
											{
							 | 
						|||
| 
								 | 
							
												if (trusts != null)//判断需要删除的
							 | 
						|||
| 
								 | 
							
												{
							 | 
						|||
| 
								 | 
							
													foreach (var item in cH_Trust)
							 | 
						|||
| 
								 | 
							
													{
							 | 
						|||
| 
								 | 
							
														bool hasFind = false;
							 | 
						|||
| 
								 | 
							
														foreach (var trustItem in trusts)
							 | 
						|||
| 
								 | 
							
														{
							 | 
						|||
| 
								 | 
							
															if (trustItem.PMITrustItemID == item.PMITrustItemID)
							 | 
						|||
| 
								 | 
							
															{
							 | 
						|||
| 
								 | 
							
																hasFind = true;
							 | 
						|||
| 
								 | 
							
															}
							 | 
						|||
| 
								 | 
							
														}
							 | 
						|||
| 
								 | 
							
														if (!hasFind)
							 | 
						|||
| 
								 | 
							
														{
							 | 
						|||
| 
								 | 
							
															needRemove.Add(item);
							 | 
						|||
| 
								 | 
							
														}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
													}
							 | 
						|||
| 
								 | 
							
												}
							 | 
						|||
| 
								 | 
							
												else
							 | 
						|||
| 
								 | 
							
												{
							 | 
						|||
| 
								 | 
							
													needRemove.AddRange(cH_Trust);
							 | 
						|||
| 
								 | 
							
												}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
											}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
											if (trusts != null)
							 | 
						|||
| 
								 | 
							
											{
							 | 
						|||
| 
								 | 
							
												foreach (var trustItem in trusts)
							 | 
						|||
| 
								 | 
							
												{
							 | 
						|||
| 
								 | 
							
													bool hasFind = false;
							 | 
						|||
| 
								 | 
							
													foreach (var item in cH_Trust)
							 | 
						|||
| 
								 | 
							
													{
							 | 
						|||
| 
								 | 
							
														if (trustItem.PMITrustItemID == item.PMITrustItemID)
							 | 
						|||
| 
								 | 
							
														{
							 | 
						|||
| 
								 | 
							
															hasFind = true;
							 | 
						|||
| 
								 | 
							
														}
							 | 
						|||
| 
								 | 
							
													}
							 | 
						|||
| 
								 | 
							
													if (!hasFind)
							 | 
						|||
| 
								 | 
							
													{
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
														PMI_TrustMangeItem newItem = new PMI_TrustMangeItem();
							 | 
						|||
| 
								 | 
							
														newItem.PMITrustItemID = SQLHelper.GetNewID(typeof(Model.PMI_TrustMangeItem));
							 | 
						|||
| 
								 | 
							
														newItem.MaterialId = trustItem.MaterialId;
							 | 
						|||
| 
								 | 
							
														newItem.PMITrustID = trustItem.PMITrustID;
							 | 
						|||
| 
								 | 
							
														newItem.PipelineNum = trustItem.PipelineNum;
							 | 
						|||
| 
								 | 
							
														newItem.PipelineName = trustItem.PipelineName;
							 | 
						|||
| 
								 | 
							
														newItem.QualityNum = trustItem.QualityNum;
							 | 
						|||
| 
								 | 
							
														newItem.LotNumber = trustItem.LotNumber;
							 | 
						|||
| 
								 | 
							
														newItem.PipeIineSpecs = trustItem.PipeIineSpecs;
							 | 
						|||
| 
								 | 
							
														newItem.PipelineMaterial = trustItem.PipelineMaterial;
							 | 
						|||
| 
								 | 
							
														newItem.HotStatus = trustItem.HotStatus;
							 | 
						|||
| 
								 | 
							
														newItem.AcceptanceCriteria = trustItem.AcceptanceCriteria;
							 | 
						|||
| 
								 | 
							
														newItem.SamplingNum = trustItem.SamplingNum;
							 | 
						|||
| 
								 | 
							
														newItem.RemarkNum = trustItem.RemarkNum;
							 | 
						|||
| 
								 | 
							
														newItem.CreateTime = DateTime.Now;
							 | 
						|||
| 
								 | 
							
														db.PMI_TrustMangeItem.InsertOnSubmit(newItem);
							 | 
						|||
| 
								 | 
							
													}
							 | 
						|||
| 
								 | 
							
												}
							 | 
						|||
| 
								 | 
							
											}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
											db.PMI_TrustMangeItem.DeleteAllOnSubmit(needRemove);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
											db.SubmitChanges();
							 | 
						|||
| 
								 | 
							
										}
							 | 
						|||
| 
								 | 
							
										public static Model.PMI_TrustMangeItem GetCH_TrustByID(string CH_TrustID)
							 | 
						|||
| 
								 | 
							
										{
							 | 
						|||
| 
								 | 
							
											Model.SGGLDB db = Funs.DB;
							 | 
						|||
| 
								 | 
							
											var view = db.PMI_TrustMangeItem.FirstOrDefault(e => e.PMITrustItemID == CH_TrustID);
							 | 
						|||
| 
								 | 
							
											return view;
							 | 
						|||
| 
								 | 
							
										}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
										public static void DeleteCH_TrustItemByCH_TrustID(string cH_TrustID)
							 | 
						|||
| 
								 | 
							
										{
							 | 
						|||
| 
								 | 
							
											Model.SGGLDB db = Funs.DB;
							 | 
						|||
| 
								 | 
							
											var cH_Trust = (from x in Funs.DB.PMI_TrustMangeItem where x.PMITrustID==cH_TrustID select x).ToList();
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            db.PMI_TrustMangeItem.DeleteAllOnSubmit(cH_Trust);
							 | 
						|||
| 
								 | 
							
											db.SubmitChanges();
							 | 
						|||
| 
								 | 
							
										}
							 | 
						|||
| 
								 | 
							
									}
							 | 
						|||
| 
								 | 
							
								}
							 |