SGGL_SHJ/SGGL/FineUIPro.Web/HJGL/PointTrust/PointWeldJointView.aspx.cs

100 lines
4.9 KiB
C#

using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
namespace FineUIPro.Web.HJGL.PointTrust
{
public partial class PointWeldJointView : PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string unitWorkId = Request.Params["unitWorkId"];
string detectionType = Request.Params["detectionType"];
string rateId = Request.Params["rateId"];
Model.SGGLDB db = Funs.DB;
var pointJoints = (from x in db.HJGL_Batch_PointBatchItem
join y in db.HJGL_Batch_PointBatch on x.PointBatchId equals y.PointBatchId
join z in db.HJGL_WeldJoint on x.WeldJointId equals z.WeldJointId
where y.DetectionRateId == rateId && y.UnitWorkId == unitWorkId && y.DetectionTypeId == detectionType
&& x.PointState == "1"
select new { x.WeldJointId, z.WeldJointCode, z.JointAttribute });
int totalJointNum = (from x in db.HJGL_WeldJoint
join y in db.HJGL_Pipeline on x.PipelineId equals y.PipelineId
where y.DetectionRateId == rateId && y.UnitWorkId == unitWorkId && y.DetectionType == detectionType
select x).Count();
int needJointNum = 0, needYZJointNum = 0, needAZJointNum = 0;
Model.Base_DetectionRate rate = BLL.Base_DetectionRateService.GetDetectionRateByDetectionRateId(rateId);
if (rate != null)
{
needJointNum = Convert.ToInt32(Math.Ceiling((totalJointNum * rate.DetectionRateValue.Value) * 0.01));
needAZJointNum = Convert.ToInt32(Math.Ceiling(needJointNum * 0.4));
needYZJointNum = needJointNum - needAZJointNum;
}
this.lbDef.Text = "预制口:" + pointJoints.Count(x => x.JointAttribute == "预制口").ToString() + "个,安装口:" + pointJoints.Count(x => x.JointAttribute == "安装口").ToString() + "个。";
this.lbNeedDef.Text = "预制口:" + (needYZJointNum - pointJoints.Count(x => x.JointAttribute == "预制口")).ToString() + "个,安装口:" + (needAZJointNum - pointJoints.Count(x => x.JointAttribute == "安装口")).ToString() + "个。";
BindGrid();
}
}
#region
/// <summary>
/// 绑定数据
/// </summary>
public void BindGrid()
{
string strSql = @"SELECT PointBatchItemId,PointBatchId,WeldJointId,PointState,PointDate,RepairDate,CutDate,WeldJointCode,IsBuildTrust,WeldTypeCode,
JointAttribute ,JointArea,IsWelderFirst,Size,WeldingDate,PipelineCode,PipingClassName,PointIsAudit,BackingWelderCode,CoverWelderCode
FROM dbo.View_HJGL_Batch_PointBatchItem
WHERE UnitWorkId=@UnitWorkId and DetectionTypeId=@DetectionTypeId and DetectionRateId=@DetectionRateId and PointState='点口'";
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@UnitWorkId", Request.Params["unitWorkId"]));
listStr.Add(new SqlParameter("@DetectionTypeId", Request.Params["detectionType"]));
listStr.Add(new SqlParameter("@DetectionRateId", Request.Params["rateId"]));
if (!string.IsNullOrEmpty(txtpipelinecode.Text.Trim()))
{
strSql += " and PipelineCode like @PipelineCode ";
listStr.Add(new SqlParameter("@PipelineCode", "%" + txtpipelinecode.Text.Trim() + "%"));
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
Grid1.RecordCount = tb.Rows.Count;
// tb = GetFilteredTable(Grid1.FilteredData, tb);
var table = this.GetPagedDataTable(Grid1, tb);
Grid1.DataSource = table;
Grid1.DataBind();
}
#endregion
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
BindGrid();
}
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
BindGrid();
}
protected void btnQuery_Click(object sender, EventArgs e)
{
this.BindGrid();
}
#region
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort(object sender, GridSortEventArgs e)
{
BindGrid();
}
#endregion
}
}