예제 #1
0
        protected override void doUpdate(EventJournal en)
        {
            MySql.Data.MySqlClient.MySqlTransaction trc = m_connection.BeginTransaction();
            m_command.Transaction = trc;
            try
            {
                CustomerOutStandingInvoice e = (CustomerOutStandingInvoice)en;
                m_command.CommandText = e.GetUpdateSQL();
                m_command.ExecuteNonQuery();

                foreach (CustomerOutStandingInvoiceItem 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 = CustomerOutStandingInvoiceItem.SelectMaxIDSQL();
                        sti.ID = Convert.ToInt32(m_command.ExecuteScalar());
                    }
                }
                m_command.CommandText = CustomerOutStandingInvoiceItem.DeleteUpdate(e.ID, e.EVENT_JOURNAL_ITEMS);
                m_command.ExecuteNonQuery();
                trc.Commit();
            }
            catch (Exception x)
            {
                trc.Rollback();
                throw x;
            }
        }
예제 #2
0
        public static IList TransformReaderList(MySql.Data.MySqlClient.MySqlDataReader r)
        {
            IList result = new ArrayList();

            while (r.Read())
            {
                CustomerOutStandingInvoice tr = new CustomerOutStandingInvoice();
                tr.ID                        = Convert.ToInt32(r["costi_id"]);
                tr.CODE                      = r["costi_code"].ToString();
                tr.TRANSACTION_DATE          = Convert.ToDateTime(r["costi_date"]);
                tr.VENDOR                    = new Customer(Convert.ToInt32(r["cus_id"]));
                tr.CURRENCY                  = new Currency(Convert.ToInt32(r["ccy_id"]));
                tr.VENDOR_BALANCE_ENTRY_TYPE = VendorBalanceEntryType.CustomerOutStandingInvoice;
                tr.NOTES                     = r["costi_notes"].ToString();
                tr.POSTED                    = Convert.ToBoolean(r["costi_posted"]);
                tr.EVENT_STATUS              = (EventStatus)Enum.Parse(typeof(EventStatus), r["costi_eventstatus"].ToString());
                tr.SUBTOTAL_AMOUNT           = Convert.ToDouble(r["costi_subtotalamount"]);
                tr.DISC_PERCENT              = Convert.ToDouble(r["costi_discpercent"]);
                tr.AMOUNT_AFTER_DISC_PERCENT = Convert.ToDouble(r["costi_amountafterdiscpercent"]);
                tr.DISC_AMOUNT               = Convert.ToDouble(r["costi_discamount"]);
                tr.AMOUNT_AFTER_DISC_AMOUNT  = Convert.ToDouble(r["costi_amountafterdiscamount"]);
                tr.OTHER_EXPENSE             = Convert.ToDouble(r["costi_otherexpense"]);
                tr.NET_AMOUNT                = Convert.ToDouble(r["costi_netamount"]);
                tr.EMPLOYEE                  = new Employee(Convert.ToInt32(r["emp_id"]));
                tr.AGAINST_RECEIPT_STATUS    = (AgainstStatus)Enum.Parse(typeof(AgainstStatus), r["costi_againstreceiptstatus"].ToString());
                tr.MODIFIED_BY               = r["modified_by"].ToString();
                tr.MODIFIED_DATE             = Convert.ToDateTime(r["modified_date"].ToString());
                tr.MODIFIED_COMPUTER_NAME    = r["modified_computer"].ToString();
                result.Add(tr);
            }
            return(result);
        }
