2023-06-12
This commit is contained in:
parent
b9315dd056
commit
624a9d9dc3
|
|
@ -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
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 元件编码
|
||||
///</summary>
|
||||
[ExcelColumnName("元件编码")]
|
||||
public string MaterialCode { get; set; }
|
||||
/// <summary>
|
||||
/// 材料描述
|
||||
///</summary>
|
||||
[ExcelColumnName("材料描述")]
|
||||
public string MaterialDef { get; set; }
|
||||
/// <summary>
|
||||
/// 规格
|
||||
///</summary>
|
||||
[ExcelColumnName("规格")]
|
||||
public string MaterialSpec { get; set; }
|
||||
/// <summary>
|
||||
/// 单位
|
||||
///</summary>
|
||||
[ExcelColumnName("单位")]
|
||||
public string MaterialUnit { get; set; }
|
||||
/// <summary>
|
||||
/// 类型
|
||||
///</summary>
|
||||
[ExcelColumnName("类型")]
|
||||
public string MaterialName { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<MaterialCodeLibDtoIn>(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, [元件编码] 不能为空</br>";
|
||||
}
|
||||
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, [元件编码] 不能为空</br>";
|
||||
// }
|
||||
// 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))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,6 +2,4 @@
|
|||
<Tree>
|
||||
<TreeNode id="D1A60816-C19B-4AC3-9399-362D1BDCE5F2" Text="人员信息" NavigateUrl="Person/ProjectPerson.aspx">
|
||||
</TreeNode>
|
||||
<TreeNode id="E1052483-2591-4408-92A4-14E85805BBA0" Text="考勤信息" NavigateUrl=""></TreeNode>
|
||||
<TreeNode id="39EE4D09-D413-4C3E-B719-542B63AEA9ED" Text="人工时信息" NavigateUrl=""></TreeNode>
|
||||
</Tree>
|
||||
Loading…
Reference in New Issue