176 lines
		
	
	
		
			6.2 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			176 lines
		
	
	
		
			6.2 KiB
		
	
	
	
		
			C#
		
	
	
	
using System;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System.Linq;
 | 
						|
using System.Text;
 | 
						|
using System.Collections;
 | 
						|
using System.Web.UI.WebControls;
 | 
						|
 | 
						|
namespace BLL
 | 
						|
{
 | 
						|
    /// <summary>
 | 
						|
    /// 探伤部位
 | 
						|
    /// </summary>
 | 
						|
    public static class InspectionAreaService
 | 
						|
    {
 | 
						|
        public static Model.SGGLDB db = Funs.DB;
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 记录数
 | 
						|
        /// </summary>
 | 
						|
        public static int count
 | 
						|
        {
 | 
						|
            get;
 | 
						|
            set;
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 定义变量
 | 
						|
        /// </summary>
 | 
						|
        public static IQueryable<Model.Base_InspectionArea> qq = from x in db.Base_InspectionArea orderby x.InspectionAreaCode select x;
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 获取分页列表
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="inspectionAreaName"></param>
 | 
						|
        /// <param name="startRowIndex"></param>
 | 
						|
        /// <param name="maximumRows"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        public static IEnumerable GetListData(string inspectionAreaName, int startRowIndex, int maximumRows)
 | 
						|
        {
 | 
						|
            IQueryable<Model.Base_InspectionArea> q = qq;
 | 
						|
            if (!string.IsNullOrEmpty(inspectionAreaName))
 | 
						|
            {
 | 
						|
                q = q.Where(e => e.InspectionAreaName.Contains(inspectionAreaName));
 | 
						|
            }
 | 
						|
 | 
						|
            count = q.Count();
 | 
						|
            if (count == 0)
 | 
						|
            {
 | 
						|
                return new object[] { "" };
 | 
						|
            }
 | 
						|
            return from x in q.Skip(startRowIndex).Take(maximumRows)
 | 
						|
                   select new
 | 
						|
                   {
 | 
						|
                       x.InspectionAreaId,
 | 
						|
                       x.InspectionAreaCode,
 | 
						|
                       x.InspectionAreaName,
 | 
						|
                       x.Remark
 | 
						|
                   };
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 获取分页列表数
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="inspectionAreaName"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        public static int GetListCount(string inspectionAreaName)
 | 
						|
        {
 | 
						|
            return count;
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 根据主键获取探伤部位
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="inspectionAreaId"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        public static Model.Base_InspectionArea GetInspectionAreaById(string inspectionAreaId)
 | 
						|
        {
 | 
						|
            return Funs.DB.Base_InspectionArea.FirstOrDefault(e => e.InspectionAreaId == inspectionAreaId);
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 添加探伤部位
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="inspectionArea"></param>
 | 
						|
        public static void AddInspectionArea(Model.Base_InspectionArea inspectionArea)
 | 
						|
        {
 | 
						|
            Model.SGGLDB db = Funs.DB;
 | 
						|
            Model.Base_InspectionArea newInspectionArea = new Model.Base_InspectionArea();
 | 
						|
            newInspectionArea.InspectionAreaId = inspectionArea.InspectionAreaId;
 | 
						|
            newInspectionArea.InspectionAreaCode = inspectionArea.InspectionAreaCode;
 | 
						|
            newInspectionArea.InspectionAreaName = inspectionArea.InspectionAreaName;
 | 
						|
            newInspectionArea.Remark = inspectionArea.Remark;
 | 
						|
            db.Base_InspectionArea.InsertOnSubmit(newInspectionArea);
 | 
						|
            db.SubmitChanges();
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 修改探伤部位
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="inspectionArea"></param>
 | 
						|
        public static void UpdateInspectionArea(Model.Base_InspectionArea inspectionArea)
 | 
						|
        {
 | 
						|
            Model.SGGLDB db = Funs.DB;
 | 
						|
            Model.Base_InspectionArea newInspectionArea = db.Base_InspectionArea.FirstOrDefault(e => e.InspectionAreaId == inspectionArea.InspectionAreaId);
 | 
						|
            if (newInspectionArea != null)
 | 
						|
            {
 | 
						|
                newInspectionArea.InspectionAreaCode = inspectionArea.InspectionAreaCode;
 | 
						|
                newInspectionArea.InspectionAreaName = inspectionArea.InspectionAreaName;
 | 
						|
                newInspectionArea.Remark = inspectionArea.Remark;
 | 
						|
                db.SubmitChanges();
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 根据主键删除探伤部位
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="inspectionAreaId"></param>
 | 
						|
        public static void DeleteInspectionAreaById(string inspectionAreaId)
 | 
						|
        {
 | 
						|
            Model.SGGLDB db = Funs.DB;
 | 
						|
            Model.Base_InspectionArea newInspectionArea = db.Base_InspectionArea.FirstOrDefault(e => e.InspectionAreaId == inspectionAreaId);
 | 
						|
            if (newInspectionArea != null)
 | 
						|
            {
 | 
						|
                db.Base_InspectionArea.DeleteOnSubmit(newInspectionArea);
 | 
						|
                db.SubmitChanges();
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        ///  获取探伤部位名称项
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="projectId"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        public static ListItem[] drpInspectionAreaList()
 | 
						|
        {
 | 
						|
            var q = (from x in Funs.DB.Base_InspectionArea orderby x.InspectionAreaCode select x).ToList();
 | 
						|
            ListItem[] list = new ListItem[q.Count()];
 | 
						|
            for (int i = 0; i < list.Count(); i++)
 | 
						|
            {
 | 
						|
                list[i] = new ListItem(q[i].InspectionAreaName ?? "", q[i].InspectionAreaId);
 | 
						|
            }
 | 
						|
            return list;
 | 
						|
        }
 | 
						|
        public static void InitInspectionAreaDownList(FineUIPro.DropDownList dropName, bool isShowPlease)
 | 
						|
        {
 | 
						|
            dropName.DataValueField = "Value";
 | 
						|
            dropName.DataTextField = "Text";
 | 
						|
            dropName.DataSource = drpInspectionAreaList();
 | 
						|
            dropName.DataBind();
 | 
						|
            if (isShowPlease)
 | 
						|
            {
 | 
						|
                Funs.FineUIPleaseSelect(dropName);
 | 
						|
            }
 | 
						|
        }
 | 
						|
        /// <summary>
 | 
						|
        /// 判断是否存在相同的探伤部位名称
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="inspectionAreaName"></param>
 | 
						|
        /// <param name="inspectionAreaId"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        public static bool IsExitInspectionAreaName(string inspectionAreaName, string inspectionAreaId)
 | 
						|
        {
 | 
						|
            Model.SGGLDB db = Funs.DB;
 | 
						|
            var q = from x in db.Base_InspectionArea where x.InspectionAreaName == inspectionAreaName && x.InspectionAreaId != inspectionAreaId select x;
 | 
						|
            if (q.Count() > 0)
 | 
						|
            {
 | 
						|
                return true;
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                return false;
 | 
						|
            }
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |