2023-04-28 天辰质量报验移植
This commit is contained in:
@@ -96,21 +96,22 @@ 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
|
||||
{
|
||||
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;
|
||||
//打开连接
|
||||
if (conn.State == ConnectionState.Broken || conn.State == ConnectionState.Closed)
|
||||
{
|
||||
conn.Open();
|
||||
}
|
||||
OleDbDataAdapter oleAdMaster = null;
|
||||
DataTable m_tableName = new DataTable();
|
||||
DataSet ds = new DataSet();
|
||||
|
||||
oleDBConn = new OleDbConnection(oleDBConnString);
|
||||
oleDBConn.Open();
|
||||
m_tableName = oleDBConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
|
||||
m_tableName = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
|
||||
|
||||
if (m_tableName != null && m_tableName.Rows.Count > 0)
|
||||
{
|
||||
@@ -120,13 +121,14 @@ namespace FineUIPro.Web.CQMS.Comprehensive
|
||||
}
|
||||
string sqlMaster;
|
||||
sqlMaster = " SELECT * FROM [" + m_tableName.TableName + "]";
|
||||
oleAdMaster = new OleDbDataAdapter(sqlMaster, oleDBConn);
|
||||
oleAdMaster = new OleDbDataAdapter(sqlMaster, conn);
|
||||
oleAdMaster.Fill(ds, "m_tableName");
|
||||
oleAdMaster.Dispose();
|
||||
oleDBConn.Close();
|
||||
oleDBConn.Dispose();
|
||||
hdCheckResult.Text = "1";
|
||||
conn.Close();
|
||||
conn.Dispose();
|
||||
|
||||
AddDatasetToSQL(ds.Tables[0], 12);
|
||||
hdCheckResult.Text = "1";
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
@@ -134,6 +136,11 @@ namespace FineUIPro.Web.CQMS.Comprehensive
|
||||
//return null;
|
||||
// return dt;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
conn.Dispose();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -187,32 +194,15 @@ namespace FineUIPro.Web.CQMS.Comprehensive
|
||||
result += (i + 2).ToString() + "," + "报验编号" + "," + "此项为必填项!" + "|";
|
||||
}
|
||||
|
||||
string row2 = pds.Rows[i][2].ToString();
|
||||
if (!string.IsNullOrEmpty(row2))
|
||||
{
|
||||
var cn = cns.Where(x => x.ProfessionalName == row2.Trim()).FirstOrDefault();
|
||||
if (cn == null)
|
||||
{
|
||||
result += (i + 2).ToString() + "," + "专业名称" + "," + "[" + row2 + "]不存在!" + "|";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result += (i + 2).ToString() + "," + "专业名称" + "," + "此项为必填项!" + "|";
|
||||
}
|
||||
|
||||
string row3 = pds.Rows[i][3].ToString().Trim();
|
||||
string row3 = pds.Rows[i][3].ToString();
|
||||
if (!string.IsNullOrEmpty(row3))
|
||||
{
|
||||
if (row3 != "设备" && row3 != "材料")
|
||||
var cn = cns.Where(x => x.ProfessionalName == row3.Trim()).FirstOrDefault();
|
||||
if (cn == null)
|
||||
{
|
||||
result += (i + 2).ToString() + "," + "设备/材料" + "," + "[" + row2 + "]错误!" + "|";
|
||||
result += (i + 2).ToString() + "," + "专业名称" + "," + "[" + row3 + "]不存在!" + "|";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result += (i + 2).ToString() + "," + "设备/材料" + "," + "此项为必填项!" + "|";
|
||||
}
|
||||
|
||||
string row9 = pds.Rows[i][9].ToString().Trim();
|
||||
if (!string.IsNullOrEmpty(row9))
|
||||
@@ -261,7 +251,6 @@ namespace FineUIPro.Web.CQMS.Comprehensive
|
||||
errorInfos.Clear();
|
||||
if (!string.IsNullOrEmpty(result))
|
||||
{
|
||||
|
||||
string results = result;
|
||||
List<string> errorInfoList = results.Split('|').ToList();
|
||||
foreach (var item in errorInfoList)
|
||||
@@ -309,7 +298,6 @@ namespace FineUIPro.Web.CQMS.Comprehensive
|
||||
string rootPath = Server.MapPath("~/");
|
||||
ImportXlsToData2(rootPath + initPath + this.hdFileName.Text);
|
||||
hdCheckResult.Text = string.Empty;
|
||||
ShowNotify("导入成功!", MessageBoxIcon.Success);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -329,21 +317,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
|
||||
{
|
||||
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;
|
||||
//打开连接
|
||||
if (conn.State == ConnectionState.Broken || conn.State == ConnectionState.Closed)
|
||||
{
|
||||
conn.Open();
|
||||
}
|
||||
OleDbDataAdapter oleAdMaster = null;
|
||||
DataTable m_tableName = new DataTable();
|
||||
DataSet ds = new DataSet();
|
||||
|
||||
oleDBConn = new OleDbConnection(oleDBConnString);
|
||||
oleDBConn.Open();
|
||||
m_tableName = oleDBConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
|
||||
m_tableName = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
|
||||
|
||||
if (m_tableName != null && m_tableName.Rows.Count > 0)
|
||||
{
|
||||
@@ -353,11 +341,11 @@ namespace FineUIPro.Web.CQMS.Comprehensive
|
||||
}
|
||||
string sqlMaster;
|
||||
sqlMaster = " SELECT * FROM [" + m_tableName.TableName + "]";
|
||||
oleAdMaster = new OleDbDataAdapter(sqlMaster, oleDBConn);
|
||||
oleAdMaster = new OleDbDataAdapter(sqlMaster, conn);
|
||||
oleAdMaster.Fill(ds, "m_tableName");
|
||||
oleAdMaster.Dispose();
|
||||
oleDBConn.Close();
|
||||
oleDBConn.Dispose();
|
||||
conn.Close();
|
||||
conn.Dispose();
|
||||
|
||||
AddDatasetToSQL2(ds.Tables[0], 12);
|
||||
}
|
||||
@@ -405,42 +393,42 @@ namespace FineUIPro.Web.CQMS.Comprehensive
|
||||
var unitInfo = units.Where(y => y.UnitName == row0).FirstOrDefault();
|
||||
if (unitInfo != null && !string.IsNullOrEmpty(row0))
|
||||
{
|
||||
//oldViewInfo = oldViewInfos.Where(x => x.UnitId == unitInfo.UnitId
|
||||
// && x.RemarkCode == pds.Rows[i][11].ToString().Trim()
|
||||
// ).FirstOrDefault();
|
||||
//if (oldViewInfo == null)
|
||||
//{
|
||||
Model.Comprehensive_InspectionEquipment Ins = new Model.Comprehensive_InspectionEquipment();
|
||||
Ins.ProjectId = this.CurrUser.LoginProjectId;
|
||||
Ins.UnitId = unitInfo.UnitId;
|
||||
Ins.InspectionCode = pds.Rows[i][1].ToString().Trim();
|
||||
if (!string.IsNullOrEmpty(pds.Rows[i][2].ToString().Trim()))
|
||||
oldViewInfo = oldViewInfos.Where(x => x.UnitId == unitInfo.UnitId
|
||||
&& x.RemarkCode == pds.Rows[i][11].ToString().Trim()
|
||||
).FirstOrDefault();
|
||||
if (oldViewInfo == null)
|
||||
{
|
||||
Ins.CNProfessionalId = Funs.DB.Base_CNProfessional.First(e => e.ProfessionalName == pds.Rows[i][2].ToString().Trim()).CNProfessionalId;
|
||||
}
|
||||
Ins.EquipmentOrMatail = pds.Rows[i][3].ToString().Trim();
|
||||
Ins.InspectionName = pds.Rows[i][4].ToString().Trim();
|
||||
Ins.Specifications = pds.Rows[i][5].ToString().Trim();
|
||||
Ins.Supplier = pds.Rows[i][6].ToString().Trim();
|
||||
Ins.Counts = pds.Rows[i][7].ToString().Trim();
|
||||
Ins.SamplingCount = pds.Rows[i][8].ToString().Trim();
|
||||
Ins.SamplingResult = pds.Rows[i][9].ToString().Trim() == "合格" ? "1" : "2";
|
||||
Model.Comprehensive_InspectionEquipment Ins = new Model.Comprehensive_InspectionEquipment();
|
||||
Ins.ProjectId = this.CurrUser.LoginProjectId;
|
||||
Ins.UnitId = unitInfo.UnitId;
|
||||
Ins.InspectionCode = pds.Rows[i][1].ToString().Trim();
|
||||
Ins.EquipmentNO = 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;
|
||||
}
|
||||
Ins.InspectionName = pds.Rows[i][4].ToString().Trim();
|
||||
Ins.Specifications = pds.Rows[i][5].ToString().Trim();
|
||||
Ins.Supplier = pds.Rows[i][6].ToString().Trim();
|
||||
Ins.Counts = pds.Rows[i][7].ToString().Trim();
|
||||
Ins.SamplingCount = pds.Rows[i][8].ToString().Trim();
|
||||
Ins.SamplingResult = pds.Rows[i][9].ToString().Trim() == "合格" ? "1" : "2";
|
||||
|
||||
if (!string.IsNullOrEmpty(pds.Rows[i][10].ToString().Trim()))
|
||||
if (!string.IsNullOrEmpty(pds.Rows[i][10].ToString().Trim()))
|
||||
{
|
||||
Ins.InspectionDate = Convert.ToDateTime(pds.Rows[i][10].ToString().Trim());
|
||||
}
|
||||
Ins.RemarkCode = pds.Rows[i][11].ToString().Trim();
|
||||
Ins.InspectionEquipmentId = SQLHelper.GetNewID(typeof(Model.Comprehensive_InspectionEquipment));
|
||||
Ins.CompileMan = this.CurrUser.UserId;
|
||||
Ins.CompileDate = DateTime.Now.Date;
|
||||
BLL.InspectionEquipmentService.AddInspectionEquipment(Ins);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Ins.InspectionDate = Convert.ToDateTime(pds.Rows[i][10].ToString().Trim());
|
||||
result += (i + 2).ToString() + "," + "报验编号" + "," + "该单位报验编号已存在!" + "|";
|
||||
}
|
||||
Ins.RemarkCode = pds.Rows[i][11].ToString().Trim();
|
||||
Ins.InspectionEquipmentId = SQLHelper.GetNewID(typeof(Model.Comprehensive_InspectionEquipment));
|
||||
Ins.CompileMan = this.CurrUser.UserId;
|
||||
Ins.CompileDate = DateTime.Now.Date;
|
||||
BLL.InspectionEquipmentService.AddInspectionEquipment(Ins);
|
||||
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// result += (i + 2).ToString() + "," + "报验编号" + "," + "该单位报验编号已存在!" + "|";
|
||||
//}
|
||||
}
|
||||
|
||||
else
|
||||
@@ -448,7 +436,7 @@ namespace FineUIPro.Web.CQMS.Comprehensive
|
||||
result += (i + 2).ToString() + "," + "单位名称" + "," + "[" + row0 + "]不存在!" + "|";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user