374 lines
		
	
	
		
			16 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			374 lines
		
	
	
		
			16 KiB
		
	
	
	
		
			C#
		
	
	
	
| 
								 | 
							
								using BLL;
							 | 
						|||
| 
								 | 
							
								using Newtonsoft.Json.Linq;
							 | 
						|||
| 
								 | 
							
								using System;
							 | 
						|||
| 
								 | 
							
								using System.Collections.Generic;
							 | 
						|||
| 
								 | 
							
								using System.Linq;
							 | 
						|||
| 
								 | 
							
								using System.Web;
							 | 
						|||
| 
								 | 
							
								using System.Web.UI;
							 | 
						|||
| 
								 | 
							
								using System.Web.UI.WebControls;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								namespace FineUIPro.Web.TestRun.Produce
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    public partial class SubWorkInspect : PageBase
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        protected void Page_Load(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            if (!IsPostBack)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                this.BindGrid();
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        #region 数据绑定
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 绑定数据
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        public void BindGrid(bool istail = false)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            //获取子系统
							 | 
						|||
| 
								 | 
							
								            var data = from termitem in Funs.DB.ProduceRun_SubInspectTermItem
							 | 
						|||
| 
								 | 
							
								                       join b in Funs.DB.ProduceRun_InspectTailTerm on termitem.TermItemId equals b.TermItemId into t
							 | 
						|||
| 
								 | 
							
								                       from tail in t.DefaultIfEmpty()
							 | 
						|||
| 
								 | 
							
								                       where termitem.ProjectId == this.CurrUser.LoginProjectId
							 | 
						|||
| 
								 | 
							
								                       && termitem.InspectedUser == this.CurrUser.UserId
							 | 
						|||
| 
								 | 
							
								                       group termitem by new { termitem.TermItemId, termitem.SubInspectId, termitem.ProjectId, termitem.WorkInspectId, termitem.WorkInspectName,termitem.InspectedUser, termitem.InspectionResults, termitem.InspectionIllustrate, termitem.Contractor, termitem.Owner, termitem.ProcessPatent, termitem.ContractorIsPass, termitem.OwnerIsPass, termitem.ProcessPatentIsPass, termitem.ContractorRemark, termitem.OwnerRemark, termitem.ProcessPatentRemark, termitem.Remark, termitem.AddUser, termitem.AddTime, termitem.Sort, IsTailTerm = tail.TailTermId == null ? 0 : 1 } into gt
							 | 
						|||
| 
								 | 
							
								                       orderby gt.Key.Sort
							 | 
						|||
| 
								 | 
							
								                       select new TermItemBridDto()
							 | 
						|||
| 
								 | 
							
								                       {
							 | 
						|||
| 
								 | 
							
								                           TermItemId = gt.Key.TermItemId,
							 | 
						|||
| 
								 | 
							
								                           SubInspectId = gt.Key.SubInspectId,
							 | 
						|||
| 
								 | 
							
								                           ProjectId = gt.Key.ProjectId,
							 | 
						|||
| 
								 | 
							
								                           WorkInspectId = gt.Key.WorkInspectId,
							 | 
						|||
| 
								 | 
							
								                           WorkInspectName = gt.Key.WorkInspectName,
							 | 
						|||
| 
								 | 
							
								                           InspectedUser = gt.Key.InspectedUser,
							 | 
						|||
| 
								 | 
							
								                           InspectionResults = gt.Key.InspectionResults,
							 | 
						|||
| 
								 | 
							
								                           InspectionIllustrate = gt.Key.InspectionIllustrate,
							 | 
						|||
| 
								 | 
							
								                           Contractor = gt.Key.Contractor,
							 | 
						|||
| 
								 | 
							
								                           Owner = gt.Key.Owner,
							 | 
						|||
| 
								 | 
							
								                           ProcessPatent = gt.Key.ProcessPatent,
							 | 
						|||
| 
								 | 
							
								                           ContractorIsPass = gt.Key.ContractorIsPass,
							 | 
						|||
| 
								 | 
							
								                           OwnerIsPass = gt.Key.OwnerIsPass,
							 | 
						|||
| 
								 | 
							
								                           ProcessPatentIsPass = gt.Key.ProcessPatentIsPass,
							 | 
						|||
| 
								 | 
							
								                           ContractorRemark = gt.Key.ContractorRemark,
							 | 
						|||
| 
								 | 
							
								                           OwnerRemark = gt.Key.OwnerRemark,
							 | 
						|||
| 
								 | 
							
								                           ProcessPatentRemark = gt.Key.ProcessPatentRemark,
							 | 
						|||
| 
								 | 
							
								                           Remark = gt.Key.Remark,
							 | 
						|||
| 
								 | 
							
								                           AddUser = gt.Key.AddUser,
							 | 
						|||
| 
								 | 
							
								                           AddTime = gt.Key.AddTime,
							 | 
						|||
| 
								 | 
							
								                           Sort = gt.Key.Sort,
							 | 
						|||
| 
								 | 
							
								                           IsTailTerm = gt.Key.IsTailTerm
							 | 
						|||
| 
								 | 
							
								                       };
							 | 
						|||
| 
								 | 
							
								            var list = data.ToList();
							 | 
						|||
| 
								 | 
							
								            if (istail)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                JArray mergedData = Grid1.GetMergedData();
							 | 
						|||
| 
								 | 
							
								                list.ForEach(a =>
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    var itemRow = mergedData.FirstOrDefault(x => x.Value<string>("id") == a.TermItemId);
							 | 
						|||
| 
								 | 
							
								                    JObject values = itemRow.Value<JObject>("values");
							 | 
						|||
| 
								 | 
							
								                    var inspectionResults = !string.IsNullOrWhiteSpace(values.Value<string>("InspectionResults")) ? values.Value<string>("InspectionResults") : string.Empty;
							 | 
						|||
| 
								 | 
							
								                    if (!string.IsNullOrWhiteSpace(inspectionResults))
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        a.InspectionResults = int.Parse(inspectionResults);
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                });
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            Grid1.DataSource = list;
							 | 
						|||
