Basf_TCC11/HJGL/FineUIPro.Web/WeldingProcess/DataIn/DataIn.aspx.cs

1899 lines
92 KiB
C#
Raw Normal View History

2024-05-08 16:27:28 +08:00
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<string, int> percent { get; set; }
/// <summary>
/// 上传预设的虚拟路径
/// </summary>
private string initPath = Const.ExcelUrl;
/// <summary>
/// 错误集合
/// </summary>
public static string errorInfos = string.Empty;
[System.Web.Services.WebMethod]
public static int getPercent(string id)
{
return percent[id];
}
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (percent == null)
{
percent = new Dictionary<string, int>();
}
this.id.Text = this.CurrUser.UserId;
this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
// 绑定表格
this.BindGrid();
}
else if (GetRequestEventArgument() == "reloadGrid")
{
BindGrid();
}
}
#endregion
#region
/// <summary>
/// 绑定数据
/// </summary>
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<SqlParameter> listStr = new List<SqlParameter>();
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
/// <summary>
/// Grid行双击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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
/// <summary>
/// 导入信息编辑
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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);
}
}
/// <summary>
/// 删除按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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
/// <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)
{
BindGrid();
}
#endregion
#region
/// <summary>
/// 文件上传
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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();
newDataInTemp.Value39 = ds.Tables[0].Rows[i][38].ToString().Trim();
newDataInTemp.Value40 = ds.Tables[0].Rows[i][39].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("<script>alert('请您选择Excel文件')</script> ");
// return;
// }
// string IsXls = Path.GetExtension(FileExcel.FileName).ToString().Trim().ToLower();
// if (IsXls != ".xls")
// {
// Response.Write("<script>alert('只可以选择Excel文件')</script>");
// 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的数据导入数据库
/// <summary>
/// 将Dataset的数据导入数据库
/// </summary>
/// <param name="pds">数据集</param>
/// <param name="Cols">数据集列数</param>
/// <returns></returns>
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();
2024-06-05 08:24:19 +08:00
var coodeList= from x in Funs.DB.Base_MaterialCoode where x.ProjectId == this.CurrUser.LoginProjectId select x; //coode
2024-05-08 16:27:28 +08:00
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 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 += "管道等级为必填项;";
}
var pc = pipClass.FirstOrDefault(x => x.PIPClassCode == tempData.Value8);
if (pc == null)
{
//errInfo += "压力管道分级[" + tempData.Value8 + "]不存在;";
}
else
{
pipeline.PIPClassId = pc.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
{
errInfo += "介质为必填项;";
}
pipeline.Specification = tempData.Value10;
pipeline.SingleNumber = tempData.Value11;
pipeline.WorkPackageCode = tempData.Value12;
pipeline.SystemNumber = tempData.Value13;
pipeline.SubSystemNumber = tempData.Value14;
weldJoint.PipeSegment = tempData.Value15;
//if (!string.IsNullOrEmpty(tempData.Value14))
//{
// try
// {
// int pipeSegment = Convert.ToInt32(tempData.Value14);
// pipeline.PipeSegment = pipeSegment;
// }
// catch (Exception)
// {
// errInfo += "总管段数[" + tempData.Value14 + "]错误;";
// }
//}
//pipeline.Sheet = tempData.Value15;
weldJoint.PageNum = tempData.Value16;
pipeline.DrawingsNum = tempData.Value17;
pipeline.DesignTemperature = tempData.Value18;
pipeline.TestPressure = tempData.Value19;
pipeline.DesignPressure = tempData.Value20;
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
{
errInfo += "焊缝类型为必填项;";
}
decimal? size = null;
if (!string.IsNullOrEmpty(tempData.Value22))
{
try
{
size = Convert.ToDecimal(tempData.Value22);
weldJoint.Size = size;
}
catch (Exception)
{
errInfo += "寸径[" + tempData.Value22 + "]错误;";
}
}
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 (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;
}
}
weldJoint.Dia = dia;
weldJoint.Thickness = sch;
if (dia!=null && sch!=null)
{
weldJoint.Specification = "Φ" + dia.ToString() + "×" + sch.ToString();
}
}
}
else
{
errInfo += "美标壁厚[" + tempData.Value23 + "]错误;";
}
}
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 += "焊接方法为必填项;";
}
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 != "G")
{
errInfo += "焊口属性[" + tempData.Value28 + "]不存在;";
}
else
{
2024-06-05 08:24:19 +08:00
weldJoint.JointAttribute = tempData.Value28;
weldJoint.JointArea = tempData.Value28;
//if (tempData.Value28 == "S")
//{
// weldJoint.JointAttribute = "活动S";
// weldJoint.JointArea = "S";
//}
//else
//{
// weldJoint.JointAttribute = "固定F";
// weldJoint.JointArea = "F";
//}
2024-05-08 16:27:28 +08:00
}
}
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))
{
if (tempData.Value31 == "是")
{
weldJoint.IsHotProess = true;
}
else if (tempData.Value31 == "否")
{
weldJoint.IsHotProess = false;
}
}
if (!string.IsNullOrEmpty(tempData.Value32))
{
if (tempData.Value32 == "是")
{
pipeline.IfPickling = true;
}
else if (tempData.Value32 == "否")
{
pipeline.IfPickling = false;
}
}
if (!string.IsNullOrEmpty(tempData.Value33))
{
var loc = weldingLocation.FirstOrDefault(x => x.WeldingLocationCode == tempData.Value33);
if (loc == null)
{
errInfo += "焊接位置[" + tempData.Value33 + "]不存在;";
}
else
{
weldJoint.WeldingLocationId = loc.WeldingLocationId;
}
}
if (!string.IsNullOrEmpty(tempData.Value34))
{
var rate = ndtRate.FirstOrDefault(x => x.DetectionRateCode == tempData.Value34);
if (rate == null)
{
errInfo += "检测比例[" + tempData.Value34 + "]不存在;";
}
else
{
pipeline.DetectionRateId = rate.DetectionRateId;
}
}
2024-06-05 08:24:19 +08:00
else
{
errInfo += "探伤比例为必填项;";
}
2024-05-08 16:27:28 +08:00
if (!string.IsNullOrEmpty(tempData.Value35))
{
// 探伤类型如多个用“,”隔开
string[] ndtList = tempData.Value35.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.Value35 + "]不存在;";
}
else
{
ndtIds = ndtIds + ndt.DetectionTypeId + "|";
}
}
if (ndtIds != string.Empty)
{
weldJoint.DetectionType = ndtIds.Substring(0, ndtIds.Length - 1);
}
}
else
{
errInfo += "探伤类型[" + tempData.Value35 + "]不正确;";
}
}
else
{
errInfo += "探伤类型为必填项;";
}
if (!string.IsNullOrEmpty(tempData.Value36))
{
var wps = wpsList.FirstOrDefault(x => x.WPQCode == tempData.Value36);
if (wps == null)
{
errInfo += "WPS编号[" + tempData.Value36 + "]不存在;";
}
else
{
weldJoint.WPQId = wps.WPQId;
if (!string.IsNullOrEmpty(wps.WeldingMethodId))
{
weldJoint.WeldingMethodId = wps.WeldingMethodId;
}
}
}
//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.Value37))
{
// 焊丝如多个用“,”隔开
string[] silkList = tempData.Value37.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.Value37 + "]不正确,多个焊丝用,隔开;";
}
}
if (!string.IsNullOrEmpty(tempData.Value38))
{
var weldMat = consumabless.FirstOrDefault(x => x.ConsumablesCode == tempData.Value38 && x.ConsumablesType == "2");
if (weldMat == null)
{
errInfo += "焊条[" + tempData.Value38 + "]不存在;";
}
else
{
weldJoint.WeldMatId = weldMat.ConsumablesId;
}
}
2024-06-05 08:24:19 +08:00
if (!string.IsNullOrEmpty(tempData.Value39))
{
var cood = coodeList.FirstOrDefault(x => x.Coode == tempData.Value39);
if (cood == null)
{
errInfo += "Coode1:[" + tempData.Value39 + "]不存在;";
}
else
{
weldJoint.Coode1 = cood.Coode;
}
}
if (!string.IsNullOrEmpty(tempData.Value40))
{
var cood = coodeList.FirstOrDefault(x => x.Coode == tempData.Value40);
if (cood == null)
{
errInfo += "Coode2:[" + tempData.Value40 + "]不存在;";
}
else
{
weldJoint.Coode2 = cood.Coode;
}
}
if (!string.IsNullOrEmpty(tempData.Value25))
{
var cood = coodeList.FirstOrDefault(x => x.Coode == tempData.Value39 && x.HeartNo== tempData.Value25);
if (cood == null)
{
errInfo += "炉批号1:[" + tempData.Value25 + "]或对应的Coode码不存在";
}
else
{
weldJoint.HeartNo1 = tempData.Value25;
}
}
if (!string.IsNullOrEmpty(tempData.Value26))
{
var cood = coodeList.FirstOrDefault(x => x.Coode == tempData.Value40 && x.HeartNo == tempData.Value26);
if (cood == null)
{
errInfo += "炉批号2:[" + tempData.Value26 + "]或对应的Coode码不存在";
}
else
{
weldJoint.HeartNo2 = tempData.Value26;
}
}
2024-05-08 16:27:28 +08:00
//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;
// 焊接时更新部分内容
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();
}
/// <summary>
/// 提交审核事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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
/// <summary>
/// 删除所有数据事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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
/// <summary>
/// 下载模版
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void imgbtnUpload_Click(object sender, EventArgs e)
{
this.TemplateUpload(BLL.Const.HJGL_DataInTemplateUrl);
}
/// <summary>
/// 导入说明
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lkAchievements_Click(object sender, EventArgs e)
{
this.TemplateUpload(Const.HJGL_DataInHelpUrl);
}
/// <summary>
/// 模板下载方法
/// </summary>
/// <param name="initTemplatePath"></param>
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
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void TextBox_TextChanged(object sender, EventArgs e)
{
this.BindGrid();
}
#endregion
}
}