Basf_TCC11/HJGL/FineUIPro.Web/WeldingProcess/TestPackageManage/TestPackageManageComplete.a...

603 lines
25 KiB
C#
Raw Normal View History

2024-05-08 16:27:28 +08:00
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.WeldingProcess.TestPackageManage
{
public partial class TestPackageManageComplete : PageBase
{
#region
/// <summary>
/// 试压包主键
/// </summary>
public string PTP_ID
{
get
{
return (string)ViewState["PTP_ID"];
}
set
{
ViewState["PTP_ID"] = value;
}
}
/// <summary>
/// 未通过数
/// </summary>
public int Count
{
get
{
return (int)ViewState["Count"];
}
set
{
ViewState["Count"] = value;
}
}
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
this.PTP_ID = string.Empty;
this.txtSearchDate.Text = string.Format("{0:yyyy-MM}", System.DateTime.Now);
// 审核人
BLL.Project_UserService.InitProjectUserDropDownList(drpFinisher, true, this.CurrUser.LoginProjectId, Resources.Lan.PleaseSelect);
this.InitTreeMenu();//加载树
}
}
#endregion
#region --
/// <summary>
/// 加载树
/// </summary>
private void InitTreeMenu()
{
this.tvControlItem.Nodes.Clear();
TreeNode rootNode = new TreeNode();
rootNode.Text = "单位-装置-月份";
rootNode.NodeID = "0";
rootNode.Expanded = true;
this.tvControlItem.Nodes.Add(rootNode);
DateTime? startTime = Funs.GetNewDateTime(this.txtSearchDate.Text.Trim());
DateTime? endTime = startTime.HasValue ? startTime.Value.AddMonths(1) : System.DateTime.Now;
List<Model.Base_Unit> units = new List<Model.Base_Unit>(); ///单位
var pUnit = BLL.Project_UnitService.GetProject_UnitByProjectIdUnitId(this.CurrUser.LoginProjectId, this.CurrUser.UnitId);
if (pUnit == null || pUnit.UnitType == BLL.Const.UnitType_1 || pUnit.UnitType == BLL.Const.UnitType_2
|| pUnit.UnitType == BLL.Const.UnitType_3 || pUnit.UnitType == BLL.Const.UnitType_4)
{
units = (from x in Funs.DB.Base_Unit
join y in Funs.DB.Project_Unit on x.UnitId equals y.UnitId
where y.ProjectId == this.CurrUser.LoginProjectId && y.UnitType.Contains(BLL.Const.UnitType_5)
select x).ToList();
}
else
{
units.Add(BLL.Base_UnitService.GetUnit(this.CurrUser.UnitId));
}
List<Model.PTP_TestPackage> testPackageLists = (from x in Funs.DB.PTP_TestPackage
where x.ProjectId == this.CurrUser.LoginProjectId && x.TableDate >= startTime && x.TableDate < endTime
select x).ToList();
if (units != null)
{
foreach (var unit in units)
{
TreeNode rootUnitNode = new TreeNode();//定义根节点
rootUnitNode.Text = unit.UnitName;
rootUnitNode.NodeID = unit.UnitId;
rootUnitNode.Expanded = true;
rootUnitNode.ToolTip = "施工单位";
rootNode.Nodes.Add(rootUnitNode);
var testPackageUnitList = testPackageLists.Where(x => x.UnitId == unit.UnitId).ToList();
this.BindNodes(rootUnitNode, testPackageUnitList);
}
}
else
{
ShowNotify("请先增加施工单位!", MessageBoxIcon.Warning);
return;
}
}
#endregion
#region
/// <summary>
/// 绑定树节点
/// </summary>
/// <param name="node"></param>
private void BindNodes(TreeNode node, List<Model.PTP_TestPackage> testPackageUnitList)
{
if (node.ToolTip == "施工单位")
{
var installId = (from x in testPackageUnitList
where x.UnitId == node.NodeID
select x.InstallationId).Distinct();
if (installId.Count() > 0)
{
var install = from x in Funs.DB.Project_Installation
where installId.Contains(x.InstallationId)
orderby x.InstallationCode
select x;
foreach (var q in install)
{
TreeNode newNode = new TreeNode();
newNode.Text = q.InstallationName;
newNode.NodeID = q.InstallationId + "|" + node.NodeID;
newNode.ToolTip = "装置";
newNode.Expanded = true;
node.Nodes.Add(newNode);
this.BindNodes(newNode, testPackageUnitList);
}
}
}
else if (node.ToolTip == "装置")
{
string installationId = Funs.GetStrListByStr(node.NodeID, '|')[0];
var pointListMonth = (from x in testPackageUnitList
where x.InstallationId == installationId
select string.Format("{0:yyyy-MM}", x.TableDate)).Distinct();
foreach (var item in pointListMonth)
{
TreeNode newNode = new TreeNode();
newNode.Text = item;
newNode.NodeID = item + "|" + node.NodeID;
newNode.ToolTip = "月份";
node.Nodes.Add(newNode);
this.BindNodes(newNode, testPackageUnitList);
}
}
else if (node.ToolTip == "月份")
{
DateTime startTime = Convert.ToDateTime(this.txtSearchDate.Text.Trim() + "-01");
DateTime endTime = startTime.AddMonths(1);
string installationId = Funs.GetStrListByStr(node.ParentNode.NodeID, '|')[0];
var dReports = from x in testPackageUnitList
where x.InstallationId == installationId
&& x.TableDate >= startTime && x.TableDate < endTime
orderby x.TestPackageNo descending
select x;
foreach (var item in dReports)
{
TreeNode newNode = new TreeNode();
if (!string.IsNullOrEmpty(item.TestPackageNo))
{
newNode.Text = item.TestPackageNo;
}
else
{
newNode.Text = "未知";
}
if (!item.AduditDate.HasValue || string.IsNullOrEmpty(item.Auditer))
{
newNode.Text = "<font color='#FF7575'>" + newNode.Text + "</font>";
node.Text = "<font color='#FF7575'>" + node.Text + "</font>";
node.ParentNode.Text = "<font color='#FF7575'>" + node.ParentNode.Text + "</font>";
}
newNode.NodeID = item.PTP_ID;
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.PTP_ID = tvControlItem.SelectedNodeID;
this.BindGrid();
}
#endregion
#region
/// <summary>
/// 数据绑定
/// </summary>
private void BindGrid()
{
this.SetTextTemp();
this.PageInfoLoad(); ///页面输入保存信息
string strSql = @"SELECT * FROM dbo.View_PTP_TestPackageAudit
WHERE ProjectId= @ProjectId AND PTP_ID=@PTP_ID";
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
listStr.Add(new SqlParameter("@PTP_ID", this.PTP_ID));
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
// 2.获取当前分页数据
//var table = this.GetPagedDataTable(Grid1, tb1);
Grid1.RecordCount = tb.Rows.Count;
var table = this.GetPagedDataTable(Grid1, tb);
Grid1.DataSource = table;
Grid1.DataBind();
this.ShowGridItem();
}
/// <summary>
/// 行颜色设置
/// </summary>
private void ShowGridItem()
{
Count = 0;
int Count1 = 0, Count2 = 0, Count3 = 0, Count4 = 0;
int rowsCount = this.Grid1.Rows.Count;
for (int i = 0; i < rowsCount; i++)
{
int IsoInfoCount = Funs.GetNewIntOrZero(this.Grid1.Rows[i].Values[3].ToString()); //总焊口
int IsoInfoCountT = Funs.GetNewIntOrZero(this.Grid1.Rows[i].Values[4].ToString()); //完成总焊口
int CountS = Funs.GetNewIntOrZero(this.Grid1.Rows[i].Values[5].ToString()); ; //合格数
int CountU = Funs.GetNewIntOrZero(this.Grid1.Rows[i].Values[6].ToString()); ; //不合格数
decimal Rate = 0;
bool convertible = decimal.TryParse(this.Grid1.Rows[i].Values[9].ToString(), out Rate); //应检测比例
decimal Ratio = Funs.GetNewDecimalOrZero(this.Grid1.Rows[i].Values[10].ToString()); //实际检测比例
if (IsoInfoCount > IsoInfoCountT) //未焊完
{
Count1 += 1;
this.Grid1.Rows[i].RowCssClass = "Cyan";
}
else if (Rate > Ratio) //已焊完,未达检测比例
{
Count2 += 1;
this.Grid1.Rows[i].RowCssClass = "Yellow";
}
else if (CountU > 0) //已焊完,已达检测比例,但有不合格
{
Count3 += 1;
this.Grid1.Rows[i].RowCssClass = "Green";
}
else
{
Count4 += 1;
this.Grid1.Rows[i].RowCssClass = "Purple";
}
}
Count = Count1 + Count2 + Count2;
this.lab1.Text = Count1.ToString();
this.lab2.Text = Count2.ToString();
this.lab3.Text = Count3.ToString();
this.lab4.Text = Count4.ToString();
}
#region
/// <summary>
/// 加载页面输入保存信息
/// </summary>
private void PageInfoLoad()
{
this.btnAudit.Hidden = true;
this.btnCancelAudit.Hidden = true;
var testPackageManage = BLL.TestPackageManageEditService.GetTestPackageByID(this.PTP_ID);
if (testPackageManage != null)
{
this.txtTestPackageNo.Text = testPackageManage.TestPackageNo;
//if (!string.IsNullOrEmpty(testPackageManage.UnitId))
//{
// var unit = BLL.Base_UnitService.GetUnit(testPackageManage.UnitId);
// if (unit != null)
// {
// this.drpUnit.Text = unit.UnitName;
// }
//}
if (!string.IsNullOrEmpty(testPackageManage.InstallationId))
{
var install = BLL.Project_InstallationService.GetProject_InstallationByInstallationId(testPackageManage.InstallationId);
if (install != null)
{
this.drpInstallation.Text = install.InstallationName;
}
}
this.txtTestPackageName.Text = testPackageManage.TestPackageName;
//this.txtTestPackageCode.Text = testPackageManage.TestPackageCode;
if (!string.IsNullOrEmpty(testPackageManage.TestType))
{
var testType = BLL.Base_PressureService.GetPressureByPressureId(testPackageManage.TestType);
if (testType != null)
{
this.drpTestType.Text = testType.PressureName;
}
}
this.txtTestService.Text = testPackageManage.TestService;
this.txtTestHeat.Text = testPackageManage.TestHeat;
this.txtTestAmbientTemp.Text = testPackageManage.TestAmbientTemp;
this.txtTestMediumTemp.Text = testPackageManage.TestMediumTemp;
this.txtVacuumTestService.Text = testPackageManage.VacuumTestService;
this.txtVacuumTestPressure.Text = testPackageManage.VacuumTestPressure;
this.txtTightnessTestTime.Text = testPackageManage.TightnessTestTime;
this.txtTightnessTestTemp.Text = testPackageManage.TightnessTestTemp;
this.txtTightnessTest.Text = testPackageManage.TightnessTest;
this.txtTestPressure.Text = testPackageManage.TestPressure;
this.txtTestPressureTemp.Text = testPackageManage.TestPressureTemp;
this.txtTestPressureTime.Text = testPackageManage.TestPressureTime;
this.txtOperationMedium.Text = testPackageManage.OperationMedium;
this.txtPurgingMedium.Text = testPackageManage.PurgingMedium;
this.txtCleaningMedium.Text = testPackageManage.CleaningMedium;
this.txtLeakageTestService.Text = testPackageManage.LeakageTestService;
this.txtLeakageTestPressure.Text = testPackageManage.LeakageTestPressure;
this.txtAllowSeepage.Text = testPackageManage.AllowSeepage;
this.txtFactSeepage.Text = testPackageManage.FactSeepage;
this.txtModifyDate.Text = string.Format("{0:yyyy-MM-dd}", testPackageManage.ModifyDate);
if (!string.IsNullOrEmpty(testPackageManage.Modifier))
{
var users = BLL.Sys_UserService.GetUsersByUserId(testPackageManage.Modifier);
if (users != null)
{
this.drpModifier.Text = users.UserName;
}
}
this.txtTableDate.Text = string.Format("{0:yyyy-MM-dd}", testPackageManage.TableDate);
if (!string.IsNullOrEmpty(testPackageManage.Tabler))
{
var users = BLL.Sys_UserService.GetUsersByUserId(testPackageManage.Tabler);
if (users != null)
{
this.drpTabler.Text = users.UserName;
}
}
this.txtRemark.Text = testPackageManage.Remark;
this.txtAuditDate.Text = string.Format("{0:yyyy-MM-dd}", testPackageManage.AduditDate);
if (!string.IsNullOrEmpty(testPackageManage.Auditer))
{
var users = BLL.Sys_UserService.GetUsersByUserId(testPackageManage.Auditer);
if (users != null)
{
this.txtAuditMan.Text = users.UserName;
}
}
this.txtFinishDef.Text = testPackageManage.FinishDef;
this.txtFinishDate.Text = string.Format("{0:yyyy-MM-dd}", testPackageManage.FinishDate);
if (!string.IsNullOrEmpty(testPackageManage.Finisher))
{
this.drpFinisher.SelectedValue = testPackageManage.Finisher;
}
if (string.IsNullOrEmpty(testPackageManage.Finisher) || !testPackageManage.FinishDate.HasValue)
{
this.btnAudit.Hidden = false;
this.drpFinisher.Enabled = true;
this.txtFinishDate.Enabled = true;
}
else
{
this.btnCancelAudit.Hidden = false;
}
}
}
#endregion
#region
/// <summary>
/// 清空输入框
/// </summary>
private void SetTextTemp()
{
this.txtTestPackageNo.Text = string.Empty;
//this.drpUnit.Text = string.Empty;
this.drpInstallation.Text = string.Empty;
this.txtTestPackageName.Text = string.Empty;
//this.txtTestPackageCode.Text = string.Empty;
this.drpTestType.Text = string.Empty;
this.txtTestService.Text = string.Empty;
this.txtTestHeat.Text = string.Empty;
this.txtTestAmbientTemp.Text = string.Empty;
this.txtTestMediumTemp.Text = string.Empty;
this.txtVacuumTestService.Text = string.Empty;
this.txtVacuumTestPressure.Text = string.Empty;
this.txtTightnessTestTime.Text = string.Empty;
this.txtTightnessTestTemp.Text = string.Empty;
this.txtTightnessTest.Text = string.Empty;
this.txtTestPressure.Text = string.Empty;
this.txtTestPressureTemp.Text = string.Empty;
this.txtTestPressureTime.Text = string.Empty;
this.txtOperationMedium.Text = string.Empty;
this.txtPurgingMedium.Text = string.Empty;
this.txtCleaningMedium.Text = string.Empty;
this.txtLeakageTestService.Text = string.Empty;
this.txtLeakageTestPressure.Text = string.Empty;
this.txtAllowSeepage.Text = string.Empty;
this.txtFactSeepage.Text = string.Empty;
this.drpModifier.Text = string.Empty;
this.txtModifyDate.Text = string.Empty;
this.drpTabler.Text = string.Empty;
this.txtTableDate.Text = string.Empty;
this.txtRemark.Text = string.Empty;
this.drpFinisher.SelectedValue = BLL.Const._Null;
this.txtFinishDate.Text = string.Empty;
}
#endregion
#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
#region
/// <summary>
/// 审核检测单
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAudit_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.TestPackageManageCompleteMenuId, Const.BtnAuditing))
{
var updateTestPackage = BLL.TestPackageManageEditService.GetTestPackageByID(this.PTP_ID);
if (updateTestPackage != null)
{
if (!String.IsNullOrEmpty(this.txtFinishDate.Text) && this.drpFinisher.SelectedValue != BLL.Const._Null)
{
updateTestPackage.FinishDate = Funs.GetNewDateTime(this.txtFinishDate.Text);
updateTestPackage.Finisher = this.drpFinisher.SelectedValue;
updateTestPackage.FinishDef = this.txtFinishDef.Text.Trim();
BLL.TestPackageManageAuditService.AuditFinishDef(updateTestPackage);
this.InitTreeMenu();
this.BindGrid();
ShowNotify("审核完成!", MessageBoxIcon.Success);
}
else
{
ShowNotify("请填写完工人和完工日期!", MessageBoxIcon.Warning);
}
}
else
{
ShowNotify("请选择要审核的单据!", MessageBoxIcon.Warning);
}
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
#endregion
#region
/// <summary>
/// 取消审核检测单
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnCancelAudit_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.TestPackageManageCompleteMenuId, Const.BtnCancelAuditing))
{
var updateTestPackage = BLL.TestPackageManageEditService.GetTestPackageByID(this.PTP_ID);
if (updateTestPackage != null)
{
updateTestPackage.Finisher = null;
updateTestPackage.FinishDate = null;
updateTestPackage.FinishDef = this.txtFinishDef.Text.Trim();
BLL.TestPackageManageAuditService.AuditFinishDef(updateTestPackage);
this.InitTreeMenu();
this.BindGrid();
ShowNotify("取消审核完成!", MessageBoxIcon.Success);
}
else
{
ShowNotify("请确认单据!", MessageBoxIcon.Warning);
}
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
#endregion
#endregion
#region
/// <summary>
/// 关闭弹出窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
this.PTP_ID = this.hdPTP_ID.Text;
this.BindGrid();
this.InitTreeMenu();
this.hdPTP_ID.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.PTP_ID))
{
//string reportId = BLL.Const.HJGL_TrustReportId; // 试压包打印 待做模板
//PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}", reportId, this.PTP_ID, string.Empty, "打印 - ")));
}
else
{
ShowNotify("请选择无损委托记录!", MessageBoxIcon.Warning);
return;
}
}
#endregion
}
}