| 
								 | 
							
								            Grid1.DataBind();
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 排序
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        protected void Grid1_Sort(object sender, GridSortEventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            Grid1.SortDirection = e.SortDirection;
							 | 
						|||
| 
								 | 
							
								            Grid1.SortField = e.SortField;
							 | 
						|||
| 
								 | 
							
								            BindGrid();
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        #endregion
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        #region 保存
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 保存
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        protected void btnSave_Click(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            try
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                var subInspectId = this.Grid1.Rows[0].DataKeys[2].ToString();
							 | 
						|||
| 
								 | 
							
								                if (Funs.DB.ProduceRun_SubInspectTermItem.Count(x => x.SubInspectId == subInspectId && (x.ContractorIsPass != null || x.OwnerIsPass != null || x.ProcessPatentIsPass != null)) > 0)
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    ShowNotify("已进入检查表流转,无法修改检查结果!", MessageBoxIcon.Warning);
							 | 
						|||
| 
								 | 
							
								                    return;
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                JArray mergedData = Grid1.GetMergedData();
							 | 
						|||
| 
								 | 
							
								                foreach (JObject mergedRow in mergedData)
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    string status = mergedRow.Value<string>("status");
							 | 
						|||
| 
								 | 
							
								                    JObject values = mergedRow.Value<JObject>("values");
							 | 
						|||
| 
								 | 
							
								                    int i = mergedRow.Value<int>("index");
							 | 
						|||
| 
								 | 
							
								                    var termItemId = this.Grid1.Rows[i].DataKeys[0].ToString();
							 | 
						|||
| 
								 | 
							
								                    if (values.Value<string>("InspectionResults") == "0")
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        if (Funs.DB.ProduceRun_InspectTailTerm.Count(x => x.TermItemId == termItemId) == 0)
							 | 
						|||
| 
								 | 
							
								                        {
							 | 
						|||
| 
								 | 
							
								                            ShowNotify("未通过的检查项请填写尾项!", MessageBoxIcon.Warning);
							 | 
						|||
| 
								 | 
							
								                            return;
							 | 
						|||
| 
								 | 
							
								                        }
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                foreach (JObject mergedRow in mergedData)
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    string status = mergedRow.Value<string>("status");
							 | 
						|||
| 
								 | 
							
								                    JObject values = mergedRow.Value<JObject>("values");
							 | 
						|||
| 
								 | 
							
								                    int i = mergedRow.Value<int>("index");
							 | 
						|||
| 
								 | 
							
								                    var termItemId = this.Grid1.Rows[i].DataKeys[0].ToString();
							 | 
						|||
| 
								 | 
							
								                    //获取子系统信息
							 | 
						|||
| 
								 | 
							
								                    var model = Funs.DB.ProduceRun_SubInspectTermItem.FirstOrDefault(x => x.TermItemId == termItemId);
							 | 
						|||
| 
								 | 
							
								                    if (model != null)
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        model.InspectionIllustrate = !string.IsNullOrWhiteSpace(values.Value<string>("InspectionIllustrate")) ? values.Value<string>("InspectionIllustrate") : string.Empty;
							 | 
						|||
| 
								 | 
							
								                        if (!string.IsNullOrWhiteSpace(values.Value<string>("InspectionResults")))
							 | 
						|||
| 
								 | 
							
								                        {
							 | 
						|||
| 
								 | 
							
								                            model.InspectionResults = int.Parse(values.Value<string>("InspectionResults"));
							 | 
						|||
| 
								 | 
							
								                        }
							 | 
						|||
| 
								 | 
							
								                        Funs.DB.SubmitChanges();
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                var subModel = Funs.DB.ProduceRun_SubInspectTerm.FirstOrDefault(x => x.SubInspectId == subInspectId);
							 | 
						|||
| 
								 | 
							
								                if (subModel != null)
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    if (Funs.DB.ProduceRun_SubInspectTermItem.Count(x => x.SubInspectId == subInspectId && x.InspectionResults.GetValueOrDefault() != 1) == 0)
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        subModel.InspectionIsAllPass = 1;
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                    else
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        subModel.InspectionIsAllPass = 0;
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                Funs.DB.SubmitChanges();
							 | 
						|||
| 
								 | 
							
								                BindGrid();
							 | 
						|||
| 
								 | 
							
								                ShowNotify("保存成功!");
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            catch (Exception ex)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                ShowNotify(ex.Message, MessageBoxIcon.Error);
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        #endregion
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 尾项数据绑定实体
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        public class TermItemBridDto
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            /// <summary>
							 | 
						|||
| 
								 | 
							
								            /// 主键
							 | 
						|||
| 
								 | 
							
								            /// </summary>
							 | 
						|||
| 
								 | 
							
								            public string TermItemId { get; set; }
							 | 
						|||
| 
								 | 
							
								            /// <summary>
							 | 
						|||
| 
								 | 
							
								            /// 检查项主键
							 | 
						|||
| 
								 | 
							
								            /// </summary>
							 | 
						|||
| 
								 | 
							
								            public string SubItemId { get; set; }
							 | 
						|||
| 
								 | 
							
								            /// <summary>
							 | 
						|||
| 
								 | 
							
								            /// 检查表主键
							 | 
						|||
| 
								 | 
							
								            /// </summary>
							 | 
						|||
| 
								 | 
							
								            public string SubInspectId { get; set; }
							 | 
						|||
| 
								 | 
							
								            /// <summary>
							 | 
						|||
| 
								 | 
							
								            /// 工作包主键
							 | 
						|||
| 
								 | 
							
								            /// </summary>
							 | 
						|||
| 
								 | 
							
								            public string WorkPackId { get; set; }
							 | 
						|||
| 
								 | 
							
								            /// <summary>
							 | 
						|||
| 
								 | 
							
								            /// 项目主键
							 | 
						|||
| 
								 | 
							
								            /// </summary>
							 | 
						|||
| 
								 | 
							
								            public string ProjectId { get; set; }
							 | 
						|||
| 
								 | 
							
								            /// <summary>
							 | 
						|||
| 
								 | 
							
								            /// 工作包模板项主键
							 | 
						|||
| 
								 | 
							
								            /// </summary>
							 | 
						|||
| 
								 | 
							
								            public string WorkInspectId { get; set; }
							 | 
						|||
| 
								 | 
							
								            /// <summary>
							 | 
						|||
| 
								 | 
							
								            /// 检查事项名称
							 | 
						|||
| 
								 | 
							
								            /// </summary>
							 | 
						|||
| 
								 | 
							
								            public string WorkInspectName { get; set; }
							 | 
						|||
| 
								 | 
							
								            /// <summary>
							 | 
						|||
| 
								 | 
							
								            /// 检查人主键
							 | 
						|||
| 
								 | 
							
								            /// </summary>
							 | 
						|||
| 
								 | 
							
								            public string InspectedUser { get; set; }
							 | 
						|||
| 
								 | 
							
								            /// <summary>
							 | 
						|||
| 
								 | 
							
								            /// 检查结果0:未通过 1:通过
							 | 
						|||
| 
								 | 
							
								            /// </summary>
							 | 
						|||
| 
								 | 
							
								            public int? InspectionResults { get; set; }
							 | 
						|||
| 
								 | 
							
								            /// <summary>
							 | 
						|||
| 
								 | 
							
								            /// 检查说明
							 | 
						|||
| 
								 | 
							
								            /// </summary>
							 | 
						|||
| 
								 | 
							
								            public string InspectionIllustrate { get; set; }
							 | 
						|||
| 
								 | 
							
								            /// <summary>
							 | 
						|||
| 
								 | 
							
								            /// 承包商
							 | 
						|||
| 
								 | 
							
								            /// </summary>
							 | 
						|||
| 
								 | 
							
								            public string Contractor { get; set; }
							 | 
						|||
| 
								 | 
							
								            /// <summary>
							 | 
						|||
| 
								 | 
							
								            /// 业主
							 | 
						|||
| 
								 | 
							
								            /// </summary>
							 | 
						|||
| 
								 | 
							
								            public string Owner { get; set; }
							 | 
						|||
| 
								 | 
							
								            /// <summary>
							 | 
						|||
| 
								 | 
							
								            /// 工艺专利商
							 | 
						|||
| 
								 | 
							
								            /// </summary>
							 | 
						|||
| 
								 | 
							
								            public string ProcessPatent { get; set; }
							 | 
						|||
| 
								 | 
							
								            /// <summary>
							 | 
						|||
| 
								 | 
							
								            /// 承包商是否通过0/null:未通过 1:通过
							 | 
						|||
| 
								 | 
							
								            /// </summary>
							 | 
						|||
| 
								 | 
							
								            public int? ContractorIsPass { get; set; }
							 | 
						|||
| 
								 | 
							
								            /// <summary>
							 | 
						|||
| 
								 | 
							
								            /// 业主是否通过0/null:未通过 1:通过
							 | 
						|||
| 
								 | 
							
								            /// </summary>
							 | 
						|||
| 
								 | 
							
								            public int? OwnerIsPass { get; set; }
							 | 
						|||
| 
								 | 
							
								            /// <summary>
							 | 
						|||
| 
								 | 
							
								            /// 工艺专利商是否通过0/null:未通过 1:通过
							 | 
						|||
| 
								 | 
							
								            /// </summary>
							 | 
						|||
| 
								 | 
							
								            public int? ProcessPatentIsPass { get; set; }
							 | 
						|||
| 
								 | 
							
								            /// <summary>
							 | 
						|||
| 
								 | 
							
								            /// 承包商备注
							 | 
						|||
| 
								 | 
							
								            /// </summary>
							 | 
						|||
| 
								 | 
							
								            public string ContractorRemark { get; set; }
							 | 
						|||
| 
								 | 
							
								            /// <summary>
							 | 
						|||
| 
								 | 
							
								            /// 业主备注
							 | 
						|||
| 
								 | 
							
								            /// </summary>
							 | 
						|||
| 
								 | 
							
								            public string OwnerRemark { get; set; }
							 | 
						|||
| 
								 | 
							
								            /// <summary>
							 | 
						|||
| 
								 | 
							
								            /// 工艺专利商备注
							 | 
						|||
| 
								 | 
							
								            /// </summary>
							 | 
						|||
| 
								 | 
							
								            public string ProcessPatentRemark { get; set; }
							 | 
						|||
| 
								 | 
							
								            /// <summary>
							 | 
						|||
| 
								 | 
							
								            /// 备注
							 | 
						|||
| 
								 | 
							
								            /// </summary>
							 | 
						|||
| 
								 | 
							
								            public string Remark { get; set; }
							 | 
						|||
| 
								 | 
							
								            /// <summary>
							 | 
						|||
| 
								 | 
							
								            /// 添加人
							 | 
						|||
| 
								 | 
							
								            /// </summary>
							 | 
						|||
| 
								 | 
							
								            public string AddUser { get; set; }
							 | 
						|||
| 
								 | 
							
								            /// <summary>
							 | 
						|||
| 
								 | 
							
								            /// 添加日期
							 | 
						|||
| 
								 | 
							
								            /// </summary>
							 | 
						|||
| 
								 | 
							
								            public DateTime? AddTime { get; set; }
							 | 
						|||
| 
								 | 
							
								            /// <summary>
							 | 
						|||
| 
								 | 
							
								            /// 排序
							 | 
						|||
| 
								 | 
							
								            /// </summary>
							 | 
						|||
| 
								 | 
							
								            public int? Sort { get; set; }
							 | 
						|||
| 
								 | 
							
								            /// <summary>
							 | 
						|||
| 
								 | 
							
								            /// 是否存在尾项0:不存在1:存在
							 | 
						|||
| 
								 | 
							
								            /// </summary>
							 | 
						|||
| 
								 | 
							
								            public int IsTailTerm { get; set; }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 行内按钮事件
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            //尾项申请
							 | 
						|||
| 
								 | 
							
								            if (e.CommandName == "TailTerm")
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                var termItemId = Grid1.DataKeys[e.RowIndex][0].ToString();
							 | 
						|||
| 
								 | 
							
								                var inspectionResults = Grid1.DataKeys[e.RowIndex][1] != null ? int.Parse(Grid1.DataKeys[e.RowIndex][1].ToString()) : -1;
							 | 
						|||
| 
								 | 
							
								                if (inspectionResults == 0)
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("InspectTailTermEdit.aspx?TailTermId={0}&TermItemId={1}", "", termItemId, "新增 - ")));
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                else
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    JArray mergedData = Grid1.GetMergedData();
							 | 
						|||
