SGGL_SGY/SGGL/FineUIPro.Web/common/todolist.aspx.cs

463 lines
19 KiB
C#
Raw Normal View History

2025-02-19 15:58:42 +08:00
using BLL;
using Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Threading.Tasks;
namespace FineUIPro.Web.CQMS.common
{
public partial class todolist : PageBase
{
/// <summary>
/// 项目id
/// </summary>
public string ProjectId
{
get
{
return (string)ViewState["ProjectId"];
}
set
{
ViewState["ProjectId"] = value;
}
}
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
// 表头过滤
//FilterDataRowItem = FilterDataRowItemImplement;
if (!IsPostBack)
{
this.ProjectId = this.CurrUser.LoginProjectId;
//if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.ProjectId)
//{
// this.ProjectId = Request.Params["projectId"];
//}
//权限按钮方法
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
// 绑定表格
BindGrid();
}
}
#endregion
//public System.Web.UI.WebControls.ListItem[] GetHandelStatus()
//{
// var list = Handelstatus();
// System.Web.UI.WebControls.ListItem[] litem = new System.Web.UI.WebControls.ListItem[list.Count];
// for (int i = 0; i < list.Count; i++)
// {
// litem[i]= new System.Web.UI.WebControls.ListItem(list.Keys.ToString(),list.Values.ToString());
// }
// return litem;
//}
/// <summary>
/// 整改状态
/// </summary>
/// <returns></returns>
protected IDictionary<int, string> Handelstatus()
{
Dictionary<int, string> dic = new Dictionary<int, string>();
dic.Add(1, "未确认");
dic.Add(2, "已闭环");
dic.Add(3, "超期未整改");
dic.Add(4, "未整改");
return dic;
}
public Task<List<ToDoItem>> data()
{
Task<List<ToDoItem>> task = new Task<List<ToDoItem>>(() =>
{
return ChecklistData();
});
task.Start();
return task;
}
protected List<ToDoItem> ChecklistData()
{
var getDataList = Funs.DB.Sp_Main_GetToDoItems(this.CurrUser.UserId, CurrUser.LoginProjectId).ToList();
return getDataList.ToList();
}
protected void btnOut_Click(object sender, EventArgs e)
{
Response.ClearContent();
string filename = Funs.GetNewFileName();
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("日常巡检" + filename, System.Text.Encoding.UTF8) + ".xls");
Response.ContentType = "application/excel";
Response.ContentEncoding = System.Text.Encoding.UTF8;
this.Grid1.PageSize = 100000;
this.BindGrid();
Response.Write(GetGridTableHtml(Grid1));
Response.End();
}
protected string ConvertImageUrlByImage(object registrationId)
{
string url = string.Empty;
if (registrationId != null)
{
var registration = BLL.CheckControlService.GetCheckControl(registrationId.ToString());
if (registration != null)
{
url = BLL.UploadAttachmentService.ShowImage("../../", registration.AttachUrl);
}
}
return url;
}
protected string ConvertImgUrlByImage(object registrationId)
{
string url = string.Empty;
if (registrationId != null)
{
var registration = BLL.CheckControlService.GetCheckControl(registrationId.ToString());
if (registration != null)
{
url = BLL.UploadAttachmentService.ShowImage("../../", registration.ReAttachUrl);
}
}
return url;
}
/// <summary>
/// 绑定数据
/// </summary>
public void BindGrid()
{
List<ToDoItem> tb = ChecklistData();
List<ToDoItem> pageData = new List<ToDoItem>();
// 2.获取当前分页数据
//var table = this.GetPagedDataTable(Grid1, tb1);
Grid1.RecordCount = tb.Count;
int pageIndex = Grid1.PageIndex;
int pageSize = Grid1.PageSize;
int rowbegin = pageIndex * pageSize;
int rowend = (pageIndex + 1) * pageSize;
if (rowend > tb.Count)
{
rowend = tb.Count;
}
for (int i = rowbegin; i < rowend; i++)
{
pageData.Add(tb[i]);
}
Grid1.DataSource = pageData;
Grid1.DataBind();
}
#region
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void TextBox_TextChanged(object sender, EventArgs e)
{
this.BindGrid();
}
#endregion
#region
/// <summary>
/// 过滤表头
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_FilterChange(object sender, EventArgs e)
{
BindGrid();
}
/// <summary>
/// 分页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
Grid1.PageIndex = e.NewPageIndex;
BindGrid();
}
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort(object sender, GridSortEventArgs e)
{
//Grid1.SortDirection = e.SortDirection;
//Grid1.SortField = e.SortField;
BindGrid();
}
/// <summary>
/// 分页显示条数下拉框
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
BindGrid();
}
/// <summary>
/// 关闭弹出窗
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
BindGrid();
}
#endregion
#region Grid双击事件
/// <summary>
/// Grid行双击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
{
string codes = Grid1.SelectedRowID.Split(',')[0];
string type= Grid1.SelectedRow.Values[1]+"";
// btnMenuModify_Click(null, null);
switch (type)
{
case "控制点检测":
Window1.Title = "控制点检测";
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../CQMS/ProcessControl/InspectionManagementEdit.aspx?InspectionId={0}", Grid1.SelectedRowID, "编辑 - ")));
break;
case "控制点通知单":
Window1.Title = "控制点通知单";
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../CQMS/ProcessControl/InspectionNoticeEdit.aspx?InspectionId={0}", Grid1.SelectedRowID, "编辑 - ")));
break;
case "机具报验":
Window1.Title = "机具报验";
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../CQMS/Comprehensive/InspectionMachineEdit.aspx?InspectionMachineId={0}", Grid1.SelectedRowID, "编辑 - ")));
break;
case "人员报验":
Window1.Title = "人员报验";
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../CQMS/Comprehensive/InspectionPersonEdit.aspx?InspectionPersonId={0}", Grid1.SelectedRowID, "编辑 - ")));
break;
case "设备材料报验":
Window1.Title = "设备材料报验";
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../CQMS/Comprehensive/InspectionEquipmentEdit.aspx?InspectionEquipmentId={0}", Grid1.SelectedRowID, "编辑 - ")));
break;
case "设计变更单":
Window1.Title = "设计变更单";
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../CQMS/Comprehensive/DesignChangeOrderEdit.aspx?DesignChangeOrderId={0}", Grid1.SelectedRowID, "编辑 - ")));
break;
case "质量巡检":
Window1.Title = "质量巡检";
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../CQMS/Check/CheckListEdit.aspx?CheckControlCode={0}", codes, "编辑 - ")));
break;
case "施工方案":
Window1.Title = "施工方案";
Model.Solution_CQMSConstructSolution constructSolution = CQMSConstructSolutionService.GetConstructSolutionByConstructSolutionId(codes);
if (constructSolution.State == Const.CQMSConstructSolution_Complete)
{
Alert.ShowInTop("该方案已经审批完成,无法操作,请右键查看!", MessageBoxIcon.Warning);
return;
}
else if (constructSolution.State == Const.CQMSConstructSolution_Compile)
{
if (constructSolution.CompileMan == CurrUser.UserId || CurrUser.UserId == Const.sysglyId)
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../CQMS/Solution/EditConstructSolution.aspx?constructSolutionId={0}", codes)));
}
else
{
Alert.ShowInTop("您不是编制人,无法操作!请右键查看", MessageBoxIcon.Warning);
return;
}
}
else if (constructSolution.State == Const.CQMSConstructSolution_Audit || constructSolution.State == Const.CQMSConstructSolution_ReCompile)
{
Model.Solution_CQMSConstructSolutionApprove approve = CQMSConstructSolutionApproveService.GetConstructSolutionApproveByApproveMan(codes, CurrUser.UserId);
if (approve != null || CurrUser.UserId == Const.sysglyId)
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../CQMS/Solution/EditConstructSolution.aspx?constructSolutionId={0}", codes)));
return;
//Response.Redirect("CQMSConstructSolutionAudit.aspx?constructSolutionId=" + id);
//PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("CheckListView.aspx?CheckControlCode={0}", id, "查看 - ")));
}
else
{
if (constructSolution.CompileMan.Equals(CurrUser.UserId))
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../CQMS/Solution/EditConstructSolution.aspx?constructSolutionId={0}", codes)));
}
else
{
Alert.ShowInTop("您不是办理用户,无法操作!请右键查看", MessageBoxIcon.Warning);
return;
}
}
}
break;
case "安全巡检":
Window1.Title = "安全巡检";
var registration = BLL.HSSE_Hazard_HazardRegisterService.GetHazardRegisterByHazardRegisterId(codes);
if (registration != null)
{
if (registration.States == "1") //待整改
{
if (registration.ResponsibleMan == this.CurrUser.UserId) //当前人是责任人,可以进行整改操作
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../HSSE/HiddenInspection/HiddenRectificationRectify.aspx?HazardRegisterId={0}", codes, "编辑 - ")));
}
else if (registration.CCManIds.Contains(this.CurrUser.UserId)) //当前人是责任人,可以进行整改操作
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../HSSE/HiddenInspection/HiddenRectificationView.aspx?HazardRegisterId={0}", codes, "查看 - ")));
}
else
{
Alert.ShowInTop("您不是记录责任人,无法整改!", MessageBoxIcon.Warning);
return;
}
}
if (registration.States == Const.State_2) //待确认
{
if (registration.CheckManId == this.CurrUser.UserId) //当前人是检查人,可以进行确认操作
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("HiddenRectificationConfirm.aspx?HazardRegisterId={0}", codes, "编辑 - ")));
}
else
{
Alert.ShowInTop("您不是记录检查人,无法确认!", MessageBoxIcon.Warning);
return;
}
}
}
break;
case "隐患整改":
Window1.Title = "隐患整改";
string url = "../HSSE/Check/RectifyNoticesView.aspx?RectifyNoticesId={0}";
var RectifyNotices = RectifyNoticesService.GetRectifyNoticesById(Grid1.SelectedRowID);
if (RectifyNotices.States == "0" && this.CurrUser.UserId == RectifyNotices.CompleteManId)
{
url = "../HSSE/Check/RectifyNoticesAdd.aspx?RectifyNoticesId={0}";
}
else if (RectifyNotices.States == "1" && this.CurrUser.UserId == RectifyNotices.SignPerson)
{
url = "../HSSE/Check/RectifyNoticesAudit.aspx?RectifyNoticesId={0}";
}
else if (RectifyNotices.States == "2" && this.CurrUser.UserId == RectifyNotices.DutyPersonId)
{
url = "../HSSE/Check/RectifyNoticesRectify.aspx?RectifyNoticesId={0}";
}
else if (RectifyNotices.States == "3" && this.CurrUser.UserId == RectifyNotices.UnitHeadManId)
{
url = "../HSSE/Check/RectifyNoticesAudit.aspx?RectifyNoticesId={0}";
}
else if (RectifyNotices.States == "4" && (this.CurrUser.UserId == RectifyNotices.CompleteManId || this.CurrUser.UserId == RectifyNotices.SignPerson))
{
url = "../HSSE/Check/RectifyNoticesRecheck.aspx?RectifyNoticesId={0}";
}
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format(url, codes, "操作 - ")));
break;
case "现场人员":
Window1.Title = "现场人员";
break;
}
}
#endregion
protected void Grid1_RowDataBound(object sender, GridRowEventArgs e)
{
//if (checkControl.State.Equals("5") || checkControl.State.Equals("6"))
//{
// Grid1.Rows[i].RowCssClass = "lightgreen";//未确认
//}
//else if (checkControl.State == Const.CheckControl_Complete)
//{ //闭环
// Grid1.Rows[i].RowCssClass = "green";
//}
////else if( checkControl.LimitDate> )
//else if (Convert.ToDateTime(checkControl.LimitDate).AddDays(1).Date < DateTime.Now && checkControl.State != BLL.Const.CheckControl_Complete) //延期未整改
//{
// Grid1.Rows[i].RowCssClass = "orange";
//}
//else //期内未整改
//{
// Grid1.Rows[i].RowCssClass = "red";
//}
}
protected void btnMenuView_Click(object sender, EventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
return;
}
string codes = Grid1.SelectedRowID.Split(',')[0];
var checks = BLL.CheckControlService.GetCheckControl(codes);
if (checks != null)
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("CheckListView.aspx?CheckControlCode={0}", codes, "查看 - ")));
}
}
protected void btnQuery_Click(object sender, EventArgs e)
{
BindGrid();
}
}
}