653 lines
33 KiB
C#
653 lines
33 KiB
C#
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;
|
||
namespace FineUIPro.Web.HJGL.DataIn
|
||
{
|
||
public partial class JointIn : PageBase
|
||
{
|
||
/// <summary>
|
||
/// 导入的焊口Id
|
||
/// </summary>
|
||
public string JOT_IDStr
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["JOT_IDStr"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["JOT_IDStr"] = value;
|
||
}
|
||
}
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (!IsPostBack)
|
||
{
|
||
JOT_IDStr = string.Empty;
|
||
BindGrid();
|
||
}
|
||
}
|
||
private void BindGrid()
|
||
{
|
||
string strSql = @"SELECT JOT_ID,J.ProjectId,P.ProjectCode,JOT_JointNo,InstallationName,convert(int,dbo.Fun_GetParseInt(JOT_JointNo)) AS ConvertJointNo
|
||
,JOT_DailyReportNo,JOT_WeldDate,ISO_ID,ISO_IsoNo,STE_Name1,STE_Name2,WED_Code1,WED_Name1,WED_Code2
|
||
,(CASE WHEN STE_Name1 IS NOT NULL AND STE_Name2 IS NOT NULL and STE_Name1!=STE_Name2 THEN STE_Name1 + '/' + STE_Name2
|
||
WHEN STE_Name1 IS NOT NULL THEN STE_Name1 ELSE ISNULL(STE_Name2,'') END) AS STE_Name --材质
|
||
,WED_Name2,WLO_Code,(CASE WHEN WLO_Code='F' THEN '安装' WHEN WLO_Code='S' THEN '预制' ELSE '' END) AS WLO_Name
|
||
,JOT_DoneDin,IS_Compute,Component1,Component2,WeldMat,JointStatus
|
||
,(CASE WHEN JointStatus='1' THEN '点口' WHEN JointStatus='2' THEN '扩透' WHEN JointStatus='3' THEN '已切除' ELSE '' END) AS JointStatusName
|
||
,JOT_Dia,JOT_Size,JOT_Sch,JOT_FactSch,JOT_JointDesc,WeldSilk,JOTY_Name,WME_Name
|
||
,JST_Name,(CASE WHEN IS_Proess= '1' THEN '是' ELSE '否' END) AS IS_Proess
|
||
,JOT_PrepareTemp,JOT_CellTemp,JOT_LastTemp,JOT_JointAttribute,BatchCode,PointDate
|
||
,ProessTypes,JOT_Remark,NDTR_Name,Is_hj,If_dk FROM HJGL_View_JointInfo J left join Base_Project P on J.ProjectId=P.ProjectId where CHARINDEX(JOT_ID,@JOT_ID)>0";
|
||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||
listStr.Add(new SqlParameter("@JOT_ID", JOT_IDStr));
|
||
SqlParameter[] parameter = listStr.ToArray();
|
||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||
|
||
// 2.获取当前分页数据
|
||
//var table = this.GetPagedDataTable(Grid1, tb1);
|
||
Grid1.RecordCount = tb.Rows.Count;
|
||
//this.Grid1.PageIndex = 0;
|
||
tb = GetFilteredTable(Grid1.FilteredData, tb);
|
||
var table = this.GetPagedDataTable(Grid1, tb);
|
||
Grid1.DataSource = table;
|
||
Grid1.DataBind();
|
||
}
|
||
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
||
{
|
||
Grid1.PageIndex = e.NewPageIndex;
|
||
BindGrid();
|
||
}
|
||
|
||
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
||
BindGrid();
|
||
}
|
||
|
||
protected void imgbtnImport_Click(object sender, EventArgs e)
|
||
{
|
||
if (GetButtonPower(Const.BtnIn))
|
||
{
|
||
try
|
||
{
|
||
if (this.FileExcel.HasFile == false)
|
||
{
|
||
Alert.ShowInTop("请您选择Excel文件!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
string IsXls = Path.GetExtension(FileExcel.FileName).ToString().Trim().ToLower();
|
||
if (IsXls != ".xls")
|
||
{
|
||
Alert.ShowInTop("只可以选择Excel文件");
|
||
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("您没有这个权限,请与管理员联系!");
|
||
}
|
||
|
||
}
|
||
|
||
|
||
#region 将Dataset的数据导入数据库
|
||
/// <summary>
|
||
/// 将Dataset的数据导入数据库
|
||
/// </summary>
|
||
/// <param name="pds">数据集</param>
|
||
/// <param name="Cols">数据集列数</param>
|
||
/// <returns></returns>
|
||
private void AddDatasetToSQL(DataTable pds)
|
||
{
|
||
string errorInfos = string.Empty;
|
||
if (pds != null && pds.Rows.Count > 0)
|
||
{
|
||
int ir = pds.Rows.Count;
|
||
for (int i = 0; i < ir; i++)
|
||
{
|
||
string result = string.Empty;
|
||
string col0 = pds.Rows[i][0].ToString().Trim();//项目号
|
||
string col1 = pds.Rows[i][1].ToString().Trim();//管线号
|
||
string col2 = pds.Rows[i][2].ToString().Trim();//焊口号
|
||
string col3 = pds.Rows[i][3].ToString().Trim();//装置
|
||
string col4 = pds.Rows[i][4].ToString().Trim();//材质一
|
||
string col5 = pds.Rows[i][5].ToString().Trim();//材质二
|
||
string col6 = pds.Rows[i][6].ToString().Trim();//焊缝类型
|
||
string col7 = pds.Rows[i][7].ToString().Trim();//破口类型
|
||
string col8 = pds.Rows[i][8].ToString().Trim();//焊口属性
|
||
string col9 = pds.Rows[i][9].ToString().Trim();//焊接方法
|
||
string col10 = pds.Rows[i][10].ToString().Trim();//外径
|
||
string col11 = pds.Rows[i][11].ToString().Trim();//壁厚
|
||
string col12 = pds.Rows[i][12].ToString().Trim();//寸径
|
||
string col13 = pds.Rows[i][13].ToString().Trim();//焊接区域
|
||
string col14 = pds.Rows[i][14].ToString().Trim();//组件一
|
||
string col15 = pds.Rows[i][15].ToString().Trim();//组件二
|
||
string col16 = pds.Rows[i][16].ToString().Trim();//后热温度
|
||
string col17 = pds.Rows[i][17].ToString().Trim();//层间温度
|
||
string col18 = pds.Rows[i][18].ToString().Trim();//预热温度
|
||
string col19 = pds.Rows[i][19].ToString().Trim();//焊丝
|
||
string col20 = pds.Rows[i][20].ToString().Trim();//焊条
|
||
string col21 = pds.Rows[i][21].ToString().Trim();//焊接电流
|
||
string col22 = pds.Rows[i][22].ToString().Trim();//焊接电压
|
||
string col23 = pds.Rows[i][23].ToString().Trim();//是否热处理
|
||
string col24 = pds.Rows[i][24].ToString().Trim();//热处理类型
|
||
string col25 = pds.Rows[i][25].ToString().Trim();//是否特殊
|
||
string col26 = pds.Rows[i][26].ToString().Trim();//探伤比例
|
||
string col27 = pds.Rows[i][27].ToString().Trim();//合格等级
|
||
string col28 = pds.Rows[i][28].ToString().Trim();//硬度合格标准
|
||
string col29 = pds.Rows[i][29].ToString().Trim();//非常焊缝
|
||
string col30 = pds.Rows[i][30].ToString().Trim();//备注
|
||
Model.HJGL_PW_IsoInfo NewIsoInfo = new Model.HJGL_PW_IsoInfo();
|
||
var getProject = Funs.DB.Base_Project.FirstOrDefault(x => x.ProjectCode == col0);//项目号
|
||
Model.HJGL_PW_IsoInfo getPWisInfo = null;
|
||
Model.Project_Installation getInstallation = null;
|
||
if (getProject != null)
|
||
{
|
||
getPWisInfo = Funs.DB.HJGL_PW_IsoInfo.FirstOrDefault(x => x.ProjectId == getProject.ProjectId && x.ISO_IsoNo == col1);//管线
|
||
getInstallation = Funs.DB.Project_Installation.FirstOrDefault(x => x.ProjectId == getProject.ProjectId && x.InstallationName == col3);//装置
|
||
}
|
||
var getSteel1 = Funs.DB.HJGL_BS_Steel.FirstOrDefault(x => x.STE_Code == col4);//材质一
|
||
var getSteel2 = Funs.DB.HJGL_BS_Steel.FirstOrDefault(x => x.STE_Code == col5);//材质二
|
||
var getJointType = Funs.DB.HJGL_BS_JointType.FirstOrDefault(x => x.JOTY_Name == col6);//焊缝类型
|
||
var getSlopeType = Funs.DB.HJGL_BS_SlopeType.FirstOrDefault(x => x.JST_Name == col7);//坡口类型
|
||
var getWeldMethod = Funs.DB.HJGL_BS_WeldMethod.FirstOrDefault(x => x.WME_Name == col9);//焊接方法
|
||
var getComponent1 = Funs.DB.HJGL_BS_Component.FirstOrDefault(x => x.COM_Name == col14);//组件1
|
||
var getComponent2 = Funs.DB.HJGL_BS_Component.FirstOrDefault(x => x.COM_Name == col15);//组件2
|
||
var getWeldSilk = Funs.DB.HJGL_BS_WeldMaterial.FirstOrDefault(x => x.WMT_MatType == "1" && x.WMT_MatCode == col19);//焊丝
|
||
var getWeldMat = Funs.DB.HJGL_BS_WeldMaterial.FirstOrDefault(x => x.WMT_MatType == "2" && x.WMT_MatCode == col20);//焊条
|
||
var getNDTRate = Funs.DB.HJGL_BS_NDTRate.FirstOrDefault(x => x.NDTR_Name == col27);//探伤比例
|
||
var getNDTClass = BLL.DropListService.HJGL_NDTClassItem().FirstOrDefault(x => x.Value == col28);//合格等级
|
||
Model.HJGL_PW_JointInfo newJointInfo = new Model.HJGL_PW_JointInfo();
|
||
if (getProject == null)
|
||
{
|
||
if (string.IsNullOrEmpty(col1))
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "项目号不能为空" + "|";
|
||
}
|
||
else
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "该项目不存在" + "|";
|
||
}
|
||
}
|
||
if (getPWisInfo == null)
|
||
{
|
||
if (string.IsNullOrEmpty(col1))
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "管线号不能为空" + "|";
|
||
}
|
||
else
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "该管线不存在" + "|";
|
||
}
|
||
}
|
||
if (getInstallation == null)
|
||
{
|
||
if (string.IsNullOrEmpty(col3))
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "装置不能为空" + "|";
|
||
}
|
||
else
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "该装置不存在" + "|";
|
||
}
|
||
}
|
||
if (getSteel1 == null)
|
||
{
|
||
if (string.IsNullOrEmpty(col4))
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "材质一不能为空" + "|";
|
||
}
|
||
else
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "该材质一不存在" + "|";
|
||
}
|
||
}
|
||
if (getJointType == null)
|
||
{
|
||
if (string.IsNullOrEmpty(col6))
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "焊缝类型不能为空" + "|";
|
||
}
|
||
else
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "该焊缝类型不存在" + "|";
|
||
}
|
||
}
|
||
if (getSlopeType == null)
|
||
{
|
||
if (string.IsNullOrEmpty(col7))
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "坡口类型不能为空" + "|";
|
||
}
|
||
else
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "该坡口类型不存在" + "|";
|
||
}
|
||
}
|
||
if (getWeldMethod == null)
|
||
{
|
||
if (string.IsNullOrEmpty(col9))
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "焊接方法不能为空" + "|";
|
||
}
|
||
else
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "该焊接方法不存在" + "|";
|
||
}
|
||
}
|
||
if (string.IsNullOrEmpty(col8))
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "焊口属性不能为空" + "|";
|
||
}
|
||
if (!string.IsNullOrEmpty(col8))
|
||
{
|
||
if (col8 != "活动" && col8 != "固定")
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "焊口属性输入有误" + "|";
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(col10))
|
||
{
|
||
try
|
||
{
|
||
var Dia = Funs.GetNewDecimal(col10);
|
||
newJointInfo.JOT_Dia = Dia;
|
||
}
|
||
catch (Exception)
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "外径格式输入有误" + "|";
|
||
}
|
||
}
|
||
if (string.IsNullOrEmpty(col11))
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "壁厚不能为空" + "|";
|
||
}
|
||
if (!string.IsNullOrEmpty(col11))
|
||
{
|
||
try
|
||
{
|
||
var Sch = Funs.GetNewDecimal(col11);
|
||
}
|
||
catch (Exception)
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "壁厚格式输入有误" + "|";
|
||
}
|
||
}
|
||
if (string.IsNullOrEmpty(col12))
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "寸径不能为空" + "|";
|
||
}
|
||
if (!string.IsNullOrEmpty(col12))
|
||
{
|
||
try
|
||
{
|
||
var Size = Funs.GetNewDecimal(col12);
|
||
newJointInfo.JOT_Size = Size;
|
||
}
|
||
catch (Exception)
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "寸径格式输入有误" + "|";
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(col13))
|
||
{
|
||
if (col13 != "现场安装" && col13 != "预制")
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "焊接区域输入有误" + "|";
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(col16))
|
||
{
|
||
try
|
||
{
|
||
var LastTemp = Funs.GetNewDecimal(col16);
|
||
newJointInfo.JOT_LastTemp = LastTemp;
|
||
}
|
||
catch (Exception)
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "后热温度格式输入有误" + "|";
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(col17))
|
||
{
|
||
try
|
||
{
|
||
var CellTemp = Funs.GetNewDecimal(col17);
|
||
newJointInfo.JOT_CellTemp = CellTemp;
|
||
}
|
||
catch (Exception)
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "层间温度格式输入有误" + "|";
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(col18))
|
||
{
|
||
try
|
||
{
|
||
var PrepareTemp = Funs.GetNewDecimal(col18);
|
||
newJointInfo.JOT_PrepareTemp = PrepareTemp;
|
||
}
|
||
catch (Exception)
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "预热温度格式输入有误" + "|";
|
||
}
|
||
}
|
||
if (string.IsNullOrEmpty(col23))
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "是否热处理不能为空" + "|";
|
||
}
|
||
if (!string.IsNullOrEmpty(col23))
|
||
{
|
||
if (col23 != "是" && col23 != "否")
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "是否热处理格式输入有误" + "|";
|
||
}
|
||
else
|
||
{
|
||
if (col23 == "是" && !string.IsNullOrEmpty(col24))
|
||
{
|
||
string itemStr = string.Empty;
|
||
var typeStr = col24.Split(',');
|
||
foreach (var item in typeStr)
|
||
{
|
||
if (item == "预热" || item == "消氢" || item == "后热" || item == "消应力热处理" || item == "稳定化处理")
|
||
{
|
||
if (item == "预热")
|
||
{
|
||
itemStr += "1" + ",";
|
||
}
|
||
if (item == "消氢")
|
||
{
|
||
itemStr += "2" + ",";
|
||
}
|
||
if (item == "后热")
|
||
{
|
||
itemStr += "3" + ",";
|
||
}
|
||
if (item == "消应力热处理")
|
||
{
|
||
itemStr += "4" + ",";
|
||
}
|
||
if (item == "稳定化处理")
|
||
{
|
||
itemStr += "5" + ",";
|
||
}
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(itemStr))
|
||
{
|
||
newJointInfo.ProessTypes = itemStr.Substring(0, itemStr.LastIndexOf(","));
|
||
}
|
||
else {
|
||
result += "第" + (i + 2).ToString() + "行," + "热处理类型输入有误" + "|";
|
||
}
|
||
}
|
||
else if (col23 == "是" && string.IsNullOrEmpty(col24))
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "热处理类型为是时,热处理类型不能为空" + "|";
|
||
}
|
||
else if (col23 == "否" && !string.IsNullOrEmpty(col24)) {
|
||
result += "第" + (i + 2).ToString() + "行," + "热处理类型为否时,热处理类型应为空" + "|";
|
||
}
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(col25))
|
||
{
|
||
if (col25 != "是" && col25 != "否")
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "是否特殊格式输入有误" + "|";
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(col29))
|
||
{
|
||
try
|
||
{
|
||
var WeldL = Funs.GetNewInt(col29);
|
||
newJointInfo.WeldL = WeldL;
|
||
}
|
||
catch (Exception)
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "非常焊缝格式输入有误" + "|";
|
||
}
|
||
}
|
||
if(string.IsNullOrEmpty(result))
|
||
{
|
||
newJointInfo.ProjectId = getProject.ProjectId;
|
||
newJointInfo.ISO_ID = getPWisInfo.ISO_ID;
|
||
newJointInfo.JOT_JointDesc = "Φ" + col10 + "×" + col11;
|
||
newJointInfo.STE_ID = getSteel1.STE_ID;
|
||
if (getSteel2 != null)
|
||
{
|
||
newJointInfo.STE_ID2 = getSteel2.STE_ID;
|
||
}
|
||
newJointInfo.JOTY_ID = getJointType.JOTY_ID;
|
||
newJointInfo.JST_ID = getSlopeType.JST_ID;
|
||
newJointInfo.JOT_JointAttribute = col8;
|
||
newJointInfo.WME_ID = getWeldMethod.WME_ID;
|
||
newJointInfo.JOT_Sch = col11;
|
||
if (col13 == "安装")
|
||
{
|
||
newJointInfo.WLO_Code = "F";
|
||
}
|
||
else {
|
||
newJointInfo.WLO_Code = "S";
|
||
}
|
||
if (getComponent1 != null)
|
||
{
|
||
newJointInfo.JOT_Component1 = getComponent1.COM_ID;
|
||
}
|
||
if (getComponent2 != null)
|
||
{
|
||
newJointInfo.JOT_Component2 = getComponent2.COM_ID;
|
||
}
|
||
if (getWeldSilk != null)
|
||
{
|
||
newJointInfo.JOT_WeldSilk = getWeldSilk.WMT_ID;
|
||
}
|
||
if (getWeldMat != null)
|
||
{
|
||
newJointInfo.JOT_WeldMat = getWeldMat.WMT_ID;
|
||
}
|
||
newJointInfo.JOT_Electricity = col21;
|
||
newJointInfo.JOT_Voltage = col22;
|
||
if (col23 == "是")
|
||
{
|
||
newJointInfo.IS_Proess = "1";
|
||
}
|
||
else {
|
||
newJointInfo.IS_Proess = "0";
|
||
}
|
||
newJointInfo.JOT_Remark = col30;
|
||
newJointInfo.InstallationId = getInstallation.InstallationId;
|
||
if (getNDTRate != null)
|
||
{
|
||
newJointInfo.NDTR_ID = getNDTRate.NDTR_ID;
|
||
}
|
||
if (getNDTClass != null)
|
||
{
|
||
newJointInfo.JOT_QualifiedLevel = getNDTClass.Value;
|
||
}
|
||
if (col25 == "是")
|
||
{
|
||
|
||
newJointInfo.IsSpecial = true;
|
||
}
|
||
else
|
||
{
|
||
newJointInfo.IsSpecial = false;
|
||
}
|
||
var getJoint = Funs.DB.HJGL_PW_JointInfo.FirstOrDefault(x => x.ProjectId == getProject.ProjectId && x.ISO_ID == getPWisInfo.ISO_ID && x.JOT_JointNo == col2);
|
||
if (getJoint == null)
|
||
{
|
||
newJointInfo.JOT_JointNo = col2;
|
||
newJointInfo.JOT_ID = SQLHelper.GetNewID(typeof(Model.HJGL_PW_JointInfo));
|
||
BLL.HJGL_PW_JointInfoService.AddJointInfo(newJointInfo);
|
||
// 更新排序字段
|
||
string strSort = @"UPDATE dbo.HJGL_PW_JointInfo SET
|
||
Sort1=(case when PATINDEX('[A-Z]%',JOT_JointNo)>0 THEN 'B'
|
||
WHEN ISNUMERIC(JOT_JointNo)=1 then 'C' ELSE 'C' END),
|
||
Sort2=(CASE WHEN ISNUMERIC(JOT_JointNo)=1 then try_cast(REPLACE(JOT_JointNo,'.','') AS INT)
|
||
WHEN ISNUMERIC(SUBSTRING(JOT_JointNo,0,CHARINDEX('Z',JOT_JointNo)))=1
|
||
THEN TRY_CAST(SUBSTRING(JOT_JointNo,0,CHARINDEX('Z',JOT_JointNo)) as int)
|
||
WHEN PATINDEX('[0-9]%',JOT_JointNo)>0 then
|
||
TRY_CAST(left(JOT_JointNo,PATINDEX('%[^0-9]%',JOT_JointNo)-1) as int)
|
||
ELSE 0 END),
|
||
Sort3= SUBSTRING(JOT_JointNo,1,1),
|
||
Sort4=(CASE WHEN CHARINDEX('Z',JOT_JointNo)>0 and SUBSTRING(JOT_JointNo,1,1)<>'Z'
|
||
THEN ISNULL(TRY_CAST(SUBSTRING(replace(JOT_JointNo,'#',''),2,CHARINDEX('Z',JOT_JointNo)-2) as int),0)
|
||
WHEN PATINDEX('%[A-G]%',SUBSTRING(replace(JOT_JointNo,'#',''),2,len(JOT_JointNo)))>0
|
||
THEN ISNULL(TRY_CAST(SUBSTRING(JOT_JointNo,2,len(JOT_JointNo)-2) as int),0)
|
||
ELSE ISNULL(TRY_CAST(SUBSTRING(replace(JOT_JointNo,'#',''),2,len(JOT_JointNo)) as int),0) END),
|
||
Sort5=(CASE WHEN CHARINDEX('Z',JOT_JointNo)>0
|
||
THEN ISNULL(TRY_CAST(SUBSTRING(JOT_JointNo,charindex('Z',JOT_JointNo)+1,len(JOT_JointNo)) AS INT),0)
|
||
WHEN PATINDEX('%[A-Y]',SUBSTRING(replace(JOT_JointNo,'#',''),2,len(JOT_JointNo)))>0
|
||
THEN ISNULL(TRY_CAST(SUBSTRING(JOT_JointNo,2,len(JOT_JointNo)-1) as int),0) ELSE 0 END)
|
||
WHERE JOT_ID='" + newJointInfo.JOT_ID + "'";
|
||
SQLHelper.ExecutSql(strSort);
|
||
|
||
JOT_IDStr += Funs.DB.HJGL_PW_JointInfo.FirstOrDefault(x => x.ProjectId == getProject.ProjectId && x.ISO_ID == getPWisInfo.ISO_ID && x.JOT_JointNo == col2).JOT_ID + ",";
|
||
}
|
||
else
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "该焊口已存在" + "|";
|
||
}
|
||
}
|
||
errorInfos += result;
|
||
}
|
||
if (!string.IsNullOrEmpty(JOT_IDStr))
|
||
{
|
||
JOT_IDStr = JOT_IDStr.Substring(0, JOT_IDStr.LastIndexOf(","));
|
||
}
|
||
this.BindGrid();
|
||
if (!string.IsNullOrEmpty(errorInfos))
|
||
{
|
||
errorInfos = "未成功数据:" + errorInfos.Substring(0, errorInfos.LastIndexOf("|"));
|
||
Alert.ShowInParent("数据已导入!" + errorInfos, MessageBoxIcon.Warning);
|
||
}
|
||
else
|
||
{
|
||
ShowNotify("数据导入成功!", MessageBoxIcon.Success);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
ShowNotify("导入数据为空!", MessageBoxIcon.Success);
|
||
return;
|
||
}
|
||
}
|
||
#endregion
|
||
protected void imgbtnUpload_Click(object sender, EventArgs e)
|
||
{
|
||
string uploadfilepath = Server.MapPath("~/") + BLL.Const.JointInTemplateUrl;
|
||
string fileName = Path.GetFileName(BLL.Const.JointInTemplateUrl);
|
||
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);
|
||
}
|
||
}
|
||
|
||
protected void btnMenuDelete_Click(object sender, EventArgs e)
|
||
{
|
||
if (GetButtonPower(Const.BtnDelete))
|
||
{
|
||
if (Grid1.SelectedRowIndexArray.Length > 0)
|
||
{
|
||
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
||
{
|
||
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
||
var JointInfo = BLL.HJGL_PW_JointInfoService.GetJointInfoByJotID(rowID);
|
||
if (JointInfo != null)
|
||
{
|
||
BLL.HJGL_PW_JointInfoService.DeleteJointInfo(rowID);
|
||
ShowNotify("删除数据成功!(表格数据已重新绑定)");
|
||
}
|
||
}
|
||
BindGrid();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
ShowNotify("您没有这个权限,请与管理员联系!");
|
||
}
|
||
}
|
||
#region 判断按钮权限
|
||
/// <summary>
|
||
/// 获取按钮权限
|
||
/// </summary>
|
||
/// <param name="button"></param>
|
||
/// <returns></returns>
|
||
private bool GetButtonPower(string button)
|
||
{
|
||
return BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.JointInMenuId, button);
|
||
}
|
||
#endregion
|
||
}
|
||
} |