| 
								 | 
							
								                    var itemRow = mergedData[e.RowIndex].Value<JObject>("values");
							 | 
						|||
| 
								 | 
							
								                    if (itemRow.Value<string>("InspectionResults") == "0")
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("InspectTailTermEdit.aspx?TailTermId={0}&TermItemId={1}", "", termItemId, "新增 - ")));
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                    else
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        ShowNotify("仅未通过检查项才可填写!", MessageBoxIcon.Warning);
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            //尾项修改
							 | 
						|||
| 
								 | 
							
								            if (e.CommandName == "TailTermUpdate")
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                var termItemId = Grid1.DataKeys[e.RowIndex][0].ToString();
							 | 
						|||
| 
								 | 
							
								                var inspectionResults = Grid1.DataKeys[e.RowIndex][1] != null ? int.Parse(Grid1.DataKeys[e.RowIndex][1].ToString()) : -1;
							 | 
						|||
| 
								 | 
							
								                if (inspectionResults == 0)
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    var tails = Funs.DB.ProduceRun_InspectTailTerm.Where(x => x.TermItemId == termItemId).ToList();
							 | 
						|||
| 
								 | 
							
								                    if (tails.Count > 0)
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        if (tails.Count(x => x.ApproveState == 0) == 0)
							 | 
						|||
