diff --git a/SGGL/BLL/HJGL/BaseInfo/MaterialCodeLibService.cs b/SGGL/BLL/HJGL/BaseInfo/MaterialCodeLibService.cs
index ad2f067c..0cc5296a 100644
--- a/SGGL/BLL/HJGL/BaseInfo/MaterialCodeLibService.cs
+++ b/SGGL/BLL/HJGL/BaseInfo/MaterialCodeLibService.cs
@@ -1,5 +1,6 @@
namespace BLL
{
+ using MiniExcelLibs.Attributes;
using Model;
using System.Collections.Generic;
using System.Linq;
@@ -80,4 +81,35 @@
}
}
}
+
+ public class MaterialCodeLibDtoIn
+ {
+
+ ///
+ /// 元件编码
+ ///
+ [ExcelColumnName("元件编码")]
+ public string MaterialCode { get; set; }
+ ///
+ /// 材料描述
+ ///
+ [ExcelColumnName("材料描述")]
+ public string MaterialDef { get; set; }
+ ///
+ /// 规格
+ ///
+ [ExcelColumnName("规格")]
+ public string MaterialSpec { get; set; }
+ ///
+ /// 单位
+ ///
+ [ExcelColumnName("单位")]
+ public string MaterialUnit { get; set; }
+ ///
+ /// 类型
+ ///
+ [ExcelColumnName("类型")]
+ public string MaterialName { get; set; }
+ }
+
}
diff --git a/SGGL/FineUIPro.Web/HJGL/BaseInfo/MaterialCodeLibIn.aspx.cs b/SGGL/FineUIPro.Web/HJGL/BaseInfo/MaterialCodeLibIn.aspx.cs
index f41e3f9a..8b1a4f5b 100644
--- a/SGGL/FineUIPro.Web/HJGL/BaseInfo/MaterialCodeLibIn.aspx.cs
+++ b/SGGL/FineUIPro.Web/HJGL/BaseInfo/MaterialCodeLibIn.aspx.cs
@@ -1,4 +1,5 @@
using BLL;
+using MiniExcelLibs;
using Model;
using System;
using System.Collections.Generic;
@@ -121,36 +122,37 @@ namespace FineUIPro.Web.HJGL.BaseInfo
//文件上传服务器后的名称
string fileName = rootPath + initPath + this.hdFileName.Text;
//读取Excel
- DataSet ds = NPOIHelper.ExcelToDataSet(fileName, out errorInfos, true);
- //验证Excel读取是否有误
- if (!string.IsNullOrEmpty(errorInfos))
+ //DataSet ds = NPOIHelper.ExcelToDataSet(fileName, out errorInfos, true);
+ ////验证Excel读取是否有误
+ //if (!string.IsNullOrEmpty(errorInfos))
+ //{
+ // ShowNotify(errorInfos, MessageBoxIcon.Warning);
+ // return;
+ //}
+ var rows = MiniExcel.Query(fileName).ToList();
+ rows = rows.Where(x => x.MaterialCode != "" && x.MaterialName != "").ToList();
+ if (rows.Count==0)
{
- ShowNotify(errorInfos, MessageBoxIcon.Warning);
- return;
+ ShowNotify("没有数据!", MessageBoxIcon.Warning);
+ return;
}
-
- DataRow[] dv = ds.Tables[0].Select("元件编码 <>'' and 类型 <>''");
- //导入数据库
- if (dv.Length > 0)
+ for (int i = 0; i < rows.Count; i++)
{
- for (int i = 0; i < dv.Length; i++)
- {
- HJGL_MaterialCodeLib item = new HJGL_MaterialCodeLib();
-
- #region 数据验证和赋值
- if (dv[i]["元件编码"] != null && !string.IsNullOrEmpty(dv[i]["元件编码"].ToString()))
+ HJGL_MaterialCodeLib item = new HJGL_MaterialCodeLib();
+ #region 数据验证和赋值
+ if (rows[i].MaterialCode != null && !string.IsNullOrEmpty(rows[i].MaterialCode))
{
- item.MaterialCode = dv[i]["元件编码"].ToString();
+ item.MaterialCode = rows[i].MaterialCode;
}
else
{
errorInfos += (i + 2) + "Line, [元件编码] 不能为空";
}
- item.MaterialDef = dv[i]["材料描述"].ToString();
- item.MaterialSpec = dv[i]["规格"].ToString();
+ item.MaterialDef = rows[i].MaterialDef;
+ item.MaterialSpec = rows[i].MaterialSpec;
// item.MaterialMade = dv[i]["材质"].ToString();
- item.MaterialUnit = dv[i]["单位"].ToString();
- item.MaterialName = dv[i]["类型"].ToString();
+ item.MaterialUnit = rows[i].MaterialUnit;
+ item.MaterialName = rows[i].MaterialName;
//item.PipeGrade = dv[i]["管道等级"].ToString();
//item.ProjectId = CurrUser.LoginProjectId;
//= SQLHelper.GetNewID(typeof(Model.Editor_CostReport));
@@ -170,14 +172,56 @@ namespace FineUIPro.Web.HJGL.BaseInfo
}
#endregion
- }
+ }
+ // DataRow[] dv = ds.Tables[0].Select("元件编码 <>'' and 类型 <>''");
+ //导入数据库
+ //if (dv.Length > 0)
+ //{
+ // for (int i = 0; i < dv.Length; i++)
+ // {
+ // HJGL_MaterialCodeLib item = new HJGL_MaterialCodeLib();
- }
- else
- {
- ShowNotify("没有数据!", MessageBoxIcon.Warning);
- return;
- }
+ // #region 数据验证和赋值
+ // if (dv[i]["元件编码"] != null && !string.IsNullOrEmpty(dv[i]["元件编码"].ToString()))
+ // {
+ // item.MaterialCode = dv[i]["元件编码"].ToString();
+ // }
+ // else
+ // {
+ // errorInfos += (i + 2) + "Line, [元件编码] 不能为空";
+ // }
+ // item.MaterialDef = dv[i]["材料描述"].ToString();
+ // item.MaterialSpec = dv[i]["规格"].ToString();
+ // // item.MaterialMade = dv[i]["材质"].ToString();
+ // item.MaterialUnit = dv[i]["单位"].ToString();
+ // item.MaterialName = dv[i]["类型"].ToString();
+ // //item.PipeGrade = dv[i]["管道等级"].ToString();
+ // //item.ProjectId = CurrUser.LoginProjectId;
+ // //= SQLHelper.GetNewID(typeof(Model.Editor_CostReport));
+ // if (!codeLib.Select(x => x.MaterialCode).Contains(item.MaterialCode))
+ // {
+
+ // if (materialcodelist.Select(x => x.MaterialCode).Contains(item.MaterialCode))
+ // {
+ // codeLib_update.Add(item);
+ // }
+ // else
+ // {
+ // codeLib.Add(item);
+
+ // }
+
+ // }
+
+ // #endregion
+ // }
+
+ //}
+ //else
+ //{
+ // ShowNotify("没有数据!", MessageBoxIcon.Warning);
+ // return;
+ //}
if (!string.IsNullOrEmpty(errorInfos))
{
diff --git a/SGGL/FineUIPro.Web/HJGL/BaseInfo/MediumIn.aspx.cs b/SGGL/FineUIPro.Web/HJGL/BaseInfo/MediumIn.aspx.cs
index e6f1a6b9..db24c5ba 100644
--- a/SGGL/FineUIPro.Web/HJGL/BaseInfo/MediumIn.aspx.cs
+++ b/SGGL/FineUIPro.Web/HJGL/BaseInfo/MediumIn.aspx.cs
@@ -201,14 +201,14 @@ namespace FineUIPro.Web.HJGL.BaseInfo
{
result += "第" + (i + 2).ToString() + "行," + "介质代号" + "," + "此项为必填项!" + "|";
}
- else
- {
- var code = q.FirstOrDefault(x => x.MediumCode == col0);
- if (code != null)
- {
- result += "第" + (i + 2).ToString() + "行," + "此等级代号已存在" + "|";
- }
- }
+ //else
+ //{
+ // var code = q.FirstOrDefault(x => x.MediumCode == col0);
+ // if (code != null)
+ // {
+ // result += "第" + (i + 2).ToString() + "行," + "此等级代号已存在" + "|";
+ // }
+ //}
string col1 = pds.Rows[i][1].ToString();
if (string.IsNullOrEmpty(col1))
{
@@ -216,12 +216,13 @@ namespace FineUIPro.Web.HJGL.BaseInfo
}
else
{
- var code = q.FirstOrDefault(x => x.MediumName == col1);
+ var code = q.FirstOrDefault(x =>x.MediumCode== col0&& x.MediumName == col1);
if (code != null)
{
- result += "第" + (i + 2).ToString() + "行," + "此介质名称已存在" + "|";
+ result += "第" + (i + 2).ToString() + "行," + "此介质代号、名称已经存在" + "|";
}
}
+
string col2 = pds.Rows[i][2].ToString();
if (string.IsNullOrEmpty(col2))
{
diff --git a/SGGL/FineUIPro.Web/common/Menu_PPerson.xml b/SGGL/FineUIPro.Web/common/Menu_PPerson.xml
index 22c2f7ed..447c80ec 100644
--- a/SGGL/FineUIPro.Web/common/Menu_PPerson.xml
+++ b/SGGL/FineUIPro.Web/common/Menu_PPerson.xml
@@ -2,6 +2,4 @@
-
-
\ No newline at end of file