Esempio n. 1
0
        public static IList TransformReaderList(MySql.Data.MySqlClient.MySqlDataReader aReader)
        {
            IList result = new ArrayList();

            while (aReader.Read())
            {
                PurchaseOrderItem transaction = new PurchaseOrderItem();
                transaction.ID                        = Convert.ToInt32(aReader["poi_id"]);
                transaction.EVENT                     = new PurchaseOrder(Convert.ToInt32(aReader["po_id"]));
                transaction.PART                      = new Part(Convert.ToInt32(aReader["part_id"]));
                transaction.WAREHOUSE                 = new Warehouse(Convert.ToInt32(aReader["warehouse_id"]));
                transaction.QYTAMOUNT                 = Convert.ToDouble(Convert.ToInt32(aReader["poi_amount"]));
                transaction.STOCK_CARD_ENTRY          = new StockCardEntry(Convert.ToInt32(aReader["sce_id"]));
                transaction.STOCK_CARD_ENTRY_TYPE     = (StockCardEntryType)Enum.Parse(typeof(StockCardEntryType), aReader["poi_scentrytype"].ToString());
                transaction.STOCK_CARD                = new StockCard(Convert.ToInt32(aReader["sc_id"]));
                transaction.UNIT                      = new Unit(Convert.ToInt32(aReader["unit_id"]));
                transaction.PRICE                     = Convert.ToDouble(Convert.ToInt32(aReader["poi_price"]));
                transaction.DISC_PERCENT              = Convert.ToDouble(Convert.ToInt32(aReader["poi_discpercent"]));
                transaction.DISC_AMOUNT               = Convert.ToDouble(Convert.ToInt32(aReader["poi_discamount"]));
                transaction.TOTAL_DISCOUNT            = Convert.ToDouble(Convert.ToInt32(aReader["poi_totaldisc"]));
                transaction.SUBTOTAL                  = Convert.ToDouble(Convert.ToInt32(aReader["poi_subtotal"]));
                transaction.NOTES                     = aReader["poi_notes"].ToString();
                transaction.DISC_A                    = Convert.ToDouble(Convert.ToInt32(aReader["poi_disca"]));
                transaction.DISC_B                    = Convert.ToDouble(Convert.ToInt32(aReader["poi_discb"]));
                transaction.DISC_C                    = Convert.ToDouble(Convert.ToInt32(aReader["poi_discc"]));
                transaction.DISC_ABC                  = aReader["poi_discabc"].ToString();
                transaction.AGAINST_GRN_STATUS        = (AgainstStatus)Enum.Parse(typeof(AgainstStatus), aReader["poi_againstgrnstatus"].ToString());
                transaction.OUTSTANDING_AMOUNT_TO_GRN = Convert.ToDouble(Convert.ToInt32(aReader["poi_outstandingamounttogrn"]));
                transaction.RECEIVED_AMOUNT           = Convert.ToDouble(Convert.ToInt32(aReader["poi_receivedamount"]));
                transaction.PRICE_IN_SMALLEST_UNIT    = Convert.ToDouble(Convert.ToInt32(aReader["poi_priceinsmallestunit"]));
                result.Add(transaction);
            }
            return(result);
        }
Esempio n. 2
0
        public double GetReceived(int poItem)
        {
            m_command.CommandText = PurchaseOrderItem.GetReceivedSQL(poItem);
            double result = Convert.ToDouble(m_command.ExecuteScalar());

            return(result);
        }
Esempio n. 3
0
        public override bool Equals(object obj)
        {
            PurchaseOrderItem e = (PurchaseOrderItem)obj;

            if (e == null)
            {
                return(false);
            }
            return(e.ID == this.ID);
        }
Esempio n. 4
0
        public PurchaseOrderItem FindPurchaseOrderItem(int poiID)
        {
            m_command.CommandText = PurchaseOrderItem.GetByIDSQL(poiID);
            MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader();
            PurchaseOrderItem result = PurchaseOrderItem.TransformReader(r);

            r.Close();
            result.EVENT = PurchaseOrderRepository.GetHeaderOnly(m_command, result.EVENT.ID);
            result.EVENT.EVENT_ITEMS.Add(result);
            return(result);
        }