| 
								 | 
							
								                        {
							 | 
						|||
| 
								 | 
							
								                            ShowNotify("申请的尾项非“待提交处理”状态,无法修改!", MessageBoxIcon.Warning);
							 | 
						|||
| 
								 | 
							
								                            return;
							 | 
						|||
| 
								 | 
							
								                        }
							 | 
						|||
| 
								 | 
							
								                        if (tails.Count(x => x.ApproveState == 0) > 1)
							 | 
						|||
| 
								 | 
							
								                        {
							 | 
						|||
| 
								 | 
							
								                            string window = $"SelectTailTermList.aspx?TermItemId={termItemId}";
							 | 
						|||
| 
								 | 
							
								                            PageContext.RegisterStartupScript(Window2.GetSaveStateReference(this.hidTailTermId.ClientID) + Window2.GetShowReference(window));
							 | 
						|||
| 
								 | 
							
								                        }
							 | 
						|||
| 
								 | 
							
								                        else
							 | 
						|||
| 
								 | 
							
								                        {
							 | 
						|||
| 
								 | 
							
								                            var tailModel = tails.FirstOrDefault();
							 | 
						|||
| 
								 | 
							
								                            PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("InspectTailTermEdit.aspx?TailTermId={0}&TermItemId={1}", tailModel.TailTermId, tailModel.TermItemId, "编辑 - ")));
							 | 
						|||
