352 lines
		
	
	
		
			16 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			352 lines
		
	
	
		
			16 KiB
		
	
	
	
		
			C#
		
	
	
	
using BLL;
 | 
						|
using System;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System.Data;
 | 
						|
using System.Data.SqlClient;
 | 
						|
using System.Linq;
 | 
						|
using System.Reflection;
 | 
						|
using System.Web.UI.WebControls;
 | 
						|
 | 
						|
namespace FineUIPro.Web.WeldingProcess.TrustManage
 | 
						|
{
 | 
						|
    public partial class PointForAudit : PageBase
 | 
						|
    {
 | 
						|
        protected void Page_Load(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            if (!IsPostBack)
 | 
						|
            {
 | 
						|
                this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
 | 
						|
               
 | 
						|
                BLL.Base_DetectionTypeService.InitDetectionTypeDropDownList(drpNde, "", false, "");
 | 
						|
                drpNde.SelectedValue = "296add43-e979-4cf3-b13e-a68bb00a75d2";  // 默认RT
 | 
						|
                BindGrid();
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        private void BindGrid()
 | 
						|
        {
 | 
						|
            string strSql = @"SELECT PointBatchItemId,PointBatchId,PointBatchCode,WeldJointId,PointState,PointDate,WorkAreaCode,
 | 
						|
                                     WeldJointCode,JointArea,Size,WelderCode,WeldingDate,PipelineCode,PipingClassName,
 | 
						|
                                     (CASE WHEN IsWelderFirst=1 THEN '是' ELSE '否' END) AS IsWelderFirst, 
 | 
						|
                                     JLAudit,GLGSAudit,QTAudit,IsPointAudit
 | 
						|
                              FROM dbo.View_Batch_PointBatchItem 
 | 
						|
							  WHERE PointState IS NOT NULL AND TrustBatchItemId IS NULL";
 | 
						|
            List<SqlParameter> listStr = new List<SqlParameter>();
 | 
						|
            if (!string.IsNullOrEmpty(this.txtPipeCode.Text))
 | 
						|
            {
 | 
						|
                strSql += " AND PipelineCode LIKE @PipelineCode";
 | 
						|
                listStr.Add(new SqlParameter("@PipelineCode", "%" + this.txtPipeCode.Text.Trim() + "%"));
 | 
						|
            }
 | 
						|
            if (!string.IsNullOrEmpty(this.txtPointStartDate.Text))
 | 
						|
            {
 | 
						|
                strSql += " AND PointDate >= @PointStartDate";
 | 
						|
                listStr.Add(new SqlParameter("@PointStartDate", Convert.ToDateTime(this.txtPointStartDate.Text)));
 | 
						|
            }
 | 
						|
            if (!string.IsNullOrEmpty(this.txtPointEndDate.Text))
 | 
						|
            {
 | 
						|
                strSql += " AND PointDate < @PointEndDate";
 | 
						|
                listStr.Add(new SqlParameter("@PointEndDate", Convert.ToDateTime(this.txtPointEndDate.Text).AddDays(1)));
 | 
						|
            }
 | 
						|
            if (drpNoAudit.SelectedValue != "0")
 | 
						|
            {
 | 
						|
                if (drpNoAudit.SelectedValue == "1")
 | 
						|
                {
 | 
						|
                    strSql += " AND JLAudit='未审核'";
 | 
						|
                }
 | 
						|
                if (drpNoAudit.SelectedValue == "2")
 | 
						|
                {
 | 
						|
                    strSql += " AND GLGSAudit='未审核'";
 | 
						|
                }
 | 
						|
                if (drpNoAudit.SelectedValue == "3")
 | 
						|
                {
 | 
						|
                    strSql += " AND QTAudit='未审核'";
 | 
						|
                }
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                strSql += " AND (JLAudit='未审核' OR GLGSAudit='未审核' OR QTAudit='未审核')";
 | 
						|
            }
 | 
						|
 | 
						|
            if (drpNde.SelectedValue != null)
 | 
						|
            {
 | 
						|
                strSql += " AND DetectionTypeId=@DetectionTypeId";
 | 
						|
                listStr.Add(new SqlParameter("@DetectionTypeId", drpNde.SelectedValue));
 | 
						|
            }
 | 
						|
 | 
						|
            SqlParameter[] parameter = listStr.ToArray();
 | 
						|
            DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
 | 
						|
 | 
						|
            Grid1.RecordCount = tb.Rows.Count;
 | 
						|
            // tb = GetFilteredTable(Grid1.FilteredData, tb);
 | 
						|
            var table = this.GetPagedDataTable(Grid1, tb);
 | 
						|
            Grid1.DataSource = table;
 | 
						|
            Grid1.DataBind();
 | 
						|
        }
 | 
						|
 | 
						|
        #region 
 | 
						|
        /// <summary>
 | 
						|
        /// 改变索引事件
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
 | 
						|
        {
 | 
						|
            BindGrid();
 | 
						|
        }
 | 
						|
 | 
						|
        /// <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();
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 排序
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
 | 
						|
        {
 | 
						|
            this.BindGrid();
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
 | 
						|
        protected void BtnAnalyse_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            BindGrid();
 | 
						|
        }
 | 
						|
        protected void Window2_Close(object sender, WindowCloseEventArgs e)
 | 
						|
        {
 | 
						|
            this.BindGrid();
 | 
						|
        }
 | 
						|
        protected void btnJLAudit_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_PointForAuditMenuId, Const.BtnJLAudit))
 | 
						|
            {
 | 
						|
                if (Grid1.SelectedRowIndexArray.Length <= 0)
 | 
						|
                {
 | 
						|
                    Alert.ShowInTop("最少选中一行!", MessageBoxIcon.Warning);
 | 
						|
                    return;
 | 
						|
                }
 | 
						|
 | 
						|
                string userId = CurrUser.UserId;
 | 
						|
                foreach (string pointBatchItemId in Grid1.SelectedRowIDArray)
 | 
						|
                {
 | 
						|
                    var pointBatchItem = BLL.Batch_PointBatchItemService.GetPointBatchItemByPointBatchItemId(pointBatchItemId);
 | 
						|
                    pointBatchItem.JLAudit = userId;
 | 
						|
                    BLL.Funs.DB.SubmitChanges();
 | 
						|
                }
 | 
						|
                Alert.ShowInTop("所选项审核完成!", MessageBoxIcon.Warning);
 | 
						|
                BindGrid();
 | 
						|
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning);
 | 
						|
                return;
 | 
						|
            }
 | 
						|
        }
 | 
						|
        protected void btnGLGSAudit_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_PointForAuditMenuId, Const.BtnGLGSAudit))
 | 
						|
            {
 | 
						|
                if (Grid1.SelectedRowIndexArray.Length <= 0)
 | 
						|
                {
 | 
						|
                    Alert.ShowInTop("最少选中一行!", MessageBoxIcon.Warning);
 | 
						|
                    return;
 | 
						|
                }
 | 
						|
 | 
						|
                string userId = CurrUser.UserId;
 | 
						|
                foreach (string pointBatchItemId in Grid1.SelectedRowIDArray)
 | 
						|
                {
 | 
						|
                    var pointBatchItem = BLL.Batch_PointBatchItemService.GetPointBatchItemByPointBatchItemId(pointBatchItemId);
 | 
						|
                    pointBatchItem.GLGSAudit = userId;
 | 
						|
                    BLL.Funs.DB.SubmitChanges();
 | 
						|
                }
 | 
						|
                Alert.ShowInTop("所选项审核完成!", MessageBoxIcon.Warning);
 | 
						|
                BindGrid();
 | 
						|
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning);
 | 
						|
                return;
 | 
						|
            }
 | 
						|
        }
 | 
						|
        protected void btnOtherAudit_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_PointForAuditMenuId, Const.BtnQTAudit))
 | 
						|
            {
 | 
						|
                if (Grid1.SelectedRowIndexArray.Length <= 0)
 | 
						|
                {
 | 
						|
                    Alert.ShowInTop("最少选中一行!", MessageBoxIcon.Warning);
 | 
						|
                    return;
 | 
						|
                }
 | 
						|
 | 
						|
                string userId = CurrUser.UserId;
 | 
						|
                foreach (string pointBatchItemId in Grid1.SelectedRowIDArray)
 | 
						|
                {
 | 
						|
                    var pointBatchItem = BLL.Batch_PointBatchItemService.GetPointBatchItemByPointBatchItemId(pointBatchItemId);
 | 
						|
                    pointBatchItem.QTAudit = userId;
 | 
						|
                    BLL.Funs.DB.SubmitChanges();
 | 
						|
                }
 | 
						|
                Alert.ShowInTop("所选项审核完成!", MessageBoxIcon.Warning);
 | 
						|
                BindGrid();
 | 
						|
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning);
 | 
						|
                return;
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 手动生成委托单
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void btnHandGenerate_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_PointManageMenuId, Const.BtnHandGenerate))
 | 
						|
            {
 | 
						|
                List<string> selectRow = new List<string>();
 | 
						|
 | 
						|
                foreach (string pitem in Grid1.SelectedRowIDArray)
 | 
						|
                { 
 | 
						|
                    selectRow.Add(pitem);
 | 
						|
                }
 | 
						|
               
 | 
						|
                if (selectRow.Count() > 0)
 | 
						|
                {
 | 
						|
                    List<string> weldMot = new List<string>();
 | 
						|
                    List<string> grooveType = new List<string>();
 | 
						|
                    List<bool> IsFist = new List<bool>();
 | 
						|
                    List<string> pointBatchIds = new List<string>();
 | 
						|
                    string error = string.Empty;
 | 
						|
 | 
						|
                    foreach (string pointItemId in selectRow)
 | 
						|
                    {
 | 
						|
                        var pointItem = BLL.Batch_PointBatchItemService.GetPointBatchItemByPointBatchItemId(pointItemId);
 | 
						|
                        var jot = BLL.Pipeline_WeldJointService.GetWeldJointByWeldJointId(pointItem.WeldJointId);
 | 
						|
                        weldMot.Add(jot.WeldingMethodId);
 | 
						|
                        grooveType.Add(jot.GrooveTypeId);
 | 
						|
                        IsFist.Add(pointItem.IsWelderFirst == true ? true : false);
 | 
						|
                        pointBatchIds.Add(pointItem.PointBatchId);
 | 
						|
                    }
 | 
						|
 | 
						|
                    if (pointBatchIds.Distinct().Count() > 1)
 | 
						|
                    {
 | 
						|
                        error = "勾选的焊口不在一个批次中,";
 | 
						|
                    }
 | 
						|
                    if (weldMot.Distinct().Count() > 1)
 | 
						|
                    {
 | 
						|
                        error = "勾选的焊口焊接方法不一至,";
 | 
						|
                    }
 | 
						|
                    if (grooveType.Distinct().Count() > 1)
 | 
						|
                    {
 | 
						|
                        error = error + "勾选的焊口坡口类型不一至,";
 | 
						|
                    }
 | 
						|
                    if (IsFist.Distinct().Count() > 1)
 | 
						|
                    {
 | 
						|
                        error = error + "勾选的焊口是否首三不一至,";
 | 
						|
                    }
 | 
						|
 | 
						|
                    if (error == string.Empty)
 | 
						|
                    {
 | 
						|
                        var point = BLL.Batch_PointBatchService.GetPointBatchById(pointBatchIds[0]);
 | 
						|
                        var iso = BLL.Pipeline_PipelineService.GetPipelineByPipelineId(point.PipelineId);
 | 
						|
                        var project = BLL.Base_ProjectService.GetProjectByProjectId(point.ProjectId);
 | 
						|
                        var unit = BLL.Base_UnitService.GetUnit(point.UnitId);
 | 
						|
                        var ndt = BLL.Base_DetectionTypeService.GetDetectionTypeByDetectionTypeId(point.DetectionTypeId);
 | 
						|
                        var work = BLL.Project_WorkAreaService.GetProject_WorkAreaByWorkAreaId(iso.WorkAreaId);
 | 
						|
 | 
						|
                        Model.Batch_BatchTrust newBatchTrust = new Model.Batch_BatchTrust();
 | 
						|
                        string perfix = string.Empty;
 | 
						|
                        //perfix = unit.UnitCode + "-" + ins.InstallationCode + "-GD-" + ndt.DetectionTypeCode + "-";
 | 
						|
                        perfix = ndt.DetectionTypeCode + "-" + unit.UnitCode + "-" + work.WorkAreaCode + "-PI" + "-";
 | 
						|
                        newBatchTrust.TrustBatchCode = BLL.SQLHelper.RunProcNewId("SpGetNewCode", "dbo.Batch_BatchTrust", "TrustBatchCode", project.ProjectId, perfix);
 | 
						|
 | 
						|
                        string trustBatchId = SQLHelper.GetNewID(typeof(Model.Batch_BatchTrust));
 | 
						|
                        newBatchTrust.TrustBatchId = trustBatchId;
 | 
						|
 | 
						|
                        newBatchTrust.TrustDate = DateTime.Now;
 | 
						|
                        newBatchTrust.ProjectId = point.ProjectId;
 | 
						|
                        newBatchTrust.UnitId = point.UnitId;
 | 
						|
                        newBatchTrust.InstallationId = point.InstallationId;
 | 
						|
                        newBatchTrust.WorkAreaId = iso.WorkAreaId;
 | 
						|
                        newBatchTrust.WeldingMethodId = weldMot[0];
 | 
						|
                        newBatchTrust.GrooveTypeId = grooveType[0];
 | 
						|
                        newBatchTrust.IsWelderFirst = IsFist[0];
 | 
						|
                        newBatchTrust.DetectionTypeId = point.DetectionTypeId;
 | 
						|
                        newBatchTrust.PipelineId = point.PipelineId;
 | 
						|
 | 
						|
                        BLL.Batch_BatchTrustService.AddBatchTrust(newBatchTrust);  // 新增委托单
 | 
						|
 | 
						|
                        // 生成委托明细,并回写点口明细信息
 | 
						|
                        string toPointBatch = string.Empty;
 | 
						|
                        foreach (string pointItemId in selectRow)
 | 
						|
                        {
 | 
						|
                            var pointItem = BLL.Batch_PointBatchItemService.GetPointBatchItemByPointBatchItemId(pointItemId);
 | 
						|
                            if (BLL.Batch_PointBatchService.GetIsGenerateTrust(pointItem.PointBatchItemId)) ////生成委托单的条件判断
 | 
						|
                            {
 | 
						|
                                if (!toPointBatch.Contains(pointItem.PointBatchId))
 | 
						|
                                {
 | 
						|
                                    toPointBatch = toPointBatch + pointItem.PointBatchId + ",";
 | 
						|
                                }
 | 
						|
 | 
						|
                                Model.Batch_BatchTrustItem trustItem = new Model.Batch_BatchTrustItem
 | 
						|
                                {
 | 
						|
                                    TrustBatchItemId = SQLHelper.GetNewID(typeof(Model.Batch_BatchTrustItem)),
 | 
						|
                                    TrustBatchId = trustBatchId,
 | 
						|
                                    PointBatchItemId = pointItem.PointBatchItemId,
 | 
						|
                                    WeldJointId = pointItem.WeldJointId,
 | 
						|
                                    //FilmNum = fileNum,
 | 
						|
                                    CreateDate = DateTime.Now
 | 
						|
                                };
 | 
						|
                                Batch_BatchTrustItemService.AddBatchTrustItem(trustItem);
 | 
						|
                            }
 | 
						|
 | 
						|
                            //Model.Batch_PointBatchItem pointBatchItem = Funs.DB.Batch_PointBatchItem.FirstOrDefault(e => e.PointBatchItemId == item.PointBatchItemId);
 | 
						|
 | 
						|
                            pointItem.IsBuildTrust = true;
 | 
						|
                            Funs.DB.SubmitChanges();
 | 
						|
                        }
 | 
						|
 | 
						|
                        // 回写委托批对应点口信息
 | 
						|
                        if (!string.IsNullOrEmpty(toPointBatch))
 | 
						|
                        {
 | 
						|
                            toPointBatch = toPointBatch.Substring(0, toPointBatch.Length - 1);
 | 
						|
                            var updateTrut = BLL.Batch_BatchTrustService.GetBatchTrustById(trustBatchId);
 | 
						|
                            if (updateTrut != null)
 | 
						|
                            {
 | 
						|
                                updateTrut.TopointBatch = toPointBatch;
 | 
						|
                                BLL.Batch_BatchTrustService.UpdateBatchTrust(updateTrut);
 | 
						|
                            }
 | 
						|
                        }
 | 
						|
 | 
						|
                        Alert.ShowInTop("委托单已生成!", MessageBoxIcon.Success);
 | 
						|
                    }
 | 
						|
                    else
 | 
						|
                    {
 | 
						|
                        Alert.ShowInTop(error + "不能组成一个委托单!", MessageBoxIcon.Warning);
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                else
 | 
						|
                {
 | 
						|
                    Alert.ShowInTop("请勾选要生成委托单的焊口!", MessageBoxIcon.Warning);
 | 
						|
                }
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning);
 | 
						|
                return;
 | 
						|
            }
 | 
						|
        }
 | 
						|
    }
 | 
						|
} |