修改质量综合管理导入及页面显示

This commit is contained in:
2023-06-26 11:16:55 +08:00
parent 966843abbe
commit f1c55719b3
35 changed files with 2194 additions and 501 deletions
@@ -96,22 +96,21 @@ namespace FineUIPro.Web.CQMS.Comprehensive
/// <param name="filename">Excel文件路径名</param>
private void ImportXlsToData(string fileName)
{
//支持.xls和.xlsx,即包括office2010等版本的 HDR=Yes代表第一行是标题,不是数据;
string cmdText = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='Excel 12.0; HDR=Yes; IMEX=1'";
//建立连接
OleDbConnection conn = new OleDbConnection(string.Format(cmdText, fileName));
try
{
//打开连接
if (conn.State == ConnectionState.Broken || conn.State == ConnectionState.Closed)
{
conn.Open();
}
string oleDBConnString = String.Empty;
oleDBConnString = "Provider=Microsoft.Jet.OLEDB.4.0;";
oleDBConnString += "Data Source=";
oleDBConnString += fileName;
oleDBConnString += ";Extended Properties=Excel 8.0;";
OleDbConnection oleDBConn = null;
OleDbDataAdapter oleAdMaster = null;
DataTable m_tableName = new DataTable();
DataSet ds = new DataSet();
m_tableName = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
oleDBConn = new OleDbConnection(oleDBConnString);
oleDBConn.Open();
m_tableName = oleDBConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
if (m_tableName != null && m_tableName.Rows.Count > 0)
{
@@ -121,13 +120,13 @@ namespace FineUIPro.Web.CQMS.Comprehensive
}
string sqlMaster;
sqlMaster = " SELECT * FROM [" + m_tableName.TableName + "]";
oleAdMaster = new OleDbDataAdapter(sqlMaster, conn);
oleAdMaster = new OleDbDataAdapter(sqlMaster, oleDBConn);
oleAdMaster.Fill(ds, "m_tableName");
oleAdMaster.Dispose();
conn.Close();
conn.Dispose();
oleDBConn.Close();
oleDBConn.Dispose();
AddDatasetToSQL(ds.Tables[0], 13);
AddDatasetToSQL(ds.Tables[0], 12);
hdCheckResult.Text = "1";
}
catch (Exception exc)
@@ -138,8 +137,6 @@ namespace FineUIPro.Web.CQMS.Comprehensive
}
finally
{
conn.Close();
conn.Dispose();
}
}
#endregion
@@ -202,23 +199,36 @@ namespace FineUIPro.Web.CQMS.Comprehensive
result += (i + 2).ToString() + "," + "姓名" + "," + "此项为必填项!" + "|";
}
string row4 = pds.Rows[i][4].ToString();
if (!string.IsNullOrEmpty(row4))
string row3 = pds.Rows[i][3].ToString();
if (!string.IsNullOrEmpty(row3))
{
var cn = cns.Where(x => x.ProfessionalName == row4.Trim()).FirstOrDefault();
var cn = cns.Where(x => x.ProfessionalName == row3.Trim()).FirstOrDefault();
if (cn == null)
{
result += (i + 2).ToString() + "," + "专业名称" + "," + "[" + row4 + "]不存在!" + "|";
result += (i + 2).ToString() + "," + "专业名称" + "," + "[" + row3 + "]不存在!" + "|";
}
}
string row5 = pds.Rows[i][5].ToString();
if (!string.IsNullOrEmpty(row5))
string row4 = pds.Rows[i][4].ToString();
if (!string.IsNullOrEmpty(row4))
{
var post = posts.Where(x => x.PostName == row5.Trim()).FirstOrDefault();
var post = posts.Where(x => x.PostName == row4.Trim()).FirstOrDefault();
if (post == null)
{
result += (i + 2).ToString() + "," + "工种" + "," + "[" + row5 + "]不存在!" + "|";
result += (i + 2).ToString() + "," + "工种" + "," + "[" + row4 + "]不存在!" + "|";
}
}
string row7 = pds.Rows[i][7].ToString();
if (!string.IsNullOrEmpty(row7))
{
try
{
DateTime date = Convert.ToDateTime(row7.Trim());
}
catch (Exception)
{
result += (i + 2).ToString() + "," + "有效期" + "," + "[" + row7 + "]错误!" + "|";
}
}
@@ -231,42 +241,29 @@ namespace FineUIPro.Web.CQMS.Comprehensive
}
catch (Exception)
{
result += (i + 2).ToString() + "," + "有效期" + "," + "[" + row8 + "]错误!" + "|";
result += (i + 2).ToString() + "," + "批准时间" + "," + "[" + row8 + "]错误!" + "|";
}
}
string row9 = pds.Rows[i][9].ToString();
string row9 = pds.Rows[i][9].ToString().Trim();
if (!string.IsNullOrEmpty(row9))
{
try
if (row9 != "是" && row9 != "否")
{
DateTime date = Convert.ToDateTime(row9.Trim());
}
catch (Exception)
{
result += (i + 2).ToString() + "," + "批准时间" + "," + "[" + row9 + "]错误!" + "|";
result += (i + 2).ToString() + "," + "是否在场" + "," + "[" + row9 + "]错误!" + "|";
}
}
string row10 = pds.Rows[i][10].ToString().Trim();
string row10 = pds.Rows[i][10].ToString();
if (!string.IsNullOrEmpty(row10))
{
if (row10 != "是" && row10 != "否")
{
result += (i + 2).ToString() + "," + "是否在场" + "," + "[" + row10 + "]错误!" + "|";
}
}
string row11 = pds.Rows[i][11].ToString();
if (!string.IsNullOrEmpty(row11))
{
try
{
DateTime date = Convert.ToDateTime(row11.Trim());
DateTime date = Convert.ToDateTime(row10.Trim());
}
catch (Exception)
{
result += (i + 2).ToString() + "," + "离场时间" + "," + "[" + row11 + "]错误!" + "|";
result += (i + 2).ToString() + "," + "离场时间" + "," + "[" + row10 + "]错误!" + "|";
}
}
@@ -336,6 +333,8 @@ namespace FineUIPro.Web.CQMS.Comprehensive
string rootPath = Server.MapPath("~/");
ImportXlsToData2(rootPath + initPath + this.hdFileName.Text);
hdCheckResult.Text = string.Empty;
ShowNotify("导入成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
else
{
@@ -355,21 +354,21 @@ namespace FineUIPro.Web.CQMS.Comprehensive
/// <param name="filename">Excel文件路径名</param>
private void ImportXlsToData2(string fileName)
{
//支持.xls和.xlsx,即包括office2010等版本的 HDR=Yes代表第一行是标题,不是数据;
string cmdText = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='Excel 12.0; HDR=Yes; IMEX=1'";
//建立连接
OleDbConnection conn = new OleDbConnection(string.Format(cmdText, fileName));
try
{
//打开连接
if (conn.State == ConnectionState.Broken || conn.State == ConnectionState.Closed)
{
conn.Open();
}
string oleDBConnString = String.Empty;
oleDBConnString = "Provider=Microsoft.Jet.OLEDB.4.0;";
oleDBConnString += "Data Source=";
oleDBConnString += fileName;
oleDBConnString += ";Extended Properties=Excel 8.0;";
OleDbConnection oleDBConn = null;
OleDbDataAdapter oleAdMaster = null;
DataTable m_tableName = new DataTable();
DataSet ds = new DataSet();
m_tableName = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
oleDBConn = new OleDbConnection(oleDBConnString);
oleDBConn.Open();
m_tableName = oleDBConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
if (m_tableName != null && m_tableName.Rows.Count > 0)
{
@@ -379,13 +378,13 @@ namespace FineUIPro.Web.CQMS.Comprehensive
}
string sqlMaster;
sqlMaster = " SELECT * FROM [" + m_tableName.TableName + "]";
oleAdMaster = new OleDbDataAdapter(sqlMaster, conn);
oleAdMaster = new OleDbDataAdapter(sqlMaster, oleDBConn);
oleAdMaster.Fill(ds, "m_tableName");
oleAdMaster.Dispose();
conn.Close();
conn.Dispose();
oleDBConn.Close();
oleDBConn.Dispose();
AddDatasetToSQL2(ds.Tables[0], 13);
AddDatasetToSQL2(ds.Tables[0], 12);
}
catch (Exception ex)
{
@@ -443,45 +442,46 @@ namespace FineUIPro.Web.CQMS.Comprehensive
Ins.UnitId = unitInfo.UnitId;
Ins.InspectionPersonCode = pds.Rows[i][1].ToString().Trim();
Ins.PersonName = pds.Rows[i][2].ToString().Trim();
if (!string.IsNullOrEmpty(pds.Rows[i][3].ToString().Trim()))
{
Ins.CNProfessionalId = Funs.DB.Base_CNProfessional.First(e => e.ProfessionalName == pds.Rows[i][3].ToString().Trim()).CNProfessionalId;
}
if (!string.IsNullOrEmpty(pds.Rows[i][4].ToString().Trim()))
{
Ins.CNProfessionalId = Funs.DB.Base_CNProfessional.First(e => e.ProfessionalName == pds.Rows[i][4].ToString().Trim()).CNProfessionalId;
Ins.PostId = Funs.DB.Base_Post.First(e => e.PostName == pds.Rows[i][4].ToString().Trim()).PostId;
}
if (!string.IsNullOrEmpty(pds.Rows[i][5].ToString().Trim()))
Ins.CertificateNumber = pds.Rows[i][5].ToString().Trim();
Ins.QualifiedProjectCode = pds.Rows[i][6].ToString().Trim();
if (!string.IsNullOrEmpty(pds.Rows[i][7].ToString().Trim()))
{
Ins.PostId = Funs.DB.Base_Post.First(e => e.PostName == pds.Rows[i][5].ToString().Trim()).PostId;
Ins.ValidityDate = Convert.ToDateTime(pds.Rows[i][7].ToString().Trim());
}
Ins.CertificateNumber = pds.Rows[i][6].ToString().Trim();
Ins.QualifiedProjectCode = pds.Rows[i][7].ToString().Trim();
if (!string.IsNullOrEmpty(pds.Rows[i][8].ToString().Trim()))
{
Ins.ValidityDate = Convert.ToDateTime(pds.Rows[i][8].ToString().Trim());
Ins.ApprovalTime = Convert.ToDateTime(pds.Rows[i][8].ToString().Trim());
}
Ins.IsOnSite = pds.Rows[i][9].ToString().Trim() == "是" ? true : false;
if (!string.IsNullOrEmpty(pds.Rows[i][9].ToString().Trim()))
if (!string.IsNullOrEmpty(pds.Rows[i][10].ToString().Trim()))
{
Ins.ApprovalTime = Convert.ToDateTime(pds.Rows[i][9].ToString().Trim());
Ins.DepartureTime = Convert.ToDateTime(pds.Rows[i][10].ToString().Trim());
}
Ins.IsOnSite = pds.Rows[i][10].ToString().Trim() == "是" ? true : false;
if (!string.IsNullOrEmpty(pds.Rows[i][11].ToString().Trim()))
{
Ins.DepartureTime = Convert.ToDateTime(pds.Rows[i][11].ToString().Trim());
}
Ins.Remark = pds.Rows[i][12].ToString().Trim();
Ins.Remark = pds.Rows[i][11].ToString().Trim();
Ins.InspectionPersonId = SQLHelper.GetNewID(typeof(Model.Comprehensive_InspectionPerson));
Ins.CompileMan = this.CurrUser.UserId;
Ins.CompileDate = DateTime.Now.Date;
Ins.IsTrain = true;
BLL.InspectionPersonService.AddInspectionPerson(Ins);
if (pds.Rows[i][4].ToString().Trim() == "焊工")
{
Model.BS_Welder welder = new Model.BS_Welder();
welder.WED_Unit = Ins.UnitId;
welder.WED_Name = Ins.PersonName;
welder.WED_Code = pds.Rows[i][3].ToString().Trim();
welder.WED_Code = pds.Rows[i][1].ToString().Trim();
welder.LimitDate = Ins.ValidityDate;
welder.LeaveDate = Ins.DepartureTime; // Convert.ToDateTime(this.txtDepartureTime.Text.ToString());
welder.PostDate = Ins.ApprovalTime;// Convert.ToDateTime(this.txtApprovalTime.Text.ToString());