Example #1
0
        private ProcessingResult DeleteDocTemplate(int id)
        {
            ProcessingResult pr         = new ProcessingResult();
            SqlConnection    connection = new SqlConnection(Config.ConnectionString);

            try
            {
                connection.Open();
                SqlTransaction trans = null;
                try
                {
                    trans = connection.BeginTransaction();

                    DocTemplate docTemplate = new DocTemplate(trans, id, UserName);

                    DocTemplate.Delete(trans, docTemplate.ID, UserName);

                    Destination.Delete(trans, docTemplate.DocumentID, UserName);
                    Source.Delete(trans, docTemplate.DocumentID, UserName);

                    DocumentFile.DeleteFiles(trans, docTemplate.DocumentID, Worker);

                    Document.Document.Delete(trans, docTemplate.DocumentID, UserName);

                    trans.Commit();

                    pr.Success = true;
                }
                catch (Exception e)
                {
                    if (trans != null)
                    {
                        trans.Rollback();
                    }

                    pr.Message = e.Message;
                    throw;
                }
            }
            finally
            {
                connection.Close();
            }
            return(pr);
        }