예제 #3
0
        internal static CustomerOutStandingInvoiceItem FindCOIItemlistForReceipt(MySql.Data.MySqlClient.MySqlCommand cmd, int supinvItemID)
        {
            cmd.CommandText = CustomerOutStandingInvoiceItem.GetByIDSQL(supinvItemID);
            MySql.Data.MySqlClient.MySqlDataReader r      = cmd.ExecuteReader();
            CustomerOutStandingInvoiceItem         result = CustomerOutStandingInvoiceItem.TransformReader(r);

            r.Close();
            cmd.CommandText = CustomerOutStandingInvoice.GetByIDSQL(result.EVENT_JOURNAL.ID);
            r = cmd.ExecuteReader();
            result.EVENT_JOURNAL = CustomerOutStandingInvoice.TransformReader(r);
            r.Close();

            cmd.CommandText = Currency.GetByIDSQLStatic(result.CURRENCY.ID);
            r = cmd.ExecuteReader();
            result.CURRENCY = Currency.GetCurrency(r);
            r.Close();

            cmd.CommandText = TermOfPayment.GetByIDSQLStatic(result.TOP.ID);
            r          = cmd.ExecuteReader();
            result.TOP = TermOfPayment.GetTOP(r);
            r.Close();

            cmd.CommandText = Employee.GetByIDSQLStatic(result.EMPLOYEE.ID);
            r = cmd.ExecuteReader();
            result.EMPLOYEE = Employee.GetEmployee(r);
            r.Close();


            return(result);
        }
예제 #4
0
        public int RecordCount()
        {
            m_command.CommandText = CustomerOutStandingInvoice.RecordCount();
            int result = Convert.ToInt32(m_command.ExecuteScalar());

            return(result);
        }
예제 #5
0
        protected override void doSaveNoTransaction(EventJournal e)
        {
            try
            {
                DateTime     trDate     = DateTime.Today;
                string       codesample = AutoNumberSetupRepository.GetCodeSampleByDomainName(m_command, "CustomerOutStandingInvoice");
                EventJournal 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, "CustomerOutStandingInvoice", e.CODE, lastCode, lastDate, trDate, trCount == 0);

                CustomerOutStandingInvoice stk = (CustomerOutStandingInvoice)e;
                m_command.CommandText = stk.GetInsertSQL();
                m_command.ExecuteNonQuery();
                m_command.CommandText = CustomerOutStandingInvoice.SelectMaxIDSQL();
                stk.ID = Convert.ToInt32(m_command.ExecuteScalar());
                foreach (CustomerOutStandingInvoiceItem item in stk.EVENT_JOURNAL_ITEMS)
                {
                    m_command.CommandText = item.GetInsertSQL();
                    m_command.ExecuteNonQuery();
                    m_command.CommandText = CustomerOutStandingInvoiceItem.SelectMaxIDSQL();
                    item.ID = Convert.ToInt32(m_command.ExecuteScalar());
                }
            }
            catch (Exception x)
            {
                e.ID = 0;
                foreach (EventJournalItem item in e.EVENT_JOURNAL_ITEMS)
                {
                    item.ID = 0;
                }
                throw x;
            }
        }
예제 #6
0
        private EventStatus getEventStatus(int id)
        {
            m_command.CommandText = CustomerOutStandingInvoice.GetEventStatus(id);
            object      b = m_command.ExecuteScalar();
            EventStatus m = (EventStatus)Enum.Parse(typeof(EventStatus), b.ToString());

            return(m);
        }
예제 #7
0
        public override EventJournal FindLastCodeAndTransactionDate(string codesample)
        {
            m_command.CommandText = CustomerOutStandingInvoice.FindLastCodeAndTransactionDate(codesample);
            MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader();
            EventJournal e = CustomerOutStandingInvoice.TransformReader(r);

            r.Close();
            return(e);
        }
예제 #8
0
        public static void UpdateAgainstStatus(MySql.Data.MySqlClient.MySqlCommand cmd, EventJournal e, ICustomerInvoiceJournalItem ei)
        {
            CustomerOutStandingInvoice     po  = (CustomerOutStandingInvoice)e;
            CustomerOutStandingInvoiceItem poi = (CustomerOutStandingInvoiceItem)ei;

            cmd.CommandText = poi.UpdateAgainstStatus();
            cmd.ExecuteNonQuery();
            cmd.CommandText = po.UpdateAgainstStatus();
            cmd.ExecuteNonQuery();
        }
예제 #9
0
 protected override bool doIsCodeExist(string code)
 {
     try
     {
         m_command.CommandText = CustomerOutStandingInvoice.SelectCountByCode(code);
         int t = Convert.ToInt32(m_command.ExecuteScalar());
         return(t > 0);
     }
     catch (Exception x)
     {
         throw x;
     }
 }
