Ejemplo n.º 1
0
            public int Compare(object x, object y)
            {
                VendorBalanceEntry X = (VendorBalanceEntry)x;
                VendorBalanceEntry Y = (VendorBalanceEntry)y;

                return(DateTime.Compare(X.TRANSACTION_DATE, Y.TRANSACTION_DATE));
            }
Ejemplo n.º 2
0
 protected void saveVendorBalanceEntry(VendorBalanceEntry vbe)
 {
     if (vbe != null)
     {
         VendorBalanceEntryRepository.Save(m_command, vbe);
     }
 }
Ejemplo n.º 3
0
        public static VendorBalanceEntry FindVendorBalanceEntryByEventItem(MySql.Data.MySqlClient.MySqlCommand cmd, int itemID, VendorBalanceEntryType scetype)
        {
            cmd.CommandText = VendorBalanceEntry.FindByEventJournalItem(itemID, scetype);
            MySql.Data.MySqlClient.MySqlDataReader r = cmd.ExecuteReader();
            VendorBalanceEntry res = VendorBalanceEntry.TransformReader(r);

            r.Close();
            return(res);
        }
Ejemplo n.º 4
0
        public override bool Equals(object obj)
        {
            VendorBalanceEntry sce = (VendorBalanceEntry)obj;

            if (sce == null)
            {
                return(false);
            }
            return(sce.ID == ID);
        }
Ejemplo n.º 5
0
 public static void Save(MySql.Data.MySqlClient.MySqlCommand cmd, VendorBalance sc)
 {
     cmd.CommandText = sc.GetInsertSQL();
     cmd.ExecuteNonQuery();
     cmd.CommandText = VendorBalance.SelectMaxIDSQL();
     sc.ID           = Convert.ToInt32(cmd.ExecuteScalar());
     foreach (VendorBalanceEntry sce in sc.VENDOR_BALANCE_ENTRIES)
     {
         cmd.CommandText = sce.GetInsertSQL();
         cmd.ExecuteNonQuery();
         cmd.CommandText = VendorBalanceEntry.SelectMaxIDSQL();
         sce.ID          = Convert.ToInt32(cmd.ExecuteScalar());
     }
 }
Ejemplo n.º 6
0
 public static void Save(MySql.Data.MySqlClient.MySqlCommand cmd, VendorBalanceEntry sce)
 {
     if (sce.ID == 0)
     {
         cmd.CommandText = sce.GetInsertSQL();
         cmd.ExecuteNonQuery();
         cmd.CommandText = VendorBalanceEntry.SelectMaxIDSQL();
         sce.ID          = Convert.ToInt32(cmd.ExecuteScalar());
     }
     else
     {
         cmd.CommandText = sce.GetUpdateSQL();
         cmd.ExecuteNonQuery();
     }
 }
Ejemplo n.º 7
0
        public static IList TransformReaderList(MySql.Data.MySqlClient.MySqlDataReader aReader)
        {
            IList result = new ArrayList();

            while (aReader.Read())
            {
                VendorBalanceEntry tr = new VendorBalanceEntry();
                tr.ID                        = Convert.ToInt32(aReader["vbe_id"]);
                tr.VENDOR_BALANCE            = new VendorBalance(Convert.ToInt32(aReader["vb_id"]));
                tr.VENDOR_BALANCE_ENTRY_TYPE = (VendorBalanceEntryType)Enum.Parse(typeof(VendorBalanceEntryType), aReader["vbe_vendorbalanceentrytype"].ToString());
                tr.TRANSACTION_DATE          = Convert.ToDateTime(aReader["vbe_date"]);
                tr.CURRENCY                  = new Currency(Convert.ToInt32(aReader["ccy_id"]));
                tr.AMOUNT                    = Convert.ToDouble(aReader["vbe_amount"]);
                tr.EVENT_JOURNAL_ITEM        = new EventJournalItem(Convert.ToInt32(aReader["eventjournalitem_id"]));
                result.Add(tr);
            }
            return(result);
        }
