提交代码
This commit is contained in:
@@ -180,13 +180,13 @@ namespace FineUIPro.Web.HSSE.Hazard
|
||||
string result = string.Empty;
|
||||
int ic, ir;
|
||||
ic = pds.Columns.Count;
|
||||
|
||||
|
||||
|
||||
ir = pds.Rows.Count;
|
||||
if (pds != null && ir > 0)
|
||||
{
|
||||
var units = from x in Funs.DB.Base_Unit select x;
|
||||
var unitWorks = from x in Funs.DB.WBS_UnitWork where x.ProjectId == CurrUser.LoginProjectId select x;
|
||||
var unitWorks = from x in Funs.DB.ProjectData_MainItem where x.ProjectId == CurrUser.LoginProjectId select x;
|
||||
for (int i = 0; i < ir; i++)
|
||||
{
|
||||
string row0 = pds.Rows[i][0].ToString().Trim();
|
||||
@@ -208,11 +208,11 @@ namespace FineUIPro.Web.HSSE.Hazard
|
||||
}
|
||||
if (string.IsNullOrEmpty(row2))
|
||||
{
|
||||
result += (i + 2).ToString() + "," + "单位工程" + "," + "此项为必填项!" + "|";
|
||||
result += (i + 2).ToString() + "," + "单位工程" + "," + "此项为必填项!" + "|";
|
||||
}
|
||||
else
|
||||
{
|
||||
var unitWork = unitWorks.Where(x => x.UnitWorkName == row2.Trim()).FirstOrDefault();
|
||||
var unitWork = unitWorks.Where(x => x.MainItemName == row2.Trim()).FirstOrDefault();
|
||||
if (unitWork == null)
|
||||
{
|
||||
result += (i + 2).ToString() + "," + "单位工程" + "," + "此项目不存在!" + "|";
|
||||
@@ -225,7 +225,7 @@ namespace FineUIPro.Web.HSSE.Hazard
|
||||
}
|
||||
else
|
||||
{
|
||||
var unit = units.Where(x => x.UnitName == row3.Trim()).FirstOrDefault();
|
||||
var unit = units.Where(x => x.UnitName == row3.Trim()).FirstOrDefault();
|
||||
if (unit == null)
|
||||
{
|
||||
result += (i + 2).ToString() + "," + "单位" + "," + "此项目不存在!" + "|";
|
||||
@@ -288,6 +288,30 @@ namespace FineUIPro.Web.HSSE.Hazard
|
||||
{
|
||||
if (errorInfos.Count <= 0)
|
||||
{
|
||||
//string rootPath = Server.MapPath("~/");
|
||||
//string initFullPath = rootPath + initPath;
|
||||
//if (!Directory.Exists(initFullPath))
|
||||
//{
|
||||
// Directory.CreateDirectory(initFullPath);
|
||||
//}
|
||||
|
||||
//string filePath = initFullPath + this.hdfileName.Text;
|
||||
//ImportXlsToData2(filePath);
|
||||
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文件!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
if (errorInfos != null)
|
||||
{
|
||||
errorInfos.Clear();
|
||||
}
|
||||
string rootPath = Server.MapPath("~/");
|
||||
string initFullPath = rootPath + initPath;
|
||||
if (!Directory.Exists(initFullPath))
|
||||
@@ -295,7 +319,9 @@ namespace FineUIPro.Web.HSSE.Hazard
|
||||
Directory.CreateDirectory(initFullPath);
|
||||
}
|
||||
|
||||
this.hdfileName.Text = BLL.Funs.GetNewFileName() + IsXls;
|
||||
string filePath = initFullPath + this.hdfileName.Text;
|
||||
FileExcel.PostedFile.SaveAs(filePath);
|
||||
ImportXlsToData2(filePath);
|
||||
}
|
||||
else
|
||||
@@ -362,16 +388,19 @@ namespace FineUIPro.Web.HSSE.Hazard
|
||||
string result = string.Empty;
|
||||
string dReportID = string.Empty;
|
||||
string dateStr = string.Empty;
|
||||
int ir;
|
||||
|
||||
string des = "";
|
||||
int ir;
|
||||
ir = pds.Rows.Count;
|
||||
if (pds != null && ir > 0)
|
||||
{
|
||||
Model.HSSE_ConstructionRisk newConstructionRisk = null;
|
||||
var units = from x in Funs.DB.Base_Unit select x;
|
||||
var unitWorks = from x in Funs.DB.WBS_UnitWork where x.ProjectId == CurrUser.LoginProjectId select x;
|
||||
int index = 1;
|
||||
var mainItems = from x in Funs.DB.ProjectData_MainItem where x.ProjectId == CurrUser.LoginProjectId select x;
|
||||
var persons = from x in Funs.DB.Person_Persons
|
||||
join y in Funs.DB.SitePerson_Person on x.PersonId equals y.PersonId
|
||||
where y.ProjectId == this.CurrUser.LoginProjectId
|
||||
select x;
|
||||
var licenseTypes = from x in Funs.DB.Base_LicenseType orderby x.LicenseTypeCode select x;
|
||||
var licenseDesList = BLL.ConstructionRiskListService.LicenseDesList();
|
||||
for (int i = 0; i < ir; i++)
|
||||
{
|
||||
string row0 = pds.Rows[i][0].ToString().Trim();
|
||||
@@ -383,46 +412,91 @@ namespace FineUIPro.Web.HSSE.Hazard
|
||||
string row6 = pds.Rows[i][6].ToString().Trim();
|
||||
string row7 = pds.Rows[i][7].ToString().Trim();
|
||||
string row8 = pds.Rows[i][8].ToString().Trim();
|
||||
string row9 = pds.Rows[i][9].ToString().Trim();
|
||||
var unit = units.Where(x => x.UnitName == row3).FirstOrDefault();
|
||||
var unitWork = unitWorks.Where(x => x.UnitWorkName == row2).FirstOrDefault();
|
||||
var mainItem = mainItems.Where(x => x.MainItemName == row2).FirstOrDefault();
|
||||
var subDutyPerson = persons.FirstOrDefault(x => x.PersonName == row5);
|
||||
newConstructionRisk = new Model.HSSE_ConstructionRisk();
|
||||
newConstructionRisk.ConstructionRiskId = SQLHelper.GetNewID(typeof(Model.HSSE_ConstructionRisk));
|
||||
|
||||
if (des != row4)
|
||||
newConstructionRisk.ProjectId = this.CurrUser.LoginProjectId;
|
||||
if (unit != null)
|
||||
{
|
||||
index = 1;
|
||||
newConstructionRisk = new Model.HSSE_ConstructionRisk();
|
||||
newConstructionRisk.ConstructionRiskId = SQLHelper.GetNewID(typeof(Model.HSSE_ConstructionRisk));
|
||||
|
||||
newConstructionRisk.ProjectId = this.CurrUser.LoginProjectId;
|
||||
newConstructionRisk.UnitId = unit.UnitId;
|
||||
newConstructionRisk.WorkAreaId = unitWork.UnitWorkId;
|
||||
try
|
||||
{
|
||||
newConstructionRisk.DateA = Funs.GetNewDateTime(row0);
|
||||
|
||||
newConstructionRisk.DateWeek = newConstructionRisk.DateA.Value.ToString("yyyy年") + Funs.GetWeekOfYear(newConstructionRisk.DateA.Value)+"周";
|
||||
}
|
||||
catch (Exception e) { }
|
||||
try
|
||||
{
|
||||
newConstructionRisk.DateZ = Funs.GetNewDateTime(row1);
|
||||
}
|
||||
catch (Exception e) { }
|
||||
newConstructionRisk.ConstructionContent = row4;
|
||||
newConstructionRisk.RefLicense = row5;
|
||||
newConstructionRisk.LicenseDes = row6;
|
||||
newConstructionRisk.RiskLevel = row7;
|
||||
Funs.DB.HSSE_ConstructionRisk.InsertOnSubmit(newConstructionRisk);
|
||||
des = row4;
|
||||
}
|
||||
if (mainItem != null)
|
||||
{
|
||||
newConstructionRisk.WorkAreaId = mainItem.MainItemId;
|
||||
}
|
||||
try
|
||||
{
|
||||
newConstructionRisk.DateA = Funs.GetNewDateTime(row0);
|
||||
|
||||
Model.HSSE_ConstructionRiskControl constructionRiskControl = new Model.HSSE_ConstructionRiskControl();
|
||||
constructionRiskControl.ControlId = SQLHelper.GetNewID(typeof(Model.HSSE_ConstructionRiskControl));
|
||||
constructionRiskControl.ConstructionRiskId = newConstructionRisk.ConstructionRiskId;
|
||||
constructionRiskControl.Measures = row8;
|
||||
constructionRiskControl.ShowIndex = index;
|
||||
Funs.DB.HSSE_ConstructionRiskControl.InsertOnSubmit(constructionRiskControl);
|
||||
|
||||
|
||||
newConstructionRisk.DateWeek = newConstructionRisk.DateA.Value.ToString("yyyy年") + Funs.GetWeekOfYear(newConstructionRisk.DateA.Value) + "周";
|
||||
}
|
||||
catch (Exception e) { }
|
||||
try
|
||||
{
|
||||
newConstructionRisk.DateZ = Funs.GetNewDateTime(row1);
|
||||
}
|
||||
catch (Exception e) { }
|
||||
newConstructionRisk.ConstructionContent = row4;
|
||||
if (subDutyPerson != null)
|
||||
{
|
||||
newConstructionRisk.SubUnitDutyPerson = subDutyPerson.PersonId;
|
||||
}
|
||||
string refLicense = string.Empty;
|
||||
string[] refLicenses = row6.Split('|');
|
||||
foreach (var item in refLicenses)
|
||||
{
|
||||
var licenseType = licenseTypes.FirstOrDefault(x => x.LicenseTypeName == item);
|
||||
if (licenseType != null)
|
||||
{
|
||||
refLicense += item + ",";
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(refLicense))
|
||||
{
|
||||
newConstructionRisk.RefLicense = refLicense.Substring(0, refLicense.Length - 1);
|
||||
}
|
||||
string licenseDes = string.Empty;
|
||||
string[] licenseDess = row7.Split('|');
|
||||
foreach (var item in licenseDess)
|
||||
{
|
||||
var des = licenseDesList.FirstOrDefault(x => x.Text == item);
|
||||
if (des != null)
|
||||
{
|
||||
licenseDes += item + ",";
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(licenseDes))
|
||||
{
|
||||
newConstructionRisk.LicenseDes = licenseDes.Substring(0, licenseDes.Length - 1);
|
||||
}
|
||||
newConstructionRisk.RiskLevel = row8;
|
||||
newConstructionRisk.States= BLL.Const.ConstructionRisk_Compile;
|
||||
Funs.DB.HSSE_ConstructionRisk.InsertOnSubmit(newConstructionRisk);
|
||||
string[] riskControls = row9.Split('|');
|
||||
int a = 0;
|
||||
foreach (var item in riskControls)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item))
|
||||
{
|
||||
Model.HSSE_ConstructionRiskControl constructionRiskControl = new Model.HSSE_ConstructionRiskControl();
|
||||
constructionRiskControl.ControlId = SQLHelper.GetNewID(typeof(Model.HSSE_ConstructionRiskControl));
|
||||
constructionRiskControl.ConstructionRiskId = newConstructionRisk.ConstructionRiskId;
|
||||
constructionRiskControl.Measures = item;
|
||||
constructionRiskControl.ShowIndex = a;
|
||||
Funs.DB.HSSE_ConstructionRiskControl.InsertOnSubmit(constructionRiskControl);
|
||||
}
|
||||
a++;
|
||||
}
|
||||
Model.HSSE_ConstructionRiskApprove approve1 = new Model.HSSE_ConstructionRiskApprove();
|
||||
approve1.ConstructionRiskApproveId = SQLHelper.GetNewID();
|
||||
approve1.ConstructionRiskId = newConstructionRisk.ConstructionRiskId;
|
||||
approve1.ApproveMan = this.CurrUser.PersonId;
|
||||
approve1.ApproveType = BLL.Const.ConstructionRisk_Compile;
|
||||
Funs.DB.HSSE_ConstructionRiskApprove.InsertOnSubmit(approve1);
|
||||
}
|
||||
Funs.DB.SubmitChanges();
|
||||
ShowNotify("导入成功!", MessageBoxIcon.Success);
|
||||
|
||||
Reference in New Issue
Block a user