private void BillingEngine_AfterSave(object sender, EventArgs e)
{
    MercatorUi.Engine.Gescom.BillingEngine billingEngine = (MercatorUi.Engine.Gescom.BillingEngine)sender;

    using (SqlCommand sqlCom = new SqlCommand())
    {
        sqlCom.CommandText = @"
            update DOCLOCK set spid = @@SPID where (ident = @IDENT) and (spid = @SPID)
            update PIEDS_V set ...
            update DOCLOCK set spid = @SPID where (ident = @IDENT) and (spid = @@SPID) ".UnIndent(5);
        sqlCom.Parameters.AddWithValue("@SPID", MercatorUi.Globals.CurrentSpId);
        sqlCom.Parameters.AddWithValue("@IDENT", billingEngine.DocLockIdent).SqlDbType = SqlDbType.Char;
        sqlCom.Parameters.AddWithValue("@ID", billingEngine.Id).SqlDbType = SqlDbType.Char;
        sqlCom.Parameters.AddWithValue("@JOURNAL", billingEngine.Journal).SqlDbType = SqlDbType.Char;
        sqlCom.Parameters.AddWithValue("@PIECE", billingEngine.Piece);
        
        Api.SqlExec(MercatorUi.Globals.RepData, sqlCom);
    }
}