314 lines
		
	
	
		
			12 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			314 lines
		
	
	
		
			12 KiB
		
	
	
	
		
			C#
		
	
	
	
|  | using BLL; | |||
|  | using System; | |||
|  | using System.Collections.Generic; | |||
|  | using System.Data.SqlClient; | |||
|  | using System.Data; | |||
|  | using System.Linq; | |||
|  | using System.Web; | |||
|  | using System.Web.UI; | |||
|  | using System.Web.UI.WebControls; | |||
|  | 
 | |||
|  | namespace FineUIPro.Web.TestRun.Produce | |||
|  | { | |||
|  |     public partial class InspectTailTermList : PageBase | |||
|  |     { | |||
|  |         protected void Page_Load(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (!IsPostBack) | |||
|  |             { | |||
|  |                 BindGrid(); | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |         #region 绑定数据 | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 数据绑定 | |||
|  |         /// </summary> | |||
|  |         public void BindGrid() | |||
|  |         { | |||
|  |             string strSql = @"select a.TailTermId,a.ProjectId,d.ProjectCode,d.ProjectName,a.TailTermCode,a.ConstructionUnit,b.UnitName,a.SubInspectId,a.TermItemId,c.WorkInspectName,a.QuestionDesc,a.RectifyTime,a.RectifyOpinion,a.InspectUser,e.UserName as InspectUserName,a.ApproveUser,f.UserName as ApproveUserName,a.HandleUser,g.UserName as HandleUserName,a.ApproveState,(case a.ApproveState when 0 then '待提交处理' when 1 then '待处理' when 2 then '处理退回' when 3 then '审核退回' when 4 then '待审核' when 5 then '审核通过' else '' end) as ApproveStateName,a.AddTime,a.AdjustCompleteTime,DATEDIFF(DAY, GETDATE(),a.AdjustCompleteTime) as AdjustDiffDay from ProduceRun_InspectTailTerm as a inner join Base_Unit as b on a.ConstructionUnit=b.UnitId inner join ProduceRun_SubInspectTermItem as c on c.TermItemId=a.TermItemId inner join Base_Project as d on d.ProjectId=a.ProjectId inner join Sys_User as e on e.UserId=a.InspectUser inner join Sys_User as f on f.UserId=a.ApproveUser inner join Sys_User as g on g.UserId=a.HandleUser where 1=1 and a.ProjectId=@projectid and a.InspectUser=@InspectUser"; | |||
|  | 
 | |||
|  |             List<SqlParameter> listStr = new List<SqlParameter>(); | |||
|  |             listStr.Add(new SqlParameter("@projectid", this.CurrUser.LoginProjectId)); | |||
|  |             listStr.Add(new SqlParameter("@InspectUser", this.CurrUser.UserId));             | |||
|  |             //审核状态 | |||
|  |             if (!string.IsNullOrWhiteSpace(ddlApproveState.SelectedValue)) | |||
|  |             { | |||
|  |                 strSql += " and a.ApproveState=@ApproveState"; | |||
|  |                 listStr.Add(new SqlParameter("@ApproveState", ddlApproveState.SelectedValue)); | |||
|  |             } | |||
|  |             //开始时间 | |||
|  |             if (!string.IsNullOrWhiteSpace(txtStartTime.Text)) | |||
|  |             { | |||
|  |                 strSql += $" and a.RectifyTime>='{DateTime.Parse(txtStartTime.Text.Trim()).ToString("yyyy-MM-dd")} 00:00:00'"; | |||
|  |             } | |||
|  |             //结束时间 | |||
|  |             if (!string.IsNullOrWhiteSpace(txtEndTime.Text)) | |||
|  |             { | |||
|  |                 strSql += $" and a.RectifyTime<='{DateTime.Parse(txtEndTime.Text.Trim()).ToString("yyyy-MM-dd")} 23:59:59'"; | |||
|  |             } | |||
|  |             strSql += "  order by a.AddTime asc"; | |||
|  |             SqlParameter[] parameter = listStr.ToArray(); | |||
|  |             DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); | |||
|  |             Grid1.RecordCount = tb.Rows.Count; | |||
|  |             var table = this.GetPagedDataTable(Grid1, tb); | |||
|  |             Grid1.DataSource = table; | |||
|  |             Grid1.DataBind(); | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 分页 | |||
|  |         /// </summary> | |||
|  |         protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) | |||
|  |         { | |||
|  |             Grid1.PageIndex = e.NewPageIndex; | |||
|  |             BindGrid(); | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 双击事件 | |||
|  |         /// </summary> | |||
|  |         protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e) | |||
|  |         { | |||
|  |             btnMenuModify_Click(null, null); | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 分页下拉框 | |||
|  |         /// </summary> | |||
|  |         protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) | |||
|  |         { | |||
|  |             Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); | |||
|  |             BindGrid(); | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 排序 | |||
|  |         /// </summary> | |||
|  |         protected void Grid1_Sort(object sender, GridSortEventArgs e) | |||
|  |         { | |||
|  |             BindGrid(); | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 行数据处理事件 | |||
|  |         /// </summary> | |||
|  |         protected void Grid1_RowDataBound(object sender, GridRowEventArgs e) | |||
|  |         { | |||
|  |             DataRowView row = e.DataItem as DataRowView; | |||
|  | 
 | |||
|  |             // 入学年份 | |||
|  |             int diffDay = Convert.ToInt32(row["AdjustDiffDay"]); | |||
|  |             TemplateField AdjustDiffDay = Grid1.FindColumn("AdjustDiffDay") as TemplateField; | |||
|  |             int approveState = int.Parse(Grid1.DataKeys[e.RowIndex][1].ToString()); | |||
|  |             if (approveState != 5) | |||
|  |             { | |||
|  |                 if (diffDay > 0) | |||
|  |                 { | |||
|  |                     e.CellAttributes[AdjustDiffDay.ColumnIndex]["data-color"] = "color1"; | |||
|  |                 } | |||
|  |                 else if (diffDay == 0) | |||
|  |                 { | |||
|  |                     e.CellAttributes[AdjustDiffDay.ColumnIndex]["data-color"] = "color2"; | |||
|  |                 } | |||
|  |                 else if (diffDay < 0) | |||
|  |                 { | |||
|  |                     e.CellAttributes[AdjustDiffDay.ColumnIndex]["data-color"] = "color3"; | |||
|  |                 } | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 按钮 | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 修改 | |||
|  |         /// </summary> | |||
|  |         protected void btnMenuModify_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (Grid1.SelectedRowIndexArray.Length == 0) | |||
|  |             { | |||
|  |                 Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); | |||
|  |                 return; | |||
|  |             } | |||
|  | 
 | |||
|  |             var passLs = new List<int>() { 0, 2 }; | |||
|  |             var model = Funs.DB.ProduceRun_InspectTailTerm.FirstOrDefault(x => x.TailTermId == Grid1.SelectedRowID); | |||
|  |             if (model != null) | |||
|  |             { | |||
|  |                 if (!passLs.Contains(model.ApproveState.Value)) | |||
|  |                 { | |||
|  |                     Alert.ShowInTop("只可编辑“待提交处理”和“处理退回”的记录!", MessageBoxIcon.Warning); | |||
|  |                     return; | |||
|  |                 } | |||
|  |             } | |||
|  |             PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("InspectTailTermEdit.aspx?TailTermId={0}", Grid1.SelectedRowID, "编辑 - "))); | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 编辑 | |||
|  |         /// </summary> | |||
|  |         protected void btnModify_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             btnMenuModify_Click(null, null); | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 新增 | |||
|  |         /// </summary> | |||
|  |         protected void btnNew_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("InspectTailTermEdit.aspx?TailTermId=", "新增 - "))); | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 查看 | |||
|  |         /// </summary> | |||
|  |         protected void btnMenuView_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (Grid1.SelectedRowIndexArray.Length == 0) | |||
|  |             { | |||
|  |                 Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); | |||
|  |                 return; | |||
|  |             } | |||
|  |             PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("InspectTailTermEdit.aspx?IsView=true&TailTermId={0}", Grid1.SelectedRowID, "查看 - "))); | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 删除 | |||
|  |         /// </summary> | |||
|  |         protected void btnMenuDel_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (Grid1.SelectedRowIndexArray.Length == 0) | |||
|  |             { | |||
|  |                 Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); | |||
|  |                 return; | |||
|  |             } | |||
|  |             var model = Funs.DB.ProduceRun_InspectTailTerm.FirstOrDefault(x => x.TailTermId == Grid1.SelectedRowID); | |||
|  |             if (model != null) | |||
|  |             { | |||
|  |                 if (model.ApproveState != 0) | |||
|  |                 { | |||
|  |                     Alert.ShowInTop("只可删除待提交的记录!", MessageBoxIcon.Warning); | |||
|  |                     return; | |||
|  |                 } | |||
|  | 
 | |||
|  |                 Funs.DB.ProduceRun_InspectTailTerm.DeleteOnSubmit(model); | |||
|  |                 Funs.DB.SubmitChanges(); | |||
|  |                 BindGrid(); | |||
|  |                 Alert.ShowInTop("删除成功!", MessageBoxIcon.Success); | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 查询 | |||
|  |         /// </summary> | |||
|  |         protected void btnQuery_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             BindGrid(); | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 弹框关闭 | |||
|  |         /// </summary> | |||
|  |         protected void Window1_Close(object sender, WindowCloseEventArgs e) | |||
|  |         { | |||
|  |             BindGrid(); | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 提交处理 | |||
|  |         /// </summary> | |||
|  |         protected void btnSubmitReview_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (Grid1.SelectedRowIndexArray.Length == 0) | |||
|  |             { | |||
|  |                 Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); | |||
|  |                 return; | |||
|  |             } | |||
|  |             var passLs = new List<int>() { 0, 2 }; | |||
|  |             var model = Funs.DB.ProduceRun_InspectTailTerm.FirstOrDefault(x => x.TailTermId == Grid1.SelectedRowID); | |||
|  |             if (model != null) | |||
|  |             { | |||
|  |                 //0:待提交处理1:待处理2:处理退回3:审核退回4:待审核5:审核通过 | |||
|  |                 if (!passLs.Contains(model.ApproveState.Value)) | |||
|  |                 { | |||
|  |                     Alert.ShowInTop("只可提交“待提交处理”和“处理退回”的记录!", MessageBoxIcon.Warning); | |||
|  |                     return; | |||
|  |                 } | |||
|  |                 model.ApproveState = 1; | |||
|  |                 Funs.DB.SubmitChanges(); | |||
|  |                 BindGrid(); | |||
|  |                 Alert.ShowInTop("提交成功!", MessageBoxIcon.Success); | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 撤回提交 | |||
|  |         /// </summary> | |||
|  |         protected void btnwithdraw_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (Grid1.SelectedRowIndexArray.Length == 0) | |||
|  |             { | |||
|  |                 Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); | |||
|  |                 return; | |||
|  |             } | |||
|  |             var model = Funs.DB.ProduceRun_InspectTailTerm.FirstOrDefault(x => x.TailTermId == Grid1.SelectedRowID); | |||
|  |             if (model != null) | |||
|  |             { | |||
|  |                 //0:待提交处理1:待处理2:处理退回3:审核退回4:待审核5:审核通过 | |||
|  |                 if (model.ApproveState != 1) | |||
|  |                 { | |||
|  |                     Alert.ShowInTop("只可撤回“待处理”的记录!", MessageBoxIcon.Warning); | |||
|  |                     return; | |||
|  |                 } | |||
|  |                 model.ApproveState = 0; | |||
|  |                 Funs.DB.SubmitChanges(); | |||
|  |                 BindGrid(); | |||
|  |                 Alert.ShowInTop("撤回成功!", MessageBoxIcon.Success); | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 私有方法 | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 是否逾期返回 | |||
|  |         /// </summary> | |||
|  |         /// <returns></returns> | |||
|  |         public string IsOverdue(object diffDayVal, object approveStateVal) | |||
|  |         { | |||
|  |             var result = string.Empty; | |||
|  |             var diffDay = 0; | |||
|  |             var approveState = 0; | |||
|  |             if (diffDayVal != null) diffDay = int.Parse(diffDayVal.ToString()); | |||
|  |             if (approveStateVal != null) approveStateVal = int.Parse(approveStateVal.ToString()); | |||
|  |             if (approveState != 5) | |||
|  |             { | |||
|  |                 if (diffDay > 0) | |||
|  |                 { | |||
|  |                     result = "未逾期"; | |||
|  |                 } | |||
|  |                 else if (diffDay == 0) | |||
|  |                 { | |||
|  |                     result = "即将逾期"; | |||
|  |                 } | |||
|  |                 else if (diffDay < 0) | |||
|  |                 { | |||
|  |                     result = "已逾期"; | |||
|  |                 } | |||
|  |             } | |||
|  |             else | |||
|  |             { | |||
|  |                 result = "整改完毕"; | |||
|  |             } | |||
|  |             return result; | |||
|  |         } | |||
|  | 
 | |||
|  |         #endregion | |||
|  | 
 | |||
|  |     } | |||
|  | } |