Basf_TCC7/HJGL/FineUIPro.Web/WeldingProcess/PMI/PMIDetectionEntry.aspx.cs

380 lines
15 KiB
C#
Raw Normal View History

2024-05-12 10:16:07 +08:00
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using BLL;
using System.Web;
using System.Collections;
using Model;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
2024-05-12 14:50:57 +08:00
using FineUIPro.Web.common.ProjectSet;
2024-05-12 19:06:28 +08:00
using Newtonsoft.Json.Linq;
2024-05-12 10:16:07 +08:00
namespace FineUIPro.Web.WeldingProcess.PMI
{
public partial class PMIDetectionEntry : PageBase
{
#region
/// <summary>
/// 检测单主键
/// </summary>
public string PMIID
{
get
{
return (string)ViewState["PMIID"];
}
set
{
ViewState["PMIID"] = value;
}
}
#endregion
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.txtNDEDateMonth.Text = string.Format("{0:yyyy-MM}", DateTime.Now);
this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
this.PMIID = string.Empty;
this.InitTreeMenu();//加载树
}
}
#region
/// <summary>
/// 加载树
/// </summary>
private void InitTreeMenu()
{
if (!string.IsNullOrEmpty(this.txtNDEDateMonth.Text.Trim()))
{
this.tvControlItem.Nodes.Clear();
List<Model.Base_Unit> units = new List<Model.Base_Unit>();
Model.Project_Unit 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
|| pUnit.UnitType == BLL.Const.UnitType_6)
{
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));
}
if (units != null)
{
foreach (var unit in units)
{
TreeNode newNode = new TreeNode();//定义根节点
newNode.Text = unit.UnitName;
newNode.NodeID = unit.UnitId;
newNode.Expanded = true;
newNode.ToolTip = "Unit";
this.tvControlItem.Nodes.Add(newNode);
this.BindNodes(newNode);
}
}
else
{
Alert.ShowInTop(Resources.Lan.PleaseAddUnitFirst, MessageBoxIcon.Warning);
}
}
else
{
Alert.ShowInTop(Resources.Lan.PleaseSelectTrustMonth, MessageBoxIcon.Warning);
}
}
/// <summary>
/// 绑定树节点
/// </summary>
/// <param name="node"></param>
private void BindNodes(TreeNode node)
{
2024-05-12 14:50:57 +08:00
DateTime startTime = Convert.ToDateTime(this.txtNDEDateMonth.Text.Trim() + "-01");
DateTime endTime = startTime.AddMonths(1);
string searchCode = this.txtSearchCode.Text.Trim();
2024-05-12 10:16:07 +08:00
if (node.ToolTip == "Unit")
{
2024-05-12 14:50:57 +08:00
string unitId = node.NodeID;
var ndt = from x in Funs.DB.PMI_Delegation
where x.UnitId == unitId
&& x.ProjectId == this.CurrUser.LoginProjectId
&& x.DelegationDate >= startTime && x.DelegationDate <= endTime
2024-05-12 19:06:28 +08:00
&& (x.DelegationNo.Contains(searchCode) || searchCode == "")
2024-05-12 14:50:57 +08:00
select x;
//if (!string.IsNullOrWhiteSpace(searchCode))
// ndt = ndt.Where(q => q.DelegationNo.Contains(searchCode));
2024-05-12 10:16:07 +08:00
foreach (var q in ndt)
{
TreeNode newNode = new TreeNode();
newNode.Text = q.DelegationNo;
newNode.NodeID = q.Id;
newNode.ToolTip = "DelegationNo";
newNode.EnableClickEvent = true;
node.Nodes.Add(newNode);
BindNodes(newNode);
2024-05-12 14:50:57 +08:00
}
2024-05-12 19:06:28 +08:00
}
2024-05-12 10:16:07 +08:00
}
#endregion
#region TreeView
/// <summary>
/// 点击TreeView
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
{
this.PMIID = tvControlItem.SelectedNodeID;
this.hdPMIId.Text = this.PMIID;
this.BindGrid();
}
#endregion
#region
protected void TextBox_TextChanged(object sender, EventArgs e)
{
this.BindGrid();
}
/// <summary>
/// 数据绑定
/// </summary>
private void BindGrid()
{
if (!string.IsNullOrWhiteSpace(this.hdPMIId.Text) && this.tvControlItem.SelectedNode.ToolTip == "DelegationNo")
{
2024-05-12 14:50:57 +08:00
string strSql = string.Empty;
List<SqlParameter> listStr = new List<SqlParameter>();
2024-05-12 10:16:07 +08:00
this.SetTextTemp();
this.PageInfoLoad(); ///页面输入提交信息
2024-05-12 14:50:57 +08:00
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
{
var result = Funs.DB.PMI_Delegation.FirstOrDefault(t => t.Id == this.tvControlItem.SelectedNodeID);
if (result != null)
{
this.PMIID = result.Id;
strSql = @"SELECT *,
(case status when 0 then '' else '' end) StatusText
FROM [View_PMI_DelegationDetails] WHERE ProjectId= @ProjectId AND PMIID=@PMIDelegationId ";
listStr.Add(new SqlParameter("@ProjectId", result != null ? result.ProjectId : this.CurrUser.LoginProjectId));
listStr.Add(new SqlParameter("@PMIDelegationId", this.PMIID));
if (!string.IsNullOrEmpty(this.txtIsoNo.Text.Trim()))
{
strSql += @" and PipelineCode like '%'+@PipelineCode+'%' ";
listStr.Add(new SqlParameter("@PipelineCode", this.txtIsoNo.Text.Trim()));
}
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();
}
}
2024-05-12 10:16:07 +08:00
}
}
#region
/// <summary>
/// 加载页面输入提交信息
/// </summary>
private void PageInfoLoad()
{
this.SimpleForm1.Reset(); ///重置所有字段
var pageInfo = (from x in Funs.DB.PMI_Delegation
join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId
join n in Funs.DB.Project_Installation on x.InstallationId equals n.InstallationId
join u in Funs.DB.Sys_User on x.DetectionStandard equals u.UserId into u1 //左连接查询
from u in u1.DefaultIfEmpty()
2024-05-12 19:06:28 +08:00
where x.Id == hdPMIId.Text
select new
{
DelegationNo = x.DelegationNo,
DelegationDate = x.DelegationDate,
InstallationName = n.InstallationName,
UnitName = y.UnitName,
DetectionMethod = "PMI光谱分析",
Tabler = x.Tabler,
Remark = x.Remark,
DetectionStandard = x.DetectionStandard,
2024-05-12 10:16:07 +08:00
}).ToList();
2024-05-12 19:06:28 +08:00
if (pageInfo.Count > 0)
2024-05-12 10:16:07 +08:00
{
this.txtDelegationNo.Text = pageInfo[0].DelegationNo;
2024-05-12 22:53:47 +08:00
this.txtDelegationDate.Text = pageInfo[0].DelegationDate.Value.ToString("yyyy-MM-dd");
2024-05-12 10:16:07 +08:00
this.txtInstallationName.Text = pageInfo[0].InstallationName;
this.txtUnitName.Text = pageInfo[0].UnitName;
this.txtDetectionMethod.Text = pageInfo[0].DetectionMethod;
this.txtTabler.Text = pageInfo[0].Tabler;
this.txtRemark.Text = pageInfo[0].Remark;
2024-05-12 19:06:28 +08:00
this.txtDetectionStandard.Text = pageInfo[0].DetectionStandard;
2024-05-12 10:16:07 +08:00
}
}
#endregion
/// <summary>
/// 清空
/// </summary>
private void SetTextTemp()
{
this.txtDelegationNo.Text = string.Empty;
this.txtDelegationDate.Text = string.Empty;
this.txtInstallationName.Text = string.Empty;
this.txtUnitName.Text = string.Empty;
this.txtDetectionMethod.Text = string.Empty;
this.txtTabler.Text = string.Empty;
this.txtRemark.Text = string.Empty;
2024-05-12 14:50:57 +08:00
this.txtDetectionStandard.Text = string.Empty;
2024-05-12 10:16:07 +08:00
}
#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 Tree_TextChanged(object sender, EventArgs e)
{
this.InitTreeMenu();
//this.BindGrid();
}
#endregion
#region
/// <summary>
/// 获取缺陷
/// </summary>
/// <param name="bigType"></param>
/// <returns></returns>
protected string ConvertCheckDefects(object CheckDefects)
{
string str = string.Empty;
if (CheckDefects != null)
{
HttpCookie lanCookie = Request.Cookies["SelectLan"];
if (lanCookie["lan"] == "zh-CN") //中文
{
str = BLL.Base_DefectService.GetDefectNameStrByDefectIdStr(CheckDefects.ToString());
}
else
{
str = BLL.Base_DefectService.GetDefectEngNameStrByDefectIdStr(CheckDefects.ToString());
}
}
return str;
}
#endregion
2024-05-12 19:06:28 +08:00
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
//if (!CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.BItemEndCheckMenuId, Const.BtnSave))
//{
// ShowNotify("您没有这个权限,请与管理员联系!");
// return;
//}
if (Grid1.GetModifiedData().Count > 0)
{
JArray teamGroupData = Grid1.GetMergedData();
foreach (JObject teamGroupRow in teamGroupData)
{
string status = teamGroupRow.Value<string>("status");
if (status == "modified")
{
JObject values = teamGroupRow.Value<JObject>("values");
string id = teamGroupRow.Value<string>("id");
Model.PMI_DelegationDetails onePMIDelegationDetails = Funs.DB.PMI_DelegationDetails.FirstOrDefault(p => p.Id == id);
if (onePMIDelegationDetails == null)
continue;
//检测日期(缺失)
2024-05-12 22:53:47 +08:00
string DelegationDate = values.Value<string>("DelegationDate");
if (string.IsNullOrWhiteSpace(DelegationDate))
2024-05-12 19:06:28 +08:00
;
else
;
//报告日期
string createdTime = values.Value<string>("CreatedTime");
if (string.IsNullOrWhiteSpace(createdTime))
onePMIDelegationDetails.CreatedTime=null;
else
onePMIDelegationDetails.CreatedTime=Convert.ToDateTime(createdTime);
//报告编号
onePMIDelegationDetails.ReportNo = values.Value<string>("reportNo").ToString();
//是否合格 0合格 1不合格
string statusText = values.Value<string>("StatusText");
if (statusText == "合格")
onePMIDelegationDetails.Status = 0;
else
onePMIDelegationDetails.Status = 1;
Funs.DB.SubmitChanges();
}
}
this.BindGrid();
}
2024-05-12 22:53:47 +08:00
ShowNotify(Resources.Lan.SaveSuccessfully, MessageBoxIcon.Success);
2024-05-12 19:06:28 +08:00
}
2024-05-12 10:16:07 +08:00
}
}