Beispiel #1
0
        protected override void doUpdateNoTransaction(EventJournal en)
        {
            try
            {
                Receipt e = (Receipt)en;
                m_command.CommandText = e.GetUpdateSQL();
                m_command.ExecuteNonQuery();

                foreach (ReceiptItem sti in e.EVENT_JOURNAL_ITEMS)
                {
                    if (sti.ID > 0)
                    {
                        m_command.CommandText = sti.GetUpdateSQL();
                        m_command.ExecuteNonQuery();
                    }
                    else
                    {
                        m_command.CommandText = sti.GetInsertSQL();
                        m_command.ExecuteNonQuery();
                        m_command.CommandText = ReceiptItem.SelectMaxIDSQL();
                        sti.ID = Convert.ToInt32(m_command.ExecuteScalar());
                    }
                }
                m_command.CommandText = ReceiptItem.DeleteUpdate(e.ID, e.EVENT_JOURNAL_ITEMS);
                m_command.ExecuteNonQuery();
            }
            catch (Exception x)
            {
                throw x;
            }
        }
Beispiel #2
0
        protected override void doUpdate(EventJournal en)
        {
            MySql.Data.MySqlClient.MySqlTransaction trc = m_connection.BeginTransaction();
            m_command.Transaction = trc;
            try
            {
                Receipt e = (Receipt)en;
                m_command.CommandText = e.GetUpdateSQL();
                m_command.ExecuteNonQuery();

                foreach (ReceiptItem sti in e.EVENT_JOURNAL_ITEMS)
                {
                    sti.VENDOR_BALANCE_CUSTOMER_INVOICE_TYPE = sti.CUSTOMER_INVOICE_JOURNAL_ITEM.GET_EVENT_JOURNAL.VENDOR_BALANCE_ENTRY_TYPE;
                    if (sti.ID > 0)
                    {
                        m_command.CommandText = sti.GetUpdateSQL();
                        m_command.ExecuteNonQuery();
                    }
                    else
                    {
                        m_command.CommandText = sti.GetInsertSQL();
                        m_command.ExecuteNonQuery();
                        m_command.CommandText = ReceiptItem.SelectMaxIDSQL();
                        sti.ID = Convert.ToInt32(m_command.ExecuteScalar());
                    }
                    if (sti.PAYMENT_TYPE == ReceiptType.ARCreditNote)
                    {
                        m_command.CommandText = ARCreditNote.UpdateUsedForReceipt(sti.AR_CREDIT_NOTE.ID, true);
                        m_command.ExecuteNonQuery();
                    }
                }
                m_command.CommandText = ReceiptItem.GetNotInTypeARCR(e.ID, e.EVENT_JOURNAL_ITEMS);
                MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader();
                IList pymnts = ReceiptItem.TransformReaderList(r);
                r.Close();
                foreach (ReceiptItem itm in pymnts)
                {
                    m_command.CommandText = ARCreditNote.UpdateUsedForReceipt(itm.AR_CREDIT_NOTE.ID, false);
                    m_command.ExecuteNonQuery();
                }


                m_command.CommandText = ReceiptItem.DeleteUpdate(e.ID, e.EVENT_JOURNAL_ITEMS);
                m_command.ExecuteNonQuery();
                trc.Commit();
            }
            catch (Exception x)
            {
                trc.Rollback();
                throw x;
            }
        }