using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Text; using BLL; using System.Windows.Forms; using Newtonsoft.Json.Linq; using AspNet = System.Web.UI.WebControls; using FineUIPro.Web.common.BaseInfo; namespace FineUIPro.Web.HJGL.WeldingManage { public partial class PointManage : PageBase { #region 定义项 /// /// 组批主键 /// public string BatchId { get { return (string)ViewState["BatchId"]; } set { ViewState["BatchId"] = value; } } public string EventArg { get { return (string)ViewState["EventArg"]; } set { ViewState["EventArg"] = value; } } #endregion public static List trustItemList; public static List hotPass_JOT_ID_List; public static List hardPassList; public static List HotProessTrustItemList; public static List hotHardList; #region 加载页面 /// /// 加载页面 /// /// /// 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.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; //var projects = BLL.Base_ProjectService.GetProjectListByUserIdAndState(this.CurrUser.UserId, this.drpIsProjectClosed.SelectedValue); //RadioButtonList1.DataTextField = "ProjectCode"; //RadioButtonList1.DataValueField = "ProjectId"; //RadioButtonList1.DataSource = projects; //RadioButtonList1.DataBind(); this.drpIsClosed.DataTextField = "Text"; this.drpIsClosed.DataValueField = "Value"; this.drpIsClosed.DataSource = BLL.DropListService.IsTrueOrFalseDrpList(); this.drpIsClosed.DataBind(); Funs.FineUIPleaseSelect(this.drpIsClosed); this.drpIsQue.DataTextField = "Text"; this.drpIsQue.DataValueField = "Value"; this.drpIsQue.DataSource = BLL.DropListService.IsTrueOrFalseDrpList(); this.drpIsQue.DataBind(); Funs.FineUIPleaseSelect(this.drpIsQue); this.drpNDTRate.DataTextField = "NDTR_Name"; this.drpNDTRate.DataValueField = "NDTR_ID"; this.drpNDTRate.DataSource = BLL.HJGL_DetectionService.GetNDTRateNameList(); this.drpNDTRate.DataBind(); Funs.FineUIPleaseSelect(this.drpNDTRate); this.drpIsDJ.DataTextField = "Text"; this.drpIsDJ.DataValueField = "Value"; this.drpIsDJ.DataSource = BLL.DropListService.IsTrueOrFalseDrpList(); this.drpIsDJ.DataBind(); Funs.FineUIPleaseSelect(this.drpIsDJ); this.drpIsoNo.DataTextField = "ISO_IsoNo"; this.drpIsoNo.DataValueField = "ISO_ID"; Funs.FineUIPleaseSelect(this.drpIsoNo); this.drpISO_Code.DataTextField = "Text"; this.drpISO_Code.DataValueField = "Value"; Funs.FineUIPleaseSelect(this.drpISO_Code); //this.txtPointDate.Text = string.Format("{0:yyyy-MM}", DateTime.Now); //CheckBoxField cbVI = Grid1.FindColumn("IsVI") as CheckBoxField; //cbVI.HeaderText = " 外观检验"; //显示列 trustItemList = HJGL_TrustManageEditService.GetView_CH_TrustItemByProjectId(this.drpProjectId.SelectedValue); hotPass_JOT_ID_List = (from x in Funs.DB.HJGL_View_CH_HotProessResult where x.ProjectId == drpProjectId.SelectedValue select new Model.HJGLPointManageCheckIsOk { Id = x.JOT_ID, IsOK = x.IsOK }).ToList(); hardPassList = (from x in Funs.DB.HJGL_View_CH_HardTestResult where x.ProjectId == drpProjectId.SelectedValue select new Model.HJGLPointManageCheckIsOk { Id = x.JOT_ID, IsOK = x.IsOK }).ToList(); HotProessTrustItemList = (from x in Funs.DB.HJGL_View_CH_HotProessTrustItem where x.ProjectId == drpProjectId.SelectedValue && x.TrustDate != null select new Model.HJGLPointManageCheckIsOk { Id = x.JOT_ID, IsOK = x.IsOK }).ToList(); hotHardList = (from x in Funs.DB.HJGL_CH_HardTestReportItem select new Model.HJGLPointManageCheckIsOk { Id = x.JOT_ID }).ToList(); Model.Sys_UserShowColumns c = BLL.Sys_UserShowColumnsService.GetColumnsByUserId(this.CurrUser.UserId, "P"); if (c != null) { this.GetShowColumn(c.Columns); } this.InitTreeMenu();//加载树 } } /// /// 显示的列 /// /// private void GetShowColumn(string column) { if (!string.IsNullOrEmpty(column)) { this.Grid1.Columns[15].Hidden = true; this.Grid1.Columns[16].Hidden = true; this.Grid1.Columns[17].Hidden = true; this.Grid1.Columns[18].Hidden = true; this.Grid1.Columns[19].Hidden = true; List columns = column.Split(',').ToList(); foreach (var item in columns) { this.Grid1.Columns[Convert.ToInt32(item)].Hidden = false; } } } #endregion #region 选择要显示列 /// /// 选择显示列 /// /// /// protected void btnSelectColumn_Click(object sender, EventArgs e) { PageContext.RegisterStartupScript(Window4.GetShowReference(String.Format("PointManageShowColumn.aspx", "显示列 - "))); } /// /// 关闭弹出窗口4 /// /// /// protected void Window4_Close(object sender, WindowCloseEventArgs e) { this.BindGrid(); //显示列 Model.Sys_UserShowColumns c = BLL.Sys_UserShowColumnsService.GetColumnsByUserId(this.CurrUser.UserId, "P"); if (c != null) { this.GetShowColumn(c.Columns); } } #endregion #region 加载树项目-月份-批编号 /// /// 加载树 /// private void InitTreeMenu() { this.tvControlItem.Nodes.Clear(); TreeNode rootNode = new TreeNode(); rootNode.Text = "项目-月份-批编号"; rootNode.ToolTip = "项目"; rootNode.NodeID = "0"; rootNode.Expanded = true; this.tvControlItem.Nodes.Add(rootNode); List projects = BLL.Base_ProjectService.GetProjectListByUserIdAndState(this.CurrUser.UserId, this.drpIsProjectClosed.SelectedValue, "1"); if (this.drpProjectId.SelectedValue != null && this.drpProjectId.SelectedValue != "null") { projects = projects.Where(x => x.ProjectId == this.drpProjectId.SelectedValue).ToList(); } //string selectProjectIds = String.Join("|", DropDownBox1.Values); //选择显示的项目 //if (selectProjectIds.Length > 6) //勾选了显示项目 //{ // projects = projects.Where(x => selectProjectIds.Contains(x.ProjectId)).ToList(); //} foreach (var item in projects) { TreeNode rootProjectNode = new TreeNode();//定义根节点 rootProjectNode.Text = item.ProjectCode; rootProjectNode.NodeID = item.ProjectId; rootProjectNode.Expanded = true; rootProjectNode.ToolTip = item.ProjectName; rootProjectNode.CommandName = "项目名称"; rootNode.Nodes.Add(rootProjectNode); List batchLists = this.GetBatchList(item.ProjectId); if (this.drpInstallation.SelectedValue != null && this.drpInstallation.SelectedValue != "null") { batchLists = batchLists.Where(x => x.InstallationId == drpInstallation.SelectedValue).ToList(); } var pointListMonth = (from x in batchLists select string.Format("{0:yyyy-MM}", x.BatchStartDate)).Distinct(); pointListMonth = pointListMonth.OrderByDescending(x => x.ToString()); foreach (var month in pointListMonth) { TreeNode newNode = new TreeNode(); newNode.Text = month; newNode.NodeID = month + "|" + rootProjectNode.NodeID; newNode.ToolTip = "月份"; newNode.CommandName = "月份"; newNode.EnableExpandEvent = true; rootProjectNode.Nodes.Add(newNode); TreeNode tn = new TreeNode(); tn.NodeID = "temp"; tn.Text = "正在加载..."; newNode.Nodes.Add(tn); } //this.BindNodes(rootProjectNode, batchLists); } } /// /// 根据条件获取批列表 /// /// /// private List GetBatchList(string projectId) { List batchLists = (from x in Funs.DB.HJGL_BO_Batch where x.ProjectId == projectId select x).ToList(); List queBatchLists = new List();//合格批集合 List noQueBatchLists = new List();//不合格批集合 List djBatchLists = new List();//对接焊缝批集合 List nodjQueBatchLists = new List();//非对接焊缝批集合 // 筛选关闭的批 if (drpIsClosed.SelectedValue != "null") { if (Convert.ToBoolean(drpIsClosed.SelectedValue)) { batchLists = (from x in batchLists where x.BatchIsClosed == true select x).ToList(); } else { batchLists = (from x in batchLists where x.BatchIsClosed == false || x.BatchIsClosed == null select x).ToList(); } } // 筛选检验合格的批 if (drpIsQue.SelectedValue != "null") { bool isCheck = true; foreach (Model.HJGL_BO_Batch q in batchLists) { //var batchdetail = BLL.HJGL_BO_BatchDetailService.GetBatchDetailByBatchId(q.BatchId); var batchdetail = from x in Funs.DB.HJGL_BO_BatchDetail where x.BatchId == q.BatchId select x.BatchDetailId; var trust = from x in Funs.DB.HJGL_CH_Trust where x.BatchId == q.BatchId select x; var trustdetail = from x in BLL.Funs.DB.HJGL_CH_TrustItem where batchdetail.Contains(x.BatchDetailId) select x; if (trustdetail.Where(e => e.States != "2").Count() > 0) { isCheck = false; } //foreach (var detail in batchdetail) //{ // var trustdetail = from x in BLL.Funs.DB.HJGL_CH_TrustItem where x.BatchDetailId == detail.BatchDetailId select x; // if (trustdetail.Where(e => e.States != "2").Count() > 0) // { // isCheck = false; // break; // } //} if (isCheck && trust.Count() > 0) { queBatchLists.Add(q); } else { noQueBatchLists.Add(q); } } if (Convert.ToBoolean(drpIsQue.SelectedValue)) { batchLists = queBatchLists; } else { batchLists = noQueBatchLists; } } //筛选检测比例 if (this.drpNDTRate.SelectedValue != BLL.Const._Null) { batchLists = batchLists.Where(x => x.NDTR_ID == this.drpNDTRate.SelectedValue).ToList(); } //筛选是否对接焊缝 if (this.drpIsDJ.SelectedValue != BLL.Const._Null) { foreach (Model.HJGL_BO_Batch q in batchLists) { var batchdetail = BLL.HJGL_BO_BatchDetailService.GetBatchDetailByBatchId(q.BatchId).FirstOrDefault(); if (batchdetail != null) { Model.HJGL_PW_JointInfo joint = BLL.HJGL_PW_JointInfoService.GetJointInfoByJotID(batchdetail.JOT_ID); if (joint != null) { if (joint.JOTY_ID == "1e2704c8-b088-4389-9adf-9d89ceffe85b") //对接焊缝 { djBatchLists.Add(q); } else { nodjQueBatchLists.Add(q); } } } } if (Convert.ToBoolean(drpIsDJ.SelectedValue)) { batchLists = djBatchLists; } else { batchLists = nodjQueBatchLists; } } return batchLists; } #endregion #region 绑定树节点 /// /// 绑定树节点 /// /// private void BindNodes(TreeNode node, List batchLists) { //if (node.CommandName == "项目名称") //{ // var pointListMonth = (from x in batchLists // select string.Format("{0:yyyy-MM}", x.BatchStartDate)).Distinct(); // foreach (var item in pointListMonth) // { // TreeNode newNode = new TreeNode(); // newNode.Text = item; // newNode.NodeID = item + "|" + node.NodeID; ; // newNode.ToolTip = "月份"; // newNode.CommandName = "月份"; // node.Nodes.Add(newNode); // this.BindNodes(newNode, batchLists); // } //} if (node.CommandName == "月份") { var batch = from x in batchLists where string.Format("{0:yyyy-MM}", x.BatchStartDate) == node.Text orderby x.BatchCode descending select x; foreach (var item in batch) { TreeNode newNode = new TreeNode(); bool isCheck = true; //var batchdetail = BLL.HJGL_BO_BatchDetailService.GetBatchDetailByBatchId(item.BatchId); var batchdetail = from x in Funs.DB.HJGL_BO_BatchDetail where x.BatchId == item.BatchId select x.BatchDetailId; var trust = BLL.HJGL_TrustManageEditService.GetTrustByBatchId(item.BatchId); string strJoty = string.Empty; var joty = BLL.HJGL_WeldService.GetJointTypeByID(item.JOTY_ID); if (joty != null && !string.IsNullOrEmpty(joty.JOYT_ShortName)) { strJoty = joty.JOYT_ShortName; } var ndtr = BLL.HJGL_DetectionService.GetNDTRateByNDTRID(item.NDTR_ID); string batchCode = string.Format("{0:yyyy-MM-dd}", item.BatchStartDate) + "-" + ndtr.NDTR_Name + " " + item.BatchCode + "(" + strJoty + "-" + batchdetail.Count() + ")"; // 批关闭为红色 if (item.BatchIsClosed == true) { newNode.Text = "" + batchCode + ""; } else { newNode.Text = batchCode; } // 筛选检验合格的批 if (drpIsQue.SelectedValue != "null") { if (Convert.ToBoolean(drpIsQue.SelectedValue)) { isCheck = true; } else { isCheck = false; } } else { if (trust == null && ndtr.NDTR_Rate.Value != 0) { isCheck = false; } else { var trustdetail = from x in BLL.Funs.DB.HJGL_CH_TrustItem where batchdetail.Contains(x.BatchDetailId) select x; if (trustdetail.Where(e => e.States != "2").Count() > 0) { isCheck = false; } //foreach (var detail in batchdetail) //{ // var trustdetail = from x in BLL.Funs.DB.HJGL_CH_TrustItem where x.BatchDetailId == detail.BatchDetailId select x; // if (trustdetail.Where(e => e.States != "2").Count() > 0) // { // isCheck = false; // break; // } //} } } // 所有检测合格为绿色 if (isCheck == true && item.BatchIsClosed == true) { newNode.Text = "" + batchCode + ""; } newNode.NodeID = item.BatchId; newNode.ToolTip = "批关闭为红色,批检测合格为绿色"; newNode.EnableClickEvent = true; node.Nodes.Add(newNode); } } } #endregion #region 点击TreeView /// /// 点击TreeView /// /// /// protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e) { this.EmptyText(); this.BatchId = tvControlItem.SelectedNodeID; this.PageInfoLoad(); e.Node.ParentNode.Expanded = true; } protected void tvControlItem_NodeExpand(object sender, TreeNodeEventArgs e) { if (e.Node.Nodes != null) { e.Node.Nodes.Clear(); } string node = e.NodeID; string projectId = string.Empty; if (node.Split('|').Count() > 1) { projectId = node.Split('|')[1]; } List batchLists = this.GetBatchList(projectId); this.BindNodes(e.Node, batchLists); } #endregion #region 数据绑定 #region 加载加载主表信息 /// /// 加载主表信息 /// private void PageInfoLoad() { Model.HJGL_BO_Batch batch = BLL.HJGL_BO_BatchService.GetBatchById(this.BatchId); this.btnDelete.Hidden = true; if (batch != null) { var isoList = (from x in Funs.DB.HJGL_BO_BatchDetail join y in Funs.DB.HJGL_PW_IsoInfo on x.ISO_ID equals y.ISO_ID where x.BatchId == this.BatchId select new { x.ISO_ID, y.ISO_IsoNo }).Distinct(); this.drpIsoNo.Items.Clear(); this.drpIsoNo.DataSource = isoList; this.drpIsoNo.DataBind(); Funs.FineUIPleaseSelect(this.drpIsoNo); this.drpIsoNo.SelectedValue = BLL.Const._Null; var det = BLL.HJGL_BO_BatchDetailService.GetBatchDetailByBatchId(BatchId); if (det.Count() == 0) { this.btnDelete.Hidden = false; } else { drpWelder.Items.Clear(); var welderList = (from x in Funs.DB.HJGL_BO_BatchDetail join y in Funs.DB.HJGL_PW_JointInfo on x.JOT_ID equals y.JOT_ID join z in Funs.DB.HJGL_BS_Welder on y.JOT_CellWelder equals z.WED_ID join a in Funs.DB.HJGL_BS_Welder on y.JOT_FloorWelder equals a.WED_ID where x.BatchId == this.BatchId select new { WedId = y.JOT_CellWelder + "," + y.JOT_FloorWelder, WedCode = z.WED_Code != a.WED_Code ? (z.WED_Code + "/" + a.WED_Code) : z.WED_Code }).Distinct().ToList(); welderList = welderList.Distinct().ToList(); this.drpWelder.DataTextField = "WedCode"; this.drpWelder.DataValueField = "WedId"; this.drpWelder.DataSource = welderList; this.drpWelder.DataBind(); Funs.FineUIPleaseSelect(this.drpWelder); } this.lblBatchCode.Text = batch.BatchCode; if (!string.IsNullOrEmpty(batch.InstallationId)) { var installation = BLL.Project_InstallationService.GetInstallationByInstallationId(batch.InstallationId); if (installation != null) { this.lblInstallName.Text = installation.InstallationName; } } if (!string.IsNullOrEmpty(batch.ISC_ID)) { var pipelineClass = BLL.HJGL_PipingClassService.GetPipingClassByPipingClassId(batch.ISC_ID); if (pipelineClass != null) { this.lblISC_Name.Text = pipelineClass.ISC_IsoName; } } if (!string.IsNullOrEmpty(batch.ExecStandardId)) { var execStandard = BLL.HJGL_ExecStandardService.GetExecStandardById(batch.ExecStandardId); if (execStandard != null) { this.lblExecStandardName.Text = execStandard.ExecStandardName; } } //if (!string.IsNullOrEmpty(batch.SER_ID)) //{ // var ser = BLL.HJGL_MediumService.GetServiceBySERID(batch.SER_ID); // if (ser != null) // { // this.lblSer_Name.Text = ser.SER_Name; // } //} if (!string.IsNullOrEmpty(batch.STE_ID)) { var ste = BLL.HJGL_MaterialService.GetSteelBySteID(batch.STE_ID); if (ste != null) { this.lblSTE_Name.Text = ste.STE_Code; } } if (!string.IsNullOrEmpty(batch.JOTY_ID)) { var joty = BLL.HJGL_WeldService.GetJointTypeByID(batch.JOTY_ID); if (joty != null) { this.lblJOTY_Name.Text = joty.JOTY_Name; } } if (!string.IsNullOrEmpty(batch.NDTR_ID)) { var ndtr = BLL.HJGL_DetectionService.GetNDTRateByNDTRID(batch.NDTR_ID); if (ndtr != null) { this.lblNDTR_Name.Text = ndtr.NDTR_Name; } } if (batch.IsSpecial == true) { this.cbIsSpecial.Checked = true; } else { this.cbIsSpecial.Checked = false; } if (batch.BatchIsClosed == true) { this.cbBatchIsClosed.Checked = true; } else { this.cbBatchIsClosed.Checked = false; } if (batch.BatchStartDate != null) { this.txtBatchStartDate.Text = string.Format("{0:yyyy-MM-dd}", batch.BatchStartDate); } if (batch.BatchCloseDate != null) { this.lblBatchCloseDate.Text = string.Format("{0:yyyy-MM-dd}", batch.BatchCloseDate); } else { this.lblBatchCloseDate.Text = string.Empty; } this.BindGrid();//加载明细 } } #endregion #region 加载明细表信息 /// /// 数据绑定 /// private void BindGrid() { string strSql = @"SELECT * FROM (SELECT BatchDetail.BatchDetailId,BatchDetail.BatchId,BatchDetail.ISO_ID,iso.ISO_IsoNo,WeldMethod.WME_Name, BatchDetail.NDT,(Case when BatchDetail.PointType=2 then 'K' else '' end) as PointType, '1-'+IsoClass.ISC_IsoName+'-'+Ser.SER_Code+'-'+Steel.STE_Code AS ISO_Code,JointInfo.WeldL, BatchDetail.PointDate,JointInfo.JOT_JointNo,Welder1.WED_ID,Welder2.WED_ID as WED_ID2, (CASE WHEN Steel.STE_Code IS NOT NULL AND Steel2.STE_Code IS NOT NULL and Steel.STE_Code!=Steel2.STE_Code THEN Steel.STE_Code + '/' + Steel2.STE_Code WHEN Steel.STE_Code IS NOT NULL THEN Steel.STE_Code ELSE ISNULL(Steel2.STE_Code,'') END) AS STE_Code, --材质 (CASE WHEN JointInfo.JOT_CellWelder!=JointInfo.JOT_FloorWelder THEN Welder1.WED_Code+'/'+Welder2.WED_Code ELSE Welder1.WED_Code END) AS WED_Code, (CASE WHEN JointInfo.Jot_WeldingDate IS NOT NULL THEN JointInfo.Jot_WeldingDate ELSE WeldReportMain.JOT_WeldDate END) AS JOT_WeldDate, JointInfo.JOT_JointAttribute,JointInfo.JOT_Location,JointInfo.RT_States,JointInfo.PT_States,JointInfo.MT_States,JointInfo.UT_States,JointInfo.PAUT_States, JointInfo.ProessTypes,JointInfo.JOT_Dia,JointInfo.JOT_Sch,JointInfo.JOT_QualifiedLevel, (CASE WHEN JointInfo.Jot_WeldingDate IS NOT NULL THEN JointInfo.Jot_WeldingDate ELSE WeldReportMain.JOT_WeldDate END) AS ConfirmDate, BatchDetail.CheckAddress,BatchDetail.IsVI, BatchDetail.VICheckDate,BatchDetail.Checker,BatchDetail.Remark, JointInfo.Sort1,JointInfo.Sort2,JointInfo.Sort3,JointInfo.Sort4,JointInfo.Sort5 FROM HJGL_BO_BatchDetail AS BatchDetail LEFT JOIN HJGL_PW_JointInfo AS JointInfo ON JointInfo.JOT_ID = BatchDetail.JOT_ID LEFT JOIN HJGL_BS_Steel AS Steel ON Steel.STE_ID=JointInfo.STE_ID LEFT JOIN HJGL_BS_Steel AS Steel2 ON Steel2.STE_ID=JointInfo.STE_ID2 left join HJGL_BS_WeldMethod AS WeldMethod on WeldMethod.WME_ID=JointInfo.WME_ID LEFT JOIN HJGL_PW_IsoInfo AS iso ON BatchDetail.ISO_ID = iso.ISO_ID LEFT JOIN HJGL_BS_IsoClass AS IsoClass ON IsoClass.ISC_ID =iso.ISC_ID LEFT JOIN HJGL_BS_Service AS Ser ON Ser.SER_ID = iso.SER_ID LEFT JOIN HJGL_BS_Welder AS Welder1 ON Welder1.WED_ID = JointInfo.JOT_CellWelder LEFT JOIN HJGL_BS_Welder AS Welder2 ON Welder2.WED_ID = JointInfo.JOT_FloorWelder LEFT JOIN HJGL_BO_WeldReportMain AS WeldReportMain on WeldReportMain.DReportID=JointInfo.DReportID) v WHERE v.BatchId=@BatchId "; List listStr = new List(); //listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId)); listStr.Add(new SqlParameter("@BatchId", this.BatchId)); if (this.drpIsoNo.SelectedValue != BLL.Const._Null) { strSql += " AND v.ISO_ID = @IsoId"; listStr.Add(new SqlParameter("@IsoId", this.drpIsoNo.SelectedValue)); } if (this.drpISO_Code.SelectedValue != BLL.Const._Null) { strSql += " AND v.ISO_Code = @ISO_Code"; listStr.Add(new SqlParameter("@ISO_Code", this.drpISO_Code.SelectedValue)); } if (this.drpWelder.SelectedValue != "null" && this.drpWelder.SelectedValue != null) { strSql += " AND (v.WED_ID = @WED_ID1 and v.WED_ID2 = @WED_ID2)"; listStr.Add(new SqlParameter("@WED_ID1", this.drpWelder.SelectedValue.Split(',')[0])); listStr.Add(new SqlParameter("@WED_ID2", this.drpWelder.SelectedValue.Split(',')[1])); } SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); Grid1.RecordCount = tb.Rows.Count; tb = GetFilteredTable(Grid1.FilteredData, tb); // 2.获取当前排序(如不分页要调用这个排序方法) //var table = this.GetSortTable(Grid1, tb); // 2.获取当前分页数据 var table = this.GetPagedDataTable(Grid1, tb); Grid1.DataSource = table; Grid1.DataBind(); List list = (from x in tb.AsEnumerable() select x.Field("ISO_Code")).Distinct().ToList(); //for (int i = 0; i < this.Grid1.Rows.Count; i++) //{ // if (!string.IsNullOrEmpty(this.Grid1.Rows[i].Values[2].ToString())) // { // if (!list.Contains(this.Grid1.Rows[i].Values[2].ToString())) // { // list.Add(this.Grid1.Rows[i].Values[2].ToString()); // } // } //} if (list.Count > 0) { ListItem[] items = new ListItem[list.Count]; for (int i = 0; i < list.Count; i++) { items[i] = new ListItem(list[i], list[i]); } this.drpISO_Code.Items.Clear(); this.drpISO_Code.DataSource = items; this.drpISO_Code.DataBind(); Funs.FineUIPleaseSelect(this.drpISO_Code); this.drpISO_Code.SelectedValue = BLL.Const._Null; } } #endregion #endregion #region 分页 /// /// 页索引改变事件 /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { BindGrid(); } #endregion #region 分页选择下拉改变事件 /// /// 分页选择下拉改变事件 /// /// /// protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); BindGrid(); } #endregion #region 排序 /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, GridSortEventArgs e) { //Grid1.SortDirection = e.SortDirection; //Grid1.SortField = e.SortField; BindGrid(); } #endregion #region 清空文本框 private void EmptyText() { this.lblBatchCode.Text = string.Empty; this.lblInstallName.Text = string.Empty; this.lblISC_Name.Text = string.Empty; this.lblExecStandardName.Text = string.Empty; //this.lblSer_Name.Text = string.Empty; this.lblSTE_Name.Text = string.Empty; this.lblJOTY_Name.Text = string.Empty; this.lblNDTR_Name.Text = string.Empty; this.cbIsSpecial.Checked = false; this.cbBatchIsClosed.Checked = false; this.txtBatchStartDate.Text = string.Empty; this.lblBatchCloseDate.Text = string.Empty; } #endregion #region 关闭弹出窗口及刷新页面 ///// ///// 关闭弹出窗口 ///// ///// ///// //protected void Window1_Close(object sender, WindowCloseEventArgs e) //{ // this.InitTreeMenu();//加载树 // this.PageInfoLoad(); //} #endregion #region 批关闭 /// /// 批关闭按钮 /// /// /// protected void btnSystemClose_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_PointMenuId, Const.BtnBatchClose)) { var batch = BLL.HJGL_BO_BatchService.GetBatchById(this.BatchId); if (batch != null) { if (batch.BatchIsClosed != true) { batch.BatchId = this.BatchId; batch.BatchIsClosed = true; batch.BatchCloseDate = DateTime.Now; BLL.HJGL_BO_BatchService.UpdateBatchIsClosed(batch); var batchDetail = BLL.HJGL_BO_BatchDetailService.GetBatchDetailByBatchId(this.BatchId); foreach (var detail in batchDetail) { detail.IsVI = true; detail.VICheckDate = DateTime.Now.Date; BLL.HJGL_BO_BatchDetailService.UpdateBatchDetail(detail); } BindGrid(); BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "批关闭"); ShowNotify("批关闭成功!", MessageBoxIcon.Success); this.PageInfoLoad(); } else { Alert.ShowInTop("批已关闭!", MessageBoxIcon.Information); return; } } } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); return; } } #endregion #region 批打开 /// /// 批打开按钮 /// /// /// protected void btnOpen_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_PointMenuId, Const.BtnBatchOpen)) { var trust = BLL.HJGL_TrustManageEditService.GetTrustByBatchId(this.BatchId); if (trust != null) { Alert.ShowInTop("已生成委托单,不能打开批!", MessageBoxIcon.Information); return; } else { var batch = BLL.HJGL_BO_BatchService.GetBatchById(this.BatchId); if (batch != null) { batch.BatchId = this.BatchId; batch.BatchIsClosed = false; batch.BatchCloseDate = null; BLL.HJGL_BO_BatchService.UpdateBatchIsClosed(batch); BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "批打开"); ShowNotify("批打开成功!", MessageBoxIcon.Success); this.PageInfoLoad(); } } } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); return; } } #endregion /// /// 外观检测 /// /// /// //protected void btnVICheck_Click(object sender, EventArgs e) //{ // if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_PointMenuId, Const.BtnVICheck)) // { // JArray MergedData = Grid1.GetMergedData(); // for (int i = 0; i < this.Grid1.Rows.Count; i++) // { // JObject values = MergedData[i].Value("values"); // string batchDetailId = Grid1.DataKeys[i][0].ToString(); // var batchDetail = BLL.HJGL_BO_BatchDetailService.GetBatchDetailById(batchDetailId); // CheckBoxField cblIsVI = (CheckBoxField)Grid1.FindColumn("IsVI"); // bool isVI = cblIsVI.GetCheckedState(i); // if (isVI) // { // batchDetail.IsVI = true; // if (!string.IsNullOrEmpty(values.Value("VICheckDate"))) // { // batchDetail.VICheckDate = values.Value("VICheckDate"); // } // else // { // batchDetail.VICheckDate = DateTime.Now.Date; // } // } // else // { // batchDetail.IsVI = null; // batchDetail.VICheckDate = null; // } // BLL.HJGL_BO_BatchDetailService.UpdateBatchDetail(batchDetail); // } // BindGrid(); // BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "外观检验确定!"); // ShowNotify("外观检验已确认!", MessageBoxIcon.Success); // } // else // { // Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); // return; // } //} #region 探伤点口 /// /// 点口确定对话框 /// /// /// protected void PageManager1_CustomEvent(object sender, CustomEventArgs e) { if (e.EventArgument == "Confirm_OK") { ComfirmPoint(true); } else if (e.EventArgument == "Confirm_Cancel") { // AJAX回发 ShowNotify("本次点口取消!"); } } #region 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_PointMenuId, Const.BtnBatchOpen)) { Model.HJGL_BO_Batch batch = BLL.HJGL_BO_BatchService.GetBatchById(this.tvControlItem.SelectedNodeID); if (batch != null) { if (!string.IsNullOrEmpty(this.txtBatchStartDate.Text.Trim())) { batch.BatchStartDate = Funs.GetNewDateTime(this.txtBatchStartDate.Text.Trim()); BLL.HJGL_BO_BatchService.UpdateBatch(batch); } } //JArray mergedData = Grid1.GetMergedData(); //foreach (JObject mergedRow in mergedData) //{ // string status = mergedRow.Value("status"); // JObject values = mergedRow.Value("values"); // int rowIndex = mergedRow.Value("index"); // string batchDetailId = this.Grid1.Rows[rowIndex].DataKeys[0].ToString(); // Model.HJGL_BO_BatchDetail batchDetail = BLL.HJGL_BO_BatchDetailService.GetBatchDetailById(batchDetailId); // if (batchDetail != null) // { // //batchDetail.Remark = values.Value("Remark").ToString(); // BLL.HJGL_BO_BatchDetailService.UpdateBatchDetail(batchDetail); // // } //} for (int i = 0; i < this.Grid1.Rows.Count; i++) { System.Web.UI.WebControls.HiddenField hdBatchDetailId = (System.Web.UI.WebControls.HiddenField)(this.Grid1.Rows[i].FindControl("hdBatchDetailId")); System.Web.UI.WebControls.TextBox txtRemark = (System.Web.UI.WebControls.TextBox)(this.Grid1.Rows[i].FindControl("txtRemark")); Model.HJGL_BO_BatchDetail batchDetail = BLL.HJGL_BO_BatchDetailService.GetBatchDetailById(hdBatchDetailId.Value); if (batchDetail != null) { batchDetail.Remark = txtRemark.Text.Trim(); BLL.HJGL_BO_BatchDetailService.UpdateBatchDetail(batchDetail); var trustItem = (from x in Funs.DB.HJGL_CH_TrustItem where x.BatchDetailId == hdBatchDetailId.Value select x).FirstOrDefault(); if (trustItem != null) { trustItem.CH_Remark = batchDetail.Remark; BLL.HJGL_CH_TrustItemService.UpdateTrustItem(trustItem); } } } Alert.ShowInTop("提交成功!", MessageBoxIcon.Success); } } #endregion /// /// 探伤点口 /// /// /// protected void btnNDTPoint_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_PointMenuId, Const.BtnNDTPoint)) { if (!string.IsNullOrEmpty(this.BatchId)) { var batch = BLL.HJGL_BO_BatchService.GetBatchById(this.BatchId); var rate = BLL.HJGL_DetectionService.GetNDTRateByNDTRID(batch.NDTR_ID); EventArg = string.Empty; if (batch != null) { if (batch.BatchCloseDate != null) { var trust = BLL.HJGL_TrustManageEditService.GetTrustByBatchId(this.BatchId); if (trust != null) { Alert.ShowInTop("已生成委托单,不能修改点口!", MessageBoxIcon.Information); return; } else { List selectedWelder = new List(); List allJointAttribute = new List(); List GJointAttribute = new List(); List allWelder = new List(); int PointCount = 0; //int VICount = 0; // 没有进行外观检测数量 for (int i = 0; i < this.Grid1.Rows.Count; i++) { System.Web.UI.WebControls.CheckBoxList cblNDT = (System.Web.UI.WebControls.CheckBoxList)(this.Grid1.Rows[i].FindControl("cblNDT")); if (cblNDT.SelectedItem != null) { //CheckBoxField cbIsVI = (CheckBoxField)Grid1.FindColumn("IsVI"); //bool isVI = cbIsVI.GetCheckedState(i); //if (!isVI) //{ // VICount++; //} selectedWelder.Add(this.Grid1.Rows[i].Values[8].ToString()); if (this.Grid1.Rows[i].Values[10].ToString() == "固定") { GJointAttribute.Add(this.Grid1.Rows[i].Values[10].ToString()); } allJointAttribute.Add(this.Grid1.Rows[i].Values[10].ToString()); PointCount++; } allWelder.Add(this.Grid1.Rows[i].Values[8].ToString()); } if (selectedWelder.Count() > 0 && allJointAttribute.Count() > 0 && allWelder.Count() > 0) { // 焊工覆盖和固定口比例大于40%的判断 if (allWelder.Distinct().Count() == selectedWelder.Distinct().Count() && (allJointAttribute.Distinct().Count() == 1 || (allJointAttribute.Distinct().Count() == 2 && allJointAttribute.Count() * 0.4 < GJointAttribute.Count())) && (PointCount * 100.0 / this.Grid1.Rows.Count) >= Convert.ToDouble(rate.NDTR_Rate)) { ComfirmPoint(true); } else { if (allWelder.Distinct().Count() != selectedWelder.Distinct().Count()) { EventArg = EventArg + "焊工未完全覆盖,"; } if ((PointCount * 100.0 / this.Grid1.Rows.Count) < Convert.ToDouble(rate.NDTR_Rate)) { EventArg = EventArg + "未达到批检测比例,"; } if ((allJointAttribute.Distinct().Count() == 2 && allJointAttribute.Count() * 0.4 > GJointAttribute.Count())) { EventArg = EventArg + "固定口数未达到40%检测比例,"; } if (EventArg != string.Empty) { EventArg = EventArg.Substring(0, EventArg.Length - 1); PageContext.RegisterStartupScript(Confirm.GetShowReference(EventArg + "点击确定按钮继续点口,点取消按钮本次不点口!", String.Empty, MessageBoxIcon.Question, PageManager1.GetCustomEventReference(false, "Confirm_OK"), // 第一个参数 false 用来指定当前不是AJAX请求 PageManager1.GetCustomEventReference("Confirm_Cancel"))); } else { ComfirmPoint(true); } } } else { ComfirmPoint(false); } } } else { Alert.ShowInTop("批未关闭,不能探伤点口!", MessageBoxIcon.Warning); return; } } } } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); return; } } #region 点口确定 private void ComfirmPoint(bool isPoint) { if (isPoint == true) { //点口确认 for (int i = 0; i < this.Grid1.Rows.Count; i++) { string ndtId = string.Empty; System.Web.UI.WebControls.CheckBoxList cblNDT = (System.Web.UI.WebControls.CheckBoxList)(this.Grid1.Rows[i].FindControl("cblNDT")); System.Web.UI.WebControls.HiddenField hdBatchDetailId = (System.Web.UI.WebControls.HiddenField)(this.Grid1.Rows[i].FindControl("hdBatchDetailId")); var batchDetail = BLL.HJGL_BO_BatchDetailService.GetBatchDetailById(hdBatchDetailId.Value); foreach (System.Web.UI.WebControls.ListItem item in cblNDT.Items) { if (item.Selected) { ndtId += item.Value + ","; } } if (!string.IsNullOrEmpty(ndtId)) { ndtId = ndtId.Substring(0, ndtId.LastIndexOf(",")); } //修改组批已点口 if (batchDetail != null) { if (!string.IsNullOrEmpty(ndtId)) { batchDetail.NDT = ndtId; batchDetail.PointDate = DateTime.Now; batchDetail.PointType = "1"; batchDetail.Checker = this.CurrUser.UserName; } else { batchDetail.NDT = null; batchDetail.PointDate = null; batchDetail.PointType = null; batchDetail.Checker = null; } batchDetail.BatchDetailId = hdBatchDetailId.Value; batchDetail.BatchId = this.BatchId; BLL.HJGL_BO_BatchDetailService.UpdateBatchDetail(batchDetail); } } BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "点口确定!"); ShowNotify("点口成功!", MessageBoxIcon.Success); } else { for (int i = 0; i < this.Grid1.Rows.Count; i++) { System.Web.UI.WebControls.HiddenField hdBatchDetailId = (System.Web.UI.WebControls.HiddenField)(this.Grid1.Rows[i].FindControl("hdBatchDetailId")); var batchDetail = BLL.HJGL_BO_BatchDetailService.GetBatchDetailById(hdBatchDetailId.Value); if (batchDetail != null) { batchDetail.NDT = null; batchDetail.PointDate = null; batchDetail.PointType = null; batchDetail.Checker = null; } } BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "点口确定!"); ShowNotify("取消点口!", MessageBoxIcon.Success); } } #endregion /// /// 确认对话框 /// /// /// protected void Button1_Click(object sender, EventArgs e) { MessageBoxButtons messButton = MessageBoxButtons.OKCancel; DialogResult dr = MessageBox.Show(EventArg + "确定操作吗?", "操作提示", messButton); if (dr == DialogResult.OK) { ComfirmPoint(true); } } #endregion #region Grid绑定事件 /// /// Grid1绑定事件 /// /// /// protected void Grid1_RowDataBound(object sender, GridRowEventArgs e) { System.Web.UI.WebControls.CheckBoxList cblNDT = (System.Web.UI.WebControls.CheckBoxList)(this.Grid1.Rows[e.RowIndex].FindControl("cblNDT")); System.Web.UI.WebControls.HiddenField hdBatchDetailId = (System.Web.UI.WebControls.HiddenField)(this.Grid1.Rows[e.RowIndex].FindControl("hdBatchDetailId")); System.Web.UI.WebControls.Label lblTrustDate = (System.Web.UI.WebControls.Label)(this.Grid1.Rows[e.RowIndex].FindControl("lblTrustDate"));//委托日期 System.Web.UI.WebControls.Label lblCheckDate = (System.Web.UI.WebControls.Label)(this.Grid1.Rows[e.RowIndex].FindControl("lblCheckDate"));//检测时间 System.Web.UI.WebControls.CheckBox cbHotPass = (System.Web.UI.WebControls.CheckBox)(this.Grid1.Rows[e.RowIndex].FindControl("cbHotPass"));//热处理合格 System.Web.UI.WebControls.CheckBox cbHardPass = (System.Web.UI.WebControls.CheckBox)(this.Grid1.Rows[e.RowIndex].FindControl("cbHardPass"));//硬度合格 System.Web.UI.WebControls.CheckBox cbHotTrust = (System.Web.UI.WebControls.CheckBox)(this.Grid1.Rows[e.RowIndex].FindControl("cbHotTrust"));//热处理委托 System.Web.UI.WebControls.CheckBox cbHotHard = (System.Web.UI.WebControls.CheckBox)(this.Grid1.Rows[e.RowIndex].FindControl("cbHotHard"));//硬度委托 cblNDT.DataTextField = "NDT_Code"; cblNDT.DataValueField = "NDT_ID"; cblNDT.DataSource = BLL.HJGL_TestingService.GetNDTTypeNameList(); cblNDT.DataBind(); var batchDetail = BLL.HJGL_BO_BatchDetailService.GetBatchDetailById(hdBatchDetailId.Value); if (batchDetail != null) { var batch = BLL.HJGL_BO_BatchService.GetBatchById(batchDetail.BatchId); if (!string.IsNullOrEmpty(batchDetail.NDT)) { List ndtIds = batchDetail.NDT.Split(',').ToList(); foreach (var ndtId in ndtIds) { for (int i = 0; i < cblNDT.Items.Count; i++) { if (cblNDT.Items[i].Value == ndtId) { cblNDT.Items[i].Selected = true; } } } } if (!string.IsNullOrEmpty(batchDetail.JOT_ID)) { //委托日期 //var trustItem = BLL.HJGL_TrustManageEditService.GetView_CH_TrustItemByJotID(batchDetail.JOT_ID, batch.ProjectId); //if (trustItem != null) //{ // var trust = BLL.HJGL_TrustManageEditService.GetCH_TrustByID(trustItem.CH_TrustID); // if (trust != null) // { // if (trust.CH_TrustDate != null) // { // lblTrustDate.Text = string.Format("{0:yyyy-MM-dd}", trust.CH_TrustDate); // } // } var trustItem = trustItemList.FirstOrDefault(x => x.JOT_ID == batchDetail.JOT_ID); if (trustItem != null) { var trust = BLL.HJGL_TrustManageEditService.GetCH_TrustByID(trustItem.CH_TrustID); if (trust != null) { if (trust.CH_TrustDate != null) { lblTrustDate.Text = string.Format("{0:yyyy-MM-dd}", trust.CH_TrustDate); } } } //热处理合格 var hotPass = hotPass_JOT_ID_List.FirstOrDefault(x => x .Id== batchDetail.JOT_ID); if (hotPass != null) { if (hotPass.IsOK == true) { cbHotPass.Checked = true; } } //硬度合格 var hardPass = hardPassList.FirstOrDefault(x => x.Id == batchDetail.JOT_ID ); if (hardPass != null) { if (hardPass.IsOK == true) { cbHardPass.Checked = true; } } //是否热处理 var hotProessTrustItem = HotProessTrustItemList.FirstOrDefault(x => x.Id == batchDetail.JOT_ID ); if (hotProessTrustItem != null) { cbHotTrust.Checked = true; } //硬度委托 var hotHard = hotHardList.FirstOrDefault(x => x.Id == batchDetail.JOT_ID); if (hotHard != null) { cbHotHard.Checked = true; } } } } #endregion #region 生成委托单 /// /// 生成委托单 /// /// /// protected void btnGeneratingOrder_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_PointMenuId, Const.BtnGeneratingOrder)) { if (!string.IsNullOrEmpty(this.BatchId)) { var batch = BLL.HJGL_BO_BatchService.GetBatchById(this.BatchId); var detail = BLL.HJGL_BO_BatchDetailService.GetBatchDetailByBatchId(this.BatchId); foreach (var d in detail) { for (int i = 0; i < this.Grid1.Rows.Count; i++) { System.Web.UI.WebControls.HiddenField hdBatchDetailId = (System.Web.UI.WebControls.HiddenField)(this.Grid1.Rows[i].FindControl("hdBatchDetailId")); System.Web.UI.WebControls.TextBox txtCheckAddress = (System.Web.UI.WebControls.TextBox)(this.Grid1.Rows[i].FindControl("txtCheckAddress")); System.Web.UI.WebControls.TextBox txtRemark = (System.Web.UI.WebControls.TextBox)(this.Grid1.Rows[i].FindControl("txtRemark")); if (d.BatchDetailId == hdBatchDetailId.Value) { d.CheckAddress = txtCheckAddress.Text.Trim(); d.Remark = txtRemark.Text.Trim(); BLL.HJGL_BO_BatchDetailService.UpdateBatchDetail(d); //更新检测地点 } } } if (batch.BatchIsClosed == true && detail.Where(d => d.NDT != null).Count() > 0) { var trust = from x in Funs.DB.HJGL_CH_Trust where x.BatchId == this.BatchId select x; if (trust.Count() == 0) { detail = detail.Where(d => d.NDT != null).ToList(); int flag = 1; foreach (var d in detail) { string[] ndt = d.NDT.Split(','); // 可能有多种探伤类型 foreach (string n in ndt) { var trustNdt = from x in Funs.DB.HJGL_CH_Trust where x.BatchId == this.BatchId && x.CH_NDTMethod == n && x.Flag == flag select x; if (trustNdt.Count() == 0) { var joint = BLL.HJGL_PW_JointInfoService.GetJointInfoByJotID(d.JOT_ID); var iso = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByIsoInfoId(joint.ISO_ID); var ndtInfo = BLL.HJGL_TestingService.GetTestingByTestingId(n); //选择管道等级、执行标准时,自动添加对接焊缝检测比例、合格等级、支管连接接头检测比例、合格等级、角焊缝检测比例、合格等级 var weldControl = BLL.HJGL_WeldControlService.GEtWeldControlByISCIDAndExecStandardId(iso.ISC_ID, iso.ISO_Executive); Model.HJGL_CH_Trust t = new Model.HJGL_CH_Trust(); t.BatchId = this.BatchId; t.CH_TrustID = SQLHelper.GetNewID(typeof(Model.HJGL_CH_Trust)); t.CH_TrustCode = BLL.SQLHelper.RunProcNewIdByProjectId("SpGetTrustCodeByProjectId", "dbo.HJGL_CH_Trust", "CH_TrustCode", batch.ProjectId, ndtInfo.NDT_Code + "-"); //t.ISO_ID = d.ISO_ID; t.CH_NDTMethod = n; t.Flag = flag; t.CH_TrustType = "1"; t.CH_TrustDate = DateTime.Now; t.ProjectId = batch.ProjectId; t.InstallationId = batch.InstallationId; t.CH_WeldMethod = joint.WME_ID; t.CH_SlopeType = joint.JST_ID; t.CH_NDTRate = batch.NDTR_ID; t.CH_NDTCriteria = "NB/T 47013-2015"; t.CH_TrustMan = this.CurrUser.UserId; if (weldControl != null) { if (ndtInfo.NDT_Code == "RT") { t.CH_AcceptGrade = BLL.HJGL_TrustManageEditService.GetAcceptGradeList().FirstOrDefault(x => x.Text == weldControl.Joty_Level).Value; } else { t.CH_AcceptGrade = BLL.HJGL_TrustManageEditService.GetAcceptGradeList().FirstOrDefault(x => x.Text == weldControl.Joty_C_Level).Value; } } t.CH_Remark = d.Remark; BLL.HJGL_TrustManageEditService.AddCH_Trust(t); // 增加明细 Model.HJGL_CH_TrustItem item = new Model.HJGL_CH_TrustItem(); item.CH_TrustID = t.CH_TrustID; item.JOT_ID = d.JOT_ID; item.BatchDetailId = d.BatchDetailId; item.States = "1"; // 生成委托单时状态为等检测 item.CH_Remark = d.Remark; BLL.HJGL_TrustManageEditService.AddCH_TrustItem(item); BLL.HJGL_PW_JointInfoService.JointTrustWriteBack(item.JOT_ID, n, "点口", t.CH_TrustCode, t.CH_TrustDate, "待检测"); } else { Model.HJGL_CH_TrustItem item = new Model.HJGL_CH_TrustItem(); item.CH_TrustID = trustNdt.First().CH_TrustID; item.JOT_ID = d.JOT_ID; item.BatchDetailId = d.BatchDetailId; item.States = "1"; // 生成委托单时状态为等检测 item.CH_Remark = d.Remark; BLL.HJGL_TrustManageEditService.AddCH_TrustItem(item); BLL.HJGL_PW_JointInfoService.JointTrustWriteBack(item.JOT_ID, n, "点口", trustNdt.First().CH_TrustCode, trustNdt.First().CH_TrustDate, "待检测"); } } } BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "生成委托单!"); ShowNotify("成功生成委托单!", MessageBoxIcon.Warning); } else { ShowNotify("已生成委托单!", MessageBoxIcon.Warning); } } else { ShowNotify("批未关闭或批里没有点口!", MessageBoxIcon.Warning); } } } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); return; } } #endregion /// /// 再委托 /// /// /// protected void btnAgainGenerating_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_PointMenuId, Const.BtnGeneratingOrder)) { if (!string.IsNullOrEmpty(this.BatchId)) { var batch = BLL.HJGL_BO_BatchService.GetBatchById(this.BatchId); var trust = from x in Funs.DB.HJGL_CH_Trust where x.BatchId == this.BatchId select x; int? maxFlag = trust.Select(x => x.Flag).Max(); int flag = (maxFlag != null ? maxFlag.Value : 1) + 1; string ndtId = string.Empty; for (int i = 0; i < this.Grid1.Rows.Count; i++) { System.Web.UI.WebControls.HiddenField hdBatchDetailId = (System.Web.UI.WebControls.HiddenField)(this.Grid1.Rows[i].FindControl("hdBatchDetailId")); var batchDetail = BLL.HJGL_BO_BatchDetailService.GetBatchDetailById(hdBatchDetailId.Value); System.Web.UI.WebControls.CheckBoxList cblNDT = (System.Web.UI.WebControls.CheckBoxList)(this.Grid1.Rows[i].FindControl("cblNDT")); System.Web.UI.WebControls.TextBox txtCheckAddress = (System.Web.UI.WebControls.TextBox)(this.Grid1.Rows[i].FindControl("txtCheckAddress")); ; System.Web.UI.WebControls.TextBox txtRemark = (System.Web.UI.WebControls.TextBox)(this.Grid1.Rows[i].FindControl("txtRemark")); batchDetail.CheckAddress = txtCheckAddress.Text.Trim(); batchDetail.Remark = txtRemark.Text.Trim(); BLL.HJGL_BO_BatchDetailService.UpdateBatchDetail(batchDetail); //更新检测地点 if (cblNDT.SelectedItem != null) { // 生成委托单 foreach (System.Web.UI.WebControls.ListItem ndtItem in cblNDT.Items) { if (ndtItem.Selected) { var q = from x in Funs.DB.HJGL_CH_TrustItem join y in Funs.DB.HJGL_CH_Trust on x.CH_TrustID equals y.CH_TrustID where x.BatchDetailId == hdBatchDetailId.Value && y.CH_NDTMethod == ndtItem.Value select x; if (q.Count() == 0) { var trustNdt = from x in Funs.DB.HJGL_CH_Trust where x.BatchId == this.BatchId && x.CH_NDTMethod == ndtItem.Value && x.Flag == flag select x; if (trustNdt.Count() == 0) { var joint = BLL.HJGL_PW_JointInfoService.GetJointInfoByJotID(batchDetail.JOT_ID); var iso = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByIsoInfoId(joint.ISO_ID); var ndtInfo = BLL.HJGL_TestingService.GetTestingByTestingId(ndtItem.Value); //选择管道等级、执行标准时,自动添加对接焊缝检测比例、合格等级、支管连接接头检测比例、合格等级、角焊缝检测比例、合格等级 var weldControl = BLL.HJGL_WeldControlService.GEtWeldControlByISCIDAndExecStandardId(iso.ISC_ID, iso.ISO_Executive); Model.HJGL_CH_Trust t = new Model.HJGL_CH_Trust(); t.BatchId = this.BatchId; t.CH_TrustID = SQLHelper.GetNewID(typeof(Model.HJGL_CH_Trust)); t.CH_TrustCode = BLL.SQLHelper.RunProcNewIdByProjectId("SpGetTrustCodeByProjectId", "dbo.HJGL_CH_Trust", "CH_TrustCode", batch.ProjectId, ndtInfo.NDT_Code + "-"); t.CH_NDTMethod = ndtItem.Value; t.Flag = flag; t.CH_TrustType = "1"; t.CH_TrustDate = DateTime.Now; t.ProjectId = batch.ProjectId; t.InstallationId = batch.InstallationId; t.CH_WeldMethod = joint.WME_ID; t.CH_SlopeType = joint.JST_ID; t.CH_NDTRate = batch.NDTR_ID; t.CH_NDTCriteria = "NB/T 47013-2015"; t.CH_TrustMan = this.CurrUser.UserId; if (weldControl != null) { if (ndtInfo.NDT_Code == "RT") { t.CH_AcceptGrade = BLL.HJGL_TrustManageEditService.GetAcceptGradeList().FirstOrDefault(x => x.Text == weldControl.Joty_Level).Value; } else { t.CH_AcceptGrade = BLL.HJGL_TrustManageEditService.GetAcceptGradeList().FirstOrDefault(x => x.Text == weldControl.Joty_C_Level).Value; } } t.CH_Remark = batchDetail.Remark; BLL.HJGL_TrustManageEditService.AddCH_Trust(t); // 增加明细 Model.HJGL_CH_TrustItem item = new Model.HJGL_CH_TrustItem(); item.CH_TrustID = t.CH_TrustID; item.JOT_ID = batchDetail.JOT_ID; item.BatchDetailId = batchDetail.BatchDetailId; item.States = "1"; // 生成委托单时状态为等检测 item.CH_Remark = batchDetail.Remark; BLL.HJGL_TrustManageEditService.AddCH_TrustItem(item); BLL.HJGL_PW_JointInfoService.JointTrustWriteBack(item.JOT_ID, ndtItem.Value, "点口", t.CH_TrustCode, t.CH_TrustDate, "待检测"); } else { Model.HJGL_CH_TrustItem item = new Model.HJGL_CH_TrustItem(); item.CH_TrustID = trustNdt.First().CH_TrustID; item.JOT_ID = batchDetail.JOT_ID; item.BatchDetailId = batchDetail.BatchDetailId; item.States = "1"; // 生成委托单时状态为等检测 item.CH_Remark = batchDetail.Remark; BLL.HJGL_TrustManageEditService.AddCH_TrustItem(item); BLL.HJGL_PW_JointInfoService.JointTrustWriteBack(item.JOT_ID, ndtItem.Value, "点口", trustNdt.First().CH_TrustCode, trustNdt.First().CH_TrustDate, "待检测"); } } ndtId += ndtItem.Value + ","; } } if (!string.IsNullOrEmpty(ndtId)) { ndtId = ndtId.Substring(0, ndtId.LastIndexOf(",")); } if (!string.IsNullOrEmpty(ndtId)) { batchDetail.NDT = ndtId; batchDetail.PointDate = DateTime.Now; batchDetail.PointType = "1"; batchDetail.Checker = this.CurrUser.UserName; ndtId = string.Empty; } } } BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "再委托!"); ShowNotify("成功再委托!", MessageBoxIcon.Warning); BindGrid(); } } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); return; } } /// /// 删除空的检验批 /// /// /// protected void btnDelete_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_PointMenuId, Const.BtnDelete)) { BLL.HJGL_BO_BatchService.DeleteBatch(this.tvControlItem.SelectedNodeID); BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "检验批删除"); ShowNotify("检验批删除成功!", MessageBoxIcon.Success); this.InitTreeMenu(); this.PageInfoLoad(); } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); return; } } /// /// 取消委托 /// /// /// protected void btnCancel_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_PointMenuId, Const.BtnCancelTrust)) { for (int i = 0; i < this.Grid1.Rows.Count; i++) { System.Web.UI.WebControls.HiddenField hdBatchDetailId = (System.Web.UI.WebControls.HiddenField)(this.Grid1.Rows[i].FindControl("hdBatchDetailId")); var batchDetail = BLL.HJGL_BO_BatchDetailService.GetBatchDetailById(hdBatchDetailId.Value); System.Web.UI.WebControls.CheckBoxList cblNDT = (System.Web.UI.WebControls.CheckBoxList)(this.Grid1.Rows[i].FindControl("cblNDT")); string ndtId = string.Empty; // 只能取消点口委托的口(不包括扩口) if (batchDetail.NDT != null && batchDetail.PointType.Trim() == "1") { string[] ndts = batchDetail.NDT.Split(','); if (ndts.Count() == 1) { if (cblNDT.SelectedItem == null) { var t = from x in Funs.DB.HJGL_CH_TrustItem where x.BatchDetailId == hdBatchDetailId.Value select x; if (t.Count() > 0 && t.FirstOrDefault().States == "1") // 待检测状态 { BLL.HJGL_PW_JointInfoService.JointTrustWriteBack(batchDetail.JOT_ID, ndts[0], null, null, null, null); BLL.HJGL_CH_TrustItemService.DeleteTrustItemById(t.FirstOrDefault().CH_TrustItemID); } Model.HJGL_BO_BatchDetail newBatchDetail = Funs.DB.HJGL_BO_BatchDetail.FirstOrDefault(x => x.BatchDetailId == batchDetail.BatchDetailId); if (newBatchDetail != null) { newBatchDetail.NDT = null; newBatchDetail.PointDate = null; newBatchDetail.PointType = null; newBatchDetail.Checker = null; Funs.DB.SubmitChanges(); } } } else { List ndtList = ndts.ToList(); foreach (System.Web.UI.WebControls.ListItem ndtItem in cblNDT.Items) { if (!ndtItem.Selected) { if (batchDetail.NDT.Contains(ndtItem.Value)) { string ndt = ndtItem.Value; var t = from x in Funs.DB.HJGL_CH_TrustItem join y in Funs.DB.HJGL_CH_Trust on x.CH_TrustID equals y.CH_TrustID where x.JOT_ID == batchDetail.JOT_ID && y.CH_NDTMethod == ndtItem.Value select x; if (t.Count() > 0 && t.FirstOrDefault().States == "1") // 待检测状态 { BLL.HJGL_PW_JointInfoService.JointTrustWriteBack(batchDetail.JOT_ID, ndt, null, null, null, null); BLL.HJGL_CH_TrustItemService.DeleteTrustItemById(t.FirstOrDefault().CH_TrustItemID); ndtList.Remove(ndtItem.Value); } } } } Model.HJGL_BO_BatchDetail newBatchDetail = Funs.DB.HJGL_BO_BatchDetail.FirstOrDefault(x => x.BatchDetailId == batchDetail.BatchDetailId); Model.HJGL_CH_TrustItem trustItem = Funs.DB.HJGL_CH_TrustItem.FirstOrDefault(x => x.BatchDetailId == batchDetail.BatchDetailId); if (newBatchDetail != null) { if (ndtList.Count() > 0 && trustItem != null) { foreach (var q in ndtList) { ndtId = ndtId + q + ","; } newBatchDetail.NDT = ndtId.Substring(0, ndtId.Length - 1); } else { newBatchDetail.NDT = null; newBatchDetail.PointDate = null; newBatchDetail.PointType = null; newBatchDetail.Checker = null; } Funs.DB.SubmitChanges(); } } } } BindGrid(); BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "取消委托成功"); ShowNotify("取消委托成功!", MessageBoxIcon.Success); } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); return; } } #region 查询 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) { var ins = BLL.Project_InstallationService.GetInstallationList(drpProjectId.SelectedValue); this.drpInstallation.Items.Clear(); this.drpInstallation.DataTextField = "Text"; this.drpInstallation.DataValueField = "Value"; this.drpInstallation.DataSource = ins; this.drpInstallation.DataBind(); Funs.FineUIPleaseSelect(this.drpInstallation); this.InitTreeMenu(); } protected void drpInstallation_SelectedIndexChanged(object sender, EventArgs e) { this.InitTreeMenu(); } protected void drpIsClosed_SelectedIndexChanged(object sender, EventArgs e) { this.InitTreeMenu(); } protected void drpIsQue_SelectedIndexChanged(object sender, EventArgs e) { this.InitTreeMenu(); } /// /// 查询 /// /// /// protected void TextBox_TextChanged(object sender, EventArgs e) { this.BindGrid(); } protected void drpWelder_OnSelectedIndexChanged(object sender, EventArgs e) { this.BindGrid(); } #endregion #region 导出按钮 /// 导出按钮 /// /// /// protected void btnOut_Click(object sender, EventArgs e) { Response.ClearContent(); string filename = Funs.GetNewFileName(); Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("检验批导出" + filename, System.Text.Encoding.UTF8) + ".xls"); Response.ContentType = "application/excel"; Response.ContentEncoding = System.Text.Encoding.UTF8; Response.Write(GetGridTableHtml(Grid1)); Response.End(); } /// /// 导出方法 /// /// /// private string GetGridTableHtml(Grid grid) { StringBuilder sb = new StringBuilder(); sb.Append(""); sb.Append(""); sb.Append(""); this.Grid1.PageSize = 5000; BindGrid(); foreach (GridColumn column in grid.Columns) { sb.AppendFormat("", column.HeaderText); } sb.Append(""); foreach (GridRow row in grid.Rows) { sb.Append(""); foreach (GridColumn column in grid.Columns) { string html = row.Values[column.ColumnIndex].ToString(); if (column.ColumnID == "NDT") { html = ""; //(row.FindControl("cblNDT") as AspNet.CheckBoxList).SelectedItem.Text; } if (column.ColumnID == "CheckAddress") { html = (row.FindControl("txtCheckAddress") as AspNet.TextBox).Text; } if (column.ColumnID == "Remark") { html = (row.FindControl("txtRemark") as AspNet.TextBox).Text; } if (column.ColumnID == "IsVI") { if (row.Values[16].ToString() == "True") { html = "√"; } else { html = ""; } } if (column.ColumnID == "TrustDate") { html = (row.FindControl("lblTrustDate") as AspNet.Label).Text; } if (column.ColumnID == "ProessTypes") { html = (row.FindControl("lbProessTypes") as AspNet.Label).Text; } if (column.ColumnID == "HotPass") { bool a = (row.FindControl("cbHotPass") as AspNet.CheckBox).Checked; if (a) { html = "√"; } else { html = ""; } } if (column.ColumnID == "HardPass") { bool a = (row.FindControl("cbHardPass") as AspNet.CheckBox).Checked; if (a) { html = "√"; } else { html = ""; } } if (column.ColumnID == "HotTrust") { bool a = (row.FindControl("cbHotTrust") as AspNet.CheckBox).Checked; if (a) { html = "√"; } else { html = ""; } } if (column.ColumnID == "HotHard") { bool a = (row.FindControl("cbHotHard") as AspNet.CheckBox).Checked; if (a) { html = "√"; } else { html = ""; } } sb.AppendFormat("", html); } sb.Append(""); } sb.Append("
{0}
{0}
"); return sb.ToString(); } #endregion #region 格式化字符串 /// /// 转换热处理类型 /// /// /// protected string ConvertProessTypes(object ProessTypes) { string proessTypes = string.Empty; if (ProessTypes != null) { proessTypes = BLL.HJGL_PW_JointInfoService.ConvertProessTypes(ProessTypes.ToString()); } return proessTypes; } #endregion //protected void DropDownBox1_TextChanged(object sender, EventArgs e) //{ // this.InitTreeMenu(); //} } }