1083 lines
50 KiB
C#
1083 lines
50 KiB
C#
namespace FineUIPro.Web.HJGL.DataIn
|
||
{
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Data.OleDb;
|
||
using System.Data.SqlClient;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Web;
|
||
using System.Web.UI;
|
||
using System.Web.UI.WebControls;
|
||
using BLL;
|
||
|
||
public partial class DataIn : PageBase
|
||
{
|
||
#region 定义项
|
||
/// <summary>
|
||
/// 是否PDMS
|
||
/// </summary>
|
||
private string IsPDMS
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["IsPDMS"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["IsPDMS"] = value;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 加载页面
|
||
/// <summary>
|
||
/// 加载页面
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (!IsPostBack)
|
||
{
|
||
this.IsPDMS = "0";
|
||
var set = BLL.Project_SysSetService.GetSysSetBySetId("4",this.CurrUser.LoginProjectId);
|
||
if (set != null && set.IsAuto == true)
|
||
{
|
||
this.IsPDMS = "1";
|
||
this.FileExcel.EmptyText = "请上传PDMS模板的EXCEl格式文件";
|
||
}
|
||
|
||
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,Value39,Value40,Value41,Value42,Value43,Value44,Value45,Value46,Value47,Value48,Value49,Value50"
|
||
+ @" FROM HJGL_Sys_DataInTemp "
|
||
+ @" WHERE ProjectId=@ProjectId AND UserId=@UserId AND Type=@Type";
|
||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
||
listStr.Add(new SqlParameter("@UserId", this.CurrUser.UserId));
|
||
listStr.Add(new SqlParameter("@Type", this.IsPDMS));
|
||
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.HJGL_Sys_DataInTemp
|
||
where x.ProjectId == this.CurrUser.LoginProjectId && x.UserId == this.CurrUser.UserId && x.Type == this.IsPDMS
|
||
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";
|
||
}
|
||
}
|
||
}
|
||
if (this.Grid1.Columns.Count() > 0)
|
||
{
|
||
if (this.IsPDMS == "1") ///如果是PDMS
|
||
{
|
||
this.Grid1.Columns[7].Hidden = true;
|
||
this.Grid1.Columns[10].Hidden = true;
|
||
this.Grid1.Columns[12].Hidden = true;
|
||
this.Grid1.Columns[13].Hidden = true;
|
||
this.Grid1.Columns[15].Hidden = true;
|
||
this.Grid1.Columns[17].Hidden = true;
|
||
this.Grid1.Columns[18].Hidden = true;
|
||
this.Grid1.Columns[23].Hidden = true;
|
||
this.Grid1.Columns[26].Hidden = true;
|
||
this.Grid1.Columns[27].Hidden = true;
|
||
this.Grid1.Columns[28].Hidden = true;
|
||
this.Grid1.Columns[30].Hidden = true;
|
||
this.Grid1.Columns[31].Hidden = true;
|
||
this.Grid1.Columns[32].Hidden = true;
|
||
this.Grid1.Columns[33].Hidden = true;
|
||
this.Grid1.Columns[34].Hidden = true;
|
||
this.Grid1.Columns[25].HeaderText = "组件类型";
|
||
}
|
||
else
|
||
{
|
||
this.Grid1.Columns[35].Hidden = true;
|
||
this.Grid1.Columns[36].Hidden = true;
|
||
}
|
||
}
|
||
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("请选择一条记录!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_DataInMenuId, Const.BtnAdd))
|
||
{
|
||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("DataInEdit.aspx?TempId={0}", Grid1.SelectedRowID, "维护 - ")));
|
||
}
|
||
else
|
||
{
|
||
ShowNotify("您没有这个权限,请与管理员联系!", 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("请选择一条记录!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("DataInEdit.aspx?TempId={0}", Grid1.SelectedRowID, "维护 - ")));
|
||
}
|
||
else
|
||
{
|
||
ShowNotify("您没有这个权限,请与管理员联系!", 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("请选择一条记录!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
|
||
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
||
{
|
||
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
||
BLL.DataInTempService.DeleteDataInTempByDataInTempID(rowID);
|
||
BLL.Sys_LogService.AddLog(Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "删除导入信息");
|
||
}
|
||
|
||
Alert.ShowInTop("删除成功!", MessageBoxIcon.Success);
|
||
this.BindGrid();
|
||
}
|
||
else
|
||
{
|
||
ShowNotify("您没有这个权限,请与管理员联系!",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)
|
||
{
|
||
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
|
||
|
||
#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)
|
||
{
|
||
int ir = pds.Rows.Count;
|
||
for (int i = 0; i < ir; i++)
|
||
{
|
||
if (!string.IsNullOrEmpty(pds.Rows[i][3].ToString()))
|
||
{
|
||
Model.HJGL_Sys_DataInTemp newDataInTemp = new Model.HJGL_Sys_DataInTemp();
|
||
newDataInTemp.TempId = SQLHelper.GetNewID(typeof(Model.HJGL_Sys_DataInTemp));
|
||
newDataInTemp.ProjectId = this.CurrUser.LoginProjectId;
|
||
newDataInTemp.UserId = this.CurrUser.UserId;
|
||
newDataInTemp.Time = System.DateTime.Now;
|
||
newDataInTemp.Type = this.IsPDMS;
|
||
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();
|
||
if (this.IsPDMS == "0") ////非PDMS 模板
|
||
{
|
||
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();
|
||
}
|
||
else
|
||
{
|
||
newDataInTemp.Value7 = pds.Rows[i][5].ToString();
|
||
newDataInTemp.Value20 = pds.Rows[i][6].ToString();
|
||
newDataInTemp.Value15 = pds.Rows[i][7].ToString();
|
||
newDataInTemp.Value21 = pds.Rows[i][8].ToString();
|
||
newDataInTemp.Value23 = pds.Rows[i][9].ToString();
|
||
newDataInTemp.Value35 = pds.Rows[i][10].ToString();
|
||
newDataInTemp.Value13 = pds.Rows[i][11].ToString();
|
||
newDataInTemp.Value18 = pds.Rows[i][12].ToString();
|
||
newDataInTemp.Value19 = pds.Rows[i][13].ToString();
|
||
newDataInTemp.Value24 = pds.Rows[i][14].ToString();
|
||
newDataInTemp.Value34 = pds.Rows[i][15].ToString();
|
||
newDataInTemp.Value8 = pds.Rows[i][16].ToString();
|
||
newDataInTemp.Value28 = pds.Rows[i][17].ToString();
|
||
}
|
||
BLL.DataInTempService.AddDataInTemp(newDataInTemp);
|
||
}
|
||
}
|
||
this.BindGrid();
|
||
ShowNotify("数据已导入临时表!", MessageBoxIcon.Success);
|
||
}
|
||
else
|
||
{
|
||
ShowNotify("导入数据为空!", MessageBoxIcon.Success);
|
||
return;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 提交审核事件
|
||
/// <summary>
|
||
/// 提交审核事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnSave_Click(object sender, EventArgs e)
|
||
{
|
||
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 installs = from x in Funs.DB.Project_Installation where x.ProjectId == this.CurrUser.LoginProjectId select x;
|
||
var steels = from x in Funs.DB.HJGL_BS_Steel select x;
|
||
var rates = from x in Funs.DB.HJGL_BS_NDTRate select x;
|
||
var types = from x in Funs.DB.HJGL_BS_JointType select x;
|
||
var methods = from x in Funs.DB.HJGL_BS_WeldMethod select x;
|
||
var materials = from x in Funs.DB.HJGL_BS_WeldMaterial select x;
|
||
var services = from x in Funs.DB.HJGL_BS_Service select x;
|
||
var slopeTypes = from x in Funs.DB.HJGL_BS_SlopeType select x;
|
||
var isoClasss = from x in Funs.DB.HJGL_BS_IsoClass select x;
|
||
var components = from x in Funs.DB.HJGL_BS_Component select x;
|
||
var dns = from x in Funs.DB.HJGL_BS_SchTab select x;
|
||
var dataInTemp = from x in Funs.DB.HJGL_Sys_DataInTemp
|
||
where x.ProjectId == this.CurrUser.LoginProjectId && x.UserId == this.CurrUser.UserId && x.Type == this.IsPDMS
|
||
select x;
|
||
int okCount = 0;
|
||
foreach (var tempData in dataInTemp)
|
||
{
|
||
if (tempData != null)
|
||
{
|
||
string errInfo = string.Empty;
|
||
var isExitValue = Funs.DB.HJGL_View_JointInfoAndIsoInfo.FirstOrDefault(x => x.ProjectId == this.CurrUser.LoginProjectId && x.UnitCode == tempData.Value1
|
||
&& x.InstallationCode == tempData.Value2 && x.ISO_IsoNo == tempData.Value3 && x.JOT_JointNo == tempData.Value4);
|
||
if (isExitValue == null || this.ckUpdate.Checked)
|
||
{
|
||
Model.HJGL_PW_IsoInfo isoInfo = new Model.HJGL_PW_IsoInfo(); ///管线
|
||
Model.HJGL_PW_JointInfo jointInfo = new Model.HJGL_PW_JointInfo(); ///焊口
|
||
if (!string.IsNullOrEmpty(tempData.Value1))
|
||
{
|
||
var unit = units.FirstOrDefault(x => x.UnitCode == tempData.Value1);
|
||
if (unit == null)
|
||
{
|
||
errInfo += "单位代码[" + tempData.Value1 + "]不存在;";
|
||
}
|
||
else
|
||
{
|
||
isoInfo.BSU_ID = unit.UnitId;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errInfo += "单位代码为必填项;";
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(tempData.Value2))
|
||
{
|
||
var unit = units.FirstOrDefault(x => x.UnitCode == tempData.Value1);
|
||
if (unit != null)
|
||
{
|
||
var ins = installs.FirstOrDefault(x => x.InstallationCode == tempData.Value2);
|
||
if (ins == null)
|
||
{
|
||
errInfo += "装置号[" + tempData.Value2 + "]不存在;";
|
||
}
|
||
else
|
||
{
|
||
jointInfo.InstallationId = ins.InstallationId;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errInfo += "工区编号为必填项;";
|
||
}
|
||
|
||
if (string.IsNullOrEmpty(tempData.Value3))
|
||
{
|
||
errInfo += "管线代号此项为必填项!";
|
||
}
|
||
else
|
||
{
|
||
isoInfo.ISO_IsoNo = tempData.Value3;
|
||
}
|
||
if (string.IsNullOrEmpty(tempData.Value4))
|
||
{
|
||
errInfo += "焊口代号此项为必填项!";
|
||
}
|
||
else
|
||
{
|
||
jointInfo.JOT_JointNo = tempData.Value4;
|
||
}
|
||
|
||
#region 通用
|
||
if (!string.IsNullOrEmpty(tempData.Value5))
|
||
{
|
||
var steel = steels.FirstOrDefault(x => x.STE_Code == tempData.Value5);
|
||
if (steel == null)
|
||
{
|
||
errInfo += "材质1[" + tempData.Value5 + "]不存在;";
|
||
}
|
||
else
|
||
{
|
||
isoInfo.STE_ID = steel.STE_ID;
|
||
jointInfo.STE_ID = steel.STE_ID;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errInfo += "材质1为必填项;";
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(tempData.Value8))
|
||
{
|
||
var type = types.FirstOrDefault(x => x.JOTY_Code == tempData.Value8);
|
||
if (type == null)
|
||
{
|
||
errInfo += "焊缝类型代号[" + tempData.Value8 + "]不存在;";
|
||
}
|
||
else
|
||
{
|
||
jointInfo.JOTY_ID = type.JOTY_ID;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errInfo += "焊缝类型代号为必填项;";
|
||
}
|
||
|
||
if (string.IsNullOrEmpty(tempData.Value13))
|
||
{
|
||
errInfo += "壁厚此项为必填项!";
|
||
}
|
||
else
|
||
{
|
||
jointInfo.JOT_Sch = tempData.Value13;
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(tempData.Value15))
|
||
{
|
||
try
|
||
{
|
||
decimal testPress = Convert.ToDecimal(tempData.Value15);
|
||
isoInfo.ISO_TestPress = testPress;
|
||
}
|
||
catch (Exception)
|
||
{
|
||
errInfo += "试验压力[" + tempData.Value15 + "]错误;";
|
||
}
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(tempData.Value18))
|
||
{
|
||
var service = services.FirstOrDefault(x => x.SER_Code == tempData.Value18);
|
||
if (service == null)
|
||
{
|
||
errInfo += "介质代号[" + tempData.Value18 + "]不存在;";
|
||
}
|
||
else
|
||
{
|
||
isoInfo.SER_ID = service.SER_ID;
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value20))
|
||
{
|
||
try
|
||
{
|
||
decimal testPress = Convert.ToDecimal(tempData.Value20);
|
||
isoInfo.ISO_DesignPress = testPress;
|
||
}
|
||
catch (Exception)
|
||
{
|
||
errInfo += "设计压力[" + tempData.Value20 + "]错误;";
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value21))
|
||
{
|
||
try
|
||
{
|
||
decimal testPress = Convert.ToDecimal(tempData.Value21);
|
||
isoInfo.ISO_DesignTemperature = testPress;
|
||
}
|
||
catch (Exception)
|
||
{
|
||
errInfo += "设计温度[" + tempData.Value21 + "]错误;";
|
||
}
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(tempData.Value23))
|
||
{
|
||
var isoClass = isoClasss.FirstOrDefault(x => x.ISC_IsoCode == tempData.Value23);
|
||
if (isoClass == null)
|
||
{
|
||
errInfo += "管线等级代号[" + tempData.Value23 + "]不存在;";
|
||
}
|
||
else
|
||
{
|
||
isoInfo.ISC_ID = isoClass.ISC_ID;
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value24))
|
||
{
|
||
var component = components.FirstOrDefault(x => x.COM_Code == tempData.Value24);
|
||
if (component == null)
|
||
{
|
||
errInfo += "组件一代号[" + tempData.Value24 + "]不存在;";
|
||
}
|
||
else
|
||
{
|
||
jointInfo.JOT_Component1 = component.COM_ID;
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
if (this.IsPDMS == "0") ////非PDMS 模板
|
||
{
|
||
#region 非PDMS 模板
|
||
if (!string.IsNullOrEmpty(tempData.Value6))
|
||
{
|
||
var steel = steels.FirstOrDefault(x => x.STE_Code == tempData.Value6);
|
||
if (steel == null)
|
||
{
|
||
errInfo += "材质2[" + tempData.Value6 + "]不存在;";
|
||
}
|
||
else
|
||
{
|
||
jointInfo.STE_ID2 = steel.STE_ID;
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value9))
|
||
{
|
||
if (tempData.Value9 != "安装" && tempData.Value9 != "预制")
|
||
{
|
||
errInfo += "焊接区域[" + tempData.Value9 + "]不存在;";
|
||
}
|
||
else
|
||
{
|
||
if (tempData.Value9 == "安装")
|
||
{
|
||
jointInfo.WLO_Code = "F";
|
||
}
|
||
else
|
||
{
|
||
jointInfo.WLO_Code = "S";
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errInfo += "焊接区域为必填项;";
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value10))
|
||
{
|
||
if (tempData.Value10 != "固定" && tempData.Value10 != "活动")
|
||
{
|
||
errInfo += "焊口属性[" + tempData.Value10 + "]不存在;";
|
||
}
|
||
else
|
||
{
|
||
jointInfo.JOT_JointAttribute = tempData.Value10;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errInfo += "焊口属性为必填项;";
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value11))
|
||
{
|
||
try
|
||
{
|
||
decimal doneDin = Convert.ToDecimal(tempData.Value11);
|
||
jointInfo.JOT_Size = doneDin;
|
||
|
||
}
|
||
catch (Exception)
|
||
{
|
||
errInfo += "寸径数[" + tempData.Value11 + "]错误;";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errInfo += "寸径数为必填项;";
|
||
}
|
||
if (string.IsNullOrEmpty(tempData.Value12))
|
||
{
|
||
errInfo += "规格此项为必填项!";
|
||
}
|
||
else
|
||
{
|
||
jointInfo.JOT_JointDesc = tempData.Value12;
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value14))
|
||
{
|
||
var method = methods.FirstOrDefault(x => x.WME_Code == tempData.Value14);
|
||
if (method == null)
|
||
{
|
||
errInfo += "焊接方法代号[" + tempData.Value14 + "]不存在;";
|
||
}
|
||
else
|
||
{
|
||
jointInfo.WME_ID = method.WME_ID;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errInfo += "焊接方法代号为必填项;";
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value16))
|
||
{
|
||
var material = materials.FirstOrDefault(x => x.WMT_MatCode == tempData.Value16 && x.WMT_MatType == "2");
|
||
if (material == null)
|
||
{
|
||
errInfo += "焊条代号[" + tempData.Value16 + "]不存在;";
|
||
}
|
||
else
|
||
{
|
||
jointInfo.JOT_WeldMat = material.WMT_ID;
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value17))
|
||
{
|
||
var material = materials.FirstOrDefault(x => x.WMT_MatCode == tempData.Value17 && x.WMT_MatType == "1");
|
||
if (material == null)
|
||
{
|
||
errInfo += "焊丝代号[" + tempData.Value17 + "]不存在;";
|
||
}
|
||
else
|
||
{
|
||
jointInfo.JOT_WeldSilk = material.WMT_ID;
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value22))
|
||
{
|
||
var slopeType = slopeTypes.FirstOrDefault(x => x.JST_Code == tempData.Value22);
|
||
if (slopeType == null)
|
||
{
|
||
errInfo += "坡口代号[" + tempData.Value22 + "]不存在;";
|
||
}
|
||
else
|
||
{
|
||
jointInfo.JST_ID = slopeType.JST_ID;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errInfo += "坡口代号必填项;";
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value25))
|
||
{
|
||
var component = components.FirstOrDefault(x => x.COM_Code == tempData.Value25);
|
||
if (component == null)
|
||
{
|
||
errInfo += "组件二代号[" + tempData.Value25 + "]不存在;";
|
||
}
|
||
else
|
||
{
|
||
jointInfo.JOT_Component2 = component.COM_ID;
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value29))
|
||
{
|
||
try
|
||
{
|
||
decimal testPress = Convert.ToDecimal(tempData.Value29);
|
||
jointInfo.JOT_PrepareTemp = testPress;
|
||
}
|
||
catch (Exception)
|
||
{
|
||
errInfo += "预热温度[" + tempData.Value29 + "]错误;";
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value30))
|
||
{
|
||
if (tempData.Value30 != "是" && tempData.Value30 != "否")
|
||
{
|
||
errInfo += "是否热处理[" + tempData.Value30 + "]错误;";
|
||
}
|
||
else
|
||
{
|
||
if (tempData.Value30 == "是")
|
||
{
|
||
jointInfo.IS_Proess = "1";
|
||
}
|
||
else
|
||
{
|
||
jointInfo.IS_Proess = "0";
|
||
}
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value31))
|
||
{
|
||
if (tempData.Value31 != "1G" && tempData.Value31 != "2G" && tempData.Value31 != "3G"
|
||
&& tempData.Value31 != "4G" && tempData.Value31 != "5G" && tempData.Value31 != "6G"
|
||
&& tempData.Value31 != "1F" && tempData.Value31 != "2F" && tempData.Value31 != "2FR"
|
||
&& tempData.Value31 != "4F" && tempData.Value31 != "5F")
|
||
{
|
||
errInfo += "焊接位置[" + tempData.Value31 + "]不存在;";
|
||
}
|
||
else
|
||
{
|
||
jointInfo.JOT_Location = tempData.Value31;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errInfo += "焊接位置必填项;";
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value32))
|
||
{
|
||
try
|
||
{
|
||
decimal testPress = Convert.ToDecimal(tempData.Value32);
|
||
jointInfo.JOT_Dia = testPress;
|
||
}
|
||
catch (Exception)
|
||
{
|
||
errInfo += "外径[" + tempData.Value32 + "]错误;";
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
else
|
||
{
|
||
#region PDMS模板
|
||
// 生成坡口形式
|
||
if (tempData.Value8 == "BW") // BW的坡口形式为V
|
||
{
|
||
var slopeType = slopeTypes.FirstOrDefault(x => x.JST_Code == "V");
|
||
if (slopeType != null)
|
||
{
|
||
jointInfo.JST_ID = slopeType.JST_ID;
|
||
}
|
||
}
|
||
if (tempData.Value8 == "SW") // SW的坡口形式为I
|
||
{
|
||
var slopeType = slopeTypes.FirstOrDefault(x => x.JST_Code == "I");
|
||
if (slopeType != null)
|
||
{
|
||
jointInfo.JST_ID = slopeType.JST_ID;
|
||
}
|
||
}
|
||
|
||
jointInfo.WLO_Code = "S";
|
||
jointInfo.JOT_JointAttribute = "活动";
|
||
jointInfo.JOT_Location = "1G";
|
||
jointInfo.JOT_Size = BLL.HJGL_ControlService.GetSizeByDn(tempData.Value35); // 生成尺寸
|
||
if (Funs.GetNewIntOrZero(tempData.Value35) <= 50) // 生成焊接方法
|
||
{
|
||
var m = methods.FirstOrDefault(x => x.WME_Code.Contains("GTAW"));
|
||
if (m != null)
|
||
{
|
||
jointInfo.WME_ID = m.WME_ID;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
var m = methods.FirstOrDefault(x => x.WME_Code.Contains("GTAW") && x.WME_Code.Contains("SMAW"));
|
||
if (m != null)
|
||
{
|
||
jointInfo.WME_ID = m.WME_ID;
|
||
}
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(tempData.Value35) && !string.IsNullOrEmpty(tempData.Value13))
|
||
{
|
||
jointInfo.JOT_JointDesc = tempData.Value35 + "×" + tempData.Value13;
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(tempData.Value13))
|
||
{
|
||
jointInfo.JOT_Sch = tempData.Value13;
|
||
}
|
||
|
||
var mc = BLL.HJGL_MaterialCompareService.GetMaterialCompare(jointInfo.STE_ID, jointInfo.WME_ID);
|
||
if (mc != null)
|
||
{
|
||
jointInfo.JOT_WeldSilk = mc.WMT_ID1;
|
||
jointInfo.JOT_WeldMat = mc.WMT_ID2;
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(tempData.Value24))
|
||
{
|
||
var component = components.FirstOrDefault(x => x.COM_Name.Contains(tempData.Value24));
|
||
if (component != null)
|
||
{
|
||
jointInfo.JOT_Component1 = component.COM_ID;
|
||
jointInfo.JOT_Component2 = jointInfo.JOT_Component1;
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value35))
|
||
{
|
||
var dn = dns.FirstOrDefault(x => x.BST_DN == tempData.Value35);
|
||
if (dn == null)
|
||
{
|
||
errInfo += "公称直径[" + tempData.Value35 + "]基础表中不存在错误;";
|
||
}
|
||
else
|
||
{
|
||
try
|
||
{
|
||
int count = Convert.ToInt32(tempData.Value35);
|
||
}
|
||
catch (Exception)
|
||
{
|
||
errInfo += "公称直径[" + tempData.Value35 + "]错误;";
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
|
||
if (string.IsNullOrEmpty(errInfo)) ////所有信息正确的话 这插入管线焊口
|
||
{
|
||
isoInfo.ProjectId = this.CurrUser.LoginProjectId;
|
||
jointInfo.ProjectId = this.CurrUser.LoginProjectId;
|
||
var isExitISOValue = Funs.DB.HJGL_View_JointInfoAndIsoInfo.FirstOrDefault(x => x.ProjectId == this.CurrUser.LoginProjectId && x.UnitCode == tempData.Value1
|
||
&& x.InstallationCode == tempData.Value2 && x.ISO_IsoNo == tempData.Value3);
|
||
if (isExitISOValue != null) ///管线已存在
|
||
{
|
||
isoInfo.ISO_ID = isExitISOValue.ISO_ID;
|
||
jointInfo.ISO_ID = isExitISOValue.ISO_ID;
|
||
BLL.HJGL_PW_IsoInfoService.UpdateIsoInfo(isoInfo);
|
||
}
|
||
else
|
||
{
|
||
isoInfo.ISO_ID = SQLHelper.GetNewID(typeof(Model.HJGL_PW_IsoInfo));
|
||
jointInfo.ISO_ID = isoInfo.ISO_ID;
|
||
BLL.HJGL_PW_IsoInfoService.AddIsoInfo(isoInfo);
|
||
}
|
||
var isExitJotNoValue = Funs.DB.HJGL_View_JointInfoAndIsoInfo.FirstOrDefault(x => x.ProjectId == this.CurrUser.LoginProjectId && x.UnitCode == tempData.Value1
|
||
&& x.InstallationCode == tempData.Value2 && x.ISO_IsoNo == tempData.Value3 && x.JOT_JointNo == tempData.Value4);
|
||
if (isExitJotNoValue == null)
|
||
{
|
||
jointInfo.JOT_ID = SQLHelper.GetNewID(typeof(Model.HJGL_PW_JointInfo));
|
||
BLL.HJGL_PW_JointInfoService.AddJointInfo(jointInfo);
|
||
}
|
||
else
|
||
{
|
||
if (string.IsNullOrEmpty(isExitJotNoValue.DReportID))
|
||
{
|
||
jointInfo.JOT_ID = isExitJotNoValue.JOT_ID;
|
||
BLL.HJGL_PW_JointInfoService.UpdateJointInfo(jointInfo);
|
||
}
|
||
}
|
||
|
||
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
|
||
|
||
#region 删除所有数据事件
|
||
/// <summary>
|
||
/// 删除所有数据事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnAllDelete_Click(object sender, EventArgs e)
|
||
{
|
||
////先删除临时表中 该人员以前导入的数据
|
||
BLL.DataInTempService.DeleteDataInTempByProjectIdUserId(this.CurrUser.LoginProjectId, this.CurrUser.UserId, this.IsPDMS);
|
||
this.BindGrid();
|
||
ShowNotify("删除成功!", 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)
|
||
{
|
||
if (this.IsPDMS == "0")
|
||
{
|
||
this.TemplateUpload(BLL.Const.HJGL_DataInTemplateUrl);
|
||
}
|
||
else
|
||
{
|
||
this.TemplateUpload(BLL.Const.HJGL_DataIn_PDMSTemplateUrl);
|
||
}
|
||
}
|
||
|
||
/// <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
|
||
}
|
||
} |