| 
								 | 
							
								                        }
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                    else
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        ShowNotify("请填写尾项申请!", MessageBoxIcon.Warning);
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                else
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    ShowNotify("请填写尾项申请!", MessageBoxIcon.Warning);
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 窗口关闭
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        protected void Window1_Close(object sender, WindowCloseEventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            BindGrid(true);
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 行绑定
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        protected void Grid1_RowDataBound(object sender, GridRowEventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            var isTailTerm = Grid1.DataKeys[e.RowIndex][3].ToString();
							 | 
						|||
| 
								 | 
							
								            LinkButtonField TailTermUpdate = Grid1.FindColumn("TailTermUpdate") as LinkButtonField;
							 | 
						|||
| 
								 | 
							
								            if (isTailTerm == "0")
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                e.CellCssClasses[TailTermUpdate.ColumnIndex] = "hidethis";
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 尾项选择关闭
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="sender"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="e"></param>
							 | 
						|||
| 
								 | 
							
								        protected void Window2_Close(object sender, WindowCloseEventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            if (!string.IsNullOrWhiteSpace(hidTailTermId.Text))
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                var model = Funs.DB.ProduceRun_InspectTailTerm.FirstOrDefault(x => x.TailTermId == hidTailTermId.Text);
							 | 
						|||
| 
								 | 
							
								                if (model != null)
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("InspectTailTermEdit.aspx?TailTermId={0}&TermItemId={1}", hidTailTermId.Text, model.TermItemId, "编辑 - ")));
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								}
							 |