protected override Event doGet(int ID)
        {
            m_command.CommandText = SupplierInvoice.GetByIDSQL(ID);
            MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader();
            SupplierInvoice st = SupplierInvoice.TransformReader(r);

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

            r.Close();
            foreach (SupplierInvoiceItem 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);
                if (sti.GRN_ITEM.ID > 0)
                {
                    sti.GRN_ITEM = GoodReceiveNoteRepository.FindGoodReceiveNoteItem(m_command, sti.GRN_ITEM.ID);
                }
                st.EVENT_ITEMS.Add(sti);
            }
            return(st);
        }
Example #2
0
        private void assertUsedPOItemByGRNItem(EventItem item)
        {
            GoodReceiveNoteItem grnItm = GoodReceiveNoteRepository.FindPOItem(m_command, item.ID);

            if (grnItm != null)
            {
                throw new Exception("PO Item allready used by GRN item, delete GRN first : " + grnItm.EVENT.CODE);
            }
        }
Example #3
0
 protected override void doRevise(Event events, Period p)
 {
     foreach (PurchaseReturnItem item in events.EVENT_ITEMS)
     {
         assertUsedByAPDN(item);
         GoodReceiveNote po = (GoodReceiveNote)item.GRN_ITEM.EVENT;
         SetStockCard(item, p);
         item.GRN_ITEM.UnSetOSAgainstPRItem(item);
         GoodReceiveNoteRepository.UpdateAgainstStatus(m_command, po, item.GRN_ITEM);
     }
 }
Example #4
0
 protected override void doConfirm(Event events, Period p)
 {
     foreach (PurchaseReturnItem item in events.EVENT_ITEMS)
     {
         GoodReceiveNote po = (GoodReceiveNote)item.GRN_ITEM.EVENT;
         assertConfirmedPO(po);
         assertValidDate(po, item.EVENT);
         SetStockCard(item, p);
         item.GRN_ITEM.SetOSAgainstPRItem(item);
         GoodReceiveNoteRepository.UpdateAgainstStatus(m_command, po, item.GRN_ITEM);
     }
 }
Example #5
0
        public static GoodReceiveNoteItem FindGoodReceiveNoteItem(MySql.Data.MySqlClient.MySqlCommand cmd, int grniID)
        {
            cmd.CommandText = GoodReceiveNoteItem.GetByIDSQL(grniID);
            MySql.Data.MySqlClient.MySqlDataReader r = cmd.ExecuteReader();
            GoodReceiveNoteItem result = GoodReceiveNoteItem.TransformReader(r);

            r.Close();
            if (result == null)
            {
                return(null);
            }
            result.EVENT = GoodReceiveNoteRepository.GetHeaderOnly(cmd, result.EVENT.ID);
            result.EVENT.EVENT_ITEMS.Add(result);
            return(result);
        }
Example #6
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);
        }