// This function saves the personnel data
public static bool SavePersonnel(string Database, string FirstName, string LastName,
string PayRate, string StartDate, string EndDate)
{
bool recordSaved;
// ** NEW ** Add your comments here
OleDbTransaction myTransaction = null;
try
{
// Add your comments here
OleDbConnection conn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + Database);
conn.Open();
OleDbCommand command = conn.CreateCommand();
string strSQL;
// ** NEW ** Add your comments here
myTransaction = conn.BeginTransaction();
command.Transaction = myTransaction;
// Add your comments here
strSQL = "Insert into tblPersonnel " +
"(FirstName, LastName) values ('" +
FirstName + "', '" + LastName + "')";
// Add your comments here
command.CommandType = CommandType.Text;
command.CommandText = strSQL;
// Add your comments here
command.ExecuteNonQuery();
// Add your comments here
strSQL = "Update tblPersonnel " +
"Set PayRate=" + PayRate + ", " +
"StartDate="" + StartDate + "", " +
"EndDate="" + EndDate + "" " +
"Where ID=(Select Max(ID) From tblPersonnel)";
// Add your comments here
command.CommandType = CommandType.Text;
command.CommandText = strSQL;
// Add your comments here
command.ExecuteNonQuery();
// ** NEW ** Add your comments here
myTransaction.Commit();
// Add your comments here
conn.Close();
recordSaved = true;
}
catch (Exception ex)
{
// ** NEW ** Add your comments here
myTransaction.Rollback();
recordSaved = false;
}
return recordSaved;
}