protected override void doSave(Event e)
 {
     MySql.Data.MySqlClient.MySqlTransaction trc = m_connection.BeginTransaction();
     try
     {
         m_command.Transaction = trc;
         DateTime trDate     = DateTime.Today;
         string   codesample = AutoNumberSetupRepository.GetCodeSampleByDomainName(m_command, "SupplierInvoice");
         Event    codeDate   = FindLastCodeAndTransactionDate(codesample);
         string   lastCode   = codeDate == null ? string.Empty : codeDate.CODE;
         DateTime lastDate   = codeDate == null ? trDate : codeDate.TRANSACTION_DATE;
         int      trCount    = RecordCount();
         e.CODE = AutoNumberSetupRepository.GetAutoNumberByDomainName(m_command, "SupplierInvoice", e.CODE, lastCode, lastDate, trDate, trCount == 0);
         SupplierInvoice stk = (SupplierInvoice)e;
         m_command.CommandText = e.GetInsertSQL();
         m_command.ExecuteNonQuery();
         m_command.CommandText = SupplierInvoice.SelectMaxIDSQL();
         stk.ID = Convert.ToInt32(m_command.ExecuteScalar());
         foreach (SupplierInvoiceItem item in stk.EVENT_ITEMS)
         {
             item.PART.UNIT_CONVERSION_LIST = PartRepository.GetUnitConversionsStatic(m_command, item.PART.ID);
             m_command.CommandText          = item.GetInsertSQL();
             m_command.ExecuteNonQuery();
             m_command.CommandText = SupplierInvoiceItem.SelectMaxIDSQL();
             item.ID = Convert.ToInt32(m_command.ExecuteScalar());
         }
         trc.Commit();
     }
     catch (Exception x)
     {
         e.ID = 0;
         foreach (EventItem item in e.EVENT_ITEMS)
         {
             item.ID = 0;
         }
         trc.Rollback();
         throw x;
     }
 }
        protected override void doUpdate(Event en)
        {
            MySql.Data.MySqlClient.MySqlTransaction trc = m_connection.BeginTransaction();
            m_command.Transaction = trc;
            try
            {
                SupplierInvoice e = (SupplierInvoice)en;
                m_command.CommandText = e.GetUpdateSQL();
                m_command.ExecuteNonQuery();

                foreach (SupplierInvoiceItem sti in e.EVENT_ITEMS)
                {
                    sti.PART.UNIT_CONVERSION_LIST = PartRepository.GetUnitConversionsStatic(m_command, sti.PART.ID);
                    if (sti.ID > 0)
                    {
                        m_command.CommandText = sti.GetUpdateSQL();
                        m_command.ExecuteNonQuery();
                    }
                    else
                    {
                        m_command.CommandText = sti.GetInsertSQL();
                        m_command.ExecuteNonQuery();
                        m_command.CommandText = SupplierInvoiceItem.SelectMaxIDSQL();
                        sti.ID = Convert.ToInt32(m_command.ExecuteScalar());
                    }
                }
                m_command.CommandText = SupplierInvoiceItem.DeleteUpdate(e.ID, e.EVENT_ITEMS);
                m_command.ExecuteNonQuery();
                trc.Commit();
            }
            catch (Exception x)
            {
                trc.Rollback();
                throw x;
            }
        }