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

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,11 +120,11 @@ 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], 10);
hdCheckResult.Text = "1";
@@ -138,8 +137,7 @@ namespace FineUIPro.Web.CQMS.Comprehensive
}
finally
{
conn.Close();
conn.Dispose();
}
}
#endregion
@@ -303,6 +301,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
{
@@ -322,21 +322,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)
{
@@ -346,11 +346,11 @@ 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], 4);
}