196 lines
		
	
	
		
			7.9 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			196 lines
		
	
	
		
			7.9 KiB
		
	
	
	
		
			C#
		
	
	
	
using System;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System.Linq;
 | 
						|
using System.Text;
 | 
						|
 | 
						|
namespace BLL
 | 
						|
{
 | 
						|
    /// <summary>
 | 
						|
    /// 无损委托
 | 
						|
    /// </summary>
 | 
						|
    public static class Batch_BatchTrustService
 | 
						|
    {        
 | 
						|
        /// <summary>
 | 
						|
        /// 根据主键获取无损委托
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="batchTrustID"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        public static Model.Batch_BatchTrust GetBatchTrustById(string trustBatchId)
 | 
						|
        {
 | 
						|
            Model.HJGLDB db = Funs.DB;
 | 
						|
            return db.Batch_BatchTrust.FirstOrDefault(e => e.TrustBatchId == trustBatchId);
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 根据主键获取无损委托视图
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="batchTrustID"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        public static Model.View_Batch_BatchTrust GetBatchTrustViewById(string trustBatchId)
 | 
						|
        {
 | 
						|
            Model.HJGLDB db = Funs.DB;
 | 
						|
            return db.View_Batch_BatchTrust.FirstOrDefault(e => e.TrustBatchId == trustBatchId);
 | 
						|
        }
 | 
						|
 | 
						|
        #region 更新委托单 检测状态
 | 
						|
        /// <summary>
 | 
						|
        /// 更新委托单 检测状态
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="pointBatchId"></param>
 | 
						|
        /// <param name="isTrust"></param>
 | 
						|
        public static void UpdatTrustBatchtState(string trustBatchId, bool isCheck)
 | 
						|
        {
 | 
						|
            Model.HJGLDB db = Funs.DB;
 | 
						|
            Model.Batch_BatchTrust update = db.Batch_BatchTrust.FirstOrDefault(e => e.TrustBatchId == trustBatchId);
 | 
						|
            if (update != null)
 | 
						|
            {
 | 
						|
                update.IsCheck = isCheck;
 | 
						|
                db.SubmitChanges();
 | 
						|
            }
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 添加无损委托
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="batchTrust"></param>
 | 
						|
        public static void AddBatchTrust(Model.Batch_BatchTrust batchTrust)
 | 
						|
        {
 | 
						|
            Model.HJGLDB db = Funs.DB;
 | 
						|
            Model.Batch_BatchTrust newBatchTrust = new Model.Batch_BatchTrust
 | 
						|
            {
 | 
						|
                TrustBatchId = batchTrust.TrustBatchId,
 | 
						|
                TrustBatchCode = batchTrust.TrustBatchCode,
 | 
						|
                TrustDate = batchTrust.TrustDate,
 | 
						|
                ProjectId = batchTrust.ProjectId,
 | 
						|
                UnitId = batchTrust.UnitId,
 | 
						|
                InstallationId = batchTrust.InstallationId,
 | 
						|
                WorkAreaId = batchTrust.WorkAreaId,
 | 
						|
                PipelineId = batchTrust.PipelineId,
 | 
						|
                WeldingMethodId = batchTrust.WeldingMethodId,
 | 
						|
                GrooveTypeId=batchTrust.GrooveTypeId,
 | 
						|
                IsWelderFirst=batchTrust.IsWelderFirst,
 | 
						|
                TrustType = batchTrust.TrustType,
 | 
						|
                DetectionTypeId = batchTrust.DetectionTypeId,
 | 
						|
                IsCheck = batchTrust.IsCheck,
 | 
						|
                TopointBatch = batchTrust.TopointBatch
 | 
						|
            };
 | 
						|
 | 
						|
            db.Batch_BatchTrust.InsertOnSubmit(newBatchTrust);
 | 
						|
            db.SubmitChanges();
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 修改无损委托
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="batchTrust"></param>
 | 
						|
        public static void UpdateBatchTrust(Model.Batch_BatchTrust batchTrust)
 | 
						|
        {
 | 
						|
            Model.HJGLDB db = Funs.DB;
 | 
						|
            Model.Batch_BatchTrust newBatchTrust = db.Batch_BatchTrust.FirstOrDefault(e => e.TrustBatchId == batchTrust.TrustBatchId);
 | 
						|
            if (newBatchTrust != null)
 | 
						|
            {
 | 
						|
                newBatchTrust.TrustBatchCode = batchTrust.TrustBatchCode;
 | 
						|
                newBatchTrust.TrustDate = batchTrust.TrustDate;
 | 
						|
                newBatchTrust.ProjectId = batchTrust.ProjectId;
 | 
						|
                newBatchTrust.UnitId = batchTrust.UnitId;
 | 
						|
                newBatchTrust.InstallationId = batchTrust.InstallationId;
 | 
						|
                newBatchTrust.WorkAreaId = batchTrust.WorkAreaId;
 | 
						|
                newBatchTrust.PipelineId = batchTrust.PipelineId;
 | 
						|
                newBatchTrust.WeldingMethodId = batchTrust.WeldingMethodId;
 | 
						|
                newBatchTrust.GrooveTypeId = batchTrust.GrooveTypeId;
 | 
						|
                newBatchTrust.IsWelderFirst = batchTrust.IsWelderFirst;
 | 
						|
                newBatchTrust.TrustType = batchTrust.TrustType;
 | 
						|
                newBatchTrust.DetectionTypeId = batchTrust.DetectionTypeId;
 | 
						|
                newBatchTrust.IsCheck = batchTrust.IsCheck;
 | 
						|
                newBatchTrust.TopointBatch = batchTrust.TopointBatch;
 | 
						|
                db.SubmitChanges();
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        public static void BatchTrustNDEUnit(string batchTrustId, string ndeUnit,string trustBatchCode, string surfaceState, string detectionTiming, string quaCertFile,string acceptStandard,DateTime? trustDate)
 | 
						|
        {
 | 
						|
            Model.HJGLDB db = Funs.DB;
 | 
						|
            Model.Batch_BatchTrust newBatchTrust = db.Batch_BatchTrust.FirstOrDefault(e => e.TrustBatchId == batchTrustId);
 | 
						|
            if (newBatchTrust != null)
 | 
						|
            {
 | 
						|
                newBatchTrust.TrustBatchCode = trustBatchCode;
 | 
						|
                newBatchTrust.NDEUuit = ndeUnit;
 | 
						|
                newBatchTrust.SurfaceState = surfaceState;
 | 
						|
                newBatchTrust.DetectionTiming = detectionTiming;
 | 
						|
                newBatchTrust.QuaCertFile = quaCertFile;
 | 
						|
                newBatchTrust.AcceptStandard = acceptStandard;
 | 
						|
                newBatchTrust.TrustDate = trustDate;
 | 
						|
                db.SubmitChanges();
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 根据主键删除无损委托
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="batchTrustID"></param>
 | 
						|
        public static void DeleteBatchTrustById(string trustBatchId)
 | 
						|
        {
 | 
						|
            Model.HJGLDB db = Funs.DB;
 | 
						|
            Model.Batch_BatchTrust batchTrust = db.Batch_BatchTrust.FirstOrDefault(e => e.TrustBatchId == trustBatchId);
 | 
						|
            if (batchTrust != null)
 | 
						|
            {
 | 
						|
                db.Batch_BatchTrust.DeleteOnSubmit(batchTrust);
 | 
						|
                db.SubmitChanges();
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 无损委托委托单编号是否存在
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="pointNo"></param>
 | 
						|
        /// <param name="pointId"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        public static bool IsExistTrustCode(string trustBatchCode, string trustBatchId, string projectId)
 | 
						|
        {
 | 
						|
            var q = Funs.DB.Batch_BatchTrust.FirstOrDefault(x => x.TrustBatchCode == trustBatchCode && x.ProjectId == projectId && x.TrustBatchId != trustBatchId);
 | 
						|
            if (q != null)
 | 
						|
            {
 | 
						|
                return true;
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                return false;
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        #region 委托单下拉项
 | 
						|
        /// <summary>
 | 
						|
        /// 委托单下拉项
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="dropName">下拉框名称</param>
 | 
						|
        /// <param name="isShowPlease">是否显示请选择</param>
 | 
						|
        /// <param name="ComponentsType">耗材类型</param>
 | 
						|
        public static void InitTrustBatchDropDownList(FineUIPro.DropDownList dropName, bool isShowPlease, string unitId, string installationId, string detectionTypeId, string pipelineCode, string itemText)
 | 
						|
        {
 | 
						|
            dropName.DataValueField = "TrustBatchId";
 | 
						|
            dropName.DataTextField = "TrustBatchCode";
 | 
						|
 | 
						|
            var q = from x in Funs.DB.View_Batch_BatchTrust
 | 
						|
                    where x.UnitId == unitId && x.InstallationId == installationId && x.DetectionTypeId == detectionTypeId
 | 
						|
                          && x.CheckTrustBatchId == null
 | 
						|
                    select x;
 | 
						|
 | 
						|
            if (!string.IsNullOrEmpty(pipelineCode))
 | 
						|
            {
 | 
						|
                q = from x in Funs.DB.View_Batch_BatchTrust
 | 
						|
                    where x.UnitId == unitId && x.InstallationId == installationId && x.DetectionTypeId == detectionTypeId
 | 
						|
                          && x.PipelineCode.Contains(pipelineCode) && x.CheckTrustBatchId == null
 | 
						|
                    select x;
 | 
						|
            }
 | 
						|
            dropName.DataSource = q;
 | 
						|
            dropName.DataBind();
 | 
						|
            if (isShowPlease)
 | 
						|
            {
 | 
						|
                Funs.FineUIPleaseSelect(dropName, itemText);
 | 
						|
            }
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
    }
 | 
						|
}
 |