Basf_TCC7/HJGL/FineUIPro.Web/WeldingProcess/WeldingReport/RTRateConfirm.aspx.cs

94 lines
4.9 KiB
C#

using BLL;
using Newtonsoft.Json.Linq;
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.WeldingProcess.WeldingReport
{
public partial class RTRateConfirm : PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BLL.Project_WorkAreaService.InitWorkAreaDropDownList(this.drpWorkAreaId, true, this.CurrUser.LoginProjectId, string.Empty, string.Empty, string.Empty, Resources.Lan.PleaseSelect);//区域
}
}
private void BindGrid()
{
string strSql = @"SELECT t.WorkAreaId,t.PipelineCode,mat.MaterialCode,t.Specification,t.JointTotalNum,t.GJointTotalNum,
welder.WelderCode,t.WeldingNum,t.NdeNum,t.GNdeNum,(CONVERT(NVARCHAR(10),r.DetectionRateValue)+'%') AS DetectionRate,
CONVERT(NVARCHAR(10),((CAST((CASE ISNULL(t.WeldingNum,0) WHEN 0 THEN 0
ELSE 1.0 * ISNULL(t.NdeNum,0) /(1.0 * t.WeldingNum)
END ) AS DECIMAL(9,2)))*100))+'%' AS CheckRate
FROM
(SELECT pipe.WorkAreaId, jot.PipelineId,pipe.PipelineCode,pipe.MainMaterialId,pipe.DetectionRateId,jot.CoverWelderId,
COUNT(*) AS WeldingNum, pipe.Specification,--MAX(jot.Specification) AS Specification,
(SELECT COUNT(*) FROM dbo.Pipeline_WeldJoint WHERE PipelineId=jot.PipelineId) AS JointTotalNum,
(SELECT COUNT(*) FROM dbo.Pipeline_WeldJoint WHERE PipelineId=jot.PipelineId AND JointAttribute='固定F') AS GJointTotalNum,
(SELECT count(1) FROM Batch_NDEItem as nde
LEFT join Batch_BatchTrustItem as trust ON trust.TrustBatchItemId = nde.TrustBatchItemId
LEFT JOIN View_Pipeline_WeldJoint as joint ON joint.WeldJointId=trust.WeldJointId
WHERE joint.PipelineId=jot.PipelineId and joint.CoverWelderId=jot.CoverWelderId) AS NdeNum,
(SELECT count(1) FROM Batch_NDEItem as nde
LEFT join Batch_BatchTrustItem as trust ON trust.TrustBatchItemId = nde.TrustBatchItemId
LEFT JOIN View_Pipeline_WeldJoint as joint ON joint.WeldJointId=trust.WeldJointId
WHERE joint.PipelineId=jot.PipelineId and joint.CoverWelderId=jot.CoverWelderId AND joint.JointAttribute='固定F') AS GNdeNum
FROM dbo.Pipeline_WeldJoint jot
LEFT JOIN dbo.Pipeline_Pipeline pipe ON pipe.PipelineId = jot.PipelineId
WHERE jot.CoverWelderId IS NOT NULL
GROUP BY pipe.WorkAreaId, jot.PipelineId,pipe.PipelineCode,pipe.MainMaterialId,pipe.Specification,pipe.DetectionRateId,jot.CoverWelderId) t
LEFT JOIN dbo.Base_Material mat ON mat.MaterialId = t.MainMaterialId
LEFT JOIN dbo.Welder_Welder welder ON welder.WelderId = t.CoverWelderId
LEFT JOIN dbo.Base_DetectionRate r ON r.DetectionRateId = t.DetectionRateId
WHERE t.PipelineId=@PipelineId";
List<SqlParameter> listStr = new List<SqlParameter>
{
};
listStr.Add(new SqlParameter("@PipelineId", this.drpPipeLine.SelectedValue));
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
Grid1.DataSource = tb;
Grid1.DataBind();
}
protected void drpWorkAreaId_OnSelectedIndexChanged(object sender, EventArgs e)
{
string[] workAreaIds = drpWorkAreaId.SelectedValueArray;
if (workAreaIds.Length == 1)
{
BLL.Pipeline_PipelineService.InitPipelineDropDownList(drpPipeLine, workAreaIds[0], Resources.Lan.PleaseSelect);
}
}
#region
/// <summary>
/// 统计
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void BtnAnalyse_Click(object sender, EventArgs e)
{
if (drpPipeLine.SelectedValue != null && drpPipeLine.SelectedValue != Const._Null)
{
BindGrid();
}
else
{
ShowNotify("请选择管线!", MessageBoxIcon.Warning);
}
}
#endregion
}
}