public void Insert(Dictionary<string, string> dictionary, TablesNames tableName) { TableInform table; DbConnection connection; DataRow result; table = new TableInform(tableName.ToString()); connection = TableInform.Connection; result = table.ConvertDictToRow(dictionary); table.Table.Rows.Add(result); table.Update(new DataRow[] { result }); }
public void Delete(Dictionary<string, string> dictionary, TablesNames tableName) { TableInform table; DbConnection connection; DataRow row; string IdValue; IdValue = null; table = new TableInform(tableName.ToString()); table.Table.PrimaryKey = new DataColumn[] { table.Table.Columns["Id"] }; connection = TableInform.Connection; if (dictionary.TryGetValue("Id", out IdValue)) { row = table.Table.Rows.Find(IdValue); row.Delete(); table.Update(new DataRow[] { row }); } }
public void Update(Dictionary<string, string> dictionary, TablesNames tableName) { TableInform table; DbConnection connection; string IdValue; DataRow row; IdValue = null; table = new TableInform(tableName.ToString()); connection = TableInform.Connection; table.Table.PrimaryKey = new DataColumn[] { table.Table.Columns["Id"] }; if (dictionary.TryGetValue("Id", out IdValue)) { row = table.Table.Rows.Find(IdValue); foreach (KeyValuePair<string, string> pair in dictionary) { row[pair.Key] = pair.Value; } table.Update(new DataRow[] { row }); } }