Basf_TCC7/HJGL/FineUIPro.Web/WeldingProcess/TrustManage/OpenResetPoint.aspx.cs

171 lines
7.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using BLL;
namespace FineUIPro.Web.WeldingProcess.TrustManage
{
public partial class OpenResetPoint : 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)
{
if (!IsPostBack)
{
this.PointBatchId = Request.Params["PointBatchId"];
this.BindGrid();
}
}
#endregion
#region
/// <summary>
/// 数据绑定
/// </summary>
private void BindGrid()
{
string strSql = @"SELECT PointBatchItem.PointBatchItemId,PointBatch.PointBatchCode, jot.WeldJointCode,
ins.InstallationCode, WorkArea.WorkAreaCode,unit.UnitCode,
(CASE PointBatchItem.IsAudit WHEN 1 THEN '是' ELSE '否' END) AS PointIsAudit,
jot.JointArea,WeldingDaily.WeldingDate,PipingClass.PipingClassName,
(CASE WHEN jot.BackingWelderId!=jot.CoverWelderId THEN backingWelder.WelderCode+'/'+coverWelder.WelderCode ELSE backingWelder.WelderCode END) AS WelderCode--焊工号
FROM Batch_PointBatchItem AS PointBatchItem
LEFT JOIN Batch_PointBatch AS PointBatch ON PointBatch.PointBatchId=PointBatchItem.PointBatchId
LEFT JOIN Pipeline_WeldJoint AS jot ON jot.WeldJointId=PointBatchItem.WeldJointId
LEFT JOIN Pipeline_Pipeline AS Pipeline ON Pipeline.PipelineId=jot.PipelineId
LEFT JOIN dbo.Welder_Welder backingWelder ON backingWelder.WelderId = jot.BackingWelderId
LEFT JOIN dbo.Welder_Welder coverWelder ON coverWelder.WelderId = jot.CoverWelderId
LEFT JOIN Project_WorkArea AS WorkArea ON WorkArea.WorkAreaId=Pipeline.WorkAreaId
LEFT JOIN Pipeline_WeldingDaily AS WeldingDaily ON WeldingDaily.WeldingDailyId=jot.WeldingDailyId
LEFT JOIN Base_PipingClass AS PipingClass ON PipingClass.PipingClassId=Pipeline.PipingClassId
LEFT JOIN dbo.Project_Installation ins ON ins.InstallationId = PointBatch.InstallationId
LEFT JOIN dbo.Base_Unit unit ON unit.UnitId = PointBatch.UnitId
WHERE PointBatchItem.PointState IS NULL
AND PointBatch.ProjectId=@ProjectId AND PointBatchItem.PointBatchId=@PointBatchId";
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
listStr.Add(new SqlParameter("@PointBatchId", this.PointBatchId));
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();
//string ids = string.Empty;
//for (int i = 0; i < this.Grid1.Rows.Count; i++)
//{
// var pointItem = BLL.Batch_PointBatchItemService.GetPointBatchItemByPointBatchItemId(this.Grid1.Rows[i].DataKeys[0].ToString());
// if (pointItem != null && pointItem.PointState == "1")
// {
// ids += pointItem.PointBatchItemId + ",";
// }
//}
//if (!string.IsNullOrEmpty(ids))
//{
// ids = ids.Substring(0, ids.Length - 1);
// this.Grid1.SelectedRowIDArray = ids.Split(',');
//}
}
#endregion
#region
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort(object sender, GridSortEventArgs e)
{
this.BindGrid();
}
#endregion
#region
/// <summary>
/// 确定按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAccept_Click(object sender, EventArgs e)
{
Model.HJGLDB db = Funs.DB;
string[] selectRowId = Grid1.SelectedRowIDArray;
if (selectRowId.Count() > 0)
{
foreach (var item in selectRowId)
{
BLL.Batch_PointBatchItemService.UpdatePointBatchItem(item, "1", DateTime.Now, null);
var pWelder = from x in db.Batch_PointBatchItem
join y in db.Pipeline_WeldJoint on x.WeldJointId equals y.WeldJointId
where x.PointBatchItemId == item
select new { x.PointBatchId, y.BackingWelderId };
if (pWelder.Count() > 0)
{
// 查找该焊工所在批所有未关闭的焊口
var pItem = (from x in db.Batch_PointBatchItem
join y in db.Pipeline_WeldJoint on x.WeldJointId equals y.WeldJointId
where x.IsCompletedPoint == false && x.PointBatchId == pWelder.First().PointBatchId
&& y.BackingWelderId == pWelder.First().BackingWelderId
select x).ToList();
if (pItem.Count() > 0)
{
foreach (var q in pItem)
{
q.IsCompletedPoint = true;
db.SubmitChanges();
}
}
}
}
}
BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_PointManageMenuId, Const.BtnOpenResetPoint, this.PointBatchId);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
#endregion
protected void btnCancelAccept_Click(object sender, EventArgs e)
{
Model.HJGLDB db = Funs.DB;
string[] selectRowId = Grid1.SelectedRowIDArray;
if (selectRowId.Count() > 0)
{
foreach (var item in selectRowId)
{
BLL.Batch_PointBatchItemService.UpdatePointBatchItem(item, null, null, null);
}
}
BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_PointManageMenuId, Const.BtnOpenResetPoint, this.PointBatchId);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
}
}