1091 lines
50 KiB
C#
1091 lines
50 KiB
C#
using BLL;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Data.SqlClient;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Web;
|
||
|
||
namespace FineUIPro.Web.HJGL.PointTrust
|
||
{
|
||
public partial class TrustBatch : PageBase
|
||
{
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (!IsPostBack)
|
||
{
|
||
BLL.UnitService.InitUnitByProjectIdUnitTypeDropDownList(this.drpUnit, this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2, true);
|
||
this.txtTrustDateMonth.Text = string.Format("{0:yyyy-MM}", DateTime.Now);
|
||
this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
|
||
//BLL.Base_UnitService.InitProjectUnitDropDownList(this.drpNDEUnit, false, this.CurrUser.LoginProjectId, BLL.Const.UnitType_4, "请选择");
|
||
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.txtTrustDateMonth.Text.Trim() + "-01").AddMonths(1)
|
||
&& x.StartDate >= Convert.ToDateTime(this.txtTrustDateMonth.Text.Trim() + "-01")
|
||
select x;
|
||
if (p.Count() > 0)
|
||
{
|
||
TreeNode newNode = new TreeNode();
|
||
newNode.Text = "探伤类型";
|
||
newNode.NodeID = "探伤类型";
|
||
node.Nodes.Add(newNode);
|
||
}
|
||
|
||
}
|
||
#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.txtTrustDateMonth.Text.Trim() + "-01").AddMonths(1)
|
||
&& x.StartDate >= Convert.ToDateTime(this.txtTrustDateMonth.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.txtTrustDateMonth.Text.Trim() + "-01").AddMonths(1)
|
||
&& x.StartDate >= Convert.ToDateTime(this.txtTrustDateMonth.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);
|
||
}
|
||
pointManages = pointManages.OrderBy(x => x.StartDate);
|
||
|
||
foreach (var item in pointManages)
|
||
{
|
||
var pipeline = PointBatchService.GetPointBatchById(item.PointBatchId);
|
||
string startdate = string.Format("{0:yyyy-MM-dd}", pipeline.StartDate);
|
||
|
||
|
||
TreeNode newNode = new TreeNode
|
||
{
|
||
NodeID = item.PointBatchId,
|
||
ToolTip = "批",
|
||
EnableClickEvent = true,
|
||
};
|
||
string code = "DK-" + item.PointBatchCode.Substring(item.PointBatchCode.Length - 4);
|
||
// 未委托批次红色显示
|
||
if (BLL.Batch_BatchTrustService.GetBatchTrustViewByPointBatchId(item.PointBatchId) == null)
|
||
{
|
||
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)
|
||
{
|
||
PageInfo();
|
||
this.BindGrid();
|
||
}
|
||
#endregion
|
||
|
||
private void PageInfo()
|
||
{
|
||
this.txtTrustBatchCode.Text = string.Empty;
|
||
this.txtTrustDate.Text = string.Empty;
|
||
this.txtDetectionTypeCode.Text = string.Empty;
|
||
this.lbNDEUnit.Text = string.Empty;
|
||
Model.View_Batch_BatchTrust trust = BLL.Batch_BatchTrustService.GetBatchTrustViewByPointBatchId(this.tvControlItem.SelectedNodeID);
|
||
Model.HJGL_Batch_PointBatch batch = BLL.PointBatchService.GetPointBatchById(this.tvControlItem.SelectedNodeID);
|
||
if (trust != null)
|
||
{
|
||
if (batch.IsClosed == true)
|
||
{
|
||
lbIsTrust.Text = "无需委托";
|
||
}
|
||
else
|
||
{
|
||
this.txtTrustBatchCode.Text = trust.TrustBatchCode;
|
||
if (trust.TrustDate != null)
|
||
{
|
||
this.txtTrustDate.Text = string.Format("{0:yyyy-MM-dd}", trust.TrustDate);
|
||
}
|
||
this.txtDetectionTypeCode.Text = trust.DetectionTypeCode;
|
||
lbIsTrust.Text = "已委托";
|
||
if (trust.IsAudit == true)
|
||
{
|
||
lbIsAudit.Text = "已审核";
|
||
}
|
||
else
|
||
{
|
||
lbIsAudit.Text = "未审核";
|
||
}
|
||
if (!string.IsNullOrEmpty(trust.NDEUnit))
|
||
{
|
||
var unit = BLL.UnitService.GetUnitByUnitId(trust.NDEUnit);
|
||
if (unit != null)
|
||
{
|
||
lbNDEUnit.Text = unit.UnitName;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (batch != null)
|
||
{
|
||
lbIsTrust.Text = "未委托";
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <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_TrustBatchMenuId, Const.BtnGenerate))
|
||
{
|
||
//PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PointAudit.aspx", "委托 - ")));
|
||
Model.HJGL_Batch_PointBatch pointBatch = BLL.PointBatchService.GetPointBatchById(this.tvControlItem.SelectedNodeID);
|
||
if (pointBatch != null)
|
||
{
|
||
if (pointBatch.IsClosed == true)
|
||
{
|
||
ShowNotify("该检验批无需委托!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
Model.View_Batch_BatchTrust trust = BLL.Batch_BatchTrustService.GetBatchTrustViewByPointBatchId(this.tvControlItem.SelectedNodeID);
|
||
if (trust != null)
|
||
{
|
||
ShowNotify("该检验批已生成委托!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PointTrust.aspx?PointBatchId=" + this.tvControlItem.SelectedNodeID, "委托 - ")));
|
||
}
|
||
else
|
||
{
|
||
ShowNotify("请选择检验批!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
|
||
#region 数据绑定
|
||
/// <summary>
|
||
/// 数据绑定
|
||
/// </summary>
|
||
private void BindGrid()
|
||
{
|
||
if (this.tvControlItem.SelectedNode != null)
|
||
{
|
||
Model.View_Batch_BatchTrust trust = BLL.Batch_BatchTrustService.GetBatchTrustViewByPointBatchId(this.tvControlItem.SelectedNodeID);
|
||
if (trust == null) //为生成委托
|
||
{
|
||
string strSql = @"SELECT * FROM dbo.View_GenerateTrustItem d WHERE PointBatchId=@PointBatchId ";
|
||
List<SqlParameter> listStr = new List<SqlParameter>
|
||
{
|
||
|
||
};
|
||
listStr.Add(new SqlParameter("@PointBatchId", this.tvControlItem.SelectedNodeID));
|
||
SqlParameter[] parameter = listStr.ToArray();
|
||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||
|
||
// 2.获取当前分页数据
|
||
//var table = this.GetPagedDataTable(Grid1, tb1);
|
||
Grid1.RecordCount = tb.Rows.Count;
|
||
tb = GetFilteredTable(Grid1.FilteredData, tb);
|
||
var table = this.GetPagedDataTable(Grid1, tb);
|
||
Grid1.DataSource = table;
|
||
Grid1.DataBind();
|
||
}
|
||
else
|
||
{
|
||
string strSql = @"SELECT * FROM dbo.View_Batch_BatchTrustItem d WHERE TrustBatchId=@TrustBatchId ";
|
||
List<SqlParameter> listStr = new List<SqlParameter>
|
||
{
|
||
|
||
};
|
||
listStr.Add(new SqlParameter("@TrustBatchId", trust.TrustBatchId));
|
||
SqlParameter[] parameter = listStr.ToArray();
|
||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||
|
||
// 2.获取当前分页数据
|
||
//var table = this.GetPagedDataTable(Grid1, tb1);
|
||
Grid1.RecordCount = tb.Rows.Count;
|
||
tb = GetFilteredTable(Grid1.FilteredData, tb);
|
||
var table = this.GetPagedDataTable(Grid1, tb);
|
||
Grid1.DataSource = table;
|
||
Grid1.DataBind();
|
||
}
|
||
}
|
||
}
|
||
#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.InitTreeMenu();//加载树
|
||
this.BindGrid();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void TextBox_TextChanged(object sender, EventArgs e)
|
||
{
|
||
this.BindGrid();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Tree_TextChanged(object sender, EventArgs e)
|
||
{
|
||
this.InitTreeMenu();
|
||
this.BindGrid();
|
||
}
|
||
#endregion
|
||
|
||
protected void btnAudit_Click(object sender, EventArgs e)
|
||
{
|
||
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_TrustBatchMenuId, Const.BtnAuditing))
|
||
{
|
||
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
|
||
{
|
||
string trustBatchId = this.tvControlItem.SelectedNodeID;
|
||
BLL.Batch_BatchTrustService.UpdateBatchTrustAudit(trustBatchId, true);
|
||
PageInfo();
|
||
ShowNotify("该委托单已审核!", MessageBoxIcon.Success);
|
||
}
|
||
else
|
||
{
|
||
ShowNotify("请选择要审核委托单!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
|
||
protected void btnDelete_Click(object sender, EventArgs e)
|
||
{
|
||
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_TrustBatchMenuId, Const.BtnDelete))
|
||
{
|
||
Model.SGGLDB db = Funs.DB;
|
||
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
|
||
{
|
||
string trustBatchId = this.tvControlItem.SelectedNodeID;
|
||
string trustBatchCode = this.tvControlItem.SelectedNode.Text;
|
||
var trust = BLL.Batch_BatchTrustService.GetBatchTrustById(trustBatchId);
|
||
|
||
if (trust.IsAudit == true)
|
||
{
|
||
ShowNotify("该委托单已审核,不能删除!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
var batchItem = from y in db.HJGL_Batch_BatchTrustItem where y.TrustBatchId == trustBatchId select y;
|
||
foreach (var item in batchItem)
|
||
{
|
||
Model.HJGL_Batch_PointBatchItem pointBatchItem = null;
|
||
if (item.PointBatchItemId != null)
|
||
{
|
||
pointBatchItem = db.HJGL_Batch_PointBatchItem.FirstOrDefault(x => x.PointBatchItemId == item.PointBatchItemId);
|
||
}
|
||
else
|
||
{
|
||
pointBatchItem = db.HJGL_Batch_PointBatchItem.FirstOrDefault(x => x.RepairRecordId == item.RepairRecordId);
|
||
}
|
||
if (pointBatchItem != null)
|
||
{
|
||
pointBatchItem.IsBuildTrust = null;
|
||
}
|
||
}
|
||
|
||
db.HJGL_Batch_BatchTrustItem.DeleteAllOnSubmit(batchItem);
|
||
db.HJGL_Batch_BatchTrust.DeleteOnSubmit(trust);
|
||
db.SubmitChanges();
|
||
this.InitTreeMenu();
|
||
this.BindGrid();
|
||
ShowNotify("已删除委托单:" + trustBatchCode, MessageBoxIcon.Success);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
|
||
protected void btnPrint1_Click(object sender, EventArgs e)
|
||
{
|
||
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_TrustBatchMenuId, Const.BtnPrint))
|
||
{
|
||
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
|
||
{
|
||
string varValue = string.Empty;
|
||
string pointBatchId = this.tvControlItem.SelectedNodeID;
|
||
|
||
Model.View_Batch_BatchTrust trust = BLL.Batch_BatchTrustService.GetBatchTrustViewByPointBatchId(pointBatchId);
|
||
if (trust != null)
|
||
{
|
||
varValue = trust.TrustBatchCode + "|" + trust.TrustDate.Value.Date + "|";
|
||
var project = BLL.ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId);
|
||
if (project != null)
|
||
{
|
||
varValue = varValue + project.ProjectName + "|" + project.ProjectCode + "|";
|
||
}
|
||
//varValue = varValue + trust.InstallationName + "|" + trust.InstallationCode;
|
||
if (!string.IsNullOrEmpty(varValue))
|
||
{
|
||
varValue = HttpUtility.UrlEncodeUnicode(varValue);
|
||
}
|
||
|
||
//PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0", BLL.Const.CheckTrustReport, trust.TrustBatchId, varValue)));
|
||
}
|
||
else
|
||
{
|
||
ShowNotify("尚未生成委托,无法打印!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
protected void btnPrint_Click(object sender, EventArgs e)
|
||
{
|
||
// string reportId = this.tvControlItem.SelectedNode.NodeID;
|
||
// var trust = BLL.TrustManageEditService.GetCH_TrustByID(reportId);
|
||
DataTable dt = new DataTable("Table1");
|
||
dt.Columns.Add("ProjectName", typeof(String));
|
||
dt.Columns.Add("CH_CheckUnit", typeof(String));
|
||
dt.Columns.Add("WorkAreaName", typeof(String));
|
||
dt.Columns.Add("CH_TrustUnit", typeof(String));
|
||
dt.Columns.Add("CH_TrustMan", typeof(String));
|
||
dt.Columns.Add("CH_TrustCode", typeof(String));
|
||
dt.Columns.Add("WorkAreaCode", typeof(String));
|
||
dt.Columns.Add("CH_NDTCriteria", typeof(String));
|
||
dt.Columns.Add("CH_WeldMethod", typeof(String));
|
||
dt.Columns.Add("CH_AcceptGrade", typeof(String));
|
||
dt.Columns.Add("CH_NDTMethod", typeof(String));
|
||
dt.Columns.Add("CH_SlopeType", typeof(String));
|
||
dt.Columns.Add("CH_NDTRate", typeof(String));
|
||
|
||
|
||
|
||
DataRow dr = dt.NewRow();
|
||
if (this.tvControlItem.SelectedNode == null)
|
||
{
|
||
Alert.ShowInTop("请选择要打印的委托单!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
string reportId = this.tvControlItem.SelectedNode.NodeID;
|
||
// Model.View_Batch_BatchTrust trust = BLL.Batch_BatchTrustService.GetBatchTrustViewByPointBatchId(this.tvControlItem.SelectedNodeID);
|
||
// Model.HJGL_Batch_PointBatch batch = BLL.PointBatchService.GetPointBatchById(this.tvControlItem.SelectedNodeID);
|
||
var trust = BLL.Batch_BatchTrustService.GetBatchTrustViewByPointBatchId(reportId);
|
||
var CH_WeldMethod = (from batch in Funs.DB.View_Batch_BatchTrustItem
|
||
join joint in Funs.DB.View_HJGL_WeldJoint on batch.WeldJointId equals joint.WeldJointId
|
||
where batch.TrustBatchId == trust.TrustBatchId
|
||
select joint.WeldingMethodCode).Distinct().ToList();
|
||
var CH_SlopeType = (from batch in Funs.DB.View_Batch_BatchTrustItem
|
||
join joint in Funs.DB.View_HJGL_WeldJoint on batch.WeldJointId equals joint.WeldJointId
|
||
where batch.TrustBatchId == trust.TrustBatchId
|
||
select joint.GrooveTypeCode).Distinct().ToList();
|
||
if (trust != null)
|
||
{
|
||
string varValue = string.Empty;
|
||
var projectName = BLL.ProjectService.GetProjectNameByProjectId(this.CurrUser.LoginProjectId);
|
||
|
||
dr["ProjectName"] = projectName;
|
||
if (!string.IsNullOrEmpty(trust.NDEUnit))
|
||
{
|
||
dr["CH_CheckUnit"] = BLL.UnitService.GetUnitNameByUnitId(trust.NDEUnit).ToString();
|
||
|
||
}
|
||
|
||
if (CH_WeldMethod.Count > 0)
|
||
{
|
||
dr["CH_WeldMethod"] = string.Join(",", CH_WeldMethod);
|
||
}
|
||
if (CH_SlopeType.Count > 0)
|
||
{
|
||
dr["CH_SlopeType"] = string.Join(",", CH_SlopeType);
|
||
}
|
||
if (!string.IsNullOrEmpty(trust.TrustBatchCode))
|
||
{
|
||
dr["CH_TrustCode"] = trust.TrustBatchCode;
|
||
|
||
}
|
||
/* if (!string.IsNullOrEmpty(trust.CH_NDTCriteria))
|
||
{
|
||
dr["CH_NDTCriteria"] = trust.CH_NDTCriteria;
|
||
}*/
|
||
if (!string.IsNullOrEmpty(trust.DetectionTypeCode))
|
||
{
|
||
dr["CH_NDTMethod"] = trust.DetectionTypeCode;
|
||
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(trust.DetectionRateId))
|
||
{
|
||
var list = BLL.Base_DetectionRateService.GetDetectionRateByDetectionRateId(trust.DetectionRateId);
|
||
if (list != null)
|
||
{
|
||
dr["CH_NDTRate"] = list.DetectionRateValue + "%";
|
||
|
||
}
|
||
|
||
}
|
||
|
||
var PworkArea = Funs.DB.WBS_UnitWork.FirstOrDefault(x => x.UnitWorkId == trust.UnitWorkId);
|
||
if (PworkArea != null)
|
||
{
|
||
//var cel = recordSheet.GetRow(3).CreateCell(1);
|
||
//cel.SetCellValue(PworkArea.WorkAreaCode);
|
||
//cel.CellStyle = styleCenter;
|
||
dr["WorkAreaName"] = PworkArea.UnitWorkName;
|
||
dr["WorkAreaCode"] = PworkArea.UnitWorkCode;
|
||
|
||
}
|
||
dt.Rows.Add(dr);
|
||
|
||
Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
|
||
keyValuePairs.Add("TrustBatchId", trust.TrustBatchId);
|
||
keyValuePairs.Add("totalUnit", "赛鼎工程有限公司");
|
||
var unitcheck = Funs.DB.Project_ProjectUnit.FirstOrDefault(x => x.ProjectId == trust.ProjectId && x.UnitType == Const.ProjectUnitType_3);
|
||
if (unitcheck != null && !string.IsNullOrEmpty(unitcheck.UnitId))
|
||
{
|
||
keyValuePairs.Add("supUnit", BLL.UnitService.GetUnitNameByUnitId(unitcheck.UnitId).ToString());
|
||
}
|
||
/* if (!string.IsNullOrEmpty(trust.CH_CheckUnit))
|
||
{
|
||
keyValuePairs.Add("CheckUnit", BLL.UnitService.GetUnitNameByUnitId(trust.CH_CheckUnit).ToString());
|
||
|
||
}
|
||
if (!string.IsNullOrEmpty(trust.CH_TrustUnit))
|
||
{
|
||
keyValuePairs.Add("ConUnit", BLL.UnitService.GetUnitNameByUnitId(trust.CH_TrustUnit).ToString());
|
||
|
||
}
|
||
*/
|
||
|
||
BLL.FastReportService.ResetData();
|
||
BLL.FastReportService.AddFastreportTable(dt);
|
||
BLL.FastReportService.AddFastreportParameter(keyValuePairs);
|
||
|
||
// Session["Table"] = dt;
|
||
// Session["CH_TrustID"] = reportId;
|
||
string initTemplatePath = "";
|
||
string rootPath = Server.MapPath("~/");
|
||
initTemplatePath = "File\\Fastreport\\管道焊口检测委托单NoPic.frx";
|
||
|
||
if (File.Exists(rootPath + initTemplatePath))
|
||
{
|
||
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../../Controls/Fastreport.aspx?ReportPath={0}", rootPath + initTemplatePath)));
|
||
|
||
|
||
}
|
||
//if (trust != null)
|
||
//{
|
||
// string varValue = string.Empty;
|
||
// var projectName = BLL.ProjectService.GetProjectNameByProjectId(this.CurrUser.LoginProjectId);
|
||
// var installation = BLL.Project_InstallationService.GetInstallationByInstallationId(trust.InstallationId);
|
||
|
||
|
||
// string rootPath = Server.MapPath("~/") + Const.ExcelUrl;
|
||
// //模板文件
|
||
// string TempletFileName = Server.MapPath("~/") + "File/Excel/HJGL_DataOut/管道焊口检测委托单.xlsx";
|
||
// //导出文件
|
||
// string filePath = rootPath + DateTime.Now.ToString("yyyyMMddhhmmss") + "\\";
|
||
// if (!Directory.Exists(filePath))
|
||
// {
|
||
// Directory.CreateDirectory(filePath);
|
||
// }
|
||
// string ReportFileName = filePath + "out.xlsx";
|
||
|
||
// FileStream file = new FileStream(TempletFileName, FileMode.Open, FileAccess.Read);
|
||
// XSSFWorkbook hssfworkbook = new XSSFWorkbook(file);
|
||
|
||
// ICellStyle styleCenter = hssfworkbook.CreateCellStyle();
|
||
// styleCenter.VerticalAlignment = VerticalAlignment.Center;
|
||
// styleCenter.Alignment = HorizontalAlignment.Center;
|
||
// styleCenter.BorderLeft = BorderStyle.Thin;
|
||
// styleCenter.BorderTop = BorderStyle.Thin;
|
||
// styleCenter.BorderRight = BorderStyle.Thin;
|
||
// styleCenter.BorderBottom = BorderStyle.Thin;
|
||
// styleCenter.WrapText = true;
|
||
// IFont font = styleCenter.GetFont(hssfworkbook);
|
||
// font.Color = 10;//颜色
|
||
// font.FontHeightInPoints = 10;//字体高度(与excel中的字号一致)
|
||
// styleCenter.SetFont(font);
|
||
// XSSFSheet recordSheet = (XSSFSheet)hssfworkbook.GetSheet("管道焊口检测委托单");
|
||
|
||
// // recordSheet.AddMergedRegion(new CellRangeAddress(0, 0, 8, 9));
|
||
|
||
|
||
// recordSheet.GetRow(1).CreateCell(8).SetCellValue(projectName.ToString());
|
||
// recordSheet.GetRow(1).GetCell(8).CellStyle = styleCenter;
|
||
// //recordSheet.GetRow(1).CreateCell(8).SetCellValue(installation.InstallationName);
|
||
// //recordSheet.GetRow(1).GetCell(8).CellStyle = styleCenter;
|
||
// if (!string.IsNullOrEmpty(trust.CH_CheckUnit))
|
||
// {
|
||
// // recordSheet.AddMergedRegion(new CellRangeAddress(2, 2, 1, 2));
|
||
// var cel = recordSheet.GetRow(3).CreateCell(1);
|
||
// cel.SetCellValue(BLL.UnitService.GetUnitNameByUnitId(trust.CH_CheckUnit).ToString());
|
||
// cel.CellStyle = styleCenter;
|
||
// }
|
||
// if (!string.IsNullOrEmpty(trust.CH_TrustMan))
|
||
// {
|
||
// var cel = recordSheet.GetRow(3).CreateCell(5);
|
||
// cel.SetCellValue(BLL.UserService.GetUserNameByUserId(trust.CH_TrustMan));
|
||
// cel.CellStyle = styleCenter;
|
||
// }
|
||
// if (!string.IsNullOrEmpty(trust.CH_TrustCode))
|
||
// {
|
||
// var cel = recordSheet.GetRow(3).CreateCell(7);
|
||
// cel.SetCellValue(trust.CH_TrustCode);
|
||
// cel.CellStyle = styleCenter;
|
||
// }
|
||
// if (!string.IsNullOrEmpty(trust.CH_NDTCriteria))
|
||
// {
|
||
// var cel = recordSheet.GetRow(4).CreateCell(7);
|
||
// cel.SetCellValue(trust.CH_NDTCriteria);
|
||
// cel.CellStyle = styleCenter;
|
||
// }
|
||
// if (!string.IsNullOrEmpty(trust.CH_WeldMethod))
|
||
// {
|
||
// var type = BLL.Base_WeldingMethodService.GetWeldingMethodByWeldingMethodId(trust.CH_WeldMethod);
|
||
|
||
// var cel = recordSheet.GetRow(5).CreateCell(5);
|
||
// if (type != null)
|
||
// {
|
||
// cel.SetCellValue(type.WeldingMethodName);
|
||
// }
|
||
// cel.CellStyle = styleCenter;
|
||
// }
|
||
|
||
|
||
// if (!string.IsNullOrEmpty(trust.CH_AcceptGrade))
|
||
// {
|
||
// var list = BLL.TrustManageEditService.GetAcceptGradeList();
|
||
// var grade = list.FirstOrDefault(x => x.Value == trust.CH_AcceptGrade);
|
||
// var cel = recordSheet.GetRow(5).CreateCell(7);
|
||
// if (grade != null)
|
||
// {
|
||
// cel.SetCellValue(grade.Text);
|
||
// }
|
||
// cel.CellStyle = styleCenter;
|
||
// }
|
||
// if (!string.IsNullOrEmpty(trust.CH_NDTMethod))
|
||
// {
|
||
// var type = BLL.Base_DetectionTypeService.GetDetectionTypeByDetectionTypeId(trust.CH_NDTMethod);
|
||
// var cel = recordSheet.GetRow(6).CreateCell(1);
|
||
|
||
// if (type != null)
|
||
// {
|
||
// cel.SetCellValue(type.DetectionTypeName);
|
||
// }
|
||
// cel.CellStyle = styleCenter;
|
||
|
||
// }
|
||
// if (!string.IsNullOrEmpty(trust.CH_NDTRate))
|
||
// {
|
||
// var list = BLL.Base_DetectionRateService.GetNDTRateNameList();
|
||
// var rate = list.FirstOrDefault(x => x.Value == trust.CH_NDTRate);
|
||
// var cel = recordSheet.GetRow(6).CreateCell(7);
|
||
// if (rate != null)
|
||
// {
|
||
// cel.SetCellValue(rate.Text);
|
||
// }
|
||
// cel.CellStyle = styleCenter;
|
||
|
||
// }
|
||
|
||
// if (!string.IsNullOrEmpty(trust.CH_SlopeType))
|
||
// {
|
||
// var type = BLL.Base_GrooveTypeService.GetGrooveTypeByGrooveTypeId(trust.CH_SlopeType);
|
||
// var cel = recordSheet.GetRow(6).CreateCell(5);
|
||
// if (type != null)
|
||
// {
|
||
// cel.SetCellValue(type.GrooveTypeName);
|
||
// }
|
||
// cel.CellStyle = styleCenter;
|
||
// }
|
||
|
||
// string strSql = @"SELECT *
|
||
// FROM dbo.View_CH_TrustItem jot
|
||
// WHERE CH_TrustID=@CH_TrustID";
|
||
// List<SqlParameter> listStr = new List<SqlParameter>();
|
||
// listStr.Add(new SqlParameter("@CH_TrustID", tvControlItem.SelectedNodeID));
|
||
// SqlParameter[] parameter = listStr.ToArray();
|
||
// DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||
// if (tb.Rows.Count > 0 && tb.Rows[0]["WorkAreaId"] != null)
|
||
// {
|
||
|
||
// var PworkArea = Funs.DB.ProjectData_WorkArea.FirstOrDefault(x => x.WorkAreaId == tb.Rows[0]["WorkAreaId"].ToString());
|
||
// if (PworkArea != null)
|
||
// {
|
||
// //var cel = recordSheet.GetRow(3).CreateCell(1);
|
||
// //cel.SetCellValue(PworkArea.WorkAreaCode);
|
||
// //cel.CellStyle = styleCenter;
|
||
|
||
// recordSheet.GetRow(2).CreateCell(8).SetCellValue(PworkArea.WorkAreaName);
|
||
// recordSheet.GetRow(2).GetCell(8).CellStyle = styleCenter;
|
||
// recordSheet.GetRow(4).CreateCell(1).SetCellValue(PworkArea.WorkAreaCode);
|
||
// recordSheet.GetRow(4).GetCell(1).CellStyle = styleCenter;
|
||
// }
|
||
// }
|
||
|
||
|
||
// if (tb.Rows.Count > 16)
|
||
// {
|
||
// recordSheet.ShiftRows(9, 28, tb.Rows.Count - 16);
|
||
// for (int j = 0; j < tb.Rows.Count - 16; j++)
|
||
// {
|
||
// recordSheet.CopyRow(8 + j, 9 + j);
|
||
// }
|
||
// var unit = Funs.DB.Project_ProjectUnit.FirstOrDefault(x => x.ProjectId == trust.ProjectId && x.UnitType == Const.ProjectUnitType_3);
|
||
// if (unit != null && !string.IsNullOrEmpty(unit.UnitId))
|
||
// {
|
||
// recordSheet.GetRow(20 + tb.Rows.Count - 16).GetCell(0).SetCellValue(BLL.UnitService.GetUnitNameByUnitId(unit.UnitId).ToString());
|
||
|
||
// }
|
||
// recordSheet.GetRow(20 + tb.Rows.Count - 16).GetCell(2).SetCellValue("中国天辰工程有限公司");
|
||
// if (!string.IsNullOrEmpty(trust.CH_TrustUnit))
|
||
// {
|
||
// recordSheet.GetRow(20 + tb.Rows.Count - 16).GetCell(5).SetCellValue(BLL.UnitService.GetUnitNameByUnitId(trust.CH_TrustUnit).ToString());
|
||
|
||
// }
|
||
// if (!string.IsNullOrEmpty(trust.CH_CheckUnit))
|
||
// {
|
||
// recordSheet.GetRow(20 + tb.Rows.Count - 16).CreateCell(7).SetCellValue(BLL.UnitService.GetUnitNameByUnitId(trust.CH_CheckUnit).ToString());
|
||
|
||
// }
|
||
|
||
// }
|
||
// else
|
||
// {
|
||
// var unit = Funs.DB.Project_ProjectUnit.FirstOrDefault(x => x.ProjectId == trust.ProjectId && x.UnitType == Const.ProjectUnitType_3);
|
||
// if (unit != null && !string.IsNullOrEmpty(unit.UnitId))
|
||
// {
|
||
// recordSheet.GetRow(20).GetCell(0).SetCellValue(BLL.UnitService.GetUnitNameByUnitId(unit.UnitId).ToString());
|
||
|
||
// }
|
||
// recordSheet.GetRow(20).GetCell(2).SetCellValue("中国天辰工程有限公司");
|
||
|
||
// if (!string.IsNullOrEmpty(trust.CH_TrustUnit))
|
||
// {
|
||
// recordSheet.GetRow(20).GetCell(5).SetCellValue(BLL.UnitService.GetUnitNameByUnitId(trust.CH_TrustUnit).ToString());
|
||
|
||
// }
|
||
|
||
// if (!string.IsNullOrEmpty(trust.CH_CheckUnit))
|
||
// {
|
||
// recordSheet.GetRow(20).GetCell(7).SetCellValue(BLL.UnitService.GetUnitNameByUnitId(trust.CH_CheckUnit).ToString());
|
||
|
||
// }
|
||
|
||
// }
|
||
// for (int i = 0; i < tb.Rows.Count; i++)
|
||
// {
|
||
// try
|
||
// {
|
||
// recordSheet.GetRow(8 + i).GetCell(0).SetCellValue("" + (i + 1));
|
||
// recordSheet.GetRow(8 + i).GetCell(1).SetCellValue(tb.Rows[i]["ISO_IsoNo"] != null ? tb.Rows[i]["ISO_IsoNo"].ToString() : "");
|
||
// recordSheet.GetRow(8 + i).GetCell(2).SetCellValue(tb.Rows[i]["ISO_IsoNumber"] != null ? tb.Rows[i]["ISO_IsoNumber"].ToString() : "");
|
||
// recordSheet.GetRow(8 + i).GetCell(3).SetCellValue(tb.Rows[i]["JOT_JointNo"] != null ? tb.Rows[i]["JOT_JointNo"].ToString() : "");
|
||
// //recordSheet.GetRow(7 + i).GetCell(4).SetCellValue(tb.Rows[i]["ISO_IsoNumber"] != null ? tb.Rows[i]["ISO_IsoNumber"].ToString() : "");
|
||
// recordSheet.GetRow(8 + i).GetCell(7).SetCellValue(tb.Rows[i]["STE_Name1"] != null ? tb.Rows[i]["STE_Name1"].ToString() : "");
|
||
// recordSheet.GetRow(8 + i).GetCell(6).SetCellValue(tb.Rows[i]["JOT_JointDesc"] != null ? tb.Rows[i]["JOT_JointDesc"].ToString() : "");
|
||
|
||
// string WED_Name = "";
|
||
// if (!string.IsNullOrEmpty(tb.Rows[i]["WED_Code1"].ToString()))
|
||
// WED_Name += tb.Rows[i]["WED_Code1"].ToString();
|
||
|
||
// if (!string.IsNullOrEmpty(tb.Rows[i]["WED_Code2"].ToString()) && WED_Name != tb.Rows[i]["WED_Code2"].ToString())
|
||
// WED_Name += " " + tb.Rows[i]["WED_Code2"].ToString();
|
||
// recordSheet.GetRow(8 + i).GetCell(5).SetCellValue(WED_Name);
|
||
|
||
// }
|
||
// catch (Exception)
|
||
// {
|
||
|
||
// }
|
||
|
||
// }
|
||
|
||
// using (FileStream filess = File.OpenWrite(ReportFileName))
|
||
// {
|
||
// hssfworkbook.Write(filess);
|
||
// }
|
||
// //PageContext.RegisterStartupScript(Window5.GetShowReference(String.Format("../../ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId={3}", BLL.Const.HJGL_JointInfoReportId, isoId, varValue, this.CurrUser.LoginProjectId)));
|
||
|
||
// FileInfo filet = new FileInfo(ReportFileName);
|
||
// Response.Clear();
|
||
// Response.Charset = "GB2312";
|
||
// Response.ContentEncoding = System.Text.Encoding.UTF8;
|
||
// // 添加头信息,为"文件下载/另存为"对话框指定默认文件名
|
||
// Response.AddHeader("Content-Disposition", "attachment; filename=管道焊口检测委托单_" + Server.UrlEncode(DateTime.Now.ToString("yyyyMMddhhmmss") + ".xlsx"));
|
||
// // 添加头信息,指定文件大小,让浏览器能够显示下载进度
|
||
// Response.AddHeader("Content-Length", filet.Length.ToString());
|
||
// // 指定返回的是一个不能被客户端读取的流,必须被下载
|
||
// Response.ContentType = "application/ms-excel";
|
||
// // 把文件流发送到客户端
|
||
// Response.WriteFile(filet.FullName);
|
||
// // 停止页面的执行
|
||
// Response.End();
|
||
//}
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInTop("请选择要打印的委托单!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
|
||
#region 判断是否可删除
|
||
/// <summary>
|
||
/// 判断是否可以删除
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
private bool judgementDelete(string id, bool isShow)
|
||
{
|
||
string content = string.Empty;
|
||
//if (BLL.HJGL_HotProessManageEditService.GetHotProessByJotId(id) > 0)
|
||
//{
|
||
// content = "热处理已经使用了该焊口,不能删除!";
|
||
//}
|
||
//if (BLL.Funs.DB.HJGL_CH_TrustItem.FirstOrDefault(x => x.TrustBatchItemId == id) != null)
|
||
//{
|
||
// content = "无损委托已经使用了该焊口,不能删除!";
|
||
//}
|
||
//if (BLL.Funs.DB.HJGL_CH_CheckItem.FirstOrDefault(x => x.TrustBatchItemId == id) != null)
|
||
//{
|
||
// content = "检测单已经使用了该焊口,不能删除!";
|
||
//}
|
||
if (string.IsNullOrEmpty(content))
|
||
{
|
||
return true;
|
||
}
|
||
else
|
||
{
|
||
if (isShow)
|
||
{
|
||
Alert.ShowInTop(content, MessageBoxIcon.Error);
|
||
}
|
||
return false;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
/// <summary>
|
||
/// 退回
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnBack_Click(object sender, EventArgs e)
|
||
{
|
||
Model.SGGLDB db = Funs.DB;
|
||
//string trustBatchId = string.Empty;
|
||
var lists = this.Grid1.SelectedRowIDArray;
|
||
if (lists.Count() > 0)
|
||
{
|
||
if (lbIsTrust.Text == "未委托")
|
||
{
|
||
Alert.ShowInTop("未委托,无需退回!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
foreach (var pointBatchItemId in lists)
|
||
{
|
||
//删除选中委托单明细
|
||
var batchTrustItem = (from x in db.HJGL_Batch_BatchTrustItem where x.PointBatchItemId == pointBatchItemId select x).FirstOrDefault();
|
||
if (batchTrustItem != null)
|
||
{
|
||
//trustBatchId = batchTrustItem.TrustBatchId;
|
||
BLL.Batch_BatchTrustItemService.DeleteTrustItemByTrustBatchId(batchTrustItem.TrustBatchId);
|
||
BLL.Batch_BatchTrustService.DeleteBatchTrustById(batchTrustItem.TrustBatchId);
|
||
//BLL.Batch_BatchTrustItemService.DeleteTrustItemByTrustBatchItemId(batchTrustItem.TrustBatchItemId);
|
||
}
|
||
|
||
//修改点口中的委托状态
|
||
var pointBatchItem = (from x in db.HJGL_Batch_PointBatchItem where x.PointBatchItemId == pointBatchItemId select x).FirstOrDefault();
|
||
if (pointBatchItem != null)
|
||
{
|
||
if (pointBatchItem.IsBuildTrust != null)
|
||
{
|
||
pointBatchItem.IsBuildTrust = null;//是否委托
|
||
pointBatchItem.PointState = null;//点口类型
|
||
pointBatchItem.PointDate = null;//点口时间
|
||
db.SubmitChanges();
|
||
}
|
||
var pointBatch = BLL.PointBatchService.GetPointBatchById(pointBatchItem.PointBatchId);
|
||
if (pointBatch != null)
|
||
{
|
||
pointBatch.IsClosed = null;
|
||
db.SubmitChanges();
|
||
}
|
||
}
|
||
}
|
||
|
||
//var trustItemList = BLL.Batch_BatchTrustItemService.GetBatchTrustItemByTrustBatchId(trustBatchId);
|
||
//if (trustItemList.Count == 0)
|
||
//{
|
||
// BLL.Batch_BatchTrustService.DeleteBatchTrustById(trustBatchId);
|
||
//}
|
||
PageInfo();
|
||
BindGrid();
|
||
ShowNotify("退回成功!", MessageBoxIcon.Success);
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInTop("请至少选择一条记录", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
} |