ZHJA_HJGL/HJGL_ZH/FineUIPro.Web/HJGL/HotHardManage/HardTestReport.aspx.cs

856 lines
40 KiB
C#

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using BLL;
using Newtonsoft.Json.Linq;
namespace FineUIPro.Web.HJGL.HotHardManage
{
public partial class HardTestReport : PageBase
{
#region
/// <summary>
/// 硬度检测报告主键
/// </summary>
public string HardTestReportId
{
get
{
return (string)ViewState["HardTestReportId"];
}
set
{
ViewState["HardTestReportId"] = value;
}
}
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.drpIsProjectClosed.DataTextField = "Text";
this.drpIsProjectClosed.DataValueField = "Value";
this.drpIsProjectClosed.DataSource = BLL.DropListService.IsTrueOrFalseDrpList();
this.drpIsProjectClosed.DataBind();
Funs.FineUIPleaseSelect(this.drpIsProjectClosed);
this.drpIsProjectClosed.SelectedValue = BLL.Const._False;
this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
this.HardTestReportId = string.Empty;
this.drpProjectId.DataTextField = "ProjectCode";
this.drpProjectId.DataValueField = "ProjectId";
this.drpProjectId.DataSource = BLL.Base_ProjectService.GetProjectListByUserIdAndState(this.CurrUser.UserId, this.drpIsProjectClosed.SelectedValue, "1");
this.drpProjectId.DataBind();
Funs.FineUIPleaseSelect(this.drpProjectId);
//this.drpProjectId.SelectedValue = this.CurrUser.LoginProjectId;
this.tvControlItem.Nodes.Clear();
TreeNode rootNode = new TreeNode();
rootNode.Text = "项目";
rootNode.NodeID = "0";
rootNode.ToolTip = "红色表示施工号下存在未打印的硬度委托记录";
rootNode.Expanded = true;
rootNode.EnableClickEvent = true;
this.tvControlItem.Nodes.Add(rootNode);
//this.InitTreeMenu();//加载树
//this.tvControlItem.SelectedNodeID = this.CurrUser.LoginProjectId;
//BindGrid();
}
}
#endregion
protected void drpIsProjectClosed_SelectedIndexChanged(object sender, EventArgs e)
{
this.drpProjectId.Items.Clear();
this.drpProjectId.DataTextField = "ProjectCode";
this.drpProjectId.DataValueField = "ProjectId";
this.drpProjectId.DataSource = BLL.Base_ProjectService.GetProjectListByUserIdAndState(this.CurrUser.UserId, this.drpIsProjectClosed.SelectedValue, "1");
this.drpProjectId.DataBind();
Funs.FineUIPleaseSelect(this.drpProjectId);
this.InitTreeMenu();
}
protected void drpProjectId_SelectedIndexChanged(object sender, EventArgs e)
{
this.InitTreeMenu();
}
#region -
/// <summary>
/// 加载树
/// </summary>
private void InitTreeMenu()
{
this.tvControlItem.Nodes.Clear();
TreeNode rootNode = new TreeNode();
rootNode.Text = "项目";
rootNode.NodeID = "0";
rootNode.ToolTip = "红色表示施工号下存在未打印的硬度委托记录";
rootNode.Expanded = true;
rootNode.EnableClickEvent = true;
this.tvControlItem.Nodes.Add(rootNode);
List<Model.Base_Project> projects = BLL.Base_ProjectService.GetProjectListByUserIdAndState(this.CurrUser.UserId, this.drpIsProjectClosed.SelectedValue, "1");
if (this.drpProjectId.SelectedValueArray.Length > 1 || (this.drpProjectId.SelectedValueArray.Length == 1 && this.drpProjectId.SelectedValue != "null"))
{
projects = projects.Where(x => this.drpProjectId.SelectedValueArray.Contains(x.ProjectId)).ToList();
}
List<Model.HJGL_CH_HardTestReport> trustLists = new List<Model.HJGL_CH_HardTestReport>(); ///硬度检验报告
if (this.rblPrint.SelectedValue == "2") //全部
{
trustLists = (from x in Funs.DB.HJGL_CH_HardTestReport
join y in Funs.DB.HJGL_CH_HardTestReportItem
on x.HardTestReportId equals y.HardTestReportId
join z in Funs.DB.HJGL_PW_JointInfo
on y.JOT_ID equals z.JOT_ID
join a in Funs.DB.HJGL_PW_IsoInfo
on z.ISO_ID equals a.ISO_ID
where x.HardTestReportCode.Contains(this.txtSearchNo.Text.Trim())
&& a.ISO_IsoNo.Contains(this.txtTreeIsoNo.Text.Trim()) && z.JOT_JointNo.Contains(this.txtTreeJointNo.Text.Trim())
select x).Distinct().ToList();
}
else if (this.rblPrint.SelectedValue == "1") //已打印
{
trustLists = (from x in Funs.DB.HJGL_CH_HardTestReport
join y in Funs.DB.HJGL_CH_HardTestReportItem
on x.HardTestReportId equals y.HardTestReportId
join z in Funs.DB.HJGL_PW_JointInfo
on y.JOT_ID equals z.JOT_ID
join a in Funs.DB.HJGL_PW_IsoInfo
on z.ISO_ID equals a.ISO_ID
where x.HardTestReportCode.Contains(this.txtSearchNo.Text.Trim()) && x.IsPrintReport == true
&& a.ISO_IsoNo.Contains(this.txtTreeIsoNo.Text.Trim()) && z.JOT_JointNo.Contains(this.txtTreeJointNo.Text.Trim())
select x).Distinct().ToList();
}
else if (this.rblPrint.SelectedValue == "0") //未打印
{
trustLists = (from x in Funs.DB.HJGL_CH_HardTestReport
join y in Funs.DB.HJGL_CH_HardTestReportItem
on x.HardTestReportId equals y.HardTestReportId
join z in Funs.DB.HJGL_PW_JointInfo
on y.JOT_ID equals z.JOT_ID
join a in Funs.DB.HJGL_PW_IsoInfo
on z.ISO_ID equals a.ISO_ID
where x.HardTestReportCode.Contains(this.txtSearchNo.Text.Trim()) && (x.IsPrintReport == null || x.IsPrintReport == false)
&& a.ISO_IsoNo.Contains(this.txtTreeIsoNo.Text.Trim()) && z.JOT_JointNo.Contains(this.txtTreeJointNo.Text.Trim())
select x).Distinct().ToList();
}
foreach (var item in projects)
{
TreeNode rootUnitNode = new TreeNode();//定义根节点
if ((from x in trustLists where x.ProjectId == item.ProjectId && (x.IsPrintReport == null || x.IsPrintReport == false) select x).Count() > 0) //存在未打印的委托单
{
rootUnitNode.Text = "<font color='#FF7575'>" + item.ProjectCode + "</font>";
}
else
{
rootUnitNode.Text = item.ProjectCode;
}
rootUnitNode.NodeID = item.ProjectId;
rootUnitNode.EnableClickEvent = true;
rootUnitNode.EnableExpandEvent = true;
rootUnitNode.ToolTip = item.ProjectName;
rootUnitNode.CommandName = "项目名称";
rootNode.Nodes.Add(rootUnitNode);
if (!string.IsNullOrEmpty(this.txtSearchNo.Text.Trim()) || !string.IsNullOrEmpty(this.txtTreeIsoNo.Text.Trim()) || !string.IsNullOrEmpty(this.txtTreeJointNo.Text.Trim()))
{
var projectTrustLists = (from x in trustLists
where x.ProjectId == item.ProjectId && (x.FileType == null || x.FileType == "R")
orderby x.HardTestReportCode descending
select x).ToList();
if (projectTrustLists.Count > 0)
{
rootUnitNode.Expanded = true;
this.BindNodes(rootUnitNode, projectTrustLists);
}
}
else
{
TreeNode tn = new TreeNode();
tn.NodeID = "temp";
tn.Text = "正在加载...";
rootUnitNode.Nodes.Add(tn);
}
}
}
#endregion
protected void tvControlItem_NodeExpand(object sender, TreeNodeEventArgs e)
{
if (e.Node.Nodes != null)
{
e.Node.Nodes.Clear();
}
List<Model.HJGL_CH_HardTestReport> trustLists = new List<Model.HJGL_CH_HardTestReport>(); ///硬度检验报告
if (this.rblPrint.SelectedValue == "2") //全部
{
trustLists = (from x in Funs.DB.HJGL_CH_HardTestReport
join y in Funs.DB.HJGL_CH_HardTestReportItem
on x.HardTestReportId equals y.HardTestReportId
join z in Funs.DB.HJGL_PW_JointInfo
on y.JOT_ID equals z.JOT_ID
join a in Funs.DB.HJGL_PW_IsoInfo
on z.ISO_ID equals a.ISO_ID
where x.HardTestReportCode.Contains(this.txtSearchNo.Text.Trim())
&& a.ISO_IsoNo.Contains(this.txtTreeIsoNo.Text.Trim()) && z.JOT_JointNo.Contains(this.txtTreeJointNo.Text.Trim())
&& x.ProjectId == e.Node.NodeID
orderby x.HardTestReportCode descending
select x).Distinct().ToList();
}
else if (this.rblPrint.SelectedValue == "1") //已打印
{
trustLists = (from x in Funs.DB.HJGL_CH_HardTestReport
join y in Funs.DB.HJGL_CH_HardTestReportItem
on x.HardTestReportId equals y.HardTestReportId
join z in Funs.DB.HJGL_PW_JointInfo
on y.JOT_ID equals z.JOT_ID
join a in Funs.DB.HJGL_PW_IsoInfo
on z.ISO_ID equals a.ISO_ID
where x.HardTestReportCode.Contains(this.txtSearchNo.Text.Trim()) && x.IsPrintReport == true
&& a.ISO_IsoNo.Contains(this.txtTreeIsoNo.Text.Trim()) && z.JOT_JointNo.Contains(this.txtTreeJointNo.Text.Trim())
&& x.ProjectId == e.Node.NodeID
orderby x.HardTestReportCode descending
select x).Distinct().ToList();
}
else if (this.rblPrint.SelectedValue == "0") //未打印
{
trustLists = (from x in Funs.DB.HJGL_CH_HardTestReport
join y in Funs.DB.HJGL_CH_HardTestReportItem
on x.HardTestReportId equals y.HardTestReportId
join z in Funs.DB.HJGL_PW_JointInfo
on y.JOT_ID equals z.JOT_ID
join a in Funs.DB.HJGL_PW_IsoInfo
on z.ISO_ID equals a.ISO_ID
where x.HardTestReportCode.Contains(this.txtSearchNo.Text.Trim()) && (x.IsPrintReport == null || x.IsPrintReport == false)
&& a.ISO_IsoNo.Contains(this.txtTreeIsoNo.Text.Trim()) && z.JOT_JointNo.Contains(this.txtTreeJointNo.Text.Trim())
&& x.ProjectId == e.Node.NodeID
orderby x.HardTestReportCode descending
select x).Distinct().ToList();
}
trustLists = trustLists.Where(x => x.FileType == null || x.FileType == "R").ToList();
trustLists = trustLists.OrderByDescending(x => x.HardTestReportCode).ToList();
this.BindNodes(e.Node, trustLists);
}
#region
/// <summary>
/// 绑定树节点
/// </summary>
/// <param name="node"></param>
private void BindNodes(TreeNode node, List<Model.HJGL_CH_HardTestReport> trustList)
{
foreach (var item in trustList)
{
TreeNode newNode = new TreeNode();
string isoNo = string.Empty;
Model.HJGL_PW_IsoInfo iso = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByIsoInfoId(item.ISO_ID);
if (iso != null)
{
isoNo = iso.ISO_IsoNo;
}
if (item.IsPrintReport == true)
{
newNode.Text = item.HardTestReportCode + "-" + isoNo;
}
else
{
newNode.Text = "<font color='#FF7575'>" + item.HardTestReportCode + "-" + isoNo + "</font>";
}
newNode.NodeID = item.HardTestReportId;
newNode.ToolTip = item.HotHardCode;
newNode.CommandName = "报告单号";
newNode.EnableClickEvent = true;
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.HardTestReportId = tvControlItem.SelectedNodeID;
this.BindGrid();
}
#endregion
#region
/// <summary>
/// 数据绑定
/// </summary>
private void BindGrid()
{
this.SetTextTemp();
this.PageInfoLoad(); ///页面输入提交信息
string strSql = string.Empty;
string projectIds = BLL.Base_ProjectService.GetStrOnProjectIds(this.CurrUser.UserId, "1");
List<SqlParameter> listStr = new List<SqlParameter>();
if (this.tvControlItem.SelectedNode.CommandName == "报告单号")
{
strSql = @"SELECT * "
+ @" FROM dbo.HJGL_View_CH_HardTestReportItem AS Trust"
+ @" WHERE Trust.HardTestReportId=@HardTestReportId";
listStr.Add(new SqlParameter("@HardTestReportId", this.HardTestReportId));
}
else if (this.tvControlItem.SelectedNode.CommandName == "项目名称")
{
strSql = @"SELECT * "
+ @" FROM dbo.HJGL_View_CH_HardTestReportItem AS Trust"
+ @" WHERE Trust.ProjectId= @ProjectId AND Trust.HardTestReportId is not null and (Trust.FileType='R' or Trust.FileType is null)";
listStr.Add(new SqlParameter("@ProjectId", this.HardTestReportId));
}
else if (this.tvControlItem.SelectedNodeID == "0") //选择项目根节点
{
strSql = @"SELECT * "
+ @" FROM dbo.HJGL_View_CH_HardTestReportItem AS Trust"
+ @" WHERE Trust.HardTestReportId is not null and CHARINDEX(Trust.ProjectId,@ProjectId)>0 ";
listStr.Add(new SqlParameter("@ProjectId", projectIds));
}
if (!string.IsNullOrEmpty(this.txtIsoNo.Text.Trim()))
{
strSql += @" and Trust.ISO_IsoNo like @IsoNo ";
listStr.Add(new SqlParameter("@IsoNo", "%" + this.txtIsoNo.Text.Trim() + "%"));
}
if (!string.IsNullOrEmpty(this.txtJointNo.Text.Trim()))
{
strSql += @" and Trust.JOT_JointNo like @JointNo ";
listStr.Add(new SqlParameter("@JointNo", "%" + this.txtJointNo.Text.Trim() + "%"));
}
if (this.cbShowAllJoint.Checked)
{
strSql += @" and HardNessValue1 is null ";
}
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();
//if (this.Grid1.Rows.Count > 0 && !string.IsNullOrEmpty(this.txtIsoNo.Text.Trim()) && !string.IsNullOrEmpty(this.txtJointNo.Text.Trim()))
//{
// string hardTestReportItemId = this.Grid1.Rows[0].DataKeys[0].ToString();
// Model.HJGL_CH_HardTestReportItem item = Funs.DB.HJGL_CH_HardTestReportItem.FirstOrDefault(x => x.HardTestReportItemId == hardTestReportItemId);
// if (item != null)
// {
// var trust = Funs.DB.HJGL_View_CH_HardTestReport.FirstOrDefault(x => x.HardTestReportId == item.HardTestReportId);
// if (trust != null)
// {
// this.txtHardTestReportCode.Text = trust.HardTestReportCode;
// this.drpCH_TrustUnit.Text = trust.UnitName;
// this.txtISO_IsoNo.Text = trust.ISO_IsoNo;
// this.txtSTE_Code.Text = trust.STE_Code;
// this.txtHotProessState.Text = trust.HotProessState;
// this.txtEquipmentName.Text = trust.EquipmentName;
// if (trust.IsPrintReport == true)
// {
// this.cbIsPrint.Checked = true;
// }
// else
// {
// this.cbIsPrint.Checked = false;
// }
// //this.btnPrint.Hidden = false;
// //this.cbIsPrint.Hidden = false;
// //this.btnEdit.Hidden = false;
// //this.btnDelete.Hidden = false;
// }
// }
//}
}
#region
/// <summary>
/// 加载页面输入提交信息
/// </summary>
private void PageInfoLoad()
{
this.btnEdit.Hidden = true;
this.btnDelete.Hidden = true;
this.btnPrint.Hidden = true;
this.btnPrintNew.Hidden = true;
var trust = Funs.DB.HJGL_View_CH_HardTestReport.FirstOrDefault(x => x.HardTestReportId == this.HardTestReportId);
if (trust != null)
{
this.txtHardTestReportCode.Text = trust.HardTestReportCode;
this.drpCH_TrustUnit.Text = trust.UnitName;
this.txtISO_IsoNo.Text = trust.ISO_IsoNo;
this.txtSTE_Code.Text = trust.STE_Code;
this.txtHotProessState.Text = trust.HotProessState;
this.txtEquipmentName.Text = trust.EquipmentName;
this.btnEdit.Hidden = false;
if (trust.IsPrintReport == true)
{
this.cbIsPrint.Checked = true;
//this.btnEdit.Hidden = true;
}
else
{
this.cbIsPrint.Checked = false;
}
this.btnPrint.Hidden = false;
this.btnPrintNew.Hidden = false;
this.cbIsPrint.Hidden = false;
this.btnDelete.Hidden = false;
}
}
#endregion
/// <summary>
/// 情况
/// </summary>
private void SetTextTemp()
{
this.txtHardTestReportCode.Text = string.Empty;
this.txtISO_IsoNo.Text = string.Empty;
this.drpCH_TrustUnit.Text = string.Empty;
this.txtSTE_Code.Text = string.Empty;
this.txtHotProessState.Text = string.Empty;
this.txtEquipmentName.Text = string.Empty;
}
#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 btnNew_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_HardTestReportMenuId, Const.BtnAdd))
{
this.SetTextTemp();
string window = String.Format("HardTestReportEdit.aspx?HardTestReportId={0}", string.Empty, "新增 - ");
PageContext.RegisterStartupScript(Window1.GetSaveStateReference(this.hdTrustID.ClientID)
+ Window1.GetShowReference(window));
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
#region
/// <summary>
/// 编辑硬度检测报告
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnEdit_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_HardTestReportMenuId, Const.BtnSave))
{
var trustManage = BLL.HJGL_CH_HardTestReportService.GetCH_HardTestReportByID(this.HardTestReportId);
if (trustManage != null)
{
//if (trustManage.IsPrintTrust == true || trustManage.IsPrintReport == true)
//{
// ShowNotify("硬度检验报告已打印,无法修改!", MessageBoxIcon.Warning);
// return;
//}
Model.Sys_User user = BLL.Sys_UserService.GetUsersByUserId(this.CurrUser.UserId);
if (user.UnitId != "26645a1f-3256-4962-9b27-d33d7dea087e" && this.CurrUser.UserId != BLL.Const.GlyId) //非甬安公司用户或管理员,无法修改
{
ShowNotify("非甬安公司用户或管理员,无法修改!", MessageBoxIcon.Warning);
return;
}
string window = String.Format("HardTestReportEdit.aspx?HardTestReportId={0}", this.HardTestReportId, "编辑 - ");
PageContext.RegisterStartupScript(Window1.GetSaveStateReference(this.hdTrustID.ClientID)
+ Window1.GetShowReference(window));
}
else
{
ShowNotify("请选择要修改的硬度检测报告记录!", MessageBoxIcon.Warning);
}
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
#endregion
protected void btnUndo_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_HardTestReportMenuId, Const.BtnUndo))
{
var trustManage = BLL.HJGL_CH_HardTestReportService.GetCH_HardTestReportByID(this.HardTestReportId);
if (trustManage != null)
{
var items = (from x in Funs.DB.HJGL_CH_HardTestReportItem where x.HardTestReportId == this.HardTestReportId select x).ToList();
if (items.Count > 0)
{
foreach (var q in items)
{
q.HardTestReportId = null;
q.Flag = null;
Funs.DB.SubmitChanges();
}
}
BLL.HJGL_CH_HardTestReportService.DeleteCH_HardTestReportByCH_HardTestReportID(this.HardTestReportId);
BLL.Sys_LogService.AddLog(BLL.Const.System_3, trustManage.ProjectId, this.CurrUser.UserId, "撤消硬度检测报告");
Alert.ShowInTop("撤消成功!", MessageBoxIcon.Success);
this.InitTreeMenu();
this.Grid1.DataSource = null;
this.Grid1.DataBind();
}
else
{
ShowNotify("请选择要撤消的硬度检测报告!", MessageBoxIcon.Warning);
}
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
#region
/// <summary>
/// 删除硬度检测报告
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnDelete_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_HardTestReportMenuId, Const.BtnDelete))
{
var trustManage = BLL.HJGL_CH_HardTestReportService.GetCH_HardTestReportByID(this.HardTestReportId);
if (trustManage != null)
{
if (trustManage.IsPrintTrust == true || trustManage.IsPrintReport == true)
{
ShowNotify("硬度检验报告已打印,无法删除!", MessageBoxIcon.Warning);
return;
}
string projectId = trustManage.ProjectId;
var items = BLL.HJGL_CH_HardTestReportService.GetView_CH_HardTestReportItemByCH_HardTestReportID(this.HardTestReportId);
bool b = true; //是否可以删除
foreach (var item in items)
{
if (item.HardNessValue1.HasValue || item.HardNessValue2.HasValue || item.HardNessValue3.HasValue)
{
b = false;
break;
}
}
if (b)
{
BLL.HJGL_CH_HardTestResultService.DeleteHardTestResultsyHardTestReportId(this.HardTestReportId);
BLL.HJGL_CH_HardTestReportService.DeleteCH_HardTestReportItemByCH_HardTestReportID(this.HardTestReportId);
BLL.HJGL_CH_HardTestReportService.DeleteCH_HardTestReportByCH_HardTestReportID(this.HardTestReportId);
BLL.Sys_LogService.AddLog(BLL.Const.System_3, projectId, this.CurrUser.UserId, "删除硬度检测报告");
Alert.ShowInTop("删除成功!", MessageBoxIcon.Success);
this.InitTreeMenu();
this.Grid1.DataSource = null;
this.Grid1.DataBind();
this.SetTextTemp();
//this.BindGrid();
}
else
{
ShowNotify("硬度检验报告已录入数据,无法删除!", MessageBoxIcon.Warning);
return;
}
}
else
{
ShowNotify("请选择要删除的硬度检测报告记录!", MessageBoxIcon.Warning);
}
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
return;
}
}
#endregion
#endregion
#region
/// <summary>
/// 关闭弹出窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
this.HardTestReportId = this.hdTrustID.Text;
this.BindGrid();
//this.InitTreeMenu();
this.hdTrustID.Text = string.Empty;
}
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Tree_TextChanged(object sender, EventArgs e)
{
this.InitTreeMenu();
//this.BindGrid();
}
#endregion
#region
/// <summary>
/// 硬度检测报告表打印
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnPrint_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(this.HardTestReportId))
{
var hardTestReportItems = from x in Funs.DB.HJGL_CH_HardTestReportItem
where x.HardTestReportId == this.HardTestReportId
select x;
var jotIdItems = (from x in hardTestReportItems
join y in Funs.DB.HJGL_PW_JointInfo
on x.JOT_ID equals y.JOT_ID
orderby y.JOT_JointNo
select x.JOT_ID + "," + x.HotProessTrustId).Distinct();
int i = 1;
foreach (var jotIds in jotIdItems)
{
string jotId = jotIds.Split(',')[0];
string hotProessTrustId = jotIds.Split(',')[1];
var items = hardTestReportItems.Where(x => x.JOT_ID == jotId && x.HotProessTrustId == hotProessTrustId);
foreach (var item in items)
{
item.Flag = i;
BLL.HJGL_CH_HardTestReportService.UpdateCH_HardTestReportItem(item);
}
if (i == 1 || i == 2)
{
i++;
}
else
{
i = 1;
}
}
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@HardTestReportId", this.HardTestReportId));
listStr.Add(new SqlParameter("@Flag", "0"));
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = BLL.SQLHelper.GetDataTableRunProc("HJGL_spCH_HardTestReportItem", parameter);
string varValue = Funs.GetPagesCountByPageSize(18, 24, tb.Rows.Count).ToString();
Model.HJGL_CH_HardTestReport report = BLL.HJGL_CH_HardTestReportService.GetCH_HardTestReportByID(this.HardTestReportId);
if (report != null)
{
report.IsPrintReport = true;
report.PrintReportDate = DateTime.Now;
BLL.HJGL_CH_HardTestReportService.UpdateCH_HardTestReport(report);
this.cbIsPrint.Checked = true;
}
if (tb.Rows.Count <= 18)
{
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0", BLL.Const.HJGL_HardTestReportId1, this.HardTestReportId, varValue, "打印 - ")));
}
else
{
PageContext.RegisterStartupScript(Window4.GetShowReference(String.Format("../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0", BLL.Const.HJGL_HardTestReportId2, this.HardTestReportId, string.Empty, "打印 - ")));
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0", BLL.Const.HJGL_HardTestReportId1, this.HardTestReportId, varValue, "打印 - ")));
}
}
else
{
ShowNotify("请选择硬度检测报告记录!", MessageBoxIcon.Warning);
return;
}
}
#endregion
protected void cbIsPrint_CheckedChanged(object sender, CheckedEventArgs e)
{
if (this.tvControlItem.SelectedNode.CommandName == "报告单号")
{
Model.HJGL_CH_HardTestReport report = BLL.HJGL_CH_HardTestReportService.GetCH_HardTestReportByID(this.HardTestReportId);
if (report != null)
{
if (this.cbIsPrint.Checked)
{
report.IsPrintReport = true;
}
else
{
report.IsPrintReport = false;
}
BLL.HJGL_CH_HardTestReportService.UpdateCH_HardTestReport(report);
}
}
}
protected void cbShowAllJoint_CheckedChanged(object sender, CheckedEventArgs e)
{
BindGrid();
}
protected void rblPrint_SelectedIndexChanged(object sender, EventArgs e)
{
this.InitTreeMenu();
}
protected void TextBox_TextChanged(object sender, EventArgs e)
{
this.BindGrid();
}
#region
/// <summary>
/// 硬度检测报告表打印
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnPrintNew_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(this.HardTestReportId))
{
var hardTestReportItems = from x in Funs.DB.HJGL_CH_HardTestReportItem
where x.HardTestReportId == this.HardTestReportId
select x;
var jots = (from x in hardTestReportItems
join y in Funs.DB.HJGL_PW_JointInfo
on x.JOT_ID equals y.JOT_ID
select x.JOT_ID).Distinct();
var jotIdItems = from x in Funs.DB.HJGL_PW_JointInfo
where jots.Contains(x.JOT_ID)
orderby x.Sort1, x.Sort2, x.Sort3, x.Sort4, x.Sort5
select x.JOT_ID;
int i = 1;
foreach (var jotId in jotIdItems)
{
var items = hardTestReportItems.Where(x => x.JOT_ID == jotId);
foreach (var item in items)
{
item.Flag = i;
BLL.HJGL_CH_HardTestReportService.UpdateCH_HardTestReportItem(item);
}
if (i == 1 || i == 2)
{
i++;
}
else
{
i = 1;
}
}
//var jotIdItems = (from x in hardTestReportItems
// join y in Funs.DB.HJGL_PW_JointInfo
// on x.JOT_ID equals y.JOT_ID
// //orderby y.Sort1,y.Sort2,y.Sort3,y.Sort4,y.Sort5
// select x.JOT_ID + "," + x.HotProessTrustId).Distinct();
//int i = 1;
//foreach (var jotIds in jotIdItems)
//{
// string jotId = jotIds.Split(',')[0];
// string hotProessTrustId = jotIds.Split(',')[1];
// var items = hardTestReportItems.Where(x => x.JOT_ID == jotId && x.HotProessTrustId == hotProessTrustId);
// foreach (var item in items)
// {
// item.Flag = i;
// BLL.HJGL_CH_HardTestReportService.UpdateCH_HardTestReportItem(item);
// }
// if (i == 1 || i == 2)
// {
// i++;
// }
// else
// {
// i = 1;
// }
//}
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@HardTestReportId", this.HardTestReportId));
listStr.Add(new SqlParameter("@Flag", "0"));
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = BLL.SQLHelper.GetDataTableRunProc("HJGL_spCH_HardTestReportItem", parameter);
string varValue = Funs.GetPagesCountByPageSize(18, 24, tb.Rows.Count).ToString();
Model.HJGL_CH_HardTestReport report = BLL.HJGL_CH_HardTestReportService.GetCH_HardTestReportByID(this.HardTestReportId);
if (report != null)
{
report.IsPrintReport = true;
report.PrintReportDate = DateTime.Now;
BLL.HJGL_CH_HardTestReportService.UpdateCH_HardTestReport(report);
this.cbIsPrint.Checked = true;
}
if (tb.Rows.Count <= 18)
{
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0", BLL.Const.HJGL_HardTestNewReportId, this.HardTestReportId, varValue, "打印 - ")));
}
else
{
PageContext.RegisterStartupScript(Window4.GetShowReference(String.Format("../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0", BLL.Const.HJGL_HardTestNewReportId2, this.HardTestReportId, string.Empty, "打印 - ")));
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0", BLL.Const.HJGL_HardTestNewReportId, this.HardTestReportId, varValue, "打印 - ")));
}
}
else
{
ShowNotify("请选择硬度检测报告记录!", MessageBoxIcon.Warning);
return;
}
}
#endregion
}
}