Ejemplo n.º 8
0
        public static VendorBalance FindVendorBalance(MySql.Data.MySqlClient.MySqlCommand cmd, long vendor, long currency, long periodId, VendorBalanceType type)
        {
            cmd.CommandText = String.Format("select * from table_vendorbalance where vendor_id = {0} and ccy_id = {1} and period_id = {2} and vb_vendorbalancetype = '{3}'",
                                            vendor, currency, periodId, type.ToString());
            MySql.Data.MySqlClient.MySqlDataReader r = cmd.ExecuteReader();
            VendorBalance sc = VendorBalance.TransformReader(r);

            r.Close();
            if (sc != null)
            {
                sc.PERIOD       = PeriodRepository.FindPeriod(cmd, sc.PERIOD.ID);
                cmd.CommandText = VendorBalanceEntry.FindByVendorBalance(sc.ID);
                MySql.Data.MySqlClient.MySqlDataReader rx = cmd.ExecuteReader();
                sc.VENDOR_BALANCE_ENTRIES = VendorBalanceEntry.TransformReaderList(rx);
                rx.Close();
            }
            return(sc);
        }
Ejemplo n.º 9
0
        public void ProcessPosting(EventJournalItem eventItem)
        {
            assertSameCurrency(eventItem.CURRENCY);
            assertPeriodIsCurrent();
            assertInPeriodRange(eventItem.EVENT_JOURNAL.TRANSACTION_DATE);
            double qty = eventItem.AMOUNT;

            switch (eventItem.VENDOR_BALANCE_ENTRY_TYPE)
            {
            case VendorBalanceEntryType.SupplierOutStandingInvoice:
                BALANCE += qty;
                break;

            case VendorBalanceEntryType.CustomerOutStandingInvoice:
                BALANCE += qty;
                break;

            case VendorBalanceEntryType.SupplierInvoice:
                BALANCE += qty;
                break;

            case VendorBalanceEntryType.CustomerInvoice:
                BALANCE += qty;
                break;

            case VendorBalanceEntryType.Payment:
                BALANCE -= qty;
                assertNotMinusBalanceAmount();
                break;

            case VendorBalanceEntryType.Receipt:
                BALANCE -= qty;
                assertNotMinusBalanceAmount();
                break;

            default:
                break;
            }
            VendorBalanceEntry sce = new VendorBalanceEntry(this, eventItem);

            VENDOR_BALANCE_ENTRIES.Add(sce);
        }
Ejemplo n.º 10
0
        public IList GetVendorBalanceEntry(int supID)
        {
            ArrayList result = new ArrayList();

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

            m_cmd.CommandText = VendorBalanceEntry.FindByVendorBalanceByCustomer(supID, VendorBalanceType.Customer);
            r = m_cmd.ExecuteReader();
            IList vbe = VendorBalanceEntry.TransformReaderList(r);

            r.Close();

            foreach (VendorBalanceEntry v in vbe)
            {
                result.Add(v);
            }
            result.Sort(new VendorBalanceEntryDateComparer());
            return(result);
        }
Ejemplo n.º 11
0
        public static void Update(MySql.Data.MySqlClient.MySqlCommand cmd, VendorBalance sc)
        {
            cmd.CommandText = sc.GetUpdateSQL();
            cmd.ExecuteNonQuery();
            foreach (VendorBalanceEntry sce in sc.VENDOR_BALANCE_ENTRIES)
            {
                if (sce.ID == 0)
                {
                    cmd.CommandText = sce.GetInsertSQL();
                    cmd.ExecuteNonQuery();
                    cmd.CommandText = VendorBalanceEntry.SelectMaxIDSQL();
                    sce.ID          = Convert.ToInt32(cmd.ExecuteScalar());
                }
                else
                {
                    cmd.CommandText = sce.GetUpdateSQL();
                    cmd.ExecuteNonQuery();
                }
            }
            cmd.CommandText = VendorBalanceEntry.FindByVendorBalance(sc.ID);
            MySql.Data.MySqlClient.MySqlDataReader r = cmd.ExecuteReader();
            IList sces = VendorBalanceEntry.TransformReaderList(r);

            r.Close();
            foreach (VendorBalanceEntry sce in sces)
            {
                sce.UPDATED = sc.VENDOR_BALANCE_ENTRIES.Contains(sce);
            }
            foreach (VendorBalanceEntry sce in sces)
            {
                if (!sce.UPDATED)
                {
                    cmd.CommandText = VendorBalanceEntry.DeleteSQL(sce.ID);
                    cmd.ExecuteNonQuery();
                }
            }
        }
Ejemplo n.º 12
0
 public static void Delete(MySql.Data.MySqlClient.MySqlCommand cmd, VendorBalanceEntry sc)
 {
     cmd.CommandText = VendorBalanceEntry.DeleteSQL(sc.ID);
     cmd.ExecuteNonQuery();
 }
Ejemplo n.º 13
0
 protected void deleteVendorBalanceEntry(VendorBalanceEntry vbe)
 {
     VendorBalanceEntryRepository.Delete(m_command, vbe);
 }