///
/// Override the ${Copy Button}_Click and get selected records
/// and create new database records.
///
public override void ${Copy Button}_Click(object sender, EventArgs args)
{
try
{
DbUtils.StartTransaction();
${Table Name}TableControlRow[] selectedRecords = this.GetSelectedRecordControls();
if ((selectedRecords.Length > 0))
{
foreach (${Table Name}TableControlRow ${Table Name}Rec in selectedRecords)
{
${${Table Name}RecordClassName} newRec = new ${${Table Name}RecordClassName}();
newRec = (${${Table Name}RecordClassName})${Table Name}Rec.GetRecord().CopyRecord();
newRec.Save();
}
DbUtils.CommitTransaction();
}
}
catch (Exception ex)
{
DbUtils.RollBackTransaction();
// Report the error message to the user
BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(this, "UNIQUE_SCRIPTKEY", ex.Message);
}
finally
{
DbUtils.EndTransaction();
}
}
|