예제 #10
0
        //public static CustomerOutStandingInvoiceItem FindGRNItem(MySql.Data.MySqlClient.MySqlCommand cmd, int grnIID)
        //{
        //    cmd.CommandText = CustomerOutStandingInvoiceItem.FindByGrnItemIDSQL(grnIID);
        //    MySql.Data.MySqlClient.MySqlDataReader r = cmd.ExecuteReader();
        //    CustomerOutStandingInvoiceItem res = CustomerOutStandingInvoiceItem.TransformReader(r);
        //    r.Close();
        //    cmd.CommandText = CustomerOutStandingInvoice.GetByIDSQL(res.EVENT.ID);
        //    r = cmd.ExecuteReader();
        //    res.EVENT = CustomerOutStandingInvoice.TransformReader(r);
        //    r.Close();
        //    return res;
        //}

        protected override IList doSearch(string find)
        {
            try
            {
                m_command.CommandText = CustomerOutStandingInvoice.GetSearch(find);
                MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader();
                IList rest = CustomerOutStandingInvoice.TransformReaderList(r);
                r.Close();
                return(rest);
            }
            catch (Exception x)
            {
                throw x;
            }
        }
예제 #11
0
        protected override void doDeleteNoTransaction(EventJournal e)
        {
            CustomerOutStandingInvoice st = (CustomerOutStandingInvoice)e;

            try
            {
                if (getEventStatus(st.ID) == EventStatus.Confirm)
                {
                    throw new Exception("Revise before delete");
                }
                m_command.CommandText = CustomerOutStandingInvoiceItem.DeleteAllByEventSQL(st.ID);
                m_command.ExecuteNonQuery();
                m_command.CommandText = CustomerOutStandingInvoice.DeleteSQL(st.ID);
                m_command.ExecuteNonQuery();
            }
            catch (Exception x)
            {
                throw x;
            }
        }
예제 #12
0
        public IList FindCOIJournalItemlistForReceipt(string find, int ccyID, int customer, DateTime trdate, IList notIn)
        {
            StringBuilder poisSB = new StringBuilder();

            foreach (int i in notIn)
            {
                poisSB.Append(i.ToString());
                poisSB.Append(',');
            }
            string pois = poisSB.ToString();

            pois = notIn.Count > 0 ? pois.Substring(0, pois.Length - 1) : "";
            m_command.CommandText = CustomerOutStandingInvoiceItem.GetSearchForReceipt(find, ccyID, customer, pois, trdate);
            MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader();
            IList result = CustomerOutStandingInvoiceItem.TransformReaderList(r);

            r.Close();
            foreach (CustomerOutStandingInvoiceItem t in result)
            {
                m_command.CommandText = CustomerOutStandingInvoice.GetByIDSQL(t.EVENT_JOURNAL.ID);
                r = m_command.ExecuteReader();
                t.EVENT_JOURNAL = CustomerOutStandingInvoice.TransformReader(r);
                r.Close();

                m_command.CommandText = Currency.GetByIDSQLStatic(t.CURRENCY.ID);
                r          = m_command.ExecuteReader();
                t.CURRENCY = Currency.GetCurrency(r);
                r.Close();

                m_command.CommandText = TermOfPayment.GetByIDSQLStatic(t.TOP.ID);
                r     = m_command.ExecuteReader();
                t.TOP = TermOfPayment.GetTOP(r);
                r.Close();

                m_command.CommandText = Employee.GetByIDSQLStatic(t.EMPLOYEE.ID);
                r          = m_command.ExecuteReader();
                t.EMPLOYEE = Employee.GetEmployee(r);
                r.Close();
            }
            return(result);
        }
