2025-03-26 09:53:22 +08:00
using BLL ;
using System ;
using System.Collections.Generic ;
using System.Data ;
using System.Data.SqlClient ;
using System.Linq ;
2025-05-24 14:48:16 +08:00
using System.Text ;
2025-03-26 09:53:22 +08:00
namespace FineUIPro.Web.DataShow
{
public partial class JD : PageBase
{
protected void Page_Load ( object sender , EventArgs e )
{
if ( ! IsPostBack )
{
Funs . DropDownPageSize ( this . ddlPageSize ) ;
2025-03-27 15:22:48 +08:00
Funs . DropDownPageSize ( this . ddlPageSize2 ) ;
2025-03-27 17:14:51 +08:00
Funs . DropDownPageSize ( this . ddlPageSize3 ) ;
2025-05-24 14:48:16 +08:00
Funs . DropDownPageSize ( this . ddlPageSize4 ) ;
2025-05-29 16:51:23 +08:00
Funs . DropDownPageSize ( this . ddlPageSize5 ) ;
2025-03-26 09:53:22 +08:00
ddlPageSize . SelectedValue = Grid1 . PageSize . ToString ( ) ;
2025-03-27 15:22:48 +08:00
ddlPageSize2 . SelectedValue = Grid2 . PageSize . ToString ( ) ;
2025-03-27 17:14:51 +08:00
ddlPageSize3 . SelectedValue = Grid3 . PageSize . ToString ( ) ;
2025-05-24 14:48:16 +08:00
ddlPageSize4 . SelectedValue = Grid4 . PageSize . ToString ( ) ;
2025-05-29 16:51:23 +08:00
ddlPageSize5 . SelectedValue = Grid5 . PageSize . ToString ( ) ;
2025-03-26 09:53:22 +08:00
BLL . ProjectService . InitProjectDropDownList ( this . drpProject , true ) ;
2025-03-27 15:22:48 +08:00
BLL . ProjectService . InitProjectDropDownList ( this . drpProject2 , true ) ;
2025-04-01 11:14:25 +08:00
BLL . UserService . InitSGBUser ( this . drpDutyPerson2 , true ) ;
2025-03-27 17:14:51 +08:00
BLL . ProjectService . InitProjectDropDownList ( this . drpProject3 , true ) ;
2025-04-01 11:14:25 +08:00
BLL . UserService . InitSGBUser ( this . drpDutyPerson3 , true ) ;
2025-05-29 16:51:23 +08:00
BLL . UserService . InitSGBUser ( this . drpDutyPerson5 , true ) ;
2025-05-24 14:48:16 +08:00
BLL . ProjectService . InitProjectDropDownList ( this . drpProject4 , true ) ;
2025-03-26 09:53:22 +08:00
BindGrid1 ( ) ;
2025-04-18 16:59:01 +08:00
//统计月份信息
DateTime months = Convert . ToDateTime ( DateTime . Now . Year . ToString ( ) + "-" + DateTime . Now . Month . ToString ( ) + "-01" ) ;
if ( DateTime . Now . Day < 26 )
{
months = Convert . ToDateTime ( DateTime . Now . Year . ToString ( ) + "-" + DateTime . Now . AddMonths ( - 1 ) . Month . ToString ( ) + "-01" ) ;
}
this . txtMonths . Text = months . ToString ( "yyyy-MM" ) ;
2025-03-26 09:53:22 +08:00
}
}
2025-05-29 16:51:23 +08:00
/// <summary>
/// 项目基本情况
/// </summary>
2025-03-26 09:53:22 +08:00
private void BindGrid1 ( )
{
2025-03-27 15:22:48 +08:00
string strSql = @ "select p.ProjectId,ProjectCode, ProjectName,(select sum(isnull(RealNum,0)) from JDGL_ProgressCompletion a where a.ProjectId=p.ProjectId) as RealNum,
cast ( ( case when isnull ( MonthPlan . MonthPlanNum , 0 ) = 0 then 0 else isnull ( MonthPlanOK . MonthPlanOKNum , 0 ) / ( 1.0 * isnull ( MonthPlan . MonthPlanNum , 0 ) ) * 100 end ) as DECIMAL ( 19 , 2 ) ) as MonthPlanRate ,
cast ( ( case when isnull ( WeekPlan . WeekPlanNum , 0 ) = 0 then 0 else isnull ( WeekPlanOK . WeekPlanOKNum , 0 ) / ( 1.0 * isnull ( WeekPlan . WeekPlanNum , 0 ) ) * 100 end ) as DECIMAL ( 19 , 2 ) ) as WeekPlanRate
from Base_Project p
left join (
SELECT COUNT ( w . WeekPlanId ) AS WeekPlanNum , w . ProjectId FROM JDGL_WeekPlan w
GROUP BY w . ProjectId
) AS WeekPlan ON WeekPlan . ProjectId = p . ProjectId
left join (
SELECT COUNT ( w . WeekPlanId ) AS WeekPlanOKNum , w . ProjectId FROM JDGL_WeekPlan w
where w . IsOK = 1
GROUP BY w . ProjectId
) AS WeekPlanOK ON WeekPlanOK . ProjectId = p . ProjectId
left join (
SELECT COUNT ( w . MonthPlanId ) AS MonthPlanNum , w . ProjectId FROM JDGL_MonthPlan w
GROUP BY w . ProjectId
) AS MonthPlan ON MonthPlan . ProjectId = p . ProjectId
left join (
SELECT COUNT ( w . MonthPlanId ) AS MonthPlanOKNum , w . ProjectId FROM JDGL_MonthPlan w
where w . RealDate is not null and w . RealDate < = w . PlanDate
GROUP BY w . ProjectId
) AS MonthPlanOK ON MonthPlanOK . ProjectId = p . ProjectId
2025-05-24 14:48:16 +08:00
where isnull ( p . ProjectState , 1 ) = 1 ";
2025-03-26 09:53:22 +08:00
List < SqlParameter > listStr = new List < SqlParameter > ( ) ;
string cpara = string . Empty ;
if ( this . drpProject . SelectedValue ! = Const . _Null )
{
2025-03-27 17:14:51 +08:00
strSql + = " AND p.ProjectId = @projectId" ;
2025-03-26 09:53:22 +08:00
listStr . Add ( new SqlParameter ( "@projectId" , this . drpProject . SelectedValue ) ) ;
}
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 ( ) ;
}
2025-04-18 16:59:01 +08:00
#region 月 份 选 择 事 件
/// <summary>
/// 月份选择事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void txtMonths_TextChanged ( object sender , EventArgs e )
{
BindGrid2 ( ) ;
}
#endregion
2025-05-29 16:51:23 +08:00
2025-03-27 15:22:48 +08:00
/// <summary>
2025-05-29 16:51:23 +08:00
/// 月计划
2025-03-27 15:22:48 +08:00
/// </summary>
private void BindGrid2 ( )
{
2025-03-27 17:14:51 +08:00
DataTable tb = new DataTable ( ) ;
tb . Columns . Add ( new DataColumn ( "ProjectId" , typeof ( String ) ) ) ;
tb . Columns . Add ( new DataColumn ( "ProjectCode" , typeof ( String ) ) ) ;
tb . Columns . Add ( new DataColumn ( "ProjectName" , typeof ( String ) ) ) ;
tb . Columns . Add ( new DataColumn ( "PlanNum" , typeof ( decimal ) ) ) ;
tb . Columns . Add ( new DataColumn ( "CompletedNum" , typeof ( decimal ) ) ) ;
tb . Columns . Add ( new DataColumn ( "Rate" , typeof ( decimal ) ) ) ;
tb . Columns . Add ( new DataColumn ( "TotalPlanNum" , typeof ( decimal ) ) ) ;
tb . Columns . Add ( new DataColumn ( "TotalCompletedNum" , typeof ( decimal ) ) ) ;
tb . Columns . Add ( new DataColumn ( "TotalRate" , typeof ( decimal ) ) ) ;
Model . SGGLDB db = Funs . DB ;
2025-05-24 14:48:16 +08:00
var projects = from x in db . Base_Project where x . ProjectState = = Const . ProjectState_1 | | x . ProjectState = = null orderby x . ProjectName select x ;
2025-03-27 17:14:51 +08:00
if ( this . drpProject2 . SelectedValue ! = BLL . Const . _Null )
{
projects = projects . Where ( x = > x . ProjectId = = this . drpProject2 . SelectedValue ) . OrderBy ( x = > x . ProjectName ) ;
}
2025-05-24 14:48:16 +08:00
if ( this . drpDutyPerson2 . SelectedValue ! = BLL . Const . _Null )
{
var lstProject = ( from x in db . JDGL_WeekPlan
where x . DutyPerson . Contains ( this . drpDutyPerson2 . SelectedValue )
select x . ProjectId ) . ToList ( ) ;
projects = projects . Where ( x = > lstProject . Contains ( x . ProjectId ) ) . OrderBy ( x = > x . ProjectName ) ;
}
2025-04-18 16:59:01 +08:00
//////统计月份信息
//DateTime months = Convert.ToDateTime(DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-01");
//if (DateTime.Now.Day < 26)
//{
// months = Convert.ToDateTime(DateTime.Now.Year.ToString() + "-" + DateTime.Now.AddMonths(-1).Month.ToString() + "-01");
//}
DateTime months = Convert . ToDateTime ( this . txtMonths . Text . Trim ( ) + "-01" ) ;
2025-03-27 17:14:51 +08:00
//2、获取当前项目指定月所有计划
var allMonthPlans = from x in db . JDGL_MonthPlan
where x . Months = = months
select x ;
//3、获取当前项目所有月计划
var allPlans = from x in db . JDGL_MonthPlan
where x . Months < = months
select x ;
foreach ( var item in projects )
{
double planNum = allMonthPlans . Where ( x = > x . ProjectId = = item . ProjectId ) . Count ( ) ;
double completedNum = allMonthPlans . Where ( x = > x . ProjectId = = item . ProjectId & & x . RealDate ! = null ) . Count ( ) ;
2025-04-01 11:14:25 +08:00
if ( this . drpDutyPerson2 . SelectedValue ! = BLL . Const . _Null )
{
planNum = allMonthPlans . Where ( x = > x . ProjectId = = item . ProjectId & & x . DutyPerson . Contains ( this . drpDutyPerson2 . SelectedValue ) ) . Count ( ) ;
completedNum = allMonthPlans . Where ( x = > x . ProjectId = = item . ProjectId & & x . DutyPerson . Contains ( this . drpDutyPerson2 . SelectedValue ) & & x . RealDate ! = null ) . Count ( ) ;
}
2025-03-27 17:14:51 +08:00
double rate = planNum > 0 ? Math . Round ( ( completedNum / planNum ) * 100 , 2 ) : 0 ;
double totalPlanNum = allPlans . Where ( x = > x . ProjectId = = item . ProjectId ) . Count ( ) ;
double totalCompletedNum = allPlans . Where ( x = > x . ProjectId = = item . ProjectId & & x . RealDate ! = null ) . Count ( ) ;
2025-04-01 11:14:25 +08:00
if ( this . drpDutyPerson2 . SelectedValue ! = BLL . Const . _Null )
{
totalPlanNum = allPlans . Where ( x = > x . ProjectId = = item . ProjectId & & x . DutyPerson . Contains ( this . drpDutyPerson2 . SelectedValue ) ) . Count ( ) ;
totalCompletedNum = allPlans . Where ( x = > x . ProjectId = = item . ProjectId & & x . DutyPerson . Contains ( this . drpDutyPerson2 . SelectedValue ) & & x . RealDate ! = null ) . Count ( ) ;
}
2025-03-27 17:14:51 +08:00
double totalRate = totalPlanNum > 0 ? Math . Round ( ( totalCompletedNum / totalPlanNum ) * 100 , 2 ) : 0 ;
DataRow row ;
row = tb . NewRow ( ) ;
row [ 0 ] = item . ProjectId ;
row [ 1 ] = item . ProjectCode ;
row [ 2 ] = item . ProjectName ;
row [ 3 ] = planNum ;
row [ 4 ] = completedNum ;
row [ 5 ] = rate ;
row [ 6 ] = totalPlanNum ;
row [ 7 ] = totalCompletedNum ;
row [ 8 ] = totalRate ;
tb . Rows . Add ( row ) ;
}
Grid2 . RecordCount = tb . Rows . Count ;
var table = this . GetPagedDataTable ( Grid2 , tb ) ;
Grid2 . DataSource = table ;
Grid2 . DataBind ( ) ;
}
/// <summary>
2025-05-29 16:51:23 +08:00
/// 周计划
2025-03-27 17:14:51 +08:00
/// </summary>
private void BindGrid3 ( )
{
DataTable tb = new DataTable ( ) ;
tb . Columns . Add ( new DataColumn ( "ProjectId" , typeof ( String ) ) ) ;
tb . Columns . Add ( new DataColumn ( "ProjectCode" , typeof ( String ) ) ) ;
tb . Columns . Add ( new DataColumn ( "ProjectName" , typeof ( String ) ) ) ;
tb . Columns . Add ( new DataColumn ( "PlanNum" , typeof ( decimal ) ) ) ;
tb . Columns . Add ( new DataColumn ( "CompletedNum" , typeof ( decimal ) ) ) ;
tb . Columns . Add ( new DataColumn ( "Rate" , typeof ( decimal ) ) ) ;
tb . Columns . Add ( new DataColumn ( "TotalPlanNum" , typeof ( decimal ) ) ) ;
tb . Columns . Add ( new DataColumn ( "TotalCompletedNum" , typeof ( decimal ) ) ) ;
tb . Columns . Add ( new DataColumn ( "TotalRate" , typeof ( decimal ) ) ) ;
Model . SGGLDB db = Funs . DB ;
2025-05-24 14:48:16 +08:00
var projects = from x in db . Base_Project where x . ProjectState = = Const . ProjectState_1 | | x . ProjectState = = null orderby x . ProjectName select x ;
2025-03-27 17:14:51 +08:00
if ( this . drpProject3 . SelectedValue ! = BLL . Const . _Null )
{
projects = projects . Where ( x = > x . ProjectId = = this . drpProject3 . SelectedValue ) . OrderBy ( x = > x . ProjectName ) ;
}
2025-05-24 14:48:16 +08:00
if ( this . drpDutyPerson3 . SelectedValue ! = BLL . Const . _Null )
{
var lstProject = ( from x in db . JDGL_WeekPlan
where x . DutyPerson . Contains ( this . drpDutyPerson3 . SelectedValue )
select x . ProjectId ) . ToList ( ) ;
projects = projects . Where ( x = > lstProject . Contains ( x . ProjectId ) ) . OrderBy ( x = > x . ProjectName ) ;
}
2025-03-27 17:14:51 +08:00
//统计月份信息
DateTime months = Convert . ToDateTime ( DateTime . Now . Year . ToString ( ) + "-" + DateTime . Now . Month . ToString ( ) + "-01" ) ;
if ( DateTime . Now . Day < 26 )
{
months = Convert . ToDateTime ( DateTime . Now . Year . ToString ( ) + "-" + DateTime . Now . AddMonths ( - 1 ) . Month . ToString ( ) + "-01" ) ;
}
//2、获取当前项目指定月所有计划
var allWeekPlans = from x in db . JDGL_WeekPlan
select x ;
foreach ( var item in projects )
{
2025-04-18 16:59:01 +08:00
var lastWeek = ( from x in db . JDGL_WeekPlan where x . ProjectId = = item . ProjectId & & DateTime . Now > ( ( DateTime ) x . EndDate ) . AddDays ( 1 ) orderby x . EndDate descending select x ) . FirstOrDefault ( ) ;
2025-03-27 17:14:51 +08:00
double planNum = 0 , completedNum = 0 , rate = 0 ;
if ( lastWeek ! = null )
{
planNum = allWeekPlans . Where ( x = > x . ProjectId = = item . ProjectId & & x . WeekNo = = lastWeek . WeekNo ) . Count ( ) ;
completedNum = allWeekPlans . Where ( x = > x . ProjectId = = item . ProjectId & & x . WeekNo = = lastWeek . WeekNo & & x . IsOK = = true ) . Count ( ) ;
2025-04-01 11:14:25 +08:00
if ( this . drpDutyPerson3 . SelectedValue ! = BLL . Const . _Null )
{
planNum = allWeekPlans . Where ( x = > x . ProjectId = = item . ProjectId & & x . DutyPerson . Contains ( this . drpDutyPerson3 . SelectedValue ) & & x . WeekNo = = lastWeek . WeekNo ) . Count ( ) ;
completedNum = allWeekPlans . Where ( x = > x . ProjectId = = item . ProjectId & & x . DutyPerson . Contains ( this . drpDutyPerson3 . SelectedValue ) & & x . WeekNo = = lastWeek . WeekNo & & x . IsOK = = true ) . Count ( ) ;
}
2025-03-27 17:14:51 +08:00
rate = planNum > 0 ? Math . Round ( ( completedNum / planNum ) * 100 , 2 ) : 0 ;
}
double totalPlanNum = allWeekPlans . Where ( x = > x . ProjectId = = item . ProjectId ) . Count ( ) ;
double totalCompletedNum = allWeekPlans . Where ( x = > x . ProjectId = = item . ProjectId & & x . IsOK = = true ) . Count ( ) ;
2025-04-01 11:14:25 +08:00
if ( this . drpDutyPerson3 . SelectedValue ! = BLL . Const . _Null )
{
totalPlanNum = allWeekPlans . Where ( x = > x . ProjectId = = item . ProjectId & & x . DutyPerson . Contains ( this . drpDutyPerson3 . SelectedValue ) ) . Count ( ) ;
totalCompletedNum = allWeekPlans . Where ( x = > x . ProjectId = = item . ProjectId & & x . DutyPerson . Contains ( this . drpDutyPerson3 . SelectedValue ) & & x . IsOK = = true ) . Count ( ) ;
}
2025-03-27 17:14:51 +08:00
double totalRate = totalPlanNum > 0 ? Math . Round ( ( totalCompletedNum / totalPlanNum ) * 100 , 2 ) : 0 ;
DataRow row ;
row = tb . NewRow ( ) ;
row [ 0 ] = item . ProjectId ;
row [ 1 ] = item . ProjectCode ;
row [ 2 ] = item . ProjectName ;
row [ 3 ] = planNum ;
row [ 4 ] = completedNum ;
row [ 5 ] = rate ;
row [ 6 ] = totalPlanNum ;
row [ 7 ] = totalCompletedNum ;
row [ 8 ] = totalRate ;
tb . Rows . Add ( row ) ;
}
Grid3 . RecordCount = tb . Rows . Count ;
var table = this . GetPagedDataTable ( Grid3 , tb ) ;
Grid3 . DataSource = table ;
Grid3 . DataBind ( ) ;
2025-03-27 15:22:48 +08:00
}
2025-05-24 14:48:16 +08:00
/// <summary>
2025-05-29 16:51:23 +08:00
/// 实物工程量
2025-05-24 14:48:16 +08:00
/// </summary>
private void BindGrid4 ( )
{
StringBuilder strSql = new StringBuilder ( ) ;
strSql . AppendLine ( $ @ "select pro.ProjectId,pro.ProjectCode,pro.ProjectName,qc.QuantityCompletionId,ql.Name,ql.Unit,ql.DesignNum,ql.SortIndex,qco.RealNum as RealNum,qco.NextNum as NextNum,
CONVERT ( NVARCHAR ( 10 ) , ( ( CAST ( CASE ISNULL ( qco . PlanNum , 0 ) WHEN 0 THEN 0 ELSE 100 * ISNULL ( qco . RealNum , 0 ) / ( 1.0 * qco . PlanNum ) END AS DECIMAL ( 9 , 2 ) ) ) ) ) AS Rate ,
CONVERT ( FLOAT , ( select sum ( ISNULL ( PlanNum , 0 ) ) from JDGL_QuantityCompletion where ProjectId = ql . ProjectId and QuantityListId = qc . QuantityListId and Months < = @month ) ) as TotalPlanNum ,
CONVERT ( FLOAT , ( select sum ( ISNULL ( RealNum , 0 ) ) from JDGL_QuantityCompletion where ProjectId = ql . ProjectId and QuantityListId = qc . QuantityListId and Months < = @month ) ) as TotalRealNum ,
CONVERT ( NVARCHAR ( 10 ) , ( ( CAST ( CASE ( select sum ( ISNULL ( PlanNum , 0 ) ) from JDGL_QuantityCompletion where ProjectId = ql . ProjectId and QuantityListId = qc . QuantityListId and Months < = @month ) WHEN 0 THEN 0 ELSE 100 * ( select sum ( ISNULL ( RealNum , 0 ) ) from JDGL_QuantityCompletion where ProjectId = ql . ProjectId and QuantityListId = qc . QuantityListId and Months < = @month ) / ( 1.0 * ( select sum ( ISNULL ( PlanNum , 0 ) ) from JDGL_QuantityCompletion where ProjectId = ql . ProjectId and QuantityListId = qc . QuantityListId and Months < = @month ) ) END AS DECIMAL ( 9 , 2 ) ) ) ) ) AS TotalRate ,
CONVERT ( NVARCHAR ( 10 ) , ( ( CAST ( CASE ISNULL ( ql . DesignNum , 0 ) WHEN 0 THEN 0 ELSE 100 * ( select sum ( ISNULL ( RealNum , 0 ) ) from JDGL_QuantityCompletion where ProjectId = ql . ProjectId and QuantityListId = qc . QuantityListId and Months < = @month ) / ( 1.0 * ql . DesignNum ) END AS DECIMAL ( 9 , 2 ) ) ) ) ) AS SumRate ,
CONVERT ( FLOAT , ( select sum ( ISNULL ( PlanNum , 0 ) ) from JDGL_QuantityCompletion where ProjectId = ql . ProjectId and QuantityListId = qc . QuantityListId and Months < qc . Months ) ) as LastTotalPlanNum ,
CONVERT ( FLOAT , ( select sum ( ISNULL ( RealNum , 0 ) ) from JDGL_QuantityCompletion where ProjectId = ql . ProjectId and QuantityListId = qc . QuantityListId and Months < qc . Months ) ) as LastTotalRealNum ");
strSql . AppendLine ( @ "from JDGL_QuantityList ql
left join JDGL_QuantityCompletion qc on ql . QuantityListId = qc . QuantityListId
left join Base_Project pro on pro . ProjectId = qc . ProjectId
left join ( select PlanNum , RealNum , NextNum , QuantityListId from JDGL_QuantityCompletion where Months = @month ) qco on qco . QuantityListId = ql . QuantityListId ");
strSql . AppendLine ( "where isnull(pro.ProjectState,1)=1 and qc.QuantityCompletionId=(select top 1 QuantityCompletionId from JDGL_QuantityCompletion q where q.QuantityListId=qc.QuantityListId and q.Months<=@month order by q.Months desc) " ) ;
List < SqlParameter > listStr = new List < SqlParameter > ( ) ;
string month = string . Format ( "{0:yyyy-MM-01}" , DateTime . Now ) ;
if ( DateTime . Now . Day < 26 )
{
month = string . Format ( "{0:yyyy-MM-01}" , DateTime . Now . AddMonths ( - 1 ) ) ;
}
listStr . Add ( new SqlParameter ( "@month" , month ) ) ;
if ( this . drpProject4 . SelectedValue ! = Const . _Null )
{
strSql . AppendLine ( "and qc.ProjectId = @projectId " ) ;
listStr . Add ( new SqlParameter ( "@projectId" , this . drpProject4 . SelectedValue ) ) ;
}
if ( ! string . IsNullOrEmpty ( this . txtTypeName . Text . Trim ( ) ) )
{
strSql . AppendLine ( "and ql.Name like @typeName " ) ;
listStr . Add ( new SqlParameter ( "@typeName" , "%" + this . txtTypeName . Text . Trim ( ) + "%" ) ) ;
}
strSql . AppendLine ( "order by pro.ProjectCode,ql.Name " ) ;
SqlParameter [ ] parameter = listStr . ToArray ( ) ;
DataTable tb = SQLHelper . GetDataTableRunText ( strSql . ToString ( ) , parameter ) ;
Grid4 . RecordCount = tb . Rows . Count ;
var table = this . GetPagedDataTable ( Grid4 , tb ) ;
Grid4 . DataSource = table ;
Grid4 . DataBind ( ) ;
}
2025-05-29 16:51:23 +08:00
/// <summary>
/// 五环责任人完成情况
/// </summary>
private void BindGrid5 ( )
{
string strSql = $ @ "SELECT p.UserId,p.UserCode,p.UserName, cast((case when isnull(MonthPlan.MonthPlanNum,0)=0 then 0 else isnull(MonthPlanOK.MonthPlanOKNum,0)/(1.0 *isnull(MonthPlan.MonthPlanNum,0))*100 end) as DECIMAL(19,2)) as MonthPlanRate,
cast ( ( case when isnull ( WeekPlan . WeekPlanNum , 0 ) = 0 then 0 else isnull ( WeekPlanOK . WeekPlanOKNum , 0 ) / ( 1.0 * isnull ( WeekPlan . WeekPlanNum , 0 ) ) * 100 end ) as DECIMAL ( 19 , 2 ) ) as WeekPlanRate
FROM Sys_User p
LEFT JOIN (
SELECT COUNT ( w . WeekPlanId ) AS WeekPlanNum , w . pDutyPerson
FROM ( SELECT Item . value ( '.' , ' NVARCHAR ( MAX ) ' ) AS pDutyPerson , jplan . * FROM JDGL_WeekPlan as jplan CROSS APPLY ( SELECT CAST ( ' < M > ' + REPLACE ( DutyPerson , ',' , ' < / M > < M > ' ) + ' < / M > ' AS XML ) ) AS A ( x ) CROSS APPLY x . nodes ( ' / M ' ) AS B ( Item ) ) w
GROUP BY w . pDutyPerson
) AS WeekPlan ON WeekPlan . pDutyPerson = p . UserId
LEFT JOIN (
SELECT COUNT ( w . WeekPlanId ) AS WeekPlanOKNum , w . pDutyPerson
FROM ( SELECT Item . value ( '.' , ' NVARCHAR ( MAX ) ' ) AS pDutyPerson , jplan . * FROM JDGL_WeekPlan as jplan CROSS APPLY ( SELECT CAST ( ' < M > ' + REPLACE ( DutyPerson , ',' , ' < / M > < M > ' ) + ' < / M > ' AS XML ) ) AS A ( x ) CROSS APPLY x . nodes ( ' / M ' ) AS B ( Item ) ) w
WHERE w . IsOK = 1
GROUP BY w . pDutyPerson
) AS WeekPlanOK ON WeekPlanOK . pDutyPerson = p . UserId
LEFT JOIN (
SELECT COUNT ( w . MonthPlanId ) AS MonthPlanNum , w . pDutyPerson
FROM ( SELECT Item . value ( '.' , ' NVARCHAR ( MAX ) ' ) AS pDutyPerson , jplan . * FROM JDGL_MonthPlan as jplan CROSS APPLY ( SELECT CAST ( ' < M > ' + REPLACE ( DutyPerson , ',' , ' < / M > < M > ' ) + ' < / M > ' AS XML ) ) AS A ( x ) CROSS APPLY x . nodes ( ' / M ' ) AS B ( Item ) ) w
GROUP BY w . pDutyPerson
) AS MonthPlan ON MonthPlan . pDutyPerson = p . UserId
LEFT JOIN (
SELECT COUNT ( w . MonthPlanId ) AS MonthPlanOKNum , w . pDutyPerson
FROM ( SELECT Item . value ( '.' , ' NVARCHAR ( MAX ) ' ) AS pDutyPerson , jplan . * FROM JDGL_MonthPlan as jplan CROSS APPLY ( SELECT CAST ( ' < M > ' + REPLACE ( DutyPerson , ',' , ' < / M > < M > ' ) + ' < / M > ' AS XML ) ) AS A ( x ) CROSS APPLY x . nodes ( ' / M ' ) AS B ( Item ) ) w
WHERE w . RealDate is not null and w . RealDate < = w . PlanDate
GROUP BY w . pDutyPerson
) AS MonthPlanOK ON MonthPlanOK . pDutyPerson = p . UserId
WHERE p . IsPost = 1 and p . UnitId = ' { Const . UnitId_CWCEC } ' and p . DepartId = ' { Const . Depart_constructionId } ' ";// ORDER BY p.UserCode,p.UserName
List < SqlParameter > listStr = new List < SqlParameter > ( ) ;
string cpara = string . Empty ;
if ( this . drpDutyPerson5 . SelectedValue ! = Const . _Null )
{
strSql + = " AND p.UserId = @UserId" ;
listStr . Add ( new SqlParameter ( "@UserId" , this . drpDutyPerson5 . SelectedValue ) ) ;
}
SqlParameter [ ] parameter = listStr . ToArray ( ) ;
DataTable tb = SQLHelper . GetDataTableRunText ( strSql , parameter ) ;
Grid5 . RecordCount = tb . Rows . Count ;
var table = this . GetPagedDataTable ( Grid5 , tb ) ;
Grid5 . DataSource = table ;
Grid5 . DataBind ( ) ;
}
2025-03-26 09:53:22 +08:00
#region 查 询
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void TextBox_TextChanged ( object sender , EventArgs e )
{
this . BindGrid1 ( ) ;
}
#endregion
#region 表 排 序 、 分 页 、 关 闭 窗 口
/// <summary>
/// 分页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_PageIndexChange ( object sender , GridPageEventArgs e )
{
BindGrid1 ( ) ;
}
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort ( object sender , GridSortEventArgs e )
{
BindGrid1 ( ) ;
}
/// <summary>
/// 分页显示条数下拉框
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlPageSize_SelectedIndexChanged ( object sender , EventArgs e )
{
Grid1 . PageSize = Convert . ToInt32 ( ddlPageSize . SelectedValue ) ;
BindGrid1 ( ) ;
}
2025-03-27 17:14:51 +08:00
#endregion
2025-03-27 15:22:48 +08:00
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void TextBox2_TextChanged ( object sender , EventArgs e )
{
this . BindGrid2 ( ) ;
}
#region 表 排 序 、 分 页 、 关 闭 窗 口
/// <summary>
/// 分页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid2_PageIndexChange ( object sender , GridPageEventArgs e )
{
BindGrid2 ( ) ;
}
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid2_Sort ( object sender , GridSortEventArgs e )
{
BindGrid2 ( ) ;
}
/// <summary>
/// 分页显示条数下拉框
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlPageSize2_SelectedIndexChanged ( object sender , EventArgs e )
{
Grid2 . PageSize = Convert . ToInt32 ( ddlPageSize2 . SelectedValue ) ;
BindGrid2 ( ) ;
}
#endregion
2025-03-27 17:14:51 +08:00
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void TextBox3_TextChanged ( object sender , EventArgs e )
{
this . BindGrid3 ( ) ;
}
#region 表 排 序 、 分 页 、 关 闭 窗 口
/// <summary>
/// 分页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid3_PageIndexChange ( object sender , GridPageEventArgs e )
{
BindGrid3 ( ) ;
}
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid3_Sort ( object sender , GridSortEventArgs e )
{
BindGrid3 ( ) ;
}
/// <summary>
/// 分页显示条数下拉框
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlPageSize3_SelectedIndexChanged ( object sender , EventArgs e )
{
Grid3 . PageSize = Convert . ToInt32 ( ddlPageSize3 . SelectedValue ) ;
BindGrid3 ( ) ;
}
#endregion
2025-05-24 14:48:16 +08:00
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void TextBox4_TextChanged ( object sender , EventArgs e )
{
this . BindGrid4 ( ) ;
}
#region 表 排 序 、 分 页 、 关 闭 窗 口
/// <summary>
/// 分页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid4_PageIndexChange ( object sender , GridPageEventArgs e )
{
BindGrid4 ( ) ;
}
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid4_Sort ( object sender , GridSortEventArgs e )
{
BindGrid4 ( ) ;
}
/// <summary>
/// 分页显示条数下拉框
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlPageSize4_SelectedIndexChanged ( object sender , EventArgs e )
{
Grid4 . PageSize = Convert . ToInt32 ( ddlPageSize4 . SelectedValue ) ;
BindGrid4 ( ) ;
}
#endregion
2025-05-29 16:51:23 +08:00
#region 查 询
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void TextBox5_TextChanged ( object sender , EventArgs e )
{
this . BindGrid5 ( ) ;
}
#endregion
#region 表 排 序 、 分 页 、 关 闭 窗 口
/// <summary>
/// 分页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid5_PageIndexChange ( object sender , GridPageEventArgs e )
{
BindGrid5 ( ) ;
}
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid5_Sort ( object sender , GridSortEventArgs e )
{
BindGrid5 ( ) ;
}
/// <summary>
/// 分页显示条数下拉框
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlPageSize5_SelectedIndexChanged ( object sender , EventArgs e )
{
Grid5 . PageSize = Convert . ToInt32 ( ddlPageSize5 . SelectedValue ) ;
BindGrid5 ( ) ;
}
#endregion
2025-05-24 14:48:16 +08:00
2025-03-27 15:22:48 +08:00
protected void TabStrip1_TabIndexChanged ( object sender , EventArgs e )
{
if ( TabStrip1 . ActiveTabIndex = = 1 )
{
2025-03-27 17:14:51 +08:00
if ( this . Grid2 . Rows . Count = = 0 )
{
BindGrid2 ( ) ;
}
}
else if ( TabStrip1 . ActiveTabIndex = = 2 )
{
if ( this . Grid3 . Rows . Count = = 0 )
{
BindGrid3 ( ) ;
}
2025-03-27 15:22:48 +08:00
}
2025-05-24 14:48:16 +08:00
else if ( TabStrip1 . ActiveTabIndex = = 3 )
{
if ( this . Grid4 . Rows . Count = = 0 )
{
BindGrid4 ( ) ;
}
}
2025-05-29 16:51:23 +08:00
else if ( TabStrip1 . ActiveTabIndex = = 4 )
{
if ( this . Grid5 . Rows . Count = = 0 )
{
BindGrid5 ( ) ;
}
}
2025-03-27 15:22:48 +08:00
}
2025-04-10 19:04:56 +08:00
/// <summary>
/// Grid双击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid3_RowDoubleClick ( object sender , GridRowClickEventArgs e )
{
this . ViewWeekDetail ( ) ;
}
/// <summary>
/// 查看
/// </summary>
private void ViewWeekDetail ( )
{
if ( Grid3 . SelectedRowIndexArray . Length = = 0 )
{
Alert . ShowInTop ( "请选择一条记录!" , MessageBoxIcon . Warning ) ;
return ;
}
else if ( Grid3 . SelectedRowIndexArray . Length > 1 )
{
Alert . ShowInTop ( "请选择一条记录!" , MessageBoxIcon . Warning ) ;
return ;
}
string projectId = Grid3 . SelectedRowID ;
PageContext . RegisterStartupScript ( Window1 . GetShowReference ( String . Format ( "JDWeekDetail.aspx?projectId={0}" , projectId , "查看明细 - " ) ) ) ;
}
/// <summary>
/// Grid双击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid2_RowDoubleClick ( object sender , GridRowClickEventArgs e )
{
this . ViewMonthDetail ( ) ;
}
/// <summary>
/// 查看
/// </summary>
private void ViewMonthDetail ( )
{
if ( Grid2 . SelectedRowIndexArray . Length = = 0 )
{
Alert . ShowInTop ( "请选择一条记录!" , MessageBoxIcon . Warning ) ;
return ;
}
else if ( Grid2 . SelectedRowIndexArray . Length > 1 )
{
Alert . ShowInTop ( "请选择一条记录!" , MessageBoxIcon . Warning ) ;
return ;
}
2025-04-18 16:59:01 +08:00
////统计月份信息
//DateTime months = Convert.ToDateTime(DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-01");
//if (DateTime.Now.Day < 26)
//{
// months = Convert.ToDateTime(DateTime.Now.Year.ToString() + "-" + DateTime.Now.AddMonths(-1).Month.ToString() + "-01");
//}
//string month = months.ToString("yyyy-MM-dd");
2025-04-10 19:04:56 +08:00
string projectId = Grid2 . SelectedRowID ;
2025-04-18 16:59:01 +08:00
string month = this . txtMonths . Text . Trim ( ) + "-01" ;
2025-04-10 19:04:56 +08:00
PageContext . RegisterStartupScript ( Window1 . GetShowReference ( String . Format ( "JDMonthDetail.aspx?projectId={0}&month={1}" , projectId , month , "查看明细 - " ) ) ) ;
}
2025-05-29 16:51:23 +08:00
/// <summary>
/// Grid双击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid5_RowDoubleClick ( object sender , GridRowClickEventArgs e )
{
this . ViewDutyPersonDetail ( ) ;
}
/// <summary>
/// 查看
/// </summary>
private void ViewDutyPersonDetail ( )
{
if ( Grid5 . SelectedRowIndexArray . Length = = 0 )
{
Alert . ShowInTop ( "请选择一条记录!" , MessageBoxIcon . Warning ) ;
return ;
}
else if ( Grid5 . SelectedRowIndexArray . Length > 1 )
{
Alert . ShowInTop ( "请选择一条记录!" , MessageBoxIcon . Warning ) ;
return ;
}
string userId = Grid5 . SelectedRowID ;
PageContext . RegisterStartupScript ( Window1 . GetShowReference ( String . Format ( "JDDutyPersonDetail.aspx?UserId={0}" , userId , "查看明细 - " ) ) ) ;
}
2025-04-10 19:04:56 +08:00
2025-03-26 09:53:22 +08:00
}
}