using System; using System.Collections.Generic; using System.Linq; using System.Data.SqlClient; using System.Data.OleDb; using System.Data; using System.IO; using System.Threading; using BLL; namespace FineUIPro.Web.WeldingProcess.DataIn { public partial class DataIn : PageBase { public static Dictionary percent { get; set; } /// /// 上传预设的虚拟路径 /// private string initPath = Const.ExcelUrl; /// /// 错误集合 /// public static string errorInfos = string.Empty; [System.Web.Services.WebMethod] public static int getPercent(string id) { return percent[id]; } #region 加载页面 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (percent == null) { percent = new Dictionary(); } this.id.Text = this.CurrUser.UserId; this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString(); // 绑定表格 this.BindGrid(); } else if (GetRequestEventArgument() == "reloadGrid") { BindGrid(); } } #endregion #region 绑定数据 /// /// 绑定数据 /// private void BindGrid() { string strSql = @"SELECT TempId,ProjectId,UserId,Time,RowNo,ToopValue,Value1,Value2,Value3,Value4,Value5,Value6,Value7, Value8,Value9,Value10,Value11,Value12,Value13,Value14,Value15,Value16,Value17,Value18,Value19, Value20,Value21,Value22,Value23,Value24,Value25,Value26,Value27,Value28,Value29,Value30,Value31, Value32,Value33,Value34,Value35,Value36,Value37,Value38 FROM Sys_DataInTemp WHERE UserId=@UserId"; List listStr = new List(); listStr.Add(new SqlParameter("@UserId", this.CurrUser.UserId)); if (!string.IsNullOrEmpty(this.CurrUser.LoginProjectId)) { strSql += " AND ProjectId=@ProjectId "; listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId)); } if (!string.IsNullOrEmpty(this.txtValue1.Text.Trim())) { strSql += " AND Value1 LIKE @Value1"; listStr.Add(new SqlParameter("@Value1", "%" + this.txtValue1.Text.Trim() + "%")); } if (!string.IsNullOrEmpty(this.txtValue2.Text.Trim())) { strSql += " AND Value2 LIKE @Value2"; listStr.Add(new SqlParameter("@Value2", "%" + this.txtValue2.Text.Trim() + "%")); } if (!string.IsNullOrEmpty(this.txtValue3.Text.Trim())) { strSql += " AND Value3 LIKE @Value3"; listStr.Add(new SqlParameter("@Value3", "%" + this.txtValue3.Text.Trim() + "%")); } if (!string.IsNullOrEmpty(this.txtValue4.Text.Trim())) { strSql += " AND Value4 LIKE @Value4"; listStr.Add(new SqlParameter("@Value4", "%" + this.txtValue4.Text.Trim() + "%")); } if (drpIsError.SelectedValue!="0") { if (drpIsError.SelectedValue == "1") { strSql += " AND ToopValue IS NOT NULL AND ToopValue != '' "; } else { strSql += " AND (ToopValue IS NULL OR ToopValue = '') "; } } if (!string.IsNullOrEmpty(this.txtToopValue.Text.Trim())) { strSql += " AND ToopValue LIKE @ToopValue"; listStr.Add(new SqlParameter("@ToopValue", "%" + this.txtToopValue.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(); var dataInTempAll = from x in Funs.DB.Sys_DataInTemp where x.UserId == this.CurrUser.UserId select x; for (int i = 0; i < Grid1.Rows.Count; i++) { var dataInTemp = dataInTempAll.FirstOrDefault(x => x.TempId == Grid1.Rows[i].DataKeys[0].ToString()); if (dataInTemp != null) { if (!string.IsNullOrEmpty(dataInTemp.ToopValue)) { Grid1.Rows[i].RowCssClass = "color1"; } } } var errData = from x in dataInTempAll where x.ToopValue != null select x; this.lbDataCout.Text = errData.Count().ToString(); } #endregion #region 双击事件 /// /// Grid行双击事件 /// /// /// protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop(Resources.Lan.SelectLeastOneRecord, MessageBoxIcon.Warning); return; } if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_DataInMenuId, Const.BtnModify)) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("DataInEdit.aspx?TempId={0}", Grid1.SelectedRowID, "维护 - "))); } else { ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning); } } #endregion #region 导入信息 维护 /// /// 导入信息编辑 /// /// /// protected void btnMenuEdit_Click(object sender, EventArgs e) { if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.HJGL_DataInMenuId, BLL.Const.BtnModify)) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop(Resources.Lan.SelectLeastOneRecord, MessageBoxIcon.Warning); return; } PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("DataInEdit.aspx?TempId={0}", Grid1.SelectedRowID, "维护 - "))); } else { ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning); } } /// /// 删除按钮 /// /// /// protected void btnMenuDelete_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_DataInMenuId, Const.BtnDelete)) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop(Resources.Lan.SelectLeastOneRecord, MessageBoxIcon.Warning); return; } foreach (int rowIndex in Grid1.SelectedRowIndexArray) { string rowID = Grid1.DataKeys[rowIndex][0].ToString(); BLL.DataInTempService.DeleteDataInTempByDataInTempID(rowID); BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_DataInMenuId, Const.BtnDelete, string.Empty); } ShowNotify(Resources.Lan.DeletedSuccessfully, MessageBoxIcon.Success); this.BindGrid(); } else { ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning); return; } } #endregion #region 分页 排序 /// /// 分页 /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { BindGrid(); } /// /// 分页显示条数下拉框 /// /// /// protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); BindGrid(); } /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e) { BindGrid(); } #endregion #region 文件上传 /// /// 文件上传 /// /// /// protected void imgbtnImport_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_DataInMenuId, Const.BtnIn)) { string message = string.Empty; errorInfos = string.Empty; if (this.FileExcel.HasFile == false) { ShowNotify("请选择Excel文件!", MessageBoxIcon.Warning); return; } string IsXls = Path.GetExtension(this.FileExcel.FileName).ToString().Trim().ToLower(); if (IsXls != ".xls" && IsXls != ".xlsx") { ShowNotify("只能选择Excel文件!", MessageBoxIcon.Warning); return; } string rootPath = Server.MapPath("~/"); string initFullPath = rootPath + initPath; if (!Directory.Exists(initFullPath)) { Directory.CreateDirectory(initFullPath); } //指定上传文件名称 this.hidFileName.Text = BLL.Funs.GetNewFileName() + IsXls; //上传文件路径 string filePath = initFullPath + this.hidFileName.Text; //文件上传服务器 this.FileExcel.PostedFile.SaveAs(filePath); //文件上传服务器后的名称 string fileName = rootPath + initPath + this.hidFileName.Text; //读取Excel DataSet ds = NPOIHelper.ExcelToDataSet(fileName, out errorInfos, true); //验证Excel读取是否有误 if (!string.IsNullOrEmpty(errorInfos)) { ShowNotify(errorInfos, MessageBoxIcon.Warning); return; } if (ds.Tables.Count > 0) { BLL.DataInTempService.DeleteDataInTemp(this.CurrUser.LoginProjectId, this.CurrUser.UserId, ds.Tables[0].Rows[0][1].ToString()); int ir = ds.Tables[0].Rows.Count; for (int i = 0; i < ir; i++) { if (!string.IsNullOrEmpty(ds.Tables[0].Rows[i][3].ToString())) { Model.Sys_DataInTemp newDataInTemp = new Model.Sys_DataInTemp(); newDataInTemp.TempId = SQLHelper.GetNewID(typeof(Model.Sys_DataInTemp)); newDataInTemp.ProjectId = this.CurrUser.LoginProjectId; newDataInTemp.UserId = this.CurrUser.UserId; newDataInTemp.Time = System.DateTime.Now; newDataInTemp.RowNo = i + 2; newDataInTemp.Value1 = ds.Tables[0].Rows[i][0].ToString().Trim(); newDataInTemp.Value2 = ds.Tables[0].Rows[i][1].ToString().Trim(); newDataInTemp.Value3 = ds.Tables[0].Rows[i][2].ToString().Trim(); newDataInTemp.Value4 = ds.Tables[0].Rows[i][3].ToString().Trim(); newDataInTemp.Value5 = ds.Tables[0].Rows[i][4].ToString().Trim(); newDataInTemp.Value6 = ds.Tables[0].Rows[i][5].ToString().Trim(); newDataInTemp.Value7 = ds.Tables[0].Rows[i][6].ToString().Trim(); newDataInTemp.Value8 = ds.Tables[0].Rows[i][7].ToString().Trim(); newDataInTemp.Value9 = ds.Tables[0].Rows[i][8].ToString().Trim(); newDataInTemp.Value10 = ds.Tables[0].Rows[i][9].ToString().Trim(); newDataInTemp.Value11 = ds.Tables[0].Rows[i][10].ToString().Trim(); newDataInTemp.Value12 = ds.Tables[0].Rows[i][11].ToString().Trim(); newDataInTemp.Value13 = ds.Tables[0].Rows[i][12].ToString().Trim(); newDataInTemp.Value14 = ds.Tables[0].Rows[i][13].ToString().Trim(); newDataInTemp.Value15 = ds.Tables[0].Rows[i][14].ToString().Trim(); newDataInTemp.Value16 = ds.Tables[0].Rows[i][15].ToString().Trim(); newDataInTemp.Value17 = ds.Tables[0].Rows[i][16].ToString().Trim(); newDataInTemp.Value18 = ds.Tables[0].Rows[i][17].ToString().Trim(); newDataInTemp.Value19 = ds.Tables[0].Rows[i][18].ToString().Trim(); newDataInTemp.Value20 = ds.Tables[0].Rows[i][19].ToString().Trim(); newDataInTemp.Value21 = ds.Tables[0].Rows[i][20].ToString().Trim(); newDataInTemp.Value22 = ds.Tables[0].Rows[i][21].ToString().Trim(); newDataInTemp.Value23 = ds.Tables[0].Rows[i][22].ToString().Trim(); newDataInTemp.Value24 = ds.Tables[0].Rows[i][23].ToString().Trim(); newDataInTemp.Value25 = ds.Tables[0].Rows[i][24].ToString().Trim(); newDataInTemp.Value26 = ds.Tables[0].Rows[i][25].ToString().Trim(); newDataInTemp.Value27 = ds.Tables[0].Rows[i][26].ToString().Trim(); newDataInTemp.Value28 = ds.Tables[0].Rows[i][27].ToString().Trim(); newDataInTemp.Value29 = ds.Tables[0].Rows[i][28].ToString().Trim(); newDataInTemp.Value30 = ds.Tables[0].Rows[i][29].ToString().Trim(); newDataInTemp.Value31 = ds.Tables[0].Rows[i][30].ToString().Trim(); newDataInTemp.Value32 = ds.Tables[0].Rows[i][31].ToString().Trim(); newDataInTemp.Value33 = ds.Tables[0].Rows[i][32].ToString().Trim(); newDataInTemp.Value34 = ds.Tables[0].Rows[i][33].ToString().Trim(); newDataInTemp.Value35 = ds.Tables[0].Rows[i][34].ToString().Trim(); newDataInTemp.Value36 = ds.Tables[0].Rows[i][35].ToString().Trim(); newDataInTemp.Value37 = ds.Tables[0].Rows[i][36].ToString().Trim(); newDataInTemp.Value38 = ds.Tables[0].Rows[i][37].ToString().Trim(); BLL.DataInTempService.AddDataInTemp(newDataInTemp); } } this.BindGrid(); ShowNotify("数据已导入临时表!", MessageBoxIcon.Success); } else { ShowNotify("导入数据为空!", MessageBoxIcon.Success); return; } #region 不用了 //try //{ // if (this.FileExcel.HasFile == false) // { // Response.Write(" "); // return; // } // string IsXls = Path.GetExtension(FileExcel.FileName).ToString().Trim().ToLower(); // if (IsXls != ".xls") // { // Response.Write(""); // return; // } // string rootPath = Server.MapPath("~/"); // string initFullPath = rootPath + Const.ExcelUrl; // if (!Directory.Exists(initFullPath)) // { // Directory.CreateDirectory(initFullPath); // } // string fileUrl = initFullPath + BLL.Funs.GetNewFileName() + IsXls; // this.FileExcel.PostedFile.SaveAs(fileUrl); // string oleDBConnString = String.Empty; // oleDBConnString = "Provider=Microsoft.Jet.OLEDB.4.0;"; // oleDBConnString += "Data Source="; // oleDBConnString += fileUrl; // oleDBConnString += ";Extended Properties=Excel 8.0;"; // OleDbConnection oleDBConn = null; // OleDbDataAdapter oleAdMaster = null; // DataTable m_tableName = new DataTable(); // DataSet ds = new DataSet(); // oleDBConn = new OleDbConnection(oleDBConnString); // oleDBConn.Open(); // m_tableName = oleDBConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); // if (m_tableName != null && m_tableName.Rows.Count > 0) // { // m_tableName.TableName = m_tableName.Rows[0]["TABLE_NAME"].ToString().Trim(); // } // string sqlMaster; // sqlMaster = " SELECT * FROM [" + m_tableName.TableName + "]"; // oleAdMaster = new OleDbDataAdapter(sqlMaster, oleDBConn); // oleAdMaster.SelectCommand.CommandTimeout = 3600; // oleAdMaster.Fill(ds, "m_tableName"); // oleAdMaster.Dispose(); // oleDBConn.Close(); // oleDBConn.Dispose(); // this.AddDatasetToSQL(ds.Tables[0]); // if (!string.IsNullOrEmpty(fileUrl) && System.IO.File.Exists(fileUrl)) // { // System.IO.File.Delete(fileUrl);//删除上传的XLS文件 // } // this.FileExcel.Reset(); //} //catch (Exception ex) //{ // ShowNotify(ex.Message, MessageBoxIcon.Warning); // return; //} #endregion } else { ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning); return; } } #endregion #region 将Dataset的数据导入数据库 ,不用了 /// /// 将Dataset的数据导入数据库 /// /// 数据集 /// 数据集列数 /// private void AddDatasetToSQL(DataTable pds) { if (pds != null && pds.Rows.Count > 0) { BLL.DataInTempService.DeleteDataInTemp(this.CurrUser.LoginProjectId, this.CurrUser.UserId, pds.Rows[0][1].ToString()); int ir = pds.Rows.Count; for (int i = 0; i < ir; i++) { if (!string.IsNullOrEmpty(pds.Rows[i][3].ToString())) { Model.Sys_DataInTemp newDataInTemp = new Model.Sys_DataInTemp(); newDataInTemp.TempId = SQLHelper.GetNewID(typeof(Model.Sys_DataInTemp)); newDataInTemp.ProjectId = this.CurrUser.LoginProjectId; newDataInTemp.UserId = this.CurrUser.UserId; newDataInTemp.Time = System.DateTime.Now; newDataInTemp.RowNo = i + 2; newDataInTemp.Value1 = pds.Rows[i][0].ToString().Trim(); newDataInTemp.Value2 = pds.Rows[i][1].ToString().Trim(); newDataInTemp.Value3 = pds.Rows[i][2].ToString().Trim(); newDataInTemp.Value4 = pds.Rows[i][3].ToString().Trim(); newDataInTemp.Value5 = pds.Rows[i][4].ToString().Trim(); newDataInTemp.Value6 = pds.Rows[i][5].ToString().Trim(); newDataInTemp.Value7 = pds.Rows[i][6].ToString().Trim(); newDataInTemp.Value8 = pds.Rows[i][7].ToString().Trim(); newDataInTemp.Value9 = pds.Rows[i][8].ToString().Trim(); newDataInTemp.Value10 = pds.Rows[i][9].ToString().Trim(); newDataInTemp.Value11 = pds.Rows[i][10].ToString().Trim(); newDataInTemp.Value12 = pds.Rows[i][11].ToString().Trim(); newDataInTemp.Value13 = pds.Rows[i][12].ToString().Trim(); newDataInTemp.Value14 = pds.Rows[i][13].ToString().Trim(); newDataInTemp.Value15 = pds.Rows[i][14].ToString().Trim(); newDataInTemp.Value16 = pds.Rows[i][15].ToString().Trim(); newDataInTemp.Value17 = pds.Rows[i][16].ToString().Trim(); newDataInTemp.Value18 = pds.Rows[i][17].ToString().Trim(); newDataInTemp.Value19 = pds.Rows[i][18].ToString().Trim(); newDataInTemp.Value20 = pds.Rows[i][19].ToString().Trim(); newDataInTemp.Value21 = pds.Rows[i][20].ToString().Trim(); newDataInTemp.Value22 = pds.Rows[i][21].ToString().Trim(); newDataInTemp.Value23 = pds.Rows[i][22].ToString().Trim(); newDataInTemp.Value24 = pds.Rows[i][23].ToString().Trim(); newDataInTemp.Value25 = pds.Rows[i][24].ToString().Trim(); newDataInTemp.Value26 = pds.Rows[i][25].ToString().Trim(); newDataInTemp.Value27 = pds.Rows[i][26].ToString().Trim(); newDataInTemp.Value28 = pds.Rows[i][27].ToString().Trim(); newDataInTemp.Value29 = pds.Rows[i][28].ToString().Trim(); newDataInTemp.Value30 = pds.Rows[i][29].ToString().Trim(); newDataInTemp.Value31 = pds.Rows[i][30].ToString().Trim(); newDataInTemp.Value32 = pds.Rows[i][31].ToString().Trim(); newDataInTemp.Value33 = pds.Rows[i][32].ToString().Trim(); newDataInTemp.Value34 = pds.Rows[i][33].ToString().Trim(); newDataInTemp.Value35 = pds.Rows[i][34].ToString().Trim(); newDataInTemp.Value36 = pds.Rows[i][35].ToString().Trim(); BLL.DataInTempService.AddDataInTemp(newDataInTemp); } } this.BindGrid(); ShowNotify("数据已导入临时表!", MessageBoxIcon.Success); } else { ShowNotify("导入数据为空!", MessageBoxIcon.Success); return; } } #endregion #region 提交审核事件 private void SaveMethod(string LoginProjectId, string UserId) { var 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 select x;//单位 var workAreas = from x in Funs.DB.Project_WorkArea where x.ProjectId == this.CurrUser.LoginProjectId select x;//区域 var materials = from x in Funs.DB.Base_Material select x;//材质 var mediums = from x in Funs.DB.Base_Medium select x;//介质 var pipelineClasss = from x in Funs.DB.Base_PipingClass select x;//管道等级 var pipClass = from x in Funs.DB.Base_PIPClass select x; //压力管道等级 var weldTypes = from x in Funs.DB.Base_WeldType select x;//焊缝类型 //var weldingMethods = from x in Funs.DB.Base_WeldingMethod select x;//焊接方法 var grooveTypes = from x in Funs.DB.Base_GrooveType select x;//坡口类型 var componentss = from x in Funs.DB.Base_Components select x;//安装组件 var consumabless = from x in Funs.DB.Base_Consumables select x;//焊接耗材(焊丝、焊条) var weldingLocation = from x in Funs.DB.Base_WeldingLocation select x; //焊接位置 var ndtRate = from x in Funs.DB.Base_DetectionRate select x; var ndtType = from x in Funs.DB.Base_DetectionType select x; var wpsList = from x in Funs.DB.WPQ_WPQList select x; var DNCompareList = BLL.Base_DNCompareService.GetDNCompareList(); var dataInTemp = from x in Funs.DB.Sys_DataInTemp where x.UserId == this.CurrUser.UserId && x.ProjectId == this.CurrUser.LoginProjectId select x; int okCount = 0; int totalNum = dataInTemp.Count(); int rowNum = 0; foreach (var tempData in dataInTemp) { if (tempData != null) { rowNum++; percent[UserId] = (int)(100 * rowNum / totalNum); string errInfo = string.Empty; var isExitValue = Funs.DB.View_WeldJointAndPipeline.FirstOrDefault(x => x.ProjectId == this.CurrUser.LoginProjectId && x.UnitCode == tempData.Value1 && x.WorkAreaCode == tempData.Value2 && x.PipelineCode == tempData.Value3 && x.WeldJointCode == tempData.Value4); if (isExitValue == null || this.ckUpdate.Checked) { Model.Pipeline_Pipeline pipe = null; Model.Pipeline_WeldJoint jot = null; if(isExitValue!=null) { pipe = Funs.DB.Pipeline_Pipeline.FirstOrDefault(x => x.PipelineId == isExitValue.PipelineId); jot = Funs.DB.Pipeline_WeldJoint.FirstOrDefault(x => x.WeldJointId == isExitValue.WeldJointId); } Model.Pipeline_Pipeline pipeline = new Model.Pipeline_Pipeline(); ///管线 Model.Pipeline_WeldJoint weldJoint = new Model.Pipeline_WeldJoint(); ///焊口 if (!string.IsNullOrEmpty(tempData.Value1)) { var unit = units.FirstOrDefault(x => x.UnitCode == tempData.Value1); if (unit == null) { errInfo += "单位代码[" + tempData.Value1 + "]不存在;"; } else { pipeline.UnitId = unit.UnitId; } } else { errInfo += "单位代码为必填项;"; } if (!string.IsNullOrEmpty(tempData.Value2)) { var area = workAreas.FirstOrDefault(x => x.WorkAreaCode == tempData.Value2); if (area == null) { errInfo += "区域[" + tempData.Value2 + "]不存在;"; } else { pipeline.WorkAreaId = area.WorkAreaId; pipeline.InstallationId = area.InstallationId; } } else { errInfo += "区域为必填项;"; } if (string.IsNullOrEmpty(tempData.Value3)) { errInfo += "管线代号此项为必填项!"; } else { pipeline.PipelineCode = tempData.Value3; } if (string.IsNullOrEmpty(tempData.Value4)) { errInfo += "焊口代号此项为必填项!"; } else { weldJoint.WeldJointCode = tempData.Value4; } if (!string.IsNullOrEmpty(tempData.Value5)) { var steel = materials.FirstOrDefault(x => x.MaterialCode == tempData.Value5); if (steel == null) { errInfo += "材质1[" + tempData.Value5 + "]不存在;"; } else { pipeline.MainMaterialId = steel.MaterialId; weldJoint.Material1Id = steel.MaterialId; } } else { if (jot != null && !string.IsNullOrEmpty(jot.Material1Id)) { pipeline.MainMaterialId = pipe.MainMaterialId; weldJoint.Material1Id = jot.Material1Id; } else { errInfo += "材质1为必填项;"; } } if (!string.IsNullOrEmpty(tempData.Value6)) { var steel = materials.FirstOrDefault(x => x.MaterialCode == tempData.Value6); if (steel == null) { errInfo += "材质2[" + tempData.Value6 + "]不存在;"; } else { weldJoint.Material2Id = steel.MaterialId; } } else { if (jot != null && !string.IsNullOrEmpty(jot.Material2Id)) { weldJoint.Material2Id = jot.Material2Id; } } if (!string.IsNullOrEmpty(tempData.Value7)) { var pipelineClass = pipelineClasss.FirstOrDefault(x => x.PipingClassCode == tempData.Value7); if (pipelineClass == null) { errInfo += "管道等级[" + tempData.Value7 + "]不存在;"; } else { pipeline.PipingClassId = pipelineClass.PipingClassId; weldJoint.PipingClassId = pipelineClass.PipingClassId; } } else { if (jot != null && !string.IsNullOrEmpty(jot.PipingClassId)) { pipeline.PipingClassId = pipe.PipingClassId; weldJoint.PipingClassId = jot.PipingClassId; } else { errInfo += "管道等级为必填项;"; } } if (!string.IsNullOrEmpty(tempData.Value8)) { var pc = pipClass.FirstOrDefault(x => x.PIPClassCode == tempData.Value8); if (pc == null) { errInfo += "压力管道分级[" + tempData.Value8 + "]不存在;"; } else { pipeline.PIPClassId = pc.PIPClassId; } } else { if (pipe != null && !string.IsNullOrEmpty(pipe.PIPClassId)) { pipeline.PIPClassId = pipe.PIPClassId; } } if (!string.IsNullOrEmpty(tempData.Value9)) { var medium = mediums.FirstOrDefault(x => x.MediumCode == tempData.Value9); if (medium == null) { errInfo += "介质[" + tempData.Value9 + "]不存在;"; } else { pipeline.MediumId = medium.MediumId; } } else { if (pipe != null && !string.IsNullOrEmpty(pipe.MediumId)) { pipeline.MediumId = pipe.MediumId; } else { errInfo += "介质为必填项;"; } } if (!string.IsNullOrEmpty(tempData.Value10)) { pipeline.Specification = tempData.Value10; } else { if (pipe != null && !string.IsNullOrEmpty(pipe.Specification)) { pipeline.Specification = pipe.Specification; } } if (!string.IsNullOrEmpty(tempData.Value11)) { pipeline.SingleNumber = tempData.Value11; } else { if (pipe != null && !string.IsNullOrEmpty(pipe.SingleNumber)) { pipeline.SingleNumber = pipe.SingleNumber; } } if (!string.IsNullOrEmpty(tempData.Value12)) { pipeline.WorkPackageCode = tempData.Value12; } else { if (pipe != null && !string.IsNullOrEmpty(pipe.WorkPackageCode)) { pipeline.WorkPackageCode = pipe.WorkPackageCode; } } if (!string.IsNullOrEmpty(tempData.Value13)) { pipeline.SystemNumber = tempData.Value13; } else { if (pipe != null && !string.IsNullOrEmpty(pipe.SystemNumber)) { pipeline.SystemNumber = pipe.SystemNumber; } } if (!string.IsNullOrEmpty(tempData.Value14)) { pipeline.SubSystemNumber = tempData.Value14; } else { if (pipe != null && !string.IsNullOrEmpty(pipe.SubSystemNumber)) { pipeline.SubSystemNumber = pipe.SubSystemNumber; } } if (!string.IsNullOrEmpty(tempData.Value15)) { weldJoint.PipeSegment = tempData.Value15; } else { if (jot != null && !string.IsNullOrEmpty(jot.PipeSegment)) { weldJoint.PipeSegment = jot.PipeSegment; } } //if (!string.IsNullOrEmpty(tempData.Value14)) //{ // try // { // int pipeSegment = Convert.ToInt32(tempData.Value14); // pipeline.PipeSegment = pipeSegment; // } // catch (Exception) // { // errInfo += "总管段数[" + tempData.Value14 + "]错误;"; // } //} //pipeline.Sheet = tempData.Value15; if (!string.IsNullOrEmpty(tempData.Value16)) { weldJoint.PageNum = tempData.Value16; } else { if (jot != null && !string.IsNullOrEmpty(jot.PageNum)) { weldJoint.PageNum = jot.PageNum; } } if (!string.IsNullOrEmpty(tempData.Value17)) { pipeline.DrawingsNum = tempData.Value17; } else { if (pipe != null && !string.IsNullOrEmpty(pipe.DrawingsNum)) { pipeline.DrawingsNum = pipe.DrawingsNum; } } if (!string.IsNullOrEmpty(tempData.Value18)) { pipeline.DesignTemperature = tempData.Value18; } else { if (pipe != null && !string.IsNullOrEmpty(pipe.DesignTemperature)) { pipeline.DesignTemperature = pipe.DesignTemperature; } } if (!string.IsNullOrEmpty(tempData.Value19)) { pipeline.TestPressure = tempData.Value19; } else { if (pipe != null && !string.IsNullOrEmpty(pipe.TestPressure)) { pipeline.TestPressure = pipe.TestPressure; } } if (!string.IsNullOrEmpty(tempData.Value20)) { pipeline.DesignPressure = tempData.Value20; } else { if (pipe != null && !string.IsNullOrEmpty(pipe.DesignPressure)) { pipeline.DesignPressure = pipe.DesignPressure; } } if (!string.IsNullOrEmpty(tempData.Value21)) { var weldType = weldTypes.FirstOrDefault(x => x.WeldTypeCode == tempData.Value21); if (weldType == null) { errInfo += "焊缝类型[" + tempData.Value21 + "]不存在;"; } else { weldJoint.WeldTypeId = weldType.WeldTypeId; } } else { if (jot != null && !string.IsNullOrEmpty(jot.WeldTypeId)) { weldJoint.WeldTypeId = jot.WeldTypeId; } else { errInfo += "焊缝类型为必填项;"; } } decimal? size = null; if (!string.IsNullOrEmpty(tempData.Value22)) { try { size = Convert.ToDecimal(tempData.Value22); weldJoint.Size = size; } catch (Exception) { errInfo += "寸径[" + tempData.Value22 + "]错误;"; } } else { if (jot != null && jot.Size != null) { size= jot.Size; weldJoint.Size = jot.Size; } else { errInfo += "寸径为必填项;"; } } if (!string.IsNullOrEmpty(tempData.Value23)) { var q = from x in DNCompareList where x.Value == tempData.Value23 select x; if (q.Count() > 0) { weldJoint.ANSISCH = tempData.Value23; string ansi = tempData.Value23; decimal? dia = null; decimal? sch = null; var dn = from x in Funs.DB.Base_DNCompare where x.PipeSize == size select x; if (dn.Count() > 0) { if (tempData.Value23 != "FB") { if (dn.First().OutSizeDia != null) { dia = dn.First().OutSizeDia; } if (ansi == "5") { if (dn.First().SCH5 != null) { sch = dn.First().SCH5; } } if (ansi == "5S") { if (dn.First().SCH5S != null) { sch = dn.First().SCH5S; } } if (ansi == "10") { if (dn.First().SCH10 != null) { sch = dn.First().SCH10; } } if (ansi == "10S") { if (dn.First().SCH10S != null) { sch = dn.First().SCH10S; } } if (ansi == "20") { if (dn.First().SCH20 != null) { sch = dn.First().SCH20; } } if (ansi == "30") { if (dn.First().SCH30 != null) { sch = dn.First().SCH30; } } if (ansi == "40") { if (dn.First().SCH40 != null) { sch = dn.First().SCH40; } } if (ansi == "40S") { if (dn.First().SCH40S != null) { sch = dn.First().SCH40S; } } if (ansi == "STD") { if (dn.First().STD != null) { sch = dn.First().STD; } } if (ansi == "60") { if (dn.First().SCH60 != null) { sch = dn.First().SCH60; } } if (ansi == "80") { if (dn.First().SCH80 != null) { sch = dn.First().SCH80; } } if (ansi == "80S") { if (dn.First().SCH80S != null) { sch = dn.First().SCH80S; } } if (ansi == "XS") { if (dn.First().XS != null) { sch = dn.First().XS; } } if (ansi == "100") { if (dn.First().SCH100 != null) { sch = dn.First().SCH100; } } if (ansi == "120") { if (dn.First().SCH120 != null) { sch = dn.First().SCH120; } } if (ansi == "140") { if (dn.First().SCH140 != null) { sch = dn.First().SCH140; } } if (ansi == "160") { if (dn.First().SCH160 != null) { sch = dn.First().SCH160; } } if (ansi == "XXS") { if (dn.First().XXS != null) { sch = dn.First().XXS; } } } // 非美标 else { if (dn.First().OutSize_FB != null) { dia = dn.First().OutSize_FB; } if (dn.First().SCH_FB != null) { sch = dn.First().SCH_FB; } } weldJoint.Dia = dia; weldJoint.Thickness = sch; if (dia != null && sch != null) { weldJoint.Specification = "Φ" + dia.ToString() + "×" + sch.ToString(); } } else { errInfo += "管径[" + size + "]无此对昭数据;"; } } else { errInfo += "美标壁厚[" + tempData.Value23 + "]错误;"; } } else { if (jot != null && jot.ANSISCH != null) { weldJoint.ANSISCH = jot.ANSISCH; weldJoint.Dia = jot.Dia; weldJoint.Thickness = jot.Thickness; weldJoint.Specification = jot.Specification; } else { errInfo += "美标壁厚为必填项;"; } } //if (!string.IsNullOrEmpty(tempData.Value22)) //{ // try // { // decimal dia = Convert.ToDecimal(tempData.Value22); // weldJoint.Dia = dia; // } // catch (Exception) // { // errInfo += "外径[" + tempData.Value22 + "]错误;"; // } //} //else //{ // errInfo += "外径为必填项;"; //} //if (!string.IsNullOrEmpty(tempData.Value23)) //{ // try // { // decimal thickness = Convert.ToDecimal(tempData.Value23); // weldJoint.Thickness = thickness; // } // catch (Exception) // { // errInfo += "壁厚[" + tempData.Value23 + "]错误;"; // } //} //else //{ // errInfo += "壁厚为必填项;"; //} //if (!string.IsNullOrEmpty(tempData.Value23)) //{ // var weldMethod = weldingMethods.FirstOrDefault(x => x.WeldingMethodCode == tempData.Value24); // if (weldMethod == null) // { // errInfo += "焊接方法[" + tempData.Value24 + "]不存在;"; // } // else // { // weldJoint.WeldingMethodId = weldMethod.WeldingMethodId; // } //} //else //{ // errInfo += "焊接方法为必填项;"; //} if (!string.IsNullOrEmpty(tempData.Value24)) { weldJoint.HeartNo1 = tempData.Value24; } else { if (jot != null && !string.IsNullOrEmpty(jot.HeartNo1)) { weldJoint.HeartNo1 = jot.HeartNo1; } } if (!string.IsNullOrEmpty(tempData.Value25)) { weldJoint.HeartNo2 = tempData.Value25; } else { if (jot != null && !string.IsNullOrEmpty(jot.HeartNo2)) { weldJoint.HeartNo2 = jot.HeartNo2; } } if (!string.IsNullOrEmpty(tempData.Value26)) { var grooveType = grooveTypes.FirstOrDefault(x => x.GrooveTypeCode == tempData.Value26); if (grooveType == null) { errInfo += "坡口类型[" + tempData.Value26 + "]不存在;"; } else { weldJoint.GrooveTypeId = grooveType.GrooveTypeId; } } else { if (jot != null && jot.GrooveTypeId != null) { weldJoint.GrooveTypeId = jot.GrooveTypeId; } else { errInfo += "坡口类型为必填项;"; } } if (!string.IsNullOrEmpty(tempData.Value27)) { if (tempData.Value27 != "S" && tempData.Value27 != "F") { errInfo += "焊口属性[" + tempData.Value27 + "]不存在;"; } else { weldJoint.JointArea = tempData.Value27; if (tempData.Value27 == "S") { weldJoint.JointAttribute = "活动S"; } else { weldJoint.JointAttribute = "固定F"; } } } else { if (jot != null && jot.JointAttribute != null) { weldJoint.JointAttribute = jot.JointAttribute; } else { errInfo += "焊口属性为必填项;"; } } if (!string.IsNullOrEmpty(tempData.Value28)) { var com = componentss.FirstOrDefault(x => x.ComponentsCode == tempData.Value28); if (com == null) { errInfo += "组件1号[" + tempData.Value28 + "]不存在;"; } else { weldJoint.PipeAssembly1Id = com.ComponentsId; } } else { if (jot != null && jot.PipeAssembly1Id != null) { weldJoint.PipeAssembly1Id = jot.PipeAssembly1Id; } } if (!string.IsNullOrEmpty(tempData.Value29)) { var com = componentss.FirstOrDefault(x => x.ComponentsCode == tempData.Value29); if (com == null) { errInfo += "组件2号[" + tempData.Value29 + "]不存在;"; } else { weldJoint.PipeAssembly2Id = com.ComponentsId; } } else { if (jot != null && jot.PipeAssembly2Id != null) { weldJoint.PipeAssembly2Id = jot.PipeAssembly2Id; } } if (!string.IsNullOrEmpty(tempData.Value30)) { if (tempData.Value30 == "是") { weldJoint.IsHotProess = true; } else if (tempData.Value30 == "否") { weldJoint.IsHotProess = false; } } else { if (jot != null && jot.IsHotProess != null) { weldJoint.IsHotProess = jot.IsHotProess; } } if (!string.IsNullOrEmpty(tempData.Value31)) { if (tempData.Value31 == "是") { pipeline.IfPickling = true; } else if (tempData.Value31 == "否") { pipeline.IfPickling = false; } } else { if (pipe != null && pipe.IfPickling != null) { pipeline.IfPickling = pipe.IfPickling; } } if (!string.IsNullOrEmpty(tempData.Value32)) { var loc = weldingLocation.FirstOrDefault(x => x.WeldingLocationCode == tempData.Value32); if (loc == null) { errInfo += "焊接位置[" + tempData.Value32 + "]不存在;"; } else { weldJoint.WeldingLocationId = loc.WeldingLocationId; } } else { if (jot != null && !string.IsNullOrEmpty(jot.WeldingLocationId)) { weldJoint.WeldingLocationId = jot.WeldingLocationId; } } if (!string.IsNullOrEmpty(tempData.Value33)) { var rate = ndtRate.FirstOrDefault(x => x.DetectionRateCode == tempData.Value33); if (rate == null) { errInfo += "检测比例[" + tempData.Value33 + "]不存在;"; } else { pipeline.DetectionRateId = rate.DetectionRateId; } } else { if (pipe != null && pipe.DetectionRateId != null) { pipeline.DetectionRateId = pipe.DetectionRateId; } else { errInfo += "检测比例为必填项;"; } } if (!string.IsNullOrEmpty(tempData.Value34)) { // 探伤类型如多个用“,”隔开 string[] ndtList = tempData.Value34.Split(','); string ndtIds = string.Empty; if (ndtList.Count() > 0) { foreach (string ndtCode in ndtList) { var ndt = ndtType.FirstOrDefault(x => x.DetectionTypeCode == ndtCode); if (ndt == null) { errInfo += "探伤类型[" + tempData.Value34 + "]不存在;"; } else { ndtIds = ndtIds + ndt.DetectionTypeId + "|"; } } if (ndtIds != string.Empty) { weldJoint.DetectionType = ndtIds.Substring(0, ndtIds.Length - 1); } } else { errInfo += "探伤类型[" + tempData.Value34 + "]不正确;"; } } else { if (jot != null && jot.DetectionType != null) { weldJoint.DetectionType = jot.DetectionType; } else { errInfo += "探伤类型为必填项;"; } } if (!string.IsNullOrEmpty(tempData.Value35)) { var wps = wpsList.FirstOrDefault(x => x.WPQCode == tempData.Value35); if (wps == null) { errInfo += "WPS编号[" + tempData.Value35 + "]不存在;"; } else { weldJoint.WPQId = wps.WPQId; if (!string.IsNullOrEmpty(wps.WeldingMethodId)) { weldJoint.WeldingMethodId = wps.WeldingMethodId; } if (!string.IsNullOrEmpty(wps.WeldMatId)) { weldJoint.WeldMatId = wps.WeldMatId; } if (!string.IsNullOrEmpty(wps.WeldSilkId)) { weldJoint.WeldSilkId = wps.WeldSilkId.Replace("|", ","); } } } else { if (jot != null && !string.IsNullOrEmpty(jot.WPQId)) { weldJoint.WPQId = jot.WPQId; if (!string.IsNullOrEmpty(jot.WeldingMethodId)) { weldJoint.WeldingMethodId = jot.WeldingMethodId; } if (!string.IsNullOrEmpty(jot.WeldMatId)) { weldJoint.WeldMatId = jot.WeldMatId; } if (!string.IsNullOrEmpty(jot.WeldSilkId)) { weldJoint.WeldSilkId = jot.WeldSilkId.Replace("|", ","); } } } //else //{ // errInfo += "WPS为必填项;"; //} //if (!string.IsNullOrEmpty(tempData.Value36)) //{ // var weldSilk = consumabless.FirstOrDefault(x => x.ConsumablesCode == tempData.Value36 && x.ConsumablesType == "1"); // if (weldSilk == null) // { // errInfo += "焊丝[" + tempData.Value36 + "]不存在;"; // } // else // { // weldJoint.WeldSilkId = weldSilk.ConsumablesId; // } //} if (!string.IsNullOrEmpty(tempData.Value36)) { // 焊丝如多个用“,”隔开 string[] silkList = tempData.Value36.Trim().Split(','); string silkIds = string.Empty; if (silkList.Count() > 0) { foreach (string silk in silkList) { if (!string.IsNullOrEmpty(silk)) { var weldSilk = consumabless.FirstOrDefault(x => x.ConsumablesCode == silk && x.ConsumablesType == "1"); if (weldSilk == null) { errInfo += "焊丝[" + silk + "]不存在;"; } else { silkIds = silkIds + weldSilk.ConsumablesId + ","; } } } if (silkIds != string.Empty) { weldJoint.WeldSilkId = silkIds.Substring(0, silkIds.Length - 1); } } else { errInfo += "焊丝[" + tempData.Value36 + "]不正确,多个焊丝用,隔开;"; } } else { if (jot != null && !string.IsNullOrEmpty(jot.WeldSilkId)) { weldJoint.WeldSilkId = jot.WeldSilkId; } } if (!string.IsNullOrEmpty(tempData.Value37)) { var weldMat = consumabless.FirstOrDefault(x => x.ConsumablesCode == tempData.Value37 && x.ConsumablesType == "2"); if (weldMat == null) { errInfo += "焊条[" + tempData.Value37 + "]不存在;"; } else { weldJoint.WeldMatId = weldMat.ConsumablesId; } } else { if (jot != null && !string.IsNullOrEmpty(jot.WeldMatId)) { weldJoint.WeldMatId = jot.WeldMatId; } } if (!string.IsNullOrEmpty(tempData.Value38)) { if (tempData.Value38 == "是") { weldJoint.IsPMI = true; } else if (tempData.Value38 == "否") { weldJoint.IsPMI = false; } } else { if (jot != null && jot.IsPMI != null) { weldJoint.IsPMI = jot.IsPMI; } } if (string.IsNullOrEmpty(errInfo)) // 所有信息正确的话 这插入管线焊口 { pipeline.ProjectId = this.CurrUser.LoginProjectId; weldJoint.ProjectId = this.CurrUser.LoginProjectId; var isExitISOValue = Funs.DB.View_WeldJointAndPipeline.FirstOrDefault(x => x.ProjectId == this.CurrUser.LoginProjectId && x.UnitCode == tempData.Value1 && x.WorkAreaCode == tempData.Value2 && x.PipelineCode == tempData.Value3); if (isExitISOValue != null) ///管线已存在 { pipeline.PipelineId = isExitISOValue.PipelineId; weldJoint.PipelineId = isExitISOValue.PipelineId; // 焊接时更新部分内容 if (isExitValue != null && !string.IsNullOrEmpty(isExitValue.WeldingDailyId)) { BLL.Pipeline_PipelineService.UpdateDepartPipeline(pipeline); } // 未焊接时更新内容 else { BLL.Pipeline_PipelineService.UpdatePipeline(pipeline); } } else { pipeline.PipelineId = SQLHelper.GetNewID(typeof(Model.Pipeline_Pipeline)); weldJoint.PipelineId = pipeline.PipelineId; BLL.Pipeline_PipelineService.AddPipeline(pipeline); BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_PipelineManageMenuId, Const.BtnAdd, pipeline.PipelineId); } //var isExitJotNoValue = Funs.DB.View_WeldJointAndPipeline.FirstOrDefault(x => x.ProjectId == this.CurrUser.LoginProjectId && x.UnitCode == tempData.Value1 // && x.WorkAreaCode == tempData.Value2 && x.PipelineCode == tempData.Value3 && x.WeldJointCode == tempData.Value4); if (isExitValue == null) { BLL.Pipeline_WeldJointService.AddWeldJoint(weldJoint); BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_JointInfoMenuId, Const.BtnAdd, string.Empty); } else { // 未焊接时更新内容 if (string.IsNullOrEmpty(isExitValue.WeldingDailyId)) { weldJoint.WeldJointId = isExitValue.WeldJointId; BLL.Pipeline_WeldJointService.UpdateWeldJoint(weldJoint); } // 焊接时更新部分内容(暂时全放开给修改) else { weldJoint.WeldJointId = isExitValue.WeldJointId; BLL.Pipeline_WeldJointService.UpdateDepartWeldJoint(weldJoint); } } BLL.DataInTempService.DeleteDataInTempByDataInTempID(tempData.TempId); okCount++; } } else { errInfo = "该条记录已存在于管线、焊口信息表中。"; } if (!string.IsNullOrEmpty(errInfo)) { tempData.ToopValue = errInfo; BLL.DataInTempService.UpdateDataInTemp(tempData); } } } //ShowNotify("提交操作已完成,成功提交" + okCount.ToString() + "条数据到管线焊口表!", MessageBoxIcon.Success); //this.BindGrid(); } protected void btnRefresh_Click(object sender, EventArgs e) { this.BindGrid(); } /// /// 提交审核事件 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { Thread t = new Thread(new ThreadStart(() => { SaveMethod(this.CurrUser.LoginProjectId, this.CurrUser.UserId); })); t.Start(); if (percent.ContainsKey(this.CurrUser.UserId)) { percent[CurrUser.UserId] = 0; } else { percent.Add(CurrUser.UserId, 0); } PageContext.RegisterStartupScript("printX()"); #region 不用了 //var 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 // select x;//单位 //var workAreas = from x in Funs.DB.Project_WorkArea where x.ProjectId == this.CurrUser.LoginProjectId select x;//区域 //var materials = from x in Funs.DB.Base_Material select x;//材质 //var mediums = from x in Funs.DB.Base_Medium select x;//介质 //var pipelineClasss = from x in Funs.DB.Base_PipingClass select x;//管道等级 //var weldTypes = from x in Funs.DB.Base_WeldType select x;//焊缝类型 //var weldingMethods = from x in Funs.DB.Base_WeldingMethod select x;//焊接方法 //var grooveTypes = from x in Funs.DB.Base_GrooveType select x;//坡口类型 //var componentss= from x in Funs.DB.Base_Components select x;//安装组件 //var consumabless = from x in Funs.DB.Base_Consumables select x;//焊接耗材(焊丝、焊条) //var weldingLocation = from x in Funs.DB.Base_WeldingLocation select x; //焊接位置 //var ndtRate = from x in Funs.DB.Base_DetectionRate select x; //var dataInTemp = from x in Funs.DB.Sys_DataInTemp // where x.UserId == this.CurrUser.UserId && x.ProjectId == this.CurrUser.LoginProjectId // select x; //int okCount = 0; //foreach (var tempData in dataInTemp) //{ // if (tempData != null) // { // string errInfo = string.Empty; // var isExitValue = Funs.DB.View_WeldJointAndPipeline.FirstOrDefault(x => x.ProjectId == this.CurrUser.LoginProjectId && x.UnitCode == tempData.Value1 // && x.WorkAreaCode == tempData.Value2 && x.PipelineCode == tempData.Value3 && x.WeldJointCode == tempData.Value4); // if (isExitValue == null || this.ckUpdate.Checked) // { // Model.Pipeline_Pipeline pipeline = new Model.Pipeline_Pipeline(); ///管线 // Model.Pipeline_WeldJoint weldJoint = new Model.Pipeline_WeldJoint(); ///焊口 // if (!string.IsNullOrEmpty(tempData.Value1)) // { // var unit = units.FirstOrDefault(x => x.UnitCode == tempData.Value1); // if (unit == null) // { // errInfo += "单位代码[" + tempData.Value1 + "]不存在;"; // } // else // { // pipeline.UnitId = unit.UnitId; // } // } // else // { // errInfo += "单位代码为必填项;"; // } // if (!string.IsNullOrEmpty(tempData.Value2)) // { // var area = workAreas.FirstOrDefault(x => x.WorkAreaCode == tempData.Value2); // if (area == null) // { // errInfo += "区域[" + tempData.Value2 + "]不存在;"; // } // else // { // pipeline.WorkAreaId = area.WorkAreaId; // pipeline.InstallationId = area.InstallationId; // } // } // else // { // errInfo += "区域为必填项;"; // } // if (string.IsNullOrEmpty(tempData.Value3)) // { // errInfo += "管线代号此项为必填项!"; // } // else // { // pipeline.PipelineCode = tempData.Value3; // } // if (string.IsNullOrEmpty(tempData.Value4)) // { // errInfo += "焊口代号此项为必填项!"; // } // else // { // weldJoint.WeldJointCode = tempData.Value4; // } // if (!string.IsNullOrEmpty(tempData.Value5)) // { // var steel = materials.FirstOrDefault(x => x.MaterialCode == tempData.Value5); // if (steel == null) // { // errInfo += "材质1[" + tempData.Value5 + "]不存在;"; // } // else // { // pipeline.MainMaterialId = steel.MaterialId; // weldJoint.Material1Id = steel.MaterialId; // } // } // else // { // errInfo += "材质1为必填项;"; // } // if (!string.IsNullOrEmpty(tempData.Value6)) // { // var steel = materials.FirstOrDefault(x => x.MaterialCode == tempData.Value6); // if (steel == null) // { // errInfo += "材质2[" + tempData.Value6 + "]不存在;"; // } // else // { // weldJoint.Material2Id = steel.MaterialId; // } // } // if (!string.IsNullOrEmpty(tempData.Value7)) // { // var pipelineClass = pipelineClasss.FirstOrDefault(x => x.PipingClassCode == tempData.Value7); // if (pipelineClass == null) // { // errInfo += "管道等级[" + tempData.Value7 + "]不存在;"; // } // else // { // pipeline.PipingClassId = pipelineClass.PipingClassId; // weldJoint.PipingClassId = pipelineClass.PipingClassId; // } // } // else // { // errInfo += "管道等级为必填项;"; // } // if (!string.IsNullOrEmpty(tempData.Value8)) // { // var medium = mediums.FirstOrDefault(x => x.MediumCode == tempData.Value8); // if (medium == null) // { // errInfo += "介质[" + tempData.Value8 + "]不存在;"; // } // else // { // pipeline.MediumId = medium.MediumId; // } // } // else // { // errInfo += "介质为必填项;"; // } // pipeline.Specification = tempData.Value9; // pipeline.SingleNumber = tempData.Value10; // pipeline.WorkPackageCode = tempData.Value11; // pipeline.SystemNumber = tempData.Value12; // pipeline.SubSystemNumber = tempData.Value13; // if (!string.IsNullOrEmpty(tempData.Value14)) // { // try // { // int pipeSegment = Convert.ToInt32(tempData.Value14); // pipeline.PipeSegment = pipeSegment; // } // catch (Exception) // { // errInfo += "总管段数[" + tempData.Value14 + "]错误;"; // } // } // pipeline.Sheet = tempData.Value15; // pipeline.DrawingsNum = tempData.Value16; // pipeline.DesignTemperature = tempData.Value17; // pipeline.TestPressure = tempData.Value18; // pipeline.DesignPressure = tempData.Value19; // if (!string.IsNullOrEmpty(tempData.Value20)) // { // var weldType = weldTypes.FirstOrDefault(x => x.WeldTypeCode == tempData.Value20); // if (weldType == null) // { // errInfo += "焊缝类型[" + tempData.Value20 + "]不存在;"; // } // else // { // weldJoint.WeldTypeId = weldType.WeldTypeId; // } // } // else // { // errInfo += "焊缝类型为必填项;"; // } // if (!string.IsNullOrEmpty(tempData.Value21)) // { // try // { // decimal size = Convert.ToDecimal(tempData.Value21); // weldJoint.Size = size; // } // catch (Exception) // { // errInfo += "寸径[" + tempData.Value21 + "]错误;"; // } // } // else // { // errInfo += "寸径为必填项;"; // } // if (!string.IsNullOrEmpty(tempData.Value22)) // { // try // { // decimal dia = Convert.ToDecimal(tempData.Value22); // weldJoint.Dia = dia; // } // catch (Exception) // { // errInfo += "外径[" + tempData.Value22 + "]错误;"; // } // } // else // { // errInfo += "外径为必填项;"; // } // if (!string.IsNullOrEmpty(tempData.Value23)) // { // try // { // decimal thickness = Convert.ToDecimal(tempData.Value23); // weldJoint.Thickness = thickness; // } // catch (Exception) // { // errInfo += "壁厚[" + tempData.Value23 + "]错误;"; // } // } // else // { // errInfo += "壁厚为必填项;"; // } // if (!string.IsNullOrEmpty(tempData.Value24)) // { // var weldMethod = weldingMethods.FirstOrDefault(x => x.WeldingMethodCode == tempData.Value24); // if (weldMethod==null) // { // errInfo += "焊接方法[" + tempData.Value24 + "]不存在;"; // } // else // { // weldJoint.WeldingMethodId = weldMethod.WeldingMethodId; // } // } // else // { // errInfo += "焊接方法为必填项;"; // } // weldJoint.HeartNo1 = tempData.Value25; // weldJoint.HeartNo2 = tempData.Value26; // if (!string.IsNullOrEmpty(tempData.Value27)) // { // var grooveType = grooveTypes.FirstOrDefault(x => x.GrooveTypeCode == tempData.Value27); // if (grooveType==null) // { // errInfo += "坡口类型[" + tempData.Value27 + "]不存在;"; // } // else // { // weldJoint.GrooveTypeId = grooveType.GrooveTypeId; // } // } // else // { // errInfo += "坡口类型为必填项;"; // } // if (!string.IsNullOrEmpty(tempData.Value28)) // { // if (tempData.Value28 != "S" && tempData.Value28 != "F") // { // errInfo += "焊口属性[" + tempData.Value28 + "]不存在;"; // } // else // { // weldJoint.JointArea = tempData.Value28; // if (tempData.Value28 == "S") // { // weldJoint.JointAttribute = "活动S"; // } // else // { // weldJoint.JointAttribute = "固定F"; // } // } // } // else // { // errInfo += "焊口属性为必填项;"; // } // if (!string.IsNullOrEmpty(tempData.Value29)) // { // var com = componentss.FirstOrDefault(x => x.ComponentsCode == tempData.Value29); // if (com==null) // { // errInfo += "组件1号[" + tempData.Value29 + "]不存在;"; // } // else // { // weldJoint.PipeAssembly1Id = com.ComponentsId; // } // } // if (!string.IsNullOrEmpty(tempData.Value30)) // { // var com = componentss.FirstOrDefault(x => x.ComponentsCode == tempData.Value30); // if (com == null) // { // errInfo += "组件2号[" + tempData.Value30 + "]不存在;"; // } // else // { // weldJoint.PipeAssembly2Id = com.ComponentsId; // } // } // if (!string.IsNullOrEmpty(tempData.Value31)) // { // var weldSilk = consumabless.FirstOrDefault(x => x.ConsumablesCode == tempData.Value31 && x.ConsumablesType == "1"); // if (weldSilk == null) // { // errInfo += "焊丝[" + tempData.Value31 + "]不存在;"; // } // else // { // weldJoint.WeldSilkId = weldSilk.ConsumablesId; // } // } // if (!string.IsNullOrEmpty(tempData.Value32)) // { // var weldMat = consumabless.FirstOrDefault(x => x.ConsumablesCode == tempData.Value32 && x.ConsumablesType == "2"); // if (weldMat == null) // { // errInfo += "焊条[" + tempData.Value32 + "]不存在;"; // } // else // { // weldJoint.WeldMatId = weldMat.ConsumablesId; // } // } // if (!string.IsNullOrEmpty(tempData.Value33)) // { // if (tempData.Value33=="是") // { // weldJoint.IsHotProess = true; // } // else if(tempData.Value33=="否") // { // weldJoint.IsHotProess = false; // } // } // if (!string.IsNullOrEmpty(tempData.Value34)) // { // if (tempData.Value34 == "是") // { // pipeline.IfPickling = true; // } // else if (tempData.Value34 == "否") // { // pipeline.IfPickling = false; // } // } // if (!string.IsNullOrEmpty(tempData.Value35)) // { // var loc = weldingLocation.FirstOrDefault(x => x.WeldingLocationCode == tempData.Value35); // if (loc == null) // { // errInfo += "焊接位置[" + tempData.Value35 + "]不存在;"; // } // else // { // weldJoint.WeldingLocationId = loc.WeldingLocationId; // } // } // if (!string.IsNullOrEmpty(tempData.Value36)) // { // var rate = ndtRate.FirstOrDefault(x => x.DetectionRateCode == tempData.Value36); // if (rate == null) // { // errInfo += "检测比例[" + tempData.Value36 + "]不存在;"; // } // else // { // pipeline.DetectionRateId = rate.DetectionRateId; // } // } // if (!string.IsNullOrEmpty(tempData.Value22) && !string.IsNullOrEmpty(tempData.Value23)) // { // weldJoint.Specification = "Φ" + tempData.Value22 + "*" + tempData.Value23; // } // if (string.IsNullOrEmpty(errInfo)) // 所有信息正确的话 这插入管线焊口 // { // pipeline.ProjectId = this.CurrUser.LoginProjectId; // weldJoint.ProjectId = this.CurrUser.LoginProjectId; // var isExitISOValue = Funs.DB.View_WeldJointAndPipeline.FirstOrDefault(x => x.ProjectId == this.CurrUser.LoginProjectId && x.UnitCode == tempData.Value1 // && x.WorkAreaCode == tempData.Value2 && x.PipelineCode == tempData.Value3); // if (isExitISOValue != null) ///管线已存在 // { // pipeline.PipelineId = isExitISOValue.PipelineId; // weldJoint.PipelineId = isExitISOValue.PipelineId; // BLL.Pipeline_PipelineService.UpdatePipeline(pipeline); // } // else // { // pipeline.PipelineId = SQLHelper.GetNewID(typeof(Model.Pipeline_Pipeline)); // weldJoint.PipelineId = pipeline.PipelineId; // BLL.Pipeline_PipelineService.AddPipeline(pipeline); // // 管道等级明细 导入管线对应的检测 // //var classItem = from x in Funs.DB.Base_PipingClassDetail where x.PipingClassId == pipeline.PipingClassId select x; // //if (classItem.Count() > 0) // //{ // // foreach (var item in classItem) // // { // // Model.Pipeline_PipelineDetectionType ndt = new Model.Pipeline_PipelineDetectionType(); // // ndt.PipelineDetectionTypeId = SQLHelper.GetNewID(typeof(Model.Pipeline_PipelineDetectionType)); // // ndt.PipelineId = pipeline.PipelineId; // // ndt.WeldTypeId = item.WeldTypeId; // // ndt.DetectionTypeId = item.DetectionTypeId; // // ndt.DetectionRateId = item.DetectionRateId; // // ndt.MinThickness = item.ThicknessMin; // // ndt.MaxThickness = item.ThicknessMax; // // ndt.MinDia = item.SizeMin; // // ndt.MaxDia = item.SizeMax; // // BLL.Pipeline_PipelineDetectionTypeService.AddPipelineDetectionType(ndt); // // } // //} // BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_PipelineManageMenuId, Const.BtnAdd, pipeline.PipelineId); // } // var isExitJotNoValue = Funs.DB.View_WeldJointAndPipeline.FirstOrDefault(x => x.ProjectId == this.CurrUser.LoginProjectId && x.UnitCode == tempData.Value1 // && x.WorkAreaCode == tempData.Value2 && x.PipelineCode == tempData.Value3 && x.WeldJointCode == tempData.Value4); // if (isExitJotNoValue == null) // { // BLL.Pipeline_WeldJointService.AddWeldJoint(weldJoint); // BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_JointInfoMenuId, Const.BtnAdd, string.Empty); // } // else // { // if (string.IsNullOrEmpty(isExitJotNoValue.WeldingDailyId)) // { // weldJoint.WeldJointId = isExitJotNoValue.WeldJointId; // BLL.Pipeline_WeldJointService.UpdateWeldJoint(weldJoint); // } // } // BLL.DataInTempService.DeleteDataInTempByDataInTempID(tempData.TempId); // okCount++; // } // } // else // { // errInfo = "该条记录已存在于管线、焊口信息表中。"; // } // if (!string.IsNullOrEmpty(errInfo)) // { // tempData.ToopValue = errInfo; // BLL.DataInTempService.UpdateDataInTemp(tempData); // } // } //} //ShowNotify("提交操作已完成,成功提交" + okCount.ToString() + "条数据到管线焊口表!", MessageBoxIcon.Success); //this.BindGrid(); #endregion } #endregion #region 删除所有数据事件 /// /// 删除所有数据事件 /// /// /// protected void btnAllDelete_Click(object sender, EventArgs e) { ////先删除临时表中 该人员以前导入的数据 BLL.DataInTempService.DeleteDataInTempByProjectIdAndUserId(this.CurrUser.LoginProjectId, this.CurrUser.UserId); this.BindGrid(); ShowNotify(Resources.Lan.DeletedSuccessfully, MessageBoxIcon.Success); this.lbDataCout.Text = string.Empty; } #endregion #region 模版导入说明 下载 /// /// 下载模版 /// /// /// protected void imgbtnUpload_Click(object sender, EventArgs e) { this.TemplateUpload(BLL.Const.HJGL_DataInTemplateUrl); } /// /// 导入说明 /// /// /// protected void lkAchievements_Click(object sender, EventArgs e) { this.TemplateUpload(Const.HJGL_DataInHelpUrl); } /// /// 模板下载方法 /// /// protected void TemplateUpload(string initTemplatePath) { string uploadfilepath = Server.MapPath("~/") + initTemplatePath; string fileName = Path.GetFileName(initTemplatePath); FileInfo info = new FileInfo(uploadfilepath); if (info.Exists) { long fileSize = info.Length; Response.Clear(); Response.ContentType = "application/x-zip-compressed"; Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); Response.AddHeader("Content-Length", fileSize.ToString()); Response.TransmitFile(uploadfilepath, 0, fileSize); Response.Flush(); Response.Close(); } else { ShowNotify("文件不存在!", MessageBoxIcon.Warning); } } #endregion #region 查询 /// /// 查询 /// /// /// protected void TextBox_TextChanged(object sender, EventArgs e) { this.BindGrid(); } #endregion } }