예제 #13
0
        protected override EventJournal doGet(int ID)
        {
            m_command.CommandText = CustomerOutStandingInvoice.GetByIDSQL(ID);
            MySql.Data.MySqlClient.MySqlDataReader r  = m_command.ExecuteReader();
            CustomerOutStandingInvoice             st = CustomerOutStandingInvoice.TransformReader(r);

            r.Close();
            m_command.CommandText = CustomerOutStandingInvoiceItem.GetByEventIDSQL(ID);
            r = m_command.ExecuteReader();
            IList stis = CustomerOutStandingInvoiceItem.TransformReaderList(r);

            r.Close();
            foreach (CustomerOutStandingInvoiceItem 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);
                st.EVENT_JOURNAL_ITEMS.Add(sti);
            }
            return(st);
        }
예제 #14
0
        protected override void doDelete(EventJournal e)
        {
            CustomerOutStandingInvoice st = (CustomerOutStandingInvoice)e;

            MySql.Data.MySqlClient.MySqlTransaction trc = m_connection.BeginTransaction();
            m_command.Transaction = trc;
            try
            {
                if (getEventStatus(st.ID) == EventStatus.Confirm)
                {
                    throw new Exception("Revise before delete");
                }
                m_command.CommandText = CustomerOutStandingInvoiceItem.DeleteAllByEventSQL(st.ID);
                m_command.ExecuteNonQuery();
                m_command.CommandText = CustomerOutStandingInvoice.DeleteSQL(st.ID);
                m_command.ExecuteNonQuery();
                trc.Commit();
            }
            catch (Exception x)
            {
                trc.Rollback();
                throw x;
            }
        }
예제 #15
0
        public IList GetAllTransactions(int supID)
        {
            ArrayList result = new ArrayList();

            OpenConnection();
            MySql.Data.MySqlClient.MySqlDataReader r;

            m_cmd.CommandText = SalesOrder.GetByCustomerSQL(supID);
            r = m_cmd.ExecuteReader();
            IList po = SalesOrder.TransformReaderList(r);

            r.Close();
            foreach (Event e in po)
            {
                result.Add(e);
            }

            m_cmd.CommandText = DeliveryOrder.GetByCustomerSQL(supID);
            r = m_cmd.ExecuteReader();
            IList grn = DeliveryOrder.TransformReaderList(r);

            r.Close();
            foreach (Event e in grn)
            {
                result.Add(e);
            }

            m_cmd.CommandText = CustomerInvoice.GetByCustomerSQL(supID);
            r = m_cmd.ExecuteReader();
            IList si = CustomerInvoice.TransformReaderList(r);

            r.Close();
            foreach (Event e in si)
            {
                result.Add(e);
            }

            m_cmd.CommandText = POS.GetByCustomerSQL(supID);
            r = m_cmd.ExecuteReader();
            IList pos = POS.TransformReaderList(r);

            r.Close();
            foreach (Event e in pos)
            {
                result.Add(e);
            }

            m_cmd.CommandText = SalesReturn.GetByCustomerSQL(supID);
            r = m_cmd.ExecuteReader();
            IList pr = SalesReturn.TransformReaderList(r);

            r.Close();
            foreach (Event e in pr)
            {
                result.Add(e);
            }

            m_cmd.CommandText = ARCreditNote.GetByCustomerSQL(supID);
            r = m_cmd.ExecuteReader();
            IList apdn = ARCreditNote.TransformReaderList(r);

            r.Close();
            foreach (EventJournal e in apdn)
            {
                result.Add(e);
            }

            m_cmd.CommandText = Receipt.GetByCustomerSQL(supID);
            r = m_cmd.ExecuteReader();
            IList py = Receipt.TransformReaderList(r);

            r.Close();
            foreach (EventJournal e in py)
            {
                result.Add(e);
            }

            m_cmd.CommandText = CustomerOutStandingInvoice.GetByCustomerSQL(supID);
            r = m_cmd.ExecuteReader();
            IList soi = CustomerOutStandingInvoice.TransformReaderList(r);

            r.Close();
            foreach (EventJournal e in soi)
            {
                result.Add(e);
            }

            result.Sort(new EventDateComparer());
            return(result);
        }
예제 #16
0
 protected override void doUpdateStatus(EventJournal e, bool posted)
 {
     m_command.CommandText = CustomerOutStandingInvoice.GetUpdateStatusSQL(e);
     m_command.ExecuteNonQuery();
 }