diff --git a/SGGL/FineUIPro.Web/File/Excel/DataIn/PipelineMat.xlsx b/SGGL/FineUIPro.Web/File/Excel/DataIn/PipelineMat.xlsx
index 736e3a0f..d21e1b9b 100644
Binary files a/SGGL/FineUIPro.Web/File/Excel/DataIn/PipelineMat.xlsx and b/SGGL/FineUIPro.Web/File/Excel/DataIn/PipelineMat.xlsx differ
diff --git a/SGGL/FineUIPro.Web/FineUIPro.Web.csproj b/SGGL/FineUIPro.Web/FineUIPro.Web.csproj
index 4637a5cb..8bc11dec 100644
--- a/SGGL/FineUIPro.Web/FineUIPro.Web.csproj
+++ b/SGGL/FineUIPro.Web/FineUIPro.Web.csproj
@@ -17034,7 +17034,7 @@
-
+
diff --git a/SGGL/FineUIPro.Web/HJGL/WeldingManage/PipelineMatIn.aspx.cs b/SGGL/FineUIPro.Web/HJGL/WeldingManage/PipelineMatIn.aspx.cs
index c97666d8..719ec24c 100644
--- a/SGGL/FineUIPro.Web/HJGL/WeldingManage/PipelineMatIn.aspx.cs
+++ b/SGGL/FineUIPro.Web/HJGL/WeldingManage/PipelineMatIn.aspx.cs
@@ -133,207 +133,12 @@ namespace FineUIPro.Web.HJGL.WeldingManage
}
#endregion
#region 将Dataset的数据导入数据库
- ///
- /// 将Dataset的数据导入数据库
- ///
- /// 数据集
- /// 数据集行数
- ///
- private Model.ResponeData AddDatasetToSQL(DataTable pds, int Cols)
- {
- Model.ResponeData responeData = new Model.ResponeData();
- List result = new List();
-
- int ic, ir;
- ic = pds.Columns.Count;
- ir = pds.Rows.Count;
- if (ic < Cols)
- {
- responeData.code = 0;
- responeData.message = "导入Excel格式错误!Excel只有" + ic.ToString().Trim() + "列";
- return responeData;
- }
- // DataRow[] dv = pds.Select("主项编号 <>'' and 管线号 <>'' and 材料编码 <>'' and 数量 <>''and 管线划分<>'' ");
- DataRow[] dv = pds.Select(" 管线号 <>'' and 材料编码 <>'' and 数量 <>'' ");
-
- //导入数据库
- if (dv.Length > 0)
- {
- for (int i = 0; i < dv.Length; i++)
- {
- HJGL_PipeLineMat item = new HJGL_PipeLineMat();
-
- #region 数据验证和赋值
-
-
- string unitworkId = string.Empty;
- unitworkId = Request.Params["UnitWorkId"];
- string PipeArea = string.Empty;//管线划分 1工厂预制 2现场施工
-
- if (dv[i]["管线号"] != null && !string.IsNullOrEmpty(dv[i]["管线号"].ToString()))
- {
- var pipeline = from x in Funs.DB.HJGL_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == unitworkId && x.PipelineCode == dv[i]["管线号"].ToString().Trim() select x;
- if (pipeline.Count() > 0)
- {
- item.PipelineId = pipeline.First().PipelineId;
- PipeArea = pipeline.First().PipeArea;
- }
- else
- {
- // errorInfos += (i + 2) + "Line,"+ dv[i]["管线号"].ToString() + " [管线号] 不存在";
- result.Add("不存在此管线号-" + dv[i]["管线号"].ToString());
-
-
- }
-
- }
- else
- {
- //errorInfos += (i + 2) + "Line, [管线号] 不能为空";
- result.Add((i + 2) + "Line, [管线号] 不能为空");
- }
- //if (dv[i]["管线划分"] != null && !string.IsNullOrEmpty(dv[i]["管线划分"].ToString()))
- //{
- // string txtPipeArea = "";
- // switch (PipeArea)
- // {
- // case "1":
- // txtPipeArea = "工厂预制";
- // break;
- // case "2":
- // txtPipeArea = "现场施工";
- // break;
- // default:
- // txtPipeArea = "无";
- // break;
- // }
- // if (!Equals(txtPipeArea, dv[i]["管线划分"].ToString().Trim()))
- // {
- // errorInfos += (i + 2) + "Line, [管线划分] 不匹配";
-
- // }
- //}
- //else
- //{
- // errorInfos += (i + 2) + "Line, [管线划分] 不能为空";
-
- //}
-
-
- if (dv[i]["材料编码"] != null && !string.IsNullOrEmpty(dv[i]["材料编码"].ToString()))
- {
- var lib = from x in Funs.DB.HJGL_MaterialCodeLib where x.MaterialCode == dv[i]["材料编码"].ToString() select x;
- if (lib.Count() > 0)
- {
- item.MaterialCode = dv[i]["材料编码"].ToString();
- }
- else
- {
- //errorInfos += (i + 2) + "Line," + dv[i]["材料编码"].ToString() + " [材料编码] 不存在";
- result.Add("不存在此材料编码-" + dv[i]["材料编码"].ToString());
-
- }
-
- }
- else
- {
- //errorInfos += (i + 2) + "Line, [材料编码] 不能为空";
- result.Add((i + 2) + "Line, [材料编码] 不能为空");
- }
-
- if (dv[i]["数量"] != null && !string.IsNullOrEmpty(dv[i]["数量"].ToString()))
- {
- try
- {
- var number = Funs.GetNewDecimal(dv[i]["数量"].ToString());
- item.Number = number;
- }
- catch (Exception)
- {
- //errorInfos += "第" + (i + 2).ToString() + "行," + "数量格式输入有误";
- result.Add("第" + (i + 2).ToString() + "行," + "数量格式输入有误");
- }
-
- }
- else
- {
- //errorInfos += (i + 2) + "Line, [数量] 不能为空";
- result.Add((i + 2) + "Line, [数量] 不能为空");
- }
-
- if (PipeArea == "1")
- {
- if (dv[i]["预制组件"] != null && !string.IsNullOrEmpty(dv[i]["预制组件"].ToString()))
- {
- item.PrefabricatedComponents = dv[i]["预制组件"].ToString();
-
- }
- else
- {
- result.Add((i + 2) + "Line, [预制组件] 不能为空");
- }
- }
- var model = matList.Where(x => x.PipelineId == item.PipelineId && x.MaterialCode == item.MaterialCode && x.PrefabricatedComponents == item.PrefabricatedComponents);
- if (model.Count() == 0)
- {
- matList.Add(item);
-
- }
- //if (PipeArea == "1")//工厂预制
- //{
-
- // var model= matList.Where(x => x.PrefabricatedComponents == item.PrefabricatedComponents && x.MaterialCode == item.MaterialCode);
- // if (model.Count()==0)
- // {
- // matList.Add(item);
-
- // }
-
- //} else if (PipeArea == "2")//现场施工
- //{
- // var model = matList.Where(x => x.PipelineId == item.PipelineId && x.MaterialCode == item.MaterialCode);
- // if (model.Count() == 0)
- // {
- // matList.Add(item);
-
- // }
- //}
- //item.PipeLineMatId= SQLHelper.GetNewID(typeof(Model.HJGL_PipeLineMat));
- //if (!matList.Select(x => x.MaterialCode).Contains(item.MaterialCode))
- //{
- // matList.Add(item);
- //}
-
- #endregion
- }
-
- }
- else
- {
- responeData.code = 0;
- responeData.message = "没有数据";
-
- }
- if (result.Count > 0)
- {
- // result = result.Substring(0, result.LastIndexOf("|"));
- errorInfos = string.Join("|", result.Distinct());
- //Alert alert = new Alert();
- //alert.Message = result;
- //alert.Target = Target.Self;
- //alert.Show();
- responeData.code = 0;
- responeData.message = errorInfos;
- }
-
- return responeData;
- }
private Model.ResponeData AddDatasetToSQL(List pds, int count)
{
Model.ResponeData responeData = new Model.ResponeData();
List result = new List();
- if (count < 4)
+ if (count < 6)
{
responeData.code = 0;
responeData.message = "导入Excel格式错误!Excel只有" + count.ToString().Trim() + "列";
@@ -377,16 +182,30 @@ namespace FineUIPro.Web.HJGL.WeldingManage
if (pds[i].C != null && !string.IsNullOrEmpty(pds[i].C.ToString()))
{
- string materialCode = pds[i].C.ToString();
- var lib = from x in Funs.DB.HJGL_MaterialCodeLib where x.MaterialCode == materialCode select x;
- if (lib.Count() > 0)
+ string materialCode = pds[i].C.ToString().Trim();
+ string furnaceNo = pds[i].D == null ? string.Empty : pds[i].D.ToString().Trim();
+ string batchNo = pds[i].E == null ? string.Empty : pds[i].E.ToString().Trim();
+ if (pds[i].D == null || string.IsNullOrEmpty(pds[i].D.ToString()))
{
- item.MaterialCode = pds[i].C.ToString();
+ result.Add((i + 2) + "Line, [炉号] 不能为空");
}
- else
+ if (pds[i].E == null || string.IsNullOrEmpty(pds[i].E.ToString()))
{
- result.Add("不存在此材料编码-" + pds[i].C.ToString());
+ result.Add((i + 2) + "Line, [批号] 不能为空");
+ }
+ if (!string.IsNullOrEmpty(materialCode) && !string.IsNullOrEmpty(furnaceNo) && !string.IsNullOrEmpty(batchNo))
+ {
+ string fullMaterialCode = materialCode + "-" + furnaceNo + "-" + batchNo;
+ var lib = from x in Funs.DB.HJGL_MaterialCodeLib where x.MaterialCode == fullMaterialCode select x;
+ if (lib.Count() > 0)
+ {
+ item.MaterialCode = fullMaterialCode;
+ }
+ else
+ {
+ result.Add("不存在此材料:" + fullMaterialCode);
+ }
}
}
@@ -395,11 +214,11 @@ namespace FineUIPro.Web.HJGL.WeldingManage
result.Add((i + 2) + "Line, [材料编码] 不能为空");
}
- if (pds[i].D != null && !string.IsNullOrEmpty(pds[i].D.ToString()))
+ if (pds[i].F != null && !string.IsNullOrEmpty(pds[i].F.ToString()))
{
try
{
- var number = Funs.GetNewDecimal(pds[i].D.ToString());
+ var number = Funs.GetNewDecimal(pds[i].F.ToString());
item.Number = number;
}
catch (Exception)
@@ -674,4 +493,4 @@ namespace FineUIPro.Web.HJGL.WeldingManage
}
}
}
-}
\ No newline at end of file
+}