161 lines
		
	
	
		
			7.1 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			161 lines
		
	
	
		
			7.1 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.Linq;
 | |
| using System.Text;
 | |
| using System.Collections;
 | |
| 
 | |
| namespace BLL
 | |
| {
 | |
|     /// <summary>
 | |
|     /// 一般方案过程描述
 | |
|     /// </summary>
 | |
|     public static class GeneralPlanApprovalItemService
 | |
|     {
 | |
|         public static Model.SGGLDB db = Funs.DB;
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 记录数
 | |
|         /// </summary>
 | |
|         public static int count
 | |
|         {
 | |
|             get;
 | |
|             set;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 获取分页列表
 | |
|         /// </summary>
 | |
|         /// <param name="generalPlanApprovalId"></param>
 | |
|         /// <param name="startRowIndex"></param>
 | |
|         /// <param name="maximumRows"></param>
 | |
|         /// <returns></returns>
 | |
|         public static IEnumerable GetListData(string generalPlanApprovalId, int startRowIndex, int maximumRows)
 | |
|         {
 | |
|             IQueryable<Model.Comprehensive_GeneralPlanApprovalItem> q = from x in db.Comprehensive_GeneralPlanApprovalItem
 | |
|                                                                         where x.GeneralPlanApprovalId == generalPlanApprovalId
 | |
|                                                                         orderby x.SubmitDate descending
 | |
|                                                                         select x;
 | |
| 
 | |
|             count = q.Count();
 | |
|             if (count == 0)
 | |
|             {
 | |
|                 return new object[] { "" };
 | |
|             }
 | |
|             return from x in q.Skip(startRowIndex).Take(maximumRows)
 | |
|                    select new
 | |
|                    {
 | |
|                        x.GeneralPlanApprovalItemId,
 | |
|                        x.GeneralPlanApprovalId,
 | |
|                        x.UnitId,
 | |
|                        UnitName = (from y in db.Base_Unit where y.UnitId == x.UnitId select y.UnitName).FirstOrDefault(),
 | |
|                        x.Counts,
 | |
|                        x.SubmitDate,
 | |
|                        x.ReturnDate,
 | |
|                        x.ModifyContents,
 | |
|                        x.AttachUrl
 | |
|                    };
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 获取分页列表数
 | |
|         /// </summary>
 | |
|         /// <param name="generalPlanApprovalId"></param>
 | |
|         /// <returns></returns>
 | |
|         public static int GetListCount(string generalPlanApprovalId)
 | |
|         {
 | |
|             return count;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据主键获取一般方案过程描述
 | |
|         /// </summary>
 | |
|         /// <param name="generalPlanApprovalItemId"></param>
 | |
|         /// <returns></returns>
 | |
|         public static Model.Comprehensive_GeneralPlanApprovalItem GetGeneralPlanApprovalItemById(string generalPlanApprovalItemId)
 | |
|         {
 | |
|             return Funs.DB.Comprehensive_GeneralPlanApprovalItem.FirstOrDefault(e => e.GeneralPlanApprovalItemId == generalPlanApprovalItemId);
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 添加一般方案过程描述
 | |
|         /// </summary>
 | |
|         /// <param name="generalPlanApprovalItem"></param>
 | |
|         public static void AddGeneralPlanApprovalItem(Model.Comprehensive_GeneralPlanApprovalItem generalPlanApprovalItem)
 | |
|         {
 | |
|             Model.SGGLDB db = Funs.DB;
 | |
|             Model.Comprehensive_GeneralPlanApprovalItem newGeneralPlanApprovalItem = new Model.Comprehensive_GeneralPlanApprovalItem();
 | |
|             newGeneralPlanApprovalItem.GeneralPlanApprovalItemId = generalPlanApprovalItem.GeneralPlanApprovalItemId;
 | |
|             newGeneralPlanApprovalItem.GeneralPlanApprovalId = generalPlanApprovalItem.GeneralPlanApprovalId;
 | |
|             newGeneralPlanApprovalItem.UnitId = generalPlanApprovalItem.UnitId;
 | |
|             newGeneralPlanApprovalItem.Counts = generalPlanApprovalItem.Counts;
 | |
|             newGeneralPlanApprovalItem.SubmitDate = generalPlanApprovalItem.SubmitDate;
 | |
|             newGeneralPlanApprovalItem.ReturnDate = generalPlanApprovalItem.ReturnDate;
 | |
|             newGeneralPlanApprovalItem.ModifyContents = generalPlanApprovalItem.ModifyContents;
 | |
|             newGeneralPlanApprovalItem.AttachUrl = generalPlanApprovalItem.AttachUrl;
 | |
|             db.Comprehensive_GeneralPlanApprovalItem.InsertOnSubmit(newGeneralPlanApprovalItem);
 | |
|             db.SubmitChanges();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 修改一般方案过程描述
 | |
|         /// </summary>
 | |
|         /// <param name="generalPlanApprovalItem"></param>
 | |
|         public static void UpdateGeneralPlanApprovalItem(Model.Comprehensive_GeneralPlanApprovalItem generalPlanApprovalItem)
 | |
|         {
 | |
|             Model.SGGLDB db = Funs.DB;
 | |
|             Model.Comprehensive_GeneralPlanApprovalItem newGeneralPlanApprovalItem = db.Comprehensive_GeneralPlanApprovalItem.FirstOrDefault(e => e.GeneralPlanApprovalItemId == generalPlanApprovalItem.GeneralPlanApprovalItemId);
 | |
|             if (newGeneralPlanApprovalItem != null)
 | |
|             {
 | |
|                 newGeneralPlanApprovalItem.UnitId = generalPlanApprovalItem.UnitId;
 | |
|                 newGeneralPlanApprovalItem.Counts = generalPlanApprovalItem.Counts;
 | |
|                 newGeneralPlanApprovalItem.SubmitDate = generalPlanApprovalItem.SubmitDate;
 | |
|                 newGeneralPlanApprovalItem.ReturnDate = generalPlanApprovalItem.ReturnDate;
 | |
|                 newGeneralPlanApprovalItem.ModifyContents = generalPlanApprovalItem.ModifyContents;
 | |
|                 newGeneralPlanApprovalItem.AttachUrl = generalPlanApprovalItem.AttachUrl;
 | |
|                 db.SubmitChanges();
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据主键删除一般方案过程描述
 | |
|         /// </summary>
 | |
|         /// <param name="generalPlanApprovalItemId"></param>
 | |
|         public static void DeleteGeneralPlanApprovalItemById(string generalPlanApprovalItemId)
 | |
|         {
 | |
|             Model.SGGLDB db = Funs.DB;
 | |
|             Model.Comprehensive_GeneralPlanApprovalItem newGeneralPlanApprovalItem = db.Comprehensive_GeneralPlanApprovalItem.FirstOrDefault(e => e.GeneralPlanApprovalItemId == generalPlanApprovalItemId);
 | |
|             if (newGeneralPlanApprovalItem != null)
 | |
|             {
 | |
|                 if (!string.IsNullOrEmpty(newGeneralPlanApprovalItem.AttachUrl))
 | |
|                 {
 | |
|                     BLL.UploadAttachmentService.DeleteFile(Funs.RootPath, newGeneralPlanApprovalItem.AttachUrl);//删除附件
 | |
|                 }
 | |
|                 db.Comprehensive_GeneralPlanApprovalItem.DeleteOnSubmit(newGeneralPlanApprovalItem);
 | |
|                 db.SubmitChanges();
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据一般方案主键删除所有相关过程描述
 | |
|         /// </summary>
 | |
|         /// <param name="generalPlanApprovalId"></param>
 | |
|         public static void DeleteGeneralPlanApprovalItemByGeneralPlanApprovalId(string generalPlanApprovalId)
 | |
|         {
 | |
|             Model.SGGLDB db = Funs.DB;
 | |
|             var q = (from x in db.Comprehensive_GeneralPlanApprovalItem where x.GeneralPlanApprovalId == generalPlanApprovalId select x).ToList();
 | |
|             if (q != null)
 | |
|             {
 | |
|                 foreach (var att in q)
 | |
|                 {
 | |
|                     if (!string.IsNullOrEmpty(att.AttachUrl))
 | |
|                     {
 | |
|                         BLL.UploadAttachmentService.DeleteFile(Funs.RootPath, att.AttachUrl);//删除附件
 | |
|                     }
 | |
|                 }
 | |
|                 db.Comprehensive_GeneralPlanApprovalItem.DeleteAllOnSubmit(q);
 | |
|                 db.SubmitChanges();
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| }
 |