private static int Update(Project item) { Project.DoSqlSomething( "UPDATE Project SET Name = '" + item.Name.Replace("'", "''") + "', ConnectionStringSource = '" + item.ConnectionStringSource + "', ConnectionStringDestination = '" + item.ConnectionStringDestination + "', Type = " + ((int)item.Type).ToString() + " WHERE ProjectId = " + item.Id.ToString(), null); return(item.Id); }
private static int Add(Project item) { int maxId = 0; Project.DoSqlSomething( "SELECT MAX(ProjectId) AS NewId FROM Project WHERE Internal = 0", reader => maxId = int.Parse(reader["NewId"].ToString()), "INSERT INTO Project (Name, ConnectionStringSource, ConnectionStringDestination, Options, Type, Internal) VALUES ('" + item.Name.Replace("'", "''") + "','" + item.ConnectionStringSource + "','" + item.ConnectionStringDestination + "','" + item.Options + "'," + ((int)item.Type).ToString() + ",0)"); return(maxId); }
public static void SaveLastConfiguration(String ConnectionStringSource, String ConnectionStringDestination) { if (GetLastConfiguration() != null) { Project.DoSqlSomething("UPDATE Project SET ConnectionStringSource = '" + ConnectionStringSource + "', ConnectionStringDestination = '" + ConnectionStringDestination + "' WHERE Internal = 1", null); } else { Project.DoSqlSomething("INSERT INTO Project (Name, ConnectionStringSource, ConnectionStringDestination, Options, Type, Internal) VALUES ('LastConfiguration','" + ConnectionStringSource + "','" + ConnectionStringDestination + "','',1,1)", null); } }
public static Project GetLastConfiguration() { Project item = null; Project.DoSqlSomething( "SELECT * FROM Project WHERE Internal = 1 ORDER BY Name", reader => item = new Project { Id = int.Parse(reader["ProjectId"].ToString()), ConnectionStringSource = reader["ConnectionStringSource"].ToString(), ConnectionStringDestination = reader["ConnectionStringDestination"].ToString(), Type = (ProjectType)(long)reader["Type"], //Options = (SqlOption) reader["Options"], Name = reader["Name"].ToString() }); return(item); }
public static List <Project> GetAll() { List <Project> items = new List <Project>(); Project.DoSqlSomething( "SELECT * FROM Project WHERE Internal = 0 ORDER BY Name", reader => items.Add(new Project { Id = int.Parse(reader["ProjectId"].ToString()), ConnectionStringSource = reader["ConnectionStringSource"].ToString(), ConnectionStringDestination = reader["ConnectionStringDestination"].ToString(), Type = (ProjectType)(long)reader["Type"], //Options = (SqlOption) reader["Options"], Name = reader["Name"].ToString() })); return(items); }
public static void Delete(int Id) { Project.DoSqlSomething("DELETE FROM Project WHERE ProjectId = " + Id.ToString(), null); }