299 lines
13 KiB
C#
299 lines
13 KiB
C#
using BLL;
|
|
using Model;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.TestRun.BeforeTestRun
|
|
{
|
|
public partial class FourDecisionProposerHandle : PageBase
|
|
{
|
|
/// <summary>
|
|
/// 子系统主键
|
|
/// </summary>
|
|
public string SsubSystemId
|
|
{
|
|
get { return (string)ViewState["SsubSystemId"]; }
|
|
set { ViewState["SsubSystemId"] = value; }
|
|
}
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
//加载树
|
|
this.InitTreeMenu();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载树
|
|
/// </summary>
|
|
private void InitTreeMenu()
|
|
{
|
|
this.tvControlItem.Nodes.Clear();
|
|
TreeNode rootNode = new TreeNode();
|
|
rootNode.Text = "提出人处理";
|
|
rootNode.NodeID = "0";
|
|
rootNode.Expanded = true;
|
|
rootNode.ToolTip = "";
|
|
rootNode.EnableClickEvent = true;
|
|
this.tvControlItem.Nodes.Add(rootNode);
|
|
var decisions = Funs.DB.PreRun_SubThreeChecksFourDecision.Where(x => x.ProposeUser == this.CurrUser.UserId && x.ProjectId == this.CurrUser.LoginProjectId).ToList();
|
|
if (decisions.Count == 0) return;
|
|
//获取子系统主键
|
|
var subsystemids = decisions.ConvertAll(x => x.SubSystemId);
|
|
//根据子系统获取其他节点ID
|
|
var userDevices = Funs.DB.PreRun_SysDevice.Where(p => p.ProjectId == this.CurrUser.LoginProjectId && subsystemids.Contains(p.PreRunId)).ToList();
|
|
List<string> allIds = new List<string>();
|
|
allIds.AddRange(userDevices.ConvertAll(x => x.ProcessesId));
|
|
allIds.AddRange(userDevices.ConvertAll(x => x.SystemId));
|
|
allIds.AddRange(subsystemids);
|
|
var allPreRunLs = Funs.DB.PreRun_SysDevice.Where(p => p.ProjectId == this.CurrUser.LoginProjectId && p.PreRunLevel > 1 && allIds.Contains(p.PreRunId)).ToList();
|
|
var onePreRunLs = allPreRunLs.Where(p => p.PreRunLevel == 2).OrderBy(x => x.Sort);
|
|
foreach (var item in onePreRunLs)
|
|
{
|
|
TreeNode rootUnitNode = new TreeNode();//定义根节点
|
|
rootUnitNode.NodeID = item.PreRunId;
|
|
rootUnitNode.Text = item.PreRunName;
|
|
rootUnitNode.ToolTip = item.PreRunName;
|
|
rootUnitNode.CommandName = "";
|
|
rootUnitNode.EnableClickEvent = false;
|
|
rootUnitNode.EnableExpandEvent = false;
|
|
rootNode.Nodes.Add(rootUnitNode);
|
|
rootUnitNode.Expanded = true;
|
|
var otherPreRunls = allPreRunLs.Where(p => p.PreRunLevel != 1).ToList();
|
|
this.BindNodes(rootUnitNode, otherPreRunls, item.PreRunId);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定树节点
|
|
/// </summary>
|
|
private void BindNodes(TreeNode node, List<PreRun_SysDevice> list, string parentId)
|
|
{
|
|
var itemList = list.Where(p => p.ParentId == parentId).OrderBy(x => x.Sort).ToList();
|
|
if (itemList.Count > 0)
|
|
{
|
|
foreach (var item in itemList)
|
|
{
|
|
TreeNode newNode = new TreeNode();
|
|
newNode.Text = item.PreRunName;
|
|
newNode.NodeID = item.PreRunId;
|
|
newNode.ToolTip = item.PreRunName;
|
|
newNode.CommandName = "";
|
|
newNode.EnableClickEvent = item.PreRunLevel == 4 ? true : false;
|
|
newNode.EnableExpandEvent = item.PreRunLevel == 4 ? true : false;
|
|
newNode.Expanded = true;
|
|
node.Nodes.Add(newNode);
|
|
BindNodes(newNode, list, item.PreRunId);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 点击TreeView
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
|
|
{
|
|
this.SsubSystemId = tvControlItem.SelectedNodeID;
|
|
BindGrid();
|
|
}
|
|
|
|
#region 绑定数据
|
|
|
|
/// <summary>
|
|
/// 数据绑定
|
|
/// </summary>
|
|
public void BindGrid()
|
|
{
|
|
string strSql = @"select a.DecisionId,a.ProjectId,a.SubSystemId,a.ProposeUser,puser.UserName as ProposeUserName,a.ResponsibilityUser,ruser.UserName as ResponsibilityUserName,a.ResponsibilityUnit,unit.UnitName as ResponsibilityUnitName,a.QuestionDesc,a.Level,a.Speciality,a.AskDestructionTime,a.RealityDestructionTime,a.RestrictCondition,a.ResponsibilityProposeSatate,(case a.ResponsibilityProposeSatate when 0 then '待提交' when 1 then '提出人待处理' when 2 then '提出人处理退回' when 3 then '责任人待确认' when 4 then '责任人退回' when 5 then '责任人通过提出人待处理' when 6 then '提出人退回' when 7 then '提出人确认通过' else '' end) as ResponsibilityProposeSatateName,a.ProposeConfirm,(case a.ProposeConfirm when 1 then '未确认' when 2 then '确认通过' else '' end) as ProposeConfirmName,a.ResponsibilityConfirm,(case a.ResponsibilityConfirm when 1 then '未确认' when 2 then '确认通过' else '' end) as ResponsibilityConfirmName,a.ProposeConfirm,(case a.ProposeConfirm when 1 then '未确认' when 2 then '确认通过' else '' end) as ProposeConfirmName,a.GeneraConfirm,(case a.GeneraConfirm when 1 then '未确认' when 2 then '确认通过' else '' end) as GeneraConfirmName,a.SupervisionConfirm,(case a.SupervisionConfirm when 1 then '未确认' when 2 then '确认通过' else '' end) as SupervisionConfirmName,a.OwnerConfirm,(case a.OwnerConfirm when 1 then '未确认' when 2 then '确认通过' else '' end) as OwnerConfirmName,a.ProposeConfirmData,a.ResponsibilityConfirmData,a.GeneraConfirmData,a.SupervisionConfirmData,a.OwnerConfirmData,a.DecisionIsClose,(case a.DecisionIsClose when 1 then '已关闭' else '未关闭' end) as DecisionIsCloseName,(case ISNULL(a.AskDestructionTime,'') when '' then 0 else DATEDIFF(DAY, GETDATE(),a.AskDestructionTime) end) as DestructionDiffDay,a.AddUser,a.AddTime,a.Sort from PreRun_SubThreeChecksFourDecision as a left join Sys_User as puser on a.ProposeUser=puser.UserId left join Sys_User as ruser on a.ResponsibilityUser=ruser.UserId left join Base_Unit as unit on a.ResponsibilityUnit=unit.UnitId where 1=1 and a.SubSystemId=@SubSystemId and a.ProjectId=@ProjectId and a.ProposeUser=@ProposeUser and a.ResponsibilityProposeSatate in (1,2,4) ";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
|
listStr.Add(new SqlParameter("@SubSystemId", this.SsubSystemId));
|
|
listStr.Add(new SqlParameter("@ProposeUser", this.CurrUser.UserId));
|
|
//提出人处理状态
|
|
if (!string.IsNullOrWhiteSpace(ddlResponsibilityProposeSatate.SelectedValue))
|
|
{
|
|
strSql += " and a.ResponsibilityProposeSatate=@ResponsibilityProposeSatate";
|
|
listStr.Add(new SqlParameter("@ResponsibilityProposeSatate", ddlResponsibilityProposeSatate.SelectedValue));
|
|
}
|
|
//是否关闭
|
|
if (!string.IsNullOrWhiteSpace(ddlDecisionState.Text))
|
|
{
|
|
strSql += " and a.DecisionState=@DecisionState";
|
|
listStr.Add(new SqlParameter("@DecisionState", ddlDecisionState.SelectedValue));
|
|
}
|
|
strSql += " order by a.AddTime desc";
|
|
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)
|
|
{
|
|
btnSubmitConfirm_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["DestructionDiffDay"]);
|
|
TemplateField AdjustDiffDay = Grid1.FindColumn("DestructionDiffDay") as TemplateField;
|
|
int isClose = int.Parse(Grid1.DataKeys[e.RowIndex][1].ToString());
|
|
if (isClose != 1)
|
|
{
|
|
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
|
|
|
|
/// <summary>
|
|
/// 提出人处理
|
|
/// </summary>
|
|
protected void btnSubmitConfirm_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
var model = Funs.DB.PreRun_SubThreeChecksFourDecision.FirstOrDefault(x => x.DecisionId == Grid1.SelectedRowID);
|
|
if (model != null)
|
|
{
|
|
int[] arr = { 1, 4 };
|
|
if (!arr.Contains(model.ResponsibilityProposeSatate.Value))
|
|
{
|
|
Alert.ShowInTop("仅“提出人待处理”和“责任人退回”才可以进行处理操作!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("FourDecisionProposerHandleEdit.aspx?DecisionId={0}", Grid1.SelectedRowID, "提出人处理 - ")));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 搜索
|
|
/// </summary>
|
|
protected void btnQuery_Click(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查看
|
|
/// </summary>
|
|
protected void btnView_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("FourDecisionProposerHandleEdit.aspx?DecisionId={0}&IsView=true", Grid1.SelectedRowID, "查看 - ")));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 是否逾期返回
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public string IsOverdue(object diffDayVal, object stateVal)
|
|
{
|
|
var result = string.Empty;
|
|
var diffDay = 0;
|
|
var itemState = 0;
|
|
if (diffDayVal != null) diffDay = int.Parse(diffDayVal.ToString());
|
|
if (stateVal != null) itemState = int.Parse(stateVal.ToString());
|
|
if (itemState != 1)
|
|
{
|
|
if (diffDay > 0)
|
|
{
|
|
result = "未逾期";
|
|
}
|
|
else if (diffDay == 0)
|
|
{
|
|
result = "即将逾期";
|
|
}
|
|
else if (diffDay < 0)
|
|
{
|
|
result = "已逾期";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
result = "已关闭";
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 右击确认
|
|
/// </summary>
|
|
protected void btnMenuConfirm_Click(object sender, EventArgs e)
|
|
{
|
|
btnSubmitConfirm_Click(null, null);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 关闭
|
|
/// </summary>
|
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
|
|
}
|
|
}
|
|
} |