Esempio n. 5
0
        protected override void doUpdate(Event en)
        {
            MySql.Data.MySqlClient.MySqlTransaction trc = m_connection.BeginTransaction();
            m_command.Transaction = trc;
            try
            {
                PurchaseOrder e = (PurchaseOrder)en;
                m_command.CommandText = e.GetUpdateSQL();
                m_command.ExecuteNonQuery();

                foreach (PurchaseOrderItem 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 = PurchaseOrderItem.SelectMaxIDSQL();
                        sti.ID = Convert.ToInt32(m_command.ExecuteScalar());
                    }
                }
                m_command.CommandText = PurchaseOrderItem.DeleteUpdate(e.ID, e.EVENT_ITEMS);
                m_command.ExecuteNonQuery();
                //m_command.CommandText = PurchaseOrderItem.GetByEventIDSQL(e.ID);
                //MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader();
                //IList luc = PurchaseOrderItem.TransformReaderList(r);
                //r.Close();
                //foreach (PurchaseOrderItem chk in luc)
                //{
                //    chk.UPDATED = e.EVENT_ITEMS.Contains(chk);
                //}
                //foreach (PurchaseOrderItem chk in luc)
                //{
                //    if (!chk.UPDATED)
                //    {
                //        m_command.CommandText = PurchaseOrderItem.DeleteSQL(chk.ID);
                //        m_command.ExecuteNonQuery();
                //    }
                //}
                trc.Commit();
            }
            catch (Exception x)
            {
                trc.Rollback();
                throw x;
            }
        }
Esempio n. 6
0
        public double GetTheLatestPOPrice(int supID, int partID, int unitID)
        {
            m_command.CommandText = PurchaseOrderItem.GetTheLatestPOPrice(supID, partID, unitID);
            object r = m_command.ExecuteScalar();

            if (r == null)
            {
                return(0d);
            }
            double result = Convert.ToDouble(r);

            return(result);
        }
Esempio n. 7
0
        public void UpdateAgainstGRNStatusPO()
        {
            bool allClosed = true;

            for (int i = 0; i < EVENT_ITEMS.Count; i++)
            {
                PurchaseOrderItem poi = EVENT_ITEMS[i] as PurchaseOrderItem;
                if (poi.AGAINST_GRN_STATUS == AgainstStatus.Close)
                {
                    continue;
                }
                allClosed = false;
                break;
            }
            AGAINST_GRN_STATUS = allClosed ? AgainstStatus.Close : AgainstStatus.Outstanding;
        }
Esempio n. 8
0
        public IList FindPObyPartAndPONo(string find, IList exceptPOI, int supplierID, DateTime trDate)
        {
            StringBuilder poisSB = new StringBuilder();

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

            pois = exceptPOI.Count > 0?pois.Substring(0, pois.Length - 1):"";

            m_command.CommandText = PurchaseOrderItem.GetSearchByPartAndPONo(find, supplierID, pois, trDate);
            MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader();
            IList result = PurchaseOrderItem.TransformReaderList(r);

            r.Close();
            foreach (PurchaseOrderItem t in result)
            {
                m_command.CommandText = PurchaseOrder.GetByIDSQL(t.EVENT.ID);
                r       = m_command.ExecuteReader();
                t.EVENT = PurchaseOrder.TransformReader(r);
                r.Close();
                m_command.CommandText = Part.GetByIDSQLStatic(t.PART.ID);
                r      = m_command.ExecuteReader();
                t.PART = Part.GetPart(r);
                r.Close();
                m_command.CommandText = Unit.GetByIDSQLstatic(t.UNIT.ID);
                r      = m_command.ExecuteReader();
                t.UNIT = Unit.GetUnit(r);
                r.Close();
                m_command.CommandText = TermOfPayment.GetByIDSQLStatic(((PurchaseOrder)t.EVENT).TOP.ID);
                r = m_command.ExecuteReader();
                ((PurchaseOrder)t.EVENT).TOP = TermOfPayment.GetTOP(r);
                r.Close();
                m_command.CommandText = Warehouse.GetByIDSQLStatic(t.WAREHOUSE.ID);
                r           = m_command.ExecuteReader();
                t.WAREHOUSE = Warehouse.GetWarehouse(r);
                r.Close();
                m_command.CommandText = Unit.GetByIDSQLstatic(t.PART.UNIT.ID);
                r           = m_command.ExecuteReader();
                t.PART.UNIT = Unit.GetUnit(r);
                r.Close();
            }
            return(result);
        }
