Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .vs/JobFairApp/v15/.suo
Binary file not shown.
8 changes: 8 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"ExpandedNodes": [
"",
"\\JobFairApp"
],
"SelectedNode": "\\JobFairApp\\JobFairApp.sln",
"PreviewInSolutionExplorer": false
}
Binary file modified .vs/slnx.sqlite
Binary file not shown.
Binary file modified JobFairApp/.vs/JobFairApp/v15/.suo
Binary file not shown.
Binary file modified JobFairApp/.vs/JobFairApp/v15/sqlite3/storage.ide
Binary file not shown.
80 changes: 16 additions & 64 deletions JobFairApp/JobFairApp/Classes/Candidate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,15 @@ public class Candidate : ISQLObject<Candidate>
public int ID = MySQLUtils.NullID;
public int PersonID = MySQLUtils.NullID;

private Person person;
public Person Person
{
get
{
if (PersonID != MySQLUtils.NullID)
{
if (person == null)
{
person = new Person().FromID(PersonID);
}

return person;
}
else throw new InvalidOperationException("No PersonID found!");
return new Person().FromID(PersonID);
}
set
{
person = value;
PersonID = person.ID;

//rematch ID
String query = "SELECT ID FROM Candidates WHERE PersonID = '" + PersonID + "'";

SqlConnection connection = new SqlConnection(MySQLUtils.ConnectionString);
connection.Open();

SqlCommand command = new SqlCommand();
command.CommandText = query;
command.CommandType = CommandType.Text;
command.Connection = connection;

SqlDataReader reader = command.ExecuteReader();
connection.Close();

ID = reader.GetInt32(0);
PersonID = value.ID;
}
}

Expand All @@ -74,7 +47,6 @@ public Candidate FromDataReader(SqlDataReader reader)
{
ID = reader.GetInt32(reader.GetOrdinal("ID"));
PersonID = reader.GetInt32(reader.GetOrdinal("PersonID"));
person = null;//in case this was called on an existing object

reader.Read();//advance reader because it may have other records

Expand All @@ -85,24 +57,13 @@ public Candidate FromDataRow(DataRow row)
{
ID = (int)row["ID"];
PersonID = (int)row["PersonID"];
person = null;//in case this was called on an existing object

return this;
}

public int Insert()
{
if (ID == MySQLUtils.NullID) return 0;
if (PersonID == MySQLUtils.NullID)
{
if (person != null)
person.Insert();
else//there's no person ... it ... it doesn't work
{
return 0;
}
PersonID = person.ID;
}
if (ID == MySQLUtils.NullID || PersonID == MySQLUtils.NullID) return 0;

String statement;
statement = "INSERT INTO Candidates (PersonID) VALUES" +
Expand All @@ -119,19 +80,19 @@ public int Insert()

int retValue = command.ExecuteNonQuery();

//created new entry, read new ID
if(ID == MySQLUtils.NullID)
{
command.CommandText = "SELECT ID FROM Candidates";
////created new entry, read new ID
//if(ID == MySQLUtils.NullID)
//{
// command.CommandText = "SELECT ID FROM Candidates";

SqlDataReader reader = command.ExecuteReader();
// SqlDataReader reader = command.ExecuteReader();

while(reader.HasRows)
{
ID = (int)reader[0];
reader.Read();
}
}
// while(reader.HasRows)
// {
// ID = (int)reader[0];
// reader.Read();
// }
//}

connection.Close();

Expand All @@ -140,17 +101,8 @@ public int Insert()

public int Set()
{
if (ID == MySQLUtils.NullID) return 0;
if (PersonID == MySQLUtils.NullID)
{
if (person != null)
person.Insert();
else//there's no person ... it ... it doesn't work
{
return 0;
}
PersonID = person.ID;
}
if (ID == MySQLUtils.NullID || PersonID == MySQLUtils.NullID) return 0;


String statement;
statement = "UPDATE Candidates SET " +
Expand Down
68 changes: 15 additions & 53 deletions JobFairApp/JobFairApp/Classes/Interviewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,15 @@ public class Interviewer : ISQLObject<Interviewer>
public int ID = MySQLUtils.NullID;
public int PersonID = MySQLUtils.NullID;

private Person person;
public Person Person
{
get
{
if (PersonID != MySQLUtils.NullID)
{
if (person == null)
{
person = new Person().FromID(PersonID);
}

return person;
}
else throw new InvalidOperationException("No PersonID found!");
return new Person().FromID(PersonID);
}
set
{
person = value;
PersonID = person.ID;

//rematch ID
String query = "SELECT ID FROM Interviewers WHERE PersonID = '" + PersonID + "'";

SqlConnection connection = new SqlConnection(MySQLUtils.ConnectionString);
connection.Open();

SqlCommand command = new SqlCommand();
command.CommandText = query;
command.CommandType = CommandType.Text;
command.Connection = connection;

SqlDataReader reader = command.ExecuteReader();
connection.Close();

ID = reader.GetInt32(0);
PersonID = value.ID;
}
}

Expand All @@ -74,7 +47,6 @@ public Interviewer FromDataReader(SqlDataReader reader)
{
ID = reader.GetInt32(reader.GetOrdinal("ID"));
PersonID = reader.GetInt32(reader.GetOrdinal("PersonID"));
person = null;//in case this was called on an existing object

reader.Read();//advance reader because it may have other records

Expand All @@ -85,23 +57,13 @@ public Interviewer FromDataRow(DataRow row)
{
ID = (int)row["ID"];
PersonID = (int)row["PersonID"];
person = null;//in case this was called on an existing object

return this;
}

public int Insert()
{
if (PersonID == MySQLUtils.NullID)
{
if (person != null)
person.Insert();
else//there's no person ... it ... it doesn't work
{
return 0;
}
PersonID = person.ID;
}
if (PersonID == MySQLUtils.NullID) return 0;

String statement;
statement = "INSERT INTO Interviewers (ID, PersonID) VALUES" +
Expand All @@ -120,20 +82,20 @@ public int Insert()

int retValue = command.ExecuteNonQuery();

if (ID == MySQLUtils.NullID)//created new entry - read last ID to get new ID
{
command.CommandText = "SELECT ID FROM Interviewers";
SqlDataReader IDs = command.ExecuteReader();
//if (ID == MySQLUtils.NullID)//created new entry - read last ID to get new ID
//{
// command.CommandText = "SELECT ID FROM Interviewers";
// SqlDataReader IDs = command.ExecuteReader();

int newID = 0;
while (IDs.HasRows)
{
newID = IDs.GetInt32(0);
IDs.Read();
}
// int newID = 0;
// while (IDs.HasRows)
// {
// newID = IDs.GetInt32(0);
// IDs.Read();
// }

ID = newID;
}
// ID = newID;
//}

connection.Close();

Expand Down
Loading