public cComponent() { FeedBackMessage = new cFeedBackMessage(true, this); }
public cFeedBackMessage AddNewWell(cWellForDatabase WellForDatabase) { cFeedBackMessage FeedBackMessage = new cFeedBackMessage(true,null); //string WellName = "\"" + WellForDatabase.PlateName + "_" + string WellName = "\"Wellx" + WellForDatabase.PosX + "x" + WellForDatabase.PosY + "\""; FeedBackMessage.Message = WellName; string sql = "CREATE TABLE " + WellName + " ( rowid INTEGER PRIMARY KEY"; foreach (string TmpDescValue in NamesDescriptors) sql += ", \"" + TmpDescValue + "\" REAL"; sql += ");"; SQLiteCommand cmdInsert = _SQLiteConnection.CreateCommand(); cmdInsert.CommandText = sql; try { cmdInsert.ExecuteNonQuery(); } catch(SQLiteException excep) { FeedBackMessage.Message += " : " + excep.Message; FeedBackMessage.IsSucceed = false; return FeedBackMessage; } cmdInsert.Dispose(); cmdInsert = null; SQLiteTransaction mytransaction = _SQLiteConnection.BeginTransaction(); SQLiteCommand mycommand = new SQLiteCommand(_SQLiteConnection); sql = "INSERT INTO " + WellName + " ("; int Idx = 0; foreach (string TmpDescValue in NamesDescriptors) { sql += "\"" + TmpDescValue + "\", "; } string TmpSql1 = sql; sql = TmpSql1.Remove(TmpSql1.Length - 2); sql += ") VALUES ( "; string FormattedSQLCmd = sql.Remove(sql.Length - 2) + ")"; foreach (string TmpDescValue in NamesDescriptors) sql += "?, "; FormattedSQLCmd = sql.Remove(sql.Length - 2) + " )"; mycommand.CommandText = FormattedSQLCmd; foreach (string TmpDescValue in NamesDescriptors) { SQLiteParameter Param = new SQLiteParameter(DbType.Double); mycommand.Parameters.Add(Param); } foreach (List<double> Signature in WellForDatabase.ListValues) { Idx = 0; foreach (double Value in Signature) { mycommand.Parameters[Idx].Value = Value; Idx++; } mycommand.ExecuteNonQuery(); } mytransaction.Commit(); mycommand.Dispose(); mycommand = null; return FeedBackMessage; }