Esempio n. 9
0
        public static PurchaseReturn GetPurchaseReturnForDebitNote(MySql.Data.MySqlClient.MySqlCommand cmd, PurchaseReturn p)
        {
            cmd.CommandText = PurchaseReturnItem.GetByEventIDSQL(p.ID);
            MySql.Data.MySqlClient.MySqlDataReader r = cmd.ExecuteReader();
            p.EVENT_ITEMS = PurchaseReturnItem.TransformReaderList(r);
            r.Close();

            foreach (PurchaseReturnItem t in p.EVENT_ITEMS)
            {
                if ((t.GRN_ITEM == null) && (t.GRN_ITEM.ID == 0))
                {
                    continue;
                }


                cmd.CommandText = GoodReceiveNoteItem.GetByIDSQL(t.GRN_ITEM.ID);
                r          = cmd.ExecuteReader();
                t.GRN_ITEM = GoodReceiveNoteItem.TransformReader(r);
                r.Close();

                if ((t.GRN_ITEM.PO_ITEM == null))
                {
                    continue;
                }
                if (t.GRN_ITEM.PO_ITEM.ID == 0)
                {
                    continue;
                }

                cmd.CommandText = PurchaseOrderItem.GetByIDSQL(t.GRN_ITEM.PO_ITEM.ID);
                r = cmd.ExecuteReader();
                t.GRN_ITEM.PO_ITEM = PurchaseOrderItem.TransformReader(r);
                r.Close();

                t.GRN_ITEM.PART = PartRepository.GetByID(cmd, t.GRN_ITEM.PART.ID);
                t.GRN_ITEM.PART.UNIT_CONVERSION_LIST = PartRepository.GetUnitConversionsStatic(cmd, t.GRN_ITEM.PO_ITEM.PART.ID);
                t.PART = t.GRN_ITEM.PO_ITEM.PART = t.GRN_ITEM.PART;

                double subamount = (t.GRN_ITEM.PO_ITEM.SUBTOTAL / t.GRN_ITEM.PO_ITEM.GetAmountInSmallestUnit()) * t.GetAmountInSmallestUnit();
                p.TOTAL_AMOUNT_FROM_PO += subamount;

                t.GRN_ITEM.PO_ITEM.EVENT = PurchaseOrderRepository.GetHeaderOnly(cmd, t.GRN_ITEM.PO_ITEM.EVENT.ID);
                p.CURRENCY = ((PurchaseOrder)t.GRN_ITEM.PO_ITEM.EVENT).CURRENCY;
            }
            return(p);
        }
Esempio n. 10
0
        protected override Event doGet(int ID)
        {
            m_command.CommandText = PurchaseOrder.GetByIDSQL(ID);
            MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader();
            PurchaseOrder st = PurchaseOrder.TransformReader(r);

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

            r.Close();
            foreach (PurchaseOrderItem sti in stis)
            {
                sti.EVENT            = st;
                sti.PART             = PartRepository.GetByID(m_command, sti.PART.ID);
                sti.STOCK_CARD_ENTRY = StockCardEntryRepository.FindStockCardEntryByEventItem(m_command, sti.ID, sti.STOCK_CARD_ENTRY_TYPE);
                st.EVENT_ITEMS.Add(sti);
            }
            return(st);
        }
