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

1005 lines
46 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using BLL;
using Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.HJGL.PointTrust
{
public partial class PointBatch : PageBase
{
#region
/// <summary>
/// 批次主键
/// </summary>
public string PointBatchId
{
get
{
return (string)ViewState["PointBatchId"];
}
set
{
ViewState["PointBatchId"] = value;
}
}
#endregion
#region
/// <summary>
/// 加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
// ctlAuditFlow.Url = BLL.Project_SysSetService.GetAvevaNetUrl(this.CurrUser.LoginProjectId);
if (!IsPostBack)
{
BLL.UnitService.InitUnitByProjectIdUnitTypeDropDownList(this.drpUnit, this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2, true);
this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
this.txtStartTime.Text = string.Format("{0:yyyy-MM}", DateTime.Now);
this.InitTreeMenu();//加载树
}
}
#region
/// <summary>
/// 加载树
/// </summary>
private void InitTreeMenu()
{
this.tvControlItem.Nodes.Clear();
TreeNode rootNode1 = new TreeNode();
rootNode1.NodeID = "1";
rootNode1.Text = "建筑工程";
rootNode1.CommandName = "建筑工程";
rootNode1.Selectable = false;
this.tvControlItem.Nodes.Add(rootNode1);
TreeNode rootNode2 = new TreeNode();
rootNode2.NodeID = "2";
rootNode2.Text = "安装工程";
rootNode2.CommandName = "安装工程";
rootNode2.Expanded = true;
this.tvControlItem.Nodes.Add(rootNode2);
var pUnits = (from x in Funs.DB.Project_ProjectUnit where x.ProjectId == this.CurrUser.LoginProjectId select x).ToList();
// 获取当前用户所在单位
var currUnit = pUnits.FirstOrDefault(x => x.UnitId == this.CurrUser.UnitId);
var unitWorkList = (from x in Funs.DB.WBS_UnitWork
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.SuperUnitWork == null && x.UnitId != null && x.ProjectType != null
select x).ToList();
List<Model.WBS_UnitWork> unitWork1 = null;
List<Model.WBS_UnitWork> unitWork2 = null;
//// 当前为施工单位,只能操作本单位的数据
//if (currUnit != null && currUnit.UnitType == Const.ProjectUnitType_2)
//{
// unitWork1 = (from x in unitWorkList
// where x.UnitId == this.CurrUser.UnitId && x.ProjectType == "1"
// select x).ToList();
// unitWork2 = (from x in unitWorkList
// where x.UnitId == this.CurrUser.UnitId && x.ProjectType == "2"
// select x).ToList();
//}
//else
//{
unitWork1 = (from x in unitWorkList where x.ProjectType == "1" select x).ToList();
unitWork2 = (from x in unitWorkList where x.ProjectType == "2" select x).ToList();
//}
if (unitWork1.Count() > 0)
{
foreach (var q in unitWork1)
{
int a = (from x in Funs.DB.HJGL_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == q.UnitWorkId select x).Count();
var unitNamesUnitIds = BLL.UnitService.getUnitNamesUnitIds(q.UnitId);
TreeNode tn1 = new TreeNode();
tn1.NodeID = q.UnitWorkId;
tn1.Text = q.UnitWorkName;
tn1.ToolTip = "施工单位:" + unitNamesUnitIds;
tn1.CommandName = "单位工程";
tn1.EnableExpandEvent = true;
rootNode1.Nodes.Add(tn1);
BindNodes(tn1);
}
}
if (unitWork2.Count() > 0)
{
foreach (var q in unitWork2)
{
int a = (from x in Funs.DB.HJGL_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == q.UnitWorkId select x).Count();
var unitNamesUnitIds = BLL.UnitService.getUnitNamesUnitIds(q.UnitId);
TreeNode tn2 = new TreeNode();
tn2.NodeID = q.UnitWorkId;
tn2.Text = q.UnitWorkName;
tn2.ToolTip = "施工单位:" + unitNamesUnitIds;
tn2.EnableExpandEvent = true;
tn2.CommandName = "单位工程";
rootNode2.Nodes.Add(tn2);
BindNodes(tn2);
}
}
}
/// <summary>
/// 绑定树节点
/// </summary>
/// <param name="node"></param>
private void BindNodes(TreeNode node)
{
var p = from x in Funs.DB.HJGL_Batch_PointBatch
where x.UnitWorkId == node.NodeID
&& x.StartDate < Convert.ToDateTime(this.txtStartTime.Text.Trim() + "-01").AddMonths(1)
&& x.StartDate >= Convert.ToDateTime(this.txtStartTime.Text.Trim() + "-01")
select x;
if (p.Count() > 0)
{
TreeNode newNode = new TreeNode();
newNode.Text = "探伤类型";
newNode.NodeID = "探伤类型";
node.Nodes.Add(newNode);
}
}
#endregion
#endregion
#region
protected void tvControlItem_TreeNodeExpanded(object sender, TreeNodeEventArgs e)
{
e.Node.Nodes.Clear();
if (e.Node.CommandName == "单位工程")
{
var detectionTypes = from x in Funs.DB.Base_DetectionType
orderby x.DetectionTypeCode
select new { x.DetectionTypeId, x.DetectionTypeCode, x.DetectionTypeName };
foreach (var item in detectionTypes)
{
var pointManages = from x in Funs.DB.View_HJGL_Batch_PointBatch
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.UnitWorkId == e.Node.NodeID
&& x.DetectionTypeId == item.DetectionTypeId
select x;
TreeNode newNode = new TreeNode();
if (pointManages.Count() > 0)
{
newNode.Text = item.DetectionTypeCode;
newNode.NodeID = item.DetectionTypeId + "|" + e.Node.NodeID;
newNode.EnableExpandEvent = true;
newNode.ToolTip = item.DetectionTypeName;
newNode.CommandName = "探伤类型";
e.Node.Nodes.Add(newNode);
}
TreeNode tn1 = new TreeNode
{
Text = "检测比例",
NodeID = "检测比例",
};
newNode.Nodes.Add(tn1);
}
}
if (e.Node.CommandName == "探伤类型")
{
var detectionRates = from x in Funs.DB.Base_DetectionRate
orderby x.DetectionRateCode
select new { x.DetectionRateId, x.DetectionRateCode, x.DetectionRateValue };
foreach (var item in detectionRates)
{
var pointManages = from x in Funs.DB.View_HJGL_Batch_PointBatch
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.UnitWorkId == e.Node.ParentNode.NodeID
&& x.DetectionTypeId == e.Node.NodeID.Split('|')[0]
&& x.DetectionRateId == item.DetectionRateId
&& x.StartDate < Convert.ToDateTime(this.txtStartTime.Text.Trim() + "-01").AddMonths(1)
&& x.StartDate >= Convert.ToDateTime(this.txtStartTime.Text.Trim() + "-01")
select x;
if (item.DetectionRateValue > 0) //探伤比例为0的批不显示
{
TreeNode newNode = new TreeNode();
if (pointManages.Count() > 0)
{
newNode.Text = item.DetectionRateValue.ToString() + "%";
newNode.NodeID = item.DetectionRateId + "|" + e.Node.NodeID;
newNode.EnableExpandEvent = true;
newNode.ToolTip = item.DetectionRateCode;
newNode.CommandName = "检测比例";
e.Node.Nodes.Add(newNode);
}
TreeNode tn1 = new TreeNode
{
Text = "检测批",
NodeID = "检测批",
};
newNode.Nodes.Add(tn1);
}
}
}
if (e.Node.CommandName == "检测比例")
{
var pointManages = from x in Funs.DB.View_HJGL_Batch_PointBatch
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.DetectionRateId == e.NodeID.Split('|')[0]
&& x.DetectionTypeId == e.Node.ParentNode.NodeID.Split('|')[0]
&& x.UnitWorkId == e.Node.ParentNode.ParentNode.NodeID
&& x.StartDate < Convert.ToDateTime(this.txtStartTime.Text.Trim() + "-01").AddMonths(1)
&& x.StartDate >= Convert.ToDateTime(this.txtStartTime.Text.Trim() + "-01")
select x;
if (!string.IsNullOrEmpty(this.txtWelderCode.Text))
{
pointManages = pointManages.Where(x => x.WelderCode.Contains(this.txtWelderCode.Text.Trim()));
}
if (this.drpUnit.SelectedValue != BLL.Const._Null)
{
pointManages = pointManages.Where(x => x.UnitId == this.drpUnit.SelectedValue);
}
foreach (var item in pointManages)
{
TreeNode newNode = new TreeNode
{
NodeID = item.PointBatchId,
ToolTip = "批",
EnableClickEvent = true,
};
var pipeline = PointBatchService.GetPointBatchById(item.PointBatchId);
string startdate = string.Format("{0:yyyy-MM-dd}", pipeline.StartDate);
string PipeArea = "";
if (!string.IsNullOrEmpty(pipeline.PipelineId))
{
switch (PipelineService.GetPipelineByPipelineId(pipeline.PipelineId).PipeArea)
{
case PipelineService.PipeArea_SHOP:
PipeArea = "(工厂)";
break;
case PipelineService.PipeArea_FIELD:
PipeArea = "(现场)";
break;
}
}
string code = "DK-" + item.PointBatchCode.Substring(item.PointBatchCode.Length - 4) + PipeArea;
if (!item.EndDate.HasValue) ////批 没有关闭 粉色
{
newNode.Text = "<font color='#FA58D0'>" + code + "【" + startdate + "】" + "【" + item.UnitName + "】" + "</font>";
newNode.ToolTip = "批尚未关闭";
}
// 当天批
else if (string.Format("{0:yyyy-MM-dd}", item.StartDate) == string.Format("{0:yyyy-MM-dd}", System.DateTime.Now)
|| string.Format("{0:yyyy-MM-dd}", item.EndDate) == string.Format("{0:yyyy-MM-dd}", System.DateTime.Now))
{
newNode.Text = "<font color='#EE0000'>" + code + "【" + startdate + "】" + "【" + item.UnitName + "】" + "</font>";
newNode.ToolTip = "当天批";
}
else
{
newNode.Text = code + "【" + startdate + "】" + "【" + item.UnitName + "】";
}
e.Node.Nodes.Add(newNode);
}
}
}
#endregion
#region TreeView
/// <summary>
/// 点击TreeView
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
{
this.TbPipeline.Hidden = true;
this.TbNotPipeline.Hidden = true;
if (this.tvControlItem.SelectedNodeID != "0")
{
Model.SGGLDB db = Funs.DB;
this.PointBatchId = tvControlItem.SelectedNodeID;
this.BindGrid();
Model.Project_Sys_Set batch = BLL.Project_SysSetService.GetSysSetBySetId("5", this.CurrUser.LoginProjectId);
if (batch != null)
{
if (batch.SetValue.Contains("6")) //按管线组批
{
this.TbPipeline.Hidden = false;
var pipeline = (from x in db.HJGL_Pipeline
join y in db.HJGL_WeldJoint on x.PipelineId equals y.PipelineId
join z in db.HJGL_Batch_PointBatchItem on y.WeldJointId equals z.WeldJointId
where z.PointBatchId == this.PointBatchId
select x).FirstOrDefault();
if (pipeline != null)
{
this.lbPipelineCode.Text = pipeline.PipelineCode;
Model.Base_DetectionRate rate = BLL.Base_DetectionRateService.GetDetectionRateByDetectionRateId(pipeline.DetectionRateId);
if (rate != null)
{
this.lbRate.Text = rate.DetectionRateValue + "%";
int totalJointCount = db.HJGL_WeldJoint.Count(x => x.PipelineId == pipeline.PipelineId);
int needJointNum = Convert.ToInt32(Math.Ceiling((totalJointCount * rate.DetectionRateValue.Value) * 0.01));
this.lbNeedJointNum.Text = needJointNum.ToString();
var pointJointNum = (from x in db.HJGL_Batch_PointBatchItem
join y in db.HJGL_WeldJoint on x.WeldJointId equals y.WeldJointId
where y.PipelineId == pipeline.PipelineId && x.PointState == "1"
select x).Count();
this.lbPointJointNum.Text = pointJointNum.ToString();
this.lbLastJointNum.Text = (needJointNum - pointJointNum).ToString();
}
}
}
else //不按管线组批
{
this.TbNotPipeline.Hidden = false;
string unitWorkId = this.tvControlItem.SelectedNode.ParentNode.ParentNode.ParentNode.NodeID;
string rateStr = this.tvControlItem.SelectedNode.ParentNode.Text;
string rateId = this.tvControlItem.SelectedNode.ParentNode.NodeID.Split('|')[0];
string detectionType = this.tvControlItem.SelectedNode.ParentNode.ParentNode.NodeID.Split('|')[0];
this.lbTotalJointNum.Label = "本单位工程检测比例为" + rateStr + "的焊口总数";
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();
this.lbTotalJointNum.Text = totalJointNum.ToString();
Model.Base_DetectionRate rate = BLL.Base_DetectionRateService.GetDetectionRateByDetectionRateId(rateId);
if (rate != null)
{
int needJointNum = Convert.ToInt32(Math.Ceiling((totalJointNum * rate.DetectionRateValue.Value) * 0.01));
this.lbNeedJointNum2.Text = needJointNum.ToString();
var pointJointNum = (from x in db.HJGL_Batch_PointBatchItem
join y in db.HJGL_Batch_PointBatch on x.PointBatchId equals y.PointBatchId
where y.DetectionRateId == rateId && y.UnitWorkId == unitWorkId && y.DetectionTypeId == detectionType
&& x.PointState == "1"
select x).Count();
this.lbPointJointNum2.Text = pointJointNum.ToString();
this.lbLastJointNum2.Text = (needJointNum - pointJointNum).ToString();
}
}
}
}
//Model.Parameter3D parameter3D = new Model.Parameter3D();
//Model.ColorModel colorModel = new Model.ColorModel();
//colorModel = BLL.Project_SysSetService.GetColorModel(this.CurrUser.LoginProjectId);
//parameter3D.ColorModel = colorModel;
//parameter3D.TagNum = "/E-9001,/E-9002";
//parameter3D.ButtonType = "0,4";
//ctlAuditFlow.Url_item = BLL.Project_SysSetService.GetAvevaNetUrl(this.CurrUser.LoginProjectId) + "item/IPE%7CVPD%7CArea-15A";
//ctlAuditFlow.data = parameter3D;
//ctlAuditFlow.BindData();
}
#endregion
#region
#region
/// <summary>
/// 加载页面输入提交信息
/// </summary>
private void PageInfoLoad()
{
this.txtStartDate.Text = string.Empty;
this.txtEndDate.Text = string.Empty;
this.txtState.Text = "未关闭";
Model.HJGL_Batch_PointBatch pointBatch = BLL.PointBatchService.GetPointBatchById(this.PointBatchId);
if (pointBatch != null)
{
this.txtPointBatchCode.Text = pointBatch.PointBatchCode;
if (pointBatch.StartDate.HasValue)
{
this.txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", pointBatch.StartDate);
}
if (pointBatch.EndDate.HasValue)
{
this.txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", pointBatch.EndDate);
this.txtState.Text = "已关闭";
}
}
var trustItem = (from x in Funs.DB.HJGL_Batch_BatchTrustItem
join y in Funs.DB.HJGL_Batch_PointBatchItem on x.PointBatchItemId equals y.PointBatchItemId
where y.PointBatchId == this.PointBatchId
select x).FirstOrDefault();
if (trustItem != null)
{
this.txtPointState.Text = "不可调整";
}
else
{
if (pointBatch != null)
{
if (pointBatch.IsClosed == true)
{
this.txtPointState.Text = "不可调整";
}
else
{
this.txtPointState.Text = "可调整";
}
}
}
}
#endregion
/// <summary>
/// 数据绑定
/// </summary>
private void BindGrid()
{
this.PageInfoLoad();
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 PointBatchId=@PointBatchId";
List<SqlParameter> listStr = new List<SqlParameter>();
if (!string.IsNullOrEmpty(PointBatchId))
{
listStr.Add(new SqlParameter("@PointBatchId", this.PointBatchId));
}
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();
for (int i = 0; i < this.Grid1.Rows.Count; i++)
{
this.Grid1.Rows[i].CellCssClasses[3] = null;
this.Grid1.Rows[i].CellCssClasses[6] = null;
var pointItem = BLL.PointBatchDetailService.GetBatchDetailById(this.Grid1.Rows[i].DataKeys[0].ToString());
if (pointItem != null)
{
if (pointItem.PointState != null)
{
this.Grid1.Rows[i].CellCssClasses[3] = "colorredBlue";
this.Grid1.Rows[i].CellCssClasses[6] = "colorredBlue";
}
}
}
}
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void TextBox_TextChanged(object sender, EventArgs e)
{
this.BindGrid();
}
protected void btnQuery_Click(object sender, EventArgs e)
{
this.BindGrid();
}
#endregion
#region
#region
/// <summary>
/// 页索引改变事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
BindGrid();
}
#endregion
#region
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort(object sender, GridSortEventArgs e)
{
BindGrid();
}
#endregion
#region
/// <summary>
/// 分页选择下拉改变事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
BindGrid();
}
#endregion
#endregion
#region
/// <summary>
/// 批关闭
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
this.BindGrid();
}
#region
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Tree_TextChanged(object sender, EventArgs e)
{
this.InitTreeMenu();
}
#endregion
#endregion
#region
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnClose_Click(object sender, EventArgs e)
{
var batch = BLL.PointBatchService.GetPointBatchById(this.PointBatchId);
if (batch != null)
{
if (!batch.EndDate.HasValue)
{
PointBatchService.UpdateBatchIsClosed(this.PointBatchId, DateTime.Now);
/*PointBatchService.UpdateBatchIsClosed2(this.PointBatchId, DateTime.Now);
//生成委托单
Model.HJGL_Batch_BatchTrust newBatchTrust = new Model.HJGL_Batch_BatchTrust();
var project = BLL.ProjectService.GetProjectByProjectId(batch.ProjectId);
var unit = BLL.UnitService.GetUnitByUnitId(batch.UnitId);
var area = BLL.UnitWorkService.getUnitWorkByUnitWorkId(batch.UnitWorkId);
var ndt = BLL.Base_DetectionTypeService.GetDetectionTypeByDetectionTypeId(batch.DetectionTypeId);
var rate = BLL.Base_DetectionRateService.GetDetectionRateByDetectionRateId(batch.DetectionRateId);
string perfix = string.Empty;
newBatchTrust.TrustBatchCode = batch.PointBatchCode.Replace("-DK-", "-WT-");
string trustBatchId = SQLHelper.GetNewID(typeof(Model.HJGL_Batch_BatchTrust));
newBatchTrust.TrustBatchId = trustBatchId;
newBatchTrust.TrustDate = DateTime.Now;
newBatchTrust.ProjectId = batch.ProjectId;
newBatchTrust.PointBatchId = batch.PointBatchId;
newBatchTrust.UnitId = batch.UnitId;
newBatchTrust.UnitWorkId = batch.UnitWorkId;
newBatchTrust.DetectionTypeId = batch.DetectionTypeId;
newBatchTrust.DetectionRateId = batch.DetectionRateId;
newBatchTrust.PointBatchId = this.PointBatchId;
BLL.Batch_BatchTrustService.AddBatchTrust(newBatchTrust); // 新增委托单*/
this.BindGrid();
Alert.ShowInTop("关批成功!", MessageBoxIcon.Success);
}
else
{
Alert.ShowInTop("批已关闭!", MessageBoxIcon.Success);
}
}
else
{
Alert.ShowInTop("请选择检验批!", MessageBoxIcon.Success);
}
}
#endregion
#region
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAutoPoint_Click(object sender, EventArgs e)
{
var batch = BLL.PointBatchService.GetPointBatchById(this.PointBatchId);
if (!batch.EndDate.HasValue)
{
BLL.PointBatchDetailService.AutoPoint(this.PointBatchId);
this.BindGrid();
Alert.ShowInTop("已成功点口!", MessageBoxIcon.Success);
}
else
{
Alert.ShowInTop("批已关闭,不能自动点口!", MessageBoxIcon.Success);
}
}
protected void btnManual_Click(object sender, EventArgs e)
{
var batch = BLL.PointBatchService.GetPointBatchById(this.PointBatchId);
if (!batch.EndDate.HasValue)
{
if (!string.IsNullOrEmpty(Grid1.SelectedRowID))
{
Model.SGGLDB db = Funs.DB;
var weldJoint = (from x in db.HJGL_WeldJoint
join y in db.HJGL_Batch_PointBatchItem on x.WeldJointId equals y.WeldJointId
where y.PointBatchItemId == Grid1.SelectedRowID
select x).FirstOrDefault();
Model.Project_Sys_Set batchSet = BLL.Project_SysSetService.GetSysSetBySetId("5", this.CurrUser.LoginProjectId);
if (batchSet != null && weldJoint != null)
{
int needJointNum = 0;
int pointNumG = 0;
int pointNumA = 0;
if (batchSet.SetValue.Contains("6")) //按管线组批
{
var pipeline = (from x in db.HJGL_Pipeline
join y in db.HJGL_WeldJoint on x.PipelineId equals y.PipelineId
join z in db.HJGL_Batch_PointBatchItem on y.WeldJointId equals z.WeldJointId
where z.PointBatchId == this.PointBatchId
select x).FirstOrDefault();
if (pipeline != null)
{
this.lbPipelineCode.Text = pipeline.PipelineCode;
Model.Base_DetectionRate rate = BLL.Base_DetectionRateService.GetDetectionRateByDetectionRateId(pipeline.DetectionRateId);
if (rate != null)
{
int totalJointCount = db.HJGL_WeldJoint.Count(x => x.PipelineId == pipeline.PipelineId);
needJointNum = Convert.ToInt32(Math.Ceiling((totalJointCount * rate.DetectionRateValue.Value) * 0.01));
// 安装口检测数量
pointNumG = Convert.ToInt32(Math.Ceiling(needJointNum * 0.4));
// 预制口要检测的数量
pointNumA = needJointNum - pointNumG;
var pointGNum = (from x in db.HJGL_Batch_PointBatchItem
join y in db.HJGL_WeldJoint on x.WeldJointId equals y.WeldJointId
where y.PipelineId == pipeline.PipelineId && x.PointState == "1" && y.JointAttribute == "安装口"
select x).Count();
var pointNotGNum = (from x in db.HJGL_Batch_PointBatchItem
join y in db.HJGL_WeldJoint on x.WeldJointId equals y.WeldJointId
where y.PipelineId == pipeline.PipelineId && x.PointState == "1" && y.JointAttribute == "预制口"
select x).Count();
if (weldJoint.JointAttribute == "安装口" && pointGNum >= pointNumG)
{
Alert.ShowInTop("安装口已达检测标准,无需再点此安装口!", MessageBoxIcon.Warning);
return;
}
if (weldJoint.JointAttribute == "预制口" && pointNotGNum >= pointNumA)
{
Alert.ShowInTop("预制口已达检测标准,无需再点此预制口!", MessageBoxIcon.Warning);
return;
}
}
}
}
else //不按管线组批
{
string unitWorkId = this.tvControlItem.SelectedNode.ParentNode.ParentNode.ParentNode.NodeID;
string rateId = this.tvControlItem.SelectedNode.ParentNode.NodeID.Split('|')[0];
string detectionType = this.tvControlItem.SelectedNode.ParentNode.ParentNode.NodeID.Split('|')[0];
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();
Model.Base_DetectionRate rate = BLL.Base_DetectionRateService.GetDetectionRateByDetectionRateId(rateId);
if (rate != null)
{
needJointNum = Convert.ToInt32(Math.Ceiling((totalJointNum * rate.DetectionRateValue.Value) * 0.01));
// 安装口检测数量
pointNumG = Convert.ToInt32(Math.Ceiling(needJointNum * 0.4));
// 预制口要检测的数量
pointNumA = needJointNum - pointNumG;
var pointGNum = (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" && z.JointAttribute == "安装口"
select x).Count();
var pointNotGNum = (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" && z.JointAttribute == "预制口"
select x).Count();
if (weldJoint.JointAttribute == "安装口" && pointGNum >= pointNumG)
{
Alert.ShowInTop("安装口已达检测标准,无需再点此安装口!", MessageBoxIcon.Warning);
return;
}
if (weldJoint.JointAttribute == "预制口" && pointNotGNum >= pointNumA)
{
Alert.ShowInTop("预制口已达检测标准,无需再点此预制口!", MessageBoxIcon.Warning);
return;
}
}
}
}
PointBatchDetailService.UpdatePointBatchDetail(Grid1.SelectedRowID, "1", System.DateTime.Now);
this.BindGrid();
tvControlItem_NodeCommand(null, null);
Alert.ShowInTop("已成功点口!", MessageBoxIcon.Success);
}
else
{
Alert.ShowInTop("请选择点口!", MessageBoxIcon.Warning);
}
}
else
{
Alert.ShowInTop("批已关闭,不能点口!", MessageBoxIcon.Success);
}
}
/// <summary>
/// 手动点口关闭
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnPointAudit_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_PointBatchMenuId, Const.BtnPointAudit))
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PointAudit.aspx", "点口审核 - ")));
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
return;
}
}
/// <summary>
/// 打开重新点口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnbtnOpenResetPoint_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_PointBatchMenuId, Const.BtnOpenResetPoint))
{
if (!string.IsNullOrEmpty(this.PointBatchId))
{
var trustItem = (from x in Funs.DB.HJGL_Batch_BatchTrustItem
join y in Funs.DB.HJGL_Batch_PointBatchItem on x.PointBatchItemId equals y.PointBatchItemId
where y.PointBatchId == this.PointBatchId
select x).FirstOrDefault();
if (trustItem != null)
{
Alert.ShowInTop("该批次不可调整!");
return;
}
Model.HJGL_Batch_PointBatch pointBatch = BLL.PointBatchService.GetPointBatchById(this.PointBatchId);
if (pointBatch != null && pointBatch.IsClosed == true)
{
Alert.ShowInTop("该批次不可调整!");
return;
}
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("OpenResetPoint.aspx?PointBatchId={0}", this.PointBatchId, "重新点口 - ")));
}
else
{
Alert.ShowInTop("请选择要重新点口的批!");
}
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
return;
}
}
/// <summary>
/// 重新选择扩口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSelectExpandPoint_Click(object sender, EventArgs e)
{
}
#endregion
#region
/// <summary>
/// 生成
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnGenerate_Click(object sender, EventArgs e)
{
//if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_PointBatchMenuId, Const.BtnGenerate))
//{
// var getViewGenerateTrustLists = (from x in Funs.DB.View_GenerateTrust where x.ProjectId == this.CurrUser.LoginProjectId select x).ToList();
// if (getViewGenerateTrustLists.Count() > 0)
// {
// var getUnit = BLL.Base_UnitService.GetUnit(this.CurrUser.UnitId);
// if (getUnit == null || getUnit.UnitTypeId == "1" || getUnit.UnitTypeId == "2" || getUnit.UnitTypeId == "3")
// {
// GenerateTrust(getViewGenerateTrustLists);
// }
// else
// {
// var getUnitViewGenerateTrustLists = getViewGenerateTrustLists.Where(x => x.UnitId == this.CurrUser.UnitId);
// if (getUnitViewGenerateTrustLists.Count() > 0)
// {
// // 当前单位未委托批
// GenerateTrust(getUnitViewGenerateTrustLists.ToList());
// }
// else
// {
// Alert.ShowInTop("所属单位点口已全部生成委托单!", MessageBoxIcon.Warning);
// }
// }
// BLL.Sys_LogService.AddLog(BLL.Const.System_6, this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_PointBatchMenuId, Const.BtnGenerate, null);
// this.InitTreeMenu();//加载树
// this.BindGrid();
// }
// else
// {
// Alert.ShowInTop("已全部生成委托单!", MessageBoxIcon.Warning);
// }
//}
//else
//{
// ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
// return;
//}
}
/// <summary>
/// 生成委托单
/// </summary>
/// <param name="unitId"></param>
//private void GenerateTrust(List<Model.View_GenerateTrust> GenerateTrustLists)
//{
//}
#endregion
#region
#endregion
#region
/// <summary>
/// 取消扩透
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnCancel_Click(object sender, EventArgs e)
{
}
#endregion
#region
/// <summary>
/// 打印
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnPrint_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(this.PointBatchId))
{
string parm = string.Empty;
var pointBatch = Funs.DB.View_HJGL_Batch_PointBatch.FirstOrDefault(x => x.PointBatchId == this.PointBatchId);
if (pointBatch != null)
{
if (!string.IsNullOrEmpty(pointBatch.UnitCode))
{
parm = pointBatch.UnitCode;
}
else
{
parm = "NULL";
}
if (!string.IsNullOrEmpty(pointBatch.ProjectCode))
{
parm = parm + "|" + pointBatch.ProjectCode;
}
else
{
parm = parm + "|" + "NULL";
}
if (!string.IsNullOrEmpty(pointBatch.DetectionTypeCode))
{
parm = parm + "|" + "NDE Type" + pointBatch.DetectionTypeCode;
}
else
{
parm = parm + "|" + "NDE Type" + "NULL";
}
// PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../../Report/ReportPrint.aspx?report=1&pointBatchId={0}&parm={1}", this.PointBatchId, parm, "编辑 - ")));
}
}
}
#endregion
private string GetNewTrust(string code)
{
int r_num = 0;
string newTrustCode = string.Empty;
if (code.Contains("A") || code.Contains("B") || code.Contains("C"))
{
//int indexR = code.LastIndexOf("R");
//if (indexR > 0)
//{
// try
// {
// r_num = Convert.ToInt32(code.Substring(indexR + 1, 1)) + 1;
// newTrustCode = code.Substring(0, code.Length - 1) + r_num.ToString();
// }
// catch { }
//}
string s = code.Substring(code.Length - 1, 1);
string m = string.Empty;
if (s == "A")
{
m = "B";
}
else if (s == "B")
{
m = "C";
}
newTrustCode = code.Substring(0, code.Length - 1) + m;
}
else
{
newTrustCode = code + "A";
}
return newTrustCode;
}
/// <summary>
/// 已检测口明细
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnShow_Click(object sender, EventArgs e)
{
string unitWorkId = this.tvControlItem.SelectedNode.ParentNode.ParentNode.ParentNode.NodeID;
string rateId = this.tvControlItem.SelectedNode.ParentNode.NodeID.Split('|')[0];
string detectionType = this.tvControlItem.SelectedNode.ParentNode.ParentNode.NodeID.Split('|')[0];
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PointWeldJointView.aspx?unitWorkId={0}&rateId={1}&detectionType={2}", unitWorkId, rateId, detectionType, "新增 - ")));
}
}
}