Esempio n. 1
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;
            }
        }
Esempio n. 2
0
        protected override EventJournal doGet(int ID)
        {
            m_command.CommandText = Receipt.GetByIDSQL(ID);
            MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader();
            Receipt st = Receipt.TransformReader(r);

            r.Close();
            if (st == null)
            {
                return(null);
            }
            m_command.CommandText = ReceiptItem.GetByEventIDSQL(ID);
            r = m_command.ExecuteReader();
            IList stis = ReceiptItem.TransformReaderList(r);

            r.Close();
            foreach (ReceiptItem sti in stis)
            {
                sti.EVENT_JOURNAL = st;
                //sti.VENDOR = PartRepository.GetByID(m_command, sti.PART.ID);
                sti.VENDOR_BALANCE_ENTRY = VendorBalanceEntryRepository.FindVendorBalanceEntryByEventItem(m_command, sti.ID, sti.VENDOR_BALANCE_ENTRY_TYPE);
                //sti.GRN_ITEM = GoodReceiveNoteRepository.FindGoodReceiveNoteItem(m_command, sti.GRN_ITEM.ID);
                //sti.GRN_ITEM.PART = PartRepository.GetByID(m_command, sti.GRN_ITEM.PART.ID);
                if (sti.VENDOR_BALANCE_CUSTOMER_INVOICE_TYPE == VendorBalanceEntryType.CustomerInvoice)
                {
                    if (sti.CUSTOMER_INVOICE_JOURNAL_ITEM != null)
                    {
                        sti.CUSTOMER_INVOICE_JOURNAL_ITEM = CustomerInvoiceJournalRepository.FindCIJournalItemlistForReceipt(m_command, sti.CUSTOMER_INVOICE_JOURNAL_ITEM.GetID());
                    }
                }
                if (sti.VENDOR_BALANCE_CUSTOMER_INVOICE_TYPE == VendorBalanceEntryType.CustomerOutStandingInvoice)
                {
                    if (sti.CUSTOMER_INVOICE_JOURNAL_ITEM != null)
                    {
                        sti.CUSTOMER_INVOICE_JOURNAL_ITEM = CustomerOutStandingInvoiceRepository.FindCOIItemlistForReceipt(m_command, sti.CUSTOMER_INVOICE_JOURNAL_ITEM.GetID());
                    }
                }
                if (sti.PAYMENT_TYPE == ReceiptType.Bank)
                {
                    sti.BANK = getBank(sti.BANK.ID);
                }
                if (sti.PAYMENT_TYPE == ReceiptType.ARCreditNote)
                {
                    sti.AR_CREDIT_NOTE = ARCreditNoteRepository.FindARCRForReceipt(m_command, sti.AR_CREDIT_NOTE.ID);
                }
                st.EVENT_JOURNAL_ITEMS.Add(sti);
            }
            return(st);
        }
Esempio n. 3
0
        internal static IList FindReceiptUsingARCR(MySql.Data.MySqlClient.MySqlCommand cmd, int apDNID)
        {
            cmd.CommandText = ReceiptItem.GetReceiptItemByARCR(apDNID);
            MySql.Data.MySqlClient.MySqlDataReader r = cmd.ExecuteReader();
            IList result = ReceiptItem.TransformReaderList(r);

            r.Close();
            foreach (ReceiptItem i in result)
            {
                cmd.CommandText = Receipt.GetByIDSQL(i.EVENT_JOURNAL.ID);
                r = cmd.ExecuteReader();
                i.EVENT_JOURNAL = Receipt.TransformReader(r);
                r.Close();
            }
            return(result);
        }
Esempio n. 4
0
        internal static IList FindPaidCustomerInvoice(MySql.Data.MySqlClient.MySqlCommand cmd, int siID)
        {
            cmd.CommandText = ReceiptItem.GetCustomerInvoiceBySOIID(siID, VendorBalanceEntryType.CustomerInvoice);
            MySql.Data.MySqlClient.MySqlDataReader r = cmd.ExecuteReader();
            IList result = ReceiptItem.TransformReaderList(r);

            r.Close();
            foreach (ReceiptItem i in result)
            {
                cmd.CommandText = Receipt.GetByIDSQL(i.EVENT_JOURNAL.ID);
                r = cmd.ExecuteReader();
                i.EVENT_JOURNAL = Receipt.TransformReader(r);
                r.Close();
            }
            return(result);
        }