Esempio n. 11
0
 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, "PurchaseOrder");
         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, "PurchaseOrder", e.CODE, lastCode, lastDate, trDate, trCount == 0);
         PurchaseOrder stk = (PurchaseOrder)e;
         m_command.CommandText = e.GetInsertSQL();
         m_command.ExecuteNonQuery();
         m_command.CommandText = PurchaseOrder.SelectMaxIDSQL();
         stk.ID = Convert.ToInt32(m_command.ExecuteScalar());
         foreach (PurchaseOrderItem 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 = PurchaseOrderItem.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;
     }
 }
Esempio n. 12
0
        protected override void doDelete(Event e)
        {
            PurchaseOrder st = (PurchaseOrder)e;//this.Get(e.ID);

            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 = PurchaseOrderItem.DeleteAllByEventSQL(st.ID);
                m_command.ExecuteNonQuery();
                m_command.CommandText = PurchaseOrder.DeleteSQL(st.ID);
                m_command.ExecuteNonQuery();
                trc.Commit();
            }
            catch (Exception x)
            {
                trc.Rollback();
                throw x;
            }
        }
Esempio n. 13
0
 public static void UpdateAgainstStatus(MySql.Data.MySqlClient.MySqlCommand cmd, PurchaseOrder po, PurchaseOrderItem poi)
 {
     cmd.CommandText = poi.UpdateAgainstStatus();
     cmd.ExecuteNonQuery();
     cmd.CommandText = po.UpdateAgainstStatus();
     cmd.ExecuteNonQuery();
 }
Esempio n. 14
0
        //-------------
        //public void UpdatePart()
        //{
        //    MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand();
        //    cmd.Connection = m_connection;
        //    m_connection.Open();
        //    cmd.CommandText = m_entity.GetAllSQL();

        //    MySql.Data.MySqlClient.MySqlDataReader r = cmd.ExecuteReader();
        //    IList result = new ArrayList();
        //    while (r.Read())
        //    {
        //        PartUnit pu = new PartUnit();
        //        pu.PART = Convert.ToInt32(r["part_id"]);
        //        pu.UNIT = Convert.ToInt32(r["unit_id"]);
        //        result.Add(pu);
        //    }
        //    r.Close();
        //    foreach (PartUnit e in result)
        //    {
        //        cmd.CommandText = UnitConversion.GetByPartAndUnitConIDSQL(e.PART, e.UNIT);
        //        r = cmd.ExecuteReader();
        //        UnitConversion uc = UnitConversion.GetUnitConversion(r);
        //        r.Close();
        //        if (uc == null)
        //        {
        //            uc = new UnitConversion();
        //            uc.BARCODE = e.BARCODE;
        //            uc.CONVERSION_QTY = 1;
        //            uc.CONVERSION_UNIT = e.UNIT;
        //            uc.COST_PRICE = e.COST_PRICE;
        //            uc.ORIGINAL_QTY = 1;
        //            uc.PART = e;
        //            uc.SELL_PRICE = e.SELL_PRICE;
        //            cmd.CommandText = uc.GetInsertSQL();
        //            cmd.ExecuteNonQuery();
        //        }
        //    }
        //}
        //private class PartUnit
        //{
        //    public int PART, UNIT;

        //}
        public IList GetAllEvents(int partID)
        {
            ArrayList result = new ArrayList();

            OpenConnection();
            MySql.Data.MySqlClient.MySqlDataReader rdr;
            Part p = PartRepository.GetByID(m_cmd, partID);

            m_cmd.CommandText = PurchaseOrderItem.GetByPartIDSQL(partID);
            rdr = m_cmd.ExecuteReader();
            IList pois = PurchaseOrderItem.TransformReaderList(rdr);

            rdr.Close();
            foreach (PurchaseOrderItem itm in pois)
            {
                itm.EVENT = PurchaseOrderRepository.GetHeaderOnly(m_cmd, itm.EVENT.ID);
                itm.PART  = p;
                result.Add(itm);
            }

            m_cmd.CommandText = SalesOrderItem.GetByPartIDSQL(partID);
            rdr = m_cmd.ExecuteReader();
            IList sois = SalesOrderItem.TransformReaderList(rdr);

            rdr.Close();
            foreach (SalesOrderItem itm in sois)
            {
                itm.EVENT = SalesOrderRepository.GetHeaderOnly(m_cmd, itm.EVENT.ID);
                itm.PART  = p;
                result.Add(itm);
            }


            m_cmd.CommandText = GoodReceiveNoteItem.GetByPartIDSQL(partID);
            rdr = m_cmd.ExecuteReader();
            IList grnis = GoodReceiveNoteItem.TransformReaderList(rdr);

            rdr.Close();
            foreach (GoodReceiveNoteItem itm in grnis)
            {
                itm.EVENT = GoodReceiveNoteRepository.GetHeaderOnly(m_cmd, itm.EVENT.ID);
                itm.PART  = p;
                result.Add(itm);
            }

            m_cmd.CommandText = PurchaseReturnItem.GetByPartIDSQL(partID);
            rdr = m_cmd.ExecuteReader();
            IList prnis = PurchaseReturnItem.TransformReaderList(rdr);

            rdr.Close();
            foreach (PurchaseReturnItem itm in prnis)
            {
                itm.EVENT = PurchaseReturnRepository.GetHeaderOnly(m_cmd, itm.EVENT.ID);
                itm.PART  = p;
                result.Add(itm);
            }

            m_cmd.CommandText = SalesReturnItem.GetByPartIDSQL(partID);
            rdr = m_cmd.ExecuteReader();
            IList srnis = SalesReturnItem.TransformReaderList(rdr);

            rdr.Close();
            foreach (SalesReturnItem itm in srnis)
            {
                itm.EVENT = SalesReturnRepository.GetHeaderOnly(m_cmd, itm.EVENT.ID);
                itm.PART  = p;
                result.Add(itm);
            }

            m_cmd.CommandText = SupplierInvoiceItem.GetByPartIDSQL(partID);
            rdr = m_cmd.ExecuteReader();
            IList piis = SupplierInvoiceItem.TransformReaderList(rdr);

            rdr.Close();
            foreach (SupplierInvoiceItem itm in piis)
            {
                itm.EVENT = SupplierInvoiceRepository.GetHeaderOnly(m_cmd, itm.EVENT.ID);
                itm.PART  = p;
                if (itm.GRN_ITEM.ID == 0)
                {
                    result.Add(itm);
                }
            }

            m_cmd.CommandText = CustomerInvoiceItem.GetByPartIDSQL(partID);
            rdr = m_cmd.ExecuteReader();
            IList ciis = CustomerInvoiceItem.TransformReaderList(rdr);

            rdr.Close();
            foreach (CustomerInvoiceItem itm in ciis)
            {
                itm.EVENT = CustomerInvoiceRepository.GetHeaderOnly(m_cmd, itm.EVENT.ID);
                itm.PART  = p;
                if (itm.DO_ITEM.ID == 0)
                {
                    result.Add(itm);
                }
            }

            m_cmd.CommandText = POSItem.GetByPartIDSQL(partID);
            rdr = m_cmd.ExecuteReader();
            IList posi = POSItem.TransformReaderList(rdr);

            rdr.Close();
            foreach (POSItem itm in posi)
            {
                itm.EVENT = POSRepository.GetHeaderOnly(m_cmd, itm.EVENT.ID);
                itm.PART  = p;
                if (itm.DO_ITEM.ID == 0)
                {
                    result.Add(itm);
                }
            }

            m_cmd.CommandText = StockTakingItems.GetByPartIDSQL(partID);
            rdr = m_cmd.ExecuteReader();
            IList sti = StockTakingItems.TransformReaderList(rdr);

            rdr.Close();
            foreach (StockTakingItems itm in sti)
            {
                itm.EVENT = StockTakingRepository.GetHeaderOnly(m_cmd, itm.EVENT.ID);
                itm.PART  = p;
                result.Add(itm);
            }

            m_cmd.CommandText = OpeningStockItem.GetByPartIDSQL(partID);
            rdr = m_cmd.ExecuteReader();
            IList opi = OpeningStockItem.TransformReaderList(rdr);

            rdr.Close();
            foreach (OpeningStockItem itm in opi)
            {
                itm.EVENT = OpeningStockRepository.GetHeaderOnly(m_cmd, itm.EVENT.ID);
                itm.PART  = p;
                result.Add(itm);
            }

            m_cmd.CommandText = DeliveryOrderItem.GetByPartIDSQL(partID);
            rdr = m_cmd.ExecuteReader();
            IList doi = DeliveryOrderItem.TransformReaderList(rdr);

            rdr.Close();
            foreach (DeliveryOrderItem itm in doi)
            {
                itm.EVENT = DeliveryOrderRepository.GetHeaderOnly(m_cmd, itm.EVENT.ID);
                itm.PART  = p;
                result.Add(itm);
            }

            result.Sort(new EventDateComparer());
            return(result);
        }
Esempio n. 15
0
        public IList FindPRForAPDebitNote(string find, int supID, DateTime trdate, IList added)
        {
            m_command.CommandText = APDebitNoteItem.GetPRUsedByAPDN();
            MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader();
            if (r.HasRows)
            {
                while (r.Read())
                {
                    int id = Convert.ToInt32(r[0]);
                    if (!added.Contains(id))
                    {
                        added.Add(id);
                    }
                }
            }
            r.Close();
            StringBuilder poisSB = new StringBuilder();

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

            pois = added.Count > 0 ? pois.Substring(0, pois.Length - 1) : "";

            m_command.CommandText = PurchaseReturn.GetSearchPRNoForAPDN(find, supID, pois, trdate);
            r = m_command.ExecuteReader();
            IList result = PurchaseReturn.TransformReaderList(r);

            r.Close();
            foreach (PurchaseReturn p in result)
            {
                m_command.CommandText = PurchaseReturnItem.GetByEventIDSQL(p.ID);
                r             = m_command.ExecuteReader();
                p.EVENT_ITEMS = PurchaseReturnItem.TransformReaderList(r);
                r.Close();

                foreach (PurchaseReturnItem t in p.EVENT_ITEMS)
                {
                    if ((t.GRN_ITEM == null) && (t.GRN_ITEM.ID == 0))
                    {
                        continue;
                    }


                    m_command.CommandText = GoodReceiveNoteItem.GetByIDSQL(t.GRN_ITEM.ID);
                    r          = m_command.ExecuteReader();
                    t.GRN_ITEM = GoodReceiveNoteItem.TransformReader(r);
                    r.Close();

                    if ((t.GRN_ITEM.PO_ITEM == null))
                    {
                        continue;
                    }
                    if (t.GRN_ITEM.PO_ITEM.ID == 0)
                    {
                        continue;
                    }

                    m_command.CommandText = PurchaseOrderItem.GetByIDSQL(t.GRN_ITEM.PO_ITEM.ID);
                    r = m_command.ExecuteReader();
                    t.GRN_ITEM.PO_ITEM = PurchaseOrderItem.TransformReader(r);
                    r.Close();

                    t.GRN_ITEM.PART = PartRepository.GetByID(m_command, t.GRN_ITEM.PART.ID);
                    t.GRN_ITEM.PART.UNIT_CONVERSION_LIST = PartRepository.GetUnitConversionsStatic(m_command, t.GRN_ITEM.PO_ITEM.PART.ID);
                    t.PART = t.GRN_ITEM.PO_ITEM.PART = t.GRN_ITEM.PART;

                    double subamount = (t.GRN_ITEM.PO_ITEM.SUBTOTAL / t.GRN_ITEM.PO_ITEM.GetAmountInSmallestUnit()) * t.GetAmountInSmallestUnit();
                    p.TOTAL_AMOUNT_FROM_PO += subamount;

                    t.GRN_ITEM.PO_ITEM.EVENT = PurchaseOrderRepository.GetHeaderOnly(m_command, t.GRN_ITEM.PO_ITEM.EVENT.ID);
                    p.CURRENCY = ((PurchaseOrder)t.GRN_ITEM.PO_ITEM.EVENT).CURRENCY;
                }
            }
            return(result);
        }