using System; using System.Collections.Generic; using System.Linq; using System.Data.SqlClient; using System.Data.OleDb; using System.Data; using System.IO; using BLL; namespace FineUIPro.Web.WeldingProcess.DataIn { public partial class DataIn : PageBase { #region 加载页面 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString(); BLL.Project_InstallationService.InitInstallationDropDownList(this.drpInstallation, true, this.CurrUser.LoginProjectId, Resources.Lan.PleaseSelect);//装置 // 绑定表格 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" + @" 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 (!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 = "red"; } } } 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)) { 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; } } else { ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning); return; } } #endregion #region 将Dataset的数据导入数据库 /// /// 将Dataset的数据导入数据库 /// /// 数据集 /// 数据集列数 /// private void AddDatasetToSQL(DataTable pds) { if (pds != null && pds.Rows.Count > 0) { 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(); newDataInTemp.Value2 = pds.Rows[i][1].ToString(); newDataInTemp.Value3 = pds.Rows[i][2].ToString(); newDataInTemp.Value4 = pds.Rows[i][3].ToString(); newDataInTemp.Value5 = pds.Rows[i][4].ToString(); newDataInTemp.Value6 = pds.Rows[i][5].ToString(); newDataInTemp.Value7 = pds.Rows[i][6].ToString(); newDataInTemp.Value8 = pds.Rows[i][7].ToString(); newDataInTemp.Value9 = pds.Rows[i][8].ToString(); newDataInTemp.Value10 = pds.Rows[i][9].ToString(); newDataInTemp.Value11 = pds.Rows[i][10].ToString(); newDataInTemp.Value12 = pds.Rows[i][11].ToString(); newDataInTemp.Value13 = pds.Rows[i][12].ToString(); newDataInTemp.Value14 = pds.Rows[i][13].ToString(); newDataInTemp.Value15 = pds.Rows[i][14].ToString(); newDataInTemp.Value16 = pds.Rows[i][15].ToString(); newDataInTemp.Value17 = pds.Rows[i][16].ToString(); newDataInTemp.Value18 = pds.Rows[i][17].ToString(); newDataInTemp.Value19 = pds.Rows[i][18].ToString(); newDataInTemp.Value20 = pds.Rows[i][19].ToString(); newDataInTemp.Value21 = pds.Rows[i][20].ToString(); newDataInTemp.Value22 = pds.Rows[i][21].ToString(); newDataInTemp.Value23 = pds.Rows[i][22].ToString(); newDataInTemp.Value24 = pds.Rows[i][23].ToString(); newDataInTemp.Value25 = pds.Rows[i][24].ToString(); newDataInTemp.Value26 = pds.Rows[i][25].ToString(); newDataInTemp.Value27 = pds.Rows[i][26].ToString(); newDataInTemp.Value28 = pds.Rows[i][27].ToString(); newDataInTemp.Value29 = pds.Rows[i][28].ToString(); newDataInTemp.Value30 = pds.Rows[i][29].ToString(); newDataInTemp.Value31 = pds.Rows[i][30].ToString(); newDataInTemp.Value32 = pds.Rows[i][31].ToString(); newDataInTemp.Value33 = pds.Rows[i][32].ToString(); newDataInTemp.Value34 = pds.Rows[i][33].ToString(); newDataInTemp.Value35 = pds.Rows[i][34].ToString(); newDataInTemp.Value36 = pds.Rows[i][35].ToString(); BLL.DataInTempService.AddDataInTemp(newDataInTemp); } } this.BindGrid(); ShowNotify(Resources.Lan.Data_Into_Temp_Table, MessageBoxIcon.Success); } else { ShowNotify(Resources.Lan.Data_Is_Empty, MessageBoxIcon.Success); return; } } #endregion #region 提交审核事件 /// /// 提交审核事件 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { if (drpInstallation.SelectedValue == Const._Null) { ShowNotify(Resources.Lan.SelectInstall, MessageBoxIcon.Success); return; } 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 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 += Resources.Lan.CompanyCode + "[" + tempData.Value1 + "]" + Resources.Lan.NoExistent; } else { pipeline.UnitId = unit.UnitId; } } else { errInfo += Resources.Lan.CompanyCode+ Resources.Lan.IsRequired; } if (!string.IsNullOrEmpty(tempData.Value2)) { var area = workAreas.FirstOrDefault(x => x.WorkAreaCode == tempData.Value2 && x.InstallationId == drpInstallation.SelectedValue); if (area == null) { errInfo += Resources.Lan.Area+"[" + tempData.Value2 + "]" + Resources.Lan.NoExistent; } else { pipeline.WorkAreaId = area.WorkAreaId; pipeline.InstallationId = area.InstallationId; } } else { errInfo += Resources.Lan.Area+ Resources.Lan.IsRequired; } if (string.IsNullOrEmpty(tempData.Value3)) { errInfo += Resources.Lan.PipelineCode + Resources.Lan.IsRequired; } else { pipeline.PipelineCode = tempData.Value3; } if (string.IsNullOrEmpty(tempData.Value4)) { errInfo += Resources.Lan.WeldingJointNumber + Resources.Lan.IsRequired; } else { weldJoint.WeldJointCode = tempData.Value4; } if (!string.IsNullOrEmpty(tempData.Value5)) { var steel = materials.FirstOrDefault(x => x.MaterialCode == tempData.Value5); if (steel == null) { errInfo += Resources.Lan.MaterialSpecification1 + "[" + tempData.Value5 + "]" + Resources.Lan.NoExistent; } else { pipeline.MainMaterialId = steel.MaterialId; weldJoint.Material1Id = steel.MaterialId; } } else { errInfo += Resources.Lan.MaterialSpecification1+ Resources.Lan.IsRequired; } if (!string.IsNullOrEmpty(tempData.Value6)) { var steel = materials.FirstOrDefault(x => x.MaterialCode == tempData.Value6); if (steel == null) { errInfo += Resources.Lan.MaterialSpecification2 + "[" + tempData.Value6 + "]" + Resources.Lan.NoExistent; } else { weldJoint.Material2Id = steel.MaterialId; } } if (!string.IsNullOrEmpty(tempData.Value7)) { var pipelineClass = pipelineClasss.FirstOrDefault(x => x.PipingClassCode == tempData.Value7); if (pipelineClass == null) { errInfo += Resources.Lan.PipingClass+"[" + tempData.Value7 + "]" + Resources.Lan.NoExistent; } else { pipeline.PipingClassId = pipelineClass.PipingClassId; weldJoint.PipingClassId = pipelineClass.PipingClassId; } } else { errInfo += Resources.Lan.PipingClass + Resources.Lan.IsRequired; } if (!string.IsNullOrEmpty(tempData.Value8)) { var medium = mediums.FirstOrDefault(x => x.MediumCode == tempData.Value8); if (medium == null) { errInfo += Resources.Lan.MediumCode+"[" + tempData.Value8 + "]" + Resources.Lan.NoExistent; } else { pipeline.MediumId = medium.MediumId; } } else { errInfo += Resources.Lan.MediumCode + Resources.Lan.IsRequired; } 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 += Resources.Lan.TotalSpoolNumbers + "[" + tempData.Value14 + "]" + Resources.Lan.Error; } } 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 += Resources.Lan.WeldingJointType + "[" + tempData.Value20 + "]" + Resources.Lan.NoExistent; } else { weldJoint.WeldTypeId = weldType.WeldTypeId; } } else { errInfo += Resources.Lan.WeldingJointType + Resources.Lan.IsRequired; } if (!string.IsNullOrEmpty(tempData.Value21)) { try { decimal size = Convert.ToDecimal(tempData.Value21); weldJoint.Size = size; } catch (Exception) { errInfo += Resources.Lan.InchDiameter + "[" + tempData.Value21 + "]" + Resources.Lan.Error; } } else { errInfo += Resources.Lan.InchDiameter + Resources.Lan.IsRequired; } if (!string.IsNullOrEmpty(tempData.Value22)) { try { decimal dia = Convert.ToDecimal(tempData.Value22); weldJoint.Dia = dia; } catch (Exception) { errInfo += Resources.Lan.OutDia + "[" + tempData.Value22 + "]" + Resources.Lan.Error; } } else { errInfo += Resources.Lan.OutDia + Resources.Lan.IsRequired; } if (!string.IsNullOrEmpty(tempData.Value23)) { try { decimal thickness = Convert.ToDecimal(tempData.Value23); weldJoint.Thickness = thickness; } catch (Exception) { errInfo += Resources.Lan.WallThickness + "[" + tempData.Value23 + "]" + Resources.Lan.Error; } } else { errInfo += errInfo += Resources.Lan.WallThickness + Resources.Lan.IsRequired; } if (!string.IsNullOrEmpty(tempData.Value24)) { var weldMethod = weldingMethods.FirstOrDefault(x => x.WeldingMethodCode == tempData.Value24); if (weldMethod==null) { errInfo += Resources.Lan.WeldingMethod + "[" + tempData.Value24 + "]" + Resources.Lan.NoExistent; } else { weldJoint.WeldingMethodId = weldMethod.WeldingMethodId; } } else { errInfo += errInfo += Resources.Lan.WeldingMethod + Resources.Lan.IsRequired; } 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 += Resources.Lan.BevelType + "[" + tempData.Value27 + "]" + Resources.Lan.NoExistent; } else { weldJoint.GrooveTypeId = grooveType.GrooveTypeId; } } else { errInfo += Resources.Lan.BevelType + Resources.Lan.IsRequired; } if (!string.IsNullOrEmpty(tempData.Value28)) { if (tempData.Value28 != "S" && tempData.Value28 != "F") { errInfo += Resources.Lan.WeldingJointQuality + "[" + tempData.Value28 + "]" + Resources.Lan.NoExistent; } else { if (tempData.Value28 == "S") { weldJoint.JointArea = "S"; weldJoint.JointAttribute = "活动" + tempData.Value28; } else { weldJoint.JointArea = "F"; weldJoint.JointAttribute = "固定" + tempData.Value28; } } } else { errInfo += Resources.Lan.WeldingJointQuality + Resources.Lan.IsRequired; } if (!string.IsNullOrEmpty(tempData.Value29)) { var com = componentss.FirstOrDefault(x => x.ComponentsCode == tempData.Value29); if (com == null) { errInfo += Resources.Lan.Component1 + "[" + tempData.Value29 + "]" + Resources.Lan.NoExistent; } else { weldJoint.PipeAssembly1Id = com.ComponentsId; } } if (!string.IsNullOrEmpty(tempData.Value30)) { var com = componentss.FirstOrDefault(x => x.ComponentsCode == tempData.Value30); if (com == null) { errInfo += Resources.Lan.Component2 + "[" + tempData.Value30 + "]" + Resources.Lan.NoExistent; } 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 += Resources.Lan.WeldingWire + "[" + tempData.Value31 + "]" + Resources.Lan.NoExistent; } 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 += Resources.Lan.Electrode + "[" + tempData.Value32 + "]" + Resources.Lan.NoExistent; } else { weldJoint.WeldMatId = weldMat.ConsumablesId; } } if (!string.IsNullOrEmpty(tempData.Value33)) { if (tempData.Value33== Resources.Lan.Yes) { weldJoint.IsHotProess = true; } else if(tempData.Value33== Resources.Lan.No) { weldJoint.IsHotProess = false; } } if (!string.IsNullOrEmpty(tempData.Value34)) { if (tempData.Value34 == Resources.Lan.Yes) { pipeline.IfPickling = true; } else if (tempData.Value34 == Resources.Lan.No) { pipeline.IfPickling = false; } } if (!string.IsNullOrEmpty(tempData.Value35)) { var loc = weldingLocation.FirstOrDefault(x => x.WeldingLocationCode == tempData.Value35); if (loc == null) { errInfo += Resources.Lan.WleldingLocation + "[" + tempData.Value35 + "]" + Resources.Lan.NoExistent; } else { weldJoint.WeldingLocationId = loc.WeldingLocationId; } } weldJoint.Remark = tempData.Value36; 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.QualificationLevel = item.AcceptLevel; 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 = Resources.Lan.Exist_PipeLine_WeldLine; } if (!string.IsNullOrEmpty(errInfo)) { tempData.ToopValue = errInfo; BLL.DataInTempService.UpdateDataInTemp(tempData); } } } ShowNotify(Resources.Lan.Submit_prefix + " " + okCount.ToString() + " " + Resources.Lan.Submit_suffix, MessageBoxIcon.Success); this.BindGrid(); } #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) { if (this.GetLanguage == "zh-CN") { this.TemplateUpload(BLL.Const.HJGL_DataInTemplateUrl); } else { this.TemplateUpload(BLL.Const.HJGL_En_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(Resources.Lan.File + Resources.Lan.NoExistent, MessageBoxIcon.Warning); } } #endregion #region 查询 /// /// 查询 /// /// /// protected void TextBox_TextChanged(object sender, EventArgs e) { this.BindGrid(); } #endregion } }