2023-12-20 15:48:05 +08:00
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 SubThreeChecksFourDecisionEdit : PageBase
{
/// <summary>
/// 主键
/// </summary>
public string DecisionId
{
get { return ( string ) ViewState [ "DecisionId" ] ; }
set { ViewState [ "DecisionId" ] = value ; }
}
/// <summary>
/// 是否查看
/// </summary>
public bool IsView
{
get { return ( bool ) ViewState [ "IsView" ] ; }
set { ViewState [ "IsView" ] = value ; }
}
/// <summary>
/// 问题图片是否可编辑
/// </summary>
public int QuestionEditImg
{
get { return ( int ) ViewState [ "QuestionEditImg" ] ; }
set { ViewState [ "QuestionEditImg" ] = value ; }
}
protected void Page_Load ( object sender , EventArgs e )
{
if ( ! IsPostBack )
{
this . DecisionId = Request [ "DecisionId" ] ;
//是否查看
this . IsView = string . IsNullOrWhiteSpace ( Request [ "IsView" ] ) ? false : bool . Parse ( Request [ "IsView" ] ) ;
//数据绑定
PageInit ( ) ;
//确认情况绑定
gvDataBrid ( ) ;
//判断是否查看
if ( IsView )
{
btnSave . Hidden = true ;
btnSubmit . Hidden = true ;
QuestionEditImg = - 1 ;
ddlResponsibilityUnit . Enabled = false ;
txtQuestionDesc . Enabled = false ;
txtRestrictCondition . Enabled = false ;
txtLevel . Enabled = false ;
txtSpeciality . Enabled = false ;
txtAskDestructionTime . Enabled = false ;
lblRealityDestructionTime . Enabled = false ;
ddlResponsibilityUser . Enabled = false ;
ddlProposeUser . Enabled = false ;
ddlGeneraUser . Enabled = false ;
ddlSupervisionUser . Enabled = false ;
ddlOwnerUser . Enabled = false ;
lblDecisionIsClose . Enabled = false ;
}
}
}
/// <summary>
/// 默认绑定
/// </summary>
public void PageInit ( )
{
QuestionEditImg = 0 ;
//施工单位
2023-12-25 14:19:31 +08:00
UnitService . InitUnitByProjectIdUnitTypeDropDownList ( ddlResponsibilityUnit , this . CurrUser . LoginProjectId , BLL . Const . ProjectUnitType_2 , false ) ;
2023-12-20 15:48:05 +08:00
//获取人员信息
var userList = from user in Funs . DB . Sys_User
join projectrole in Funs . DB . Project_ProjectUser on user . UserId equals projectrole . UserId
where projectrole . ProjectId = = this . CurrUser . LoginProjectId
select user ;
var userids = new List < string > ( ) { Const . sysglyId , Const . hfnbdId , Const . sedinId } ;
var addUserList = Funs . DB . Sys_User . Where ( x = > userids . Contains ( x . UserId ) ) ;
var users = userList . ToList ( ) ;
if ( addUserList . Count ( ) > 0 )
{
users . AddRange ( addUserList ) ;
}
//人员下拉框绑定
if ( users . Count ( ) > 0 )
{
//责任人
ddlResponsibilityUser . DataTextField = "UserName" ;
ddlResponsibilityUser . DataValueField = "UserId" ;
ddlResponsibilityUser . DataSource = users ;
ddlResponsibilityUser . DataBind ( ) ;
ddlResponsibilityUser . SelectedValue = this . CurrUser . UserId ;
//提出人
ddlProposeUser . DataTextField = "UserName" ;
ddlProposeUser . DataValueField = "UserId" ;
ddlProposeUser . DataSource = users ;
ddlProposeUser . DataBind ( ) ;
ddlProposeUser . SelectedValue = this . CurrUser . UserId ;
//总包
ddlGeneraUser . DataTextField = "UserName" ;
ddlGeneraUser . DataValueField = "UserId" ;
ddlGeneraUser . DataSource = users ;
ddlGeneraUser . DataBind ( ) ;
//监理
ddlSupervisionUser . DataTextField = "UserName" ;
ddlSupervisionUser . DataValueField = "UserId" ;
ddlSupervisionUser . DataSource = users ;
ddlSupervisionUser . DataBind ( ) ;
//业主
ddlOwnerUser . DataTextField = "UserName" ;
ddlOwnerUser . DataValueField = "UserId" ;
ddlOwnerUser . DataSource = users ;
ddlOwnerUser . DataBind ( ) ;
}
var query = from a in Funs . DB . PreRun_SubThreeChecksFourDecision
join b in Funs . DB . Base_Project on a . ProjectId equals b . ProjectId
where a . DecisionId = = this . DecisionId
select new { a , b } ;
var model = query . FirstOrDefault ( ) ;
if ( model ! = null )
{
lblProjectName . Text = model . b . ProjectName ;
ddlResponsibilityUnit . SelectedValue = model . a . ResponsibilityUnit ;
txtQuestionDesc . Text = model . a . QuestionDesc ;
txtRestrictCondition . Text = model . a . RestrictCondition ;
txtLevel . Text = model . a . Level ;
txtSpeciality . Text = model . a . Speciality ;
txtAskDestructionTime . Text = model . a . AskDestructionTime ! = null ? model . a . AskDestructionTime . Value . ToString ( "yyyy-MM-dd" ) : string . Empty ;
lblRealityDestructionTime . Text = model . a . RealityDestructionTime ! = null ? model . a . RealityDestructionTime . Value . ToString ( "yyyy-MM-dd" ) : string . Empty ;
ddlResponsibilityUser . SelectedValue = model . a . ResponsibilityUser ;
ddlProposeUser . SelectedValue = model . a . ProposeUser ;
ddlGeneraUser . SelectedValue = model . a . GeneraUser ;
ddlSupervisionUser . SelectedValue = model . a . SupervisionUser ;
ddlOwnerUser . SelectedValue = model . a . OwnerUser ;
lblDecisionIsClose . Text = model . a . DecisionIsClose = = 1 ? "已关闭" : "未关闭" ;
}
}
/// <summary>
/// 确认情况绑定
/// </summary>
public void gvDataBrid ( )
{
2023-12-25 14:19:31 +08:00
string strSql = @"select a.ConfirmId,a.ProjectId,a.DecisionId,a.ConfirmDesc,a.ConfirmTime,a.ConfirmUser,b.UserName as ConfirmUserName,a.ConfirmType,(case a.ConfirmType when 1 then '提出人处理' when 2 then '责任人确认' when 3 then '提出人确认' when 4 then '总包确认' when 5 then '监理确认' when 6 then '业主确认' else '' end) as ConfirmTypeName,a.ConfirmState,(case a.ConfirmState when 1 then '确认通过' when 2 then '确认退回' else '' end) as ConfirmStateName,a.AddUser,a.AddTime from PreRun_DecisionConfirmRecords as a left join Sys_User as b on a.ConfirmUser=b.UserId where a.ProjectId=@ProjectId and a.DecisionId=@DecisionId " ;
2023-12-20 15:48:05 +08:00
List < SqlParameter > listStr = new List < SqlParameter > ( ) ;
listStr . Add ( new SqlParameter ( "@ProjectId" , this . CurrUser . LoginProjectId ) ) ;
listStr . Add ( new SqlParameter ( "@DecisionId" , this . DecisionId ) ) ;
strSql + = " order by a.AddTime asc" ;
SqlParameter [ ] parameter = listStr . ToArray ( ) ;
DataTable tb = SQLHelper . GetDataTableRunText ( strSql , parameter ) ;
2023-12-25 14:19:31 +08:00
//提出人处理
var tcrclTb = tb . AsEnumerable ( ) . Where ( row = > row . Field < int > ( "ConfirmType" ) = = 1 ) ;
gvTcrcl . DataSource = tcrclTb ;
gvTcrcl . DataBind ( ) ;
//提出人确认
var tcrqrTb = tb . AsEnumerable ( ) . Where ( row = > row . Field < int > ( "ConfirmType" ) = = 3 ) ;
gvTcrqr . DataSource = tcrqrTb ;
gvTcrqr . DataBind ( ) ;
2023-12-20 15:48:05 +08:00
//责任人确认
2023-12-25 14:19:31 +08:00
var zrrqrTb = tb . AsEnumerable ( ) . Where ( row = > row . Field < int > ( "ConfirmType" ) = = 2 ) ;
gvZrrConfirm . DataSource = zrrqrTb ;
2023-12-20 15:48:05 +08:00
gvZrrConfirm . DataBind ( ) ;
//其他人员确认
2023-12-25 14:19:31 +08:00
int [ ] type = { 4 , 5 , 6 } ;
var approveTb = tb . AsEnumerable ( ) . Where ( row = > type . Contains ( row . Field < int > ( "ConfirmType" ) ) ) ;
2023-12-20 15:48:05 +08:00
gvOtherConfirm . DataSource = approveTb ;
gvOtherConfirm . DataBind ( ) ;
}
/// <summary>
2023-12-25 14:19:31 +08:00
/// 问题图片查看
2023-12-20 15:48:05 +08:00
/// </summary>
2023-12-25 14:19:31 +08:00
protected void imgBtnQuestionFile_Click ( object sender , EventArgs e )
2023-12-20 15:48:05 +08:00
{
2023-12-25 14:19:31 +08:00
PageContext . RegisterStartupScript ( WindowAtt . GetShowReference ( String . Format ( "../../AttachFile/webuploader.aspx?type=-1&toKeyId={0}&path=FileUpload/CheckControl&menuId={1}" , this . DecisionId + "q" , Const . InspectTailTerm ) ) ) ;
2023-12-20 15:48:05 +08:00
}
2023-12-25 14:19:31 +08:00
/// <summary>
/// 整改图片查看
/// </summary>
protected void imgBtnRectifyFile_Click ( object sender , EventArgs e )
{
PageContext . RegisterStartupScript ( WindowAtt . GetShowReference ( String . Format ( "../../AttachFile/webuploader.aspx?type=-1&toKeyId={0}&path=FileUpload/CheckControl&menuId={1}" , this . DecisionId + "h" , Const . InspectTailTerm ) ) ) ;
}
2023-12-20 15:48:05 +08:00
/// <summary>
/// 保存
/// </summary>
protected void btnSave_Click ( object sender , EventArgs e )
{
if ( string . IsNullOrWhiteSpace ( ddlResponsibilityUnit . SelectedValue ) )
{
ShowNotify ( "请选择责任单位!" , MessageBoxIcon . Warning ) ;
return ;
}
if ( string . IsNullOrWhiteSpace ( ddlResponsibilityUser . SelectedValue ) )
{
ShowNotify ( "请选择责任人!" , MessageBoxIcon . Warning ) ;
return ;
}
if ( string . IsNullOrWhiteSpace ( ddlProposeUser . SelectedValue ) )
{
ShowNotify ( "请选择提出人!" , MessageBoxIcon . Warning ) ;
return ;
}
if ( string . IsNullOrWhiteSpace ( ddlGeneraUser . SelectedValue ) )
{
ShowNotify ( "请选择总包!" , MessageBoxIcon . Warning ) ;
return ;
}
if ( string . IsNullOrWhiteSpace ( ddlSupervisionUser . SelectedValue ) )
{
ShowNotify ( "请选择监理!" , MessageBoxIcon . Warning ) ;
return ;
}
if ( string . IsNullOrWhiteSpace ( ddlOwnerUser . SelectedValue ) )
{
ShowNotify ( "请选择业主!" , MessageBoxIcon . Warning ) ;
return ;
}
var isAdd = false ;
var model = Funs . DB . PreRun_SubThreeChecksFourDecision . FirstOrDefault ( x = > x . DecisionId = = this . DecisionId ) ;
if ( model = = null )
{
isAdd = true ;
model = new PreRun_SubThreeChecksFourDecision ( ) ;
model . DecisionId = this . DecisionId = Guid . NewGuid ( ) . ToString ( ) ;
model . ProjectId = this . CurrUser . LoginProjectId ;
}
model . ResponsibilityUser = ddlResponsibilityUser . SelectedValue ;
model . ProposeUser = ddlProposeUser . SelectedValue ;
model . GeneraUser = ddlGeneraUser . SelectedValue ;
model . SupervisionUser = ddlSupervisionUser . SelectedValue ;
model . OwnerUser = ddlOwnerUser . SelectedValue ;
model . ResponsibilityUnit = ddlResponsibilityUnit . SelectedValue ;
model . QuestionDesc = txtQuestionDesc . Text ;
model . Level = txtLevel . Text ;
model . Speciality = txtSpeciality . Text ;
model . AskDestructionTime = DateTime . Parse ( txtAskDestructionTime . Text ) ;
model . RestrictCondition = txtRestrictCondition . Text ;
model . AddUser = this . CurrUser . LoginProjectId ;
model . AddTime = DateTime . Now ;
2023-12-25 14:19:31 +08:00
model . ResponsibilityProposeSatate = 0 ;
2023-12-20 15:48:05 +08:00
if ( isAdd )
{
Funs . DB . PreRun_SubThreeChecksFourDecision . InsertOnSubmit ( model ) ;
}
Funs . DB . SubmitChanges ( ) ;
ShowNotify ( "操作成功!" , MessageBoxIcon . Success ) ;
PageContext . RegisterStartupScript ( ActiveWindow . GetHidePostBackReference ( ) ) ;
}
/// <summary>
2023-12-25 14:19:31 +08:00
/// 保存并提交提出人处理
2023-12-20 15:48:05 +08:00
/// </summary>
protected void btnSubmit_Click ( object sender , EventArgs e )
{
if ( string . IsNullOrWhiteSpace ( ddlResponsibilityUnit . SelectedValue ) )
{
ShowNotify ( "请选择责任单位!" , MessageBoxIcon . Warning ) ;
return ;
}
if ( string . IsNullOrWhiteSpace ( ddlResponsibilityUser . SelectedValue ) )
{
ShowNotify ( "请选择责任人!" , MessageBoxIcon . Warning ) ;
return ;
}
if ( string . IsNullOrWhiteSpace ( ddlProposeUser . SelectedValue ) )
{
ShowNotify ( "请选择提出人!" , MessageBoxIcon . Warning ) ;
return ;
}
if ( string . IsNullOrWhiteSpace ( ddlGeneraUser . SelectedValue ) )
{
ShowNotify ( "请选择总包!" , MessageBoxIcon . Warning ) ;
return ;
}
if ( string . IsNullOrWhiteSpace ( ddlSupervisionUser . SelectedValue ) )
{
ShowNotify ( "请选择监理!" , MessageBoxIcon . Warning ) ;
return ;
}
if ( string . IsNullOrWhiteSpace ( ddlOwnerUser . SelectedValue ) )
{
ShowNotify ( "请选择业主!" , MessageBoxIcon . Warning ) ;
return ;
}
var isAdd = false ;
var model = Funs . DB . PreRun_SubThreeChecksFourDecision . FirstOrDefault ( x = > x . DecisionId = = this . DecisionId ) ;
if ( model = = null )
{
isAdd = true ;
model = new PreRun_SubThreeChecksFourDecision ( ) ;
model . DecisionId = this . DecisionId = Guid . NewGuid ( ) . ToString ( ) ;
model . ProjectId = this . CurrUser . LoginProjectId ;
}
model . ResponsibilityUser = ddlResponsibilityUser . SelectedValue ;
model . ProposeUser = ddlProposeUser . SelectedValue ;
model . GeneraUser = ddlGeneraUser . SelectedValue ;
model . SupervisionUser = ddlSupervisionUser . SelectedValue ;
model . OwnerUser = ddlOwnerUser . SelectedValue ;
model . ResponsibilityUnit = ddlResponsibilityUnit . SelectedValue ;
model . QuestionDesc = txtQuestionDesc . Text ;
model . Level = txtLevel . Text ;
model . Speciality = txtSpeciality . Text ;
model . AskDestructionTime = DateTime . Parse ( txtAskDestructionTime . Text ) ;
model . RestrictCondition = txtRestrictCondition . Text ;
model . AddUser = this . CurrUser . LoginProjectId ;
model . AddTime = DateTime . Now ;
2023-12-25 14:19:31 +08:00
model . ResponsibilityProposeSatate = 1 ;
2023-12-20 15:48:05 +08:00
if ( isAdd )
{
Funs . DB . PreRun_SubThreeChecksFourDecision . InsertOnSubmit ( model ) ;
}
Funs . DB . SubmitChanges ( ) ;
ShowNotify ( "操作成功!" , MessageBoxIcon . Success ) ;
PageContext . RegisterStartupScript ( ActiveWindow . GetHidePostBackReference ( ) ) ;
}
/// <summary>
/// 关闭
/// </summary>
protected void WindowAtt_Close ( object sender , WindowCloseEventArgs e )
{
}
}
}