using System; using System.Collections.Generic; using System.Text; using System.Data; using System.Data.Common; using System.Data.OleDb; using System.Data.SqlClient; //Temp using System.Windows.Forms; using System.Diagnostics; namespace cs_XQuest_TPMC.Common { class rscImporter { DbProviderFactory DataFactory; DbConnection DataConnection; DbCommand DataCommand; DbDataReader DataReader; SqlConnection SQLConnection; SqlCommand SQLCommand; DateTime DateStamp; public rscImporter() { } public void importFile(string fileType, string fileName) { if(fileType.ToUpper() == "EXCEL") { string Excel_connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileName + ";Extended Properties='Excel 8.0;HDR=Yes;IMEX=1'"; DataFactory = DbProviderFactories.GetFactory("System.Data.OleDb"); DataConnection = DataFactory.CreateConnection(); DataConnection.ConnectionString = Excel_connectionString; } SQLConnection = new SqlConnection(Properties.Settings.Default["TPMCSCString"].ToString()); if(Properties.app.Default["appDebug"].ToString().ToUpper() == "TRUE") { //MessageBox.Show(); } } public void importMode(string importType) { if(importType == "LCC") { using (DataCommand = DataConnection.CreateCommand()) { SQLCommand = SQLConnection.CreateCommand(); DataCommand.CommandText = "SELECT citemcode, clcc FROM [LCC$]"; //SQL Statement DataConnection.Open(); SQLConnection.Open(); using (DataReader = DataCommand.ExecuteReader()) { while (DataReader.Read()) { if (DataReader["clcc"].ToString() != "") { SQLCommand.CommandText = "INSERT INTO rscLCC (LocalCollectiveCode, SpecificCode)" + " VALUES ('" + DataReader["clcc"].ToString().Trim() + "', '" + DataReader["citemcode"].ToString().Trim() + "')"; //MessageBox.Show(SQLCommand.CommandText); DateStamp = DateTime.Now; Debug.WriteLine("\n" + SQLCommand.CommandText); Debug.WriteLine(DateStamp.ToString()); Debug.WriteLine(DataReader["clcc"].ToString().Trim()); Debug.WriteLine(DataReader["citemcode"].ToString().Trim()); SQLCommand.ExecuteNonQuery(); Debug.WriteLine(SQLCommand.ExecuteNonQuery().ToString()); //Debug.WriteLine(dr["ID"].ToString()); } } } DataConnection.Close(); SQLConnection.Close(); } } if (importType == "LGC") { } if (importType == "ActSpec") { } } } }