Ejemplo n.º 1
0
        public static CustomerInvoiceItem FindCustomerInvoiceItem(MySql.Data.MySqlClient.MySqlCommand cmd, int poiID)
        {
            cmd.CommandText = CustomerInvoiceItem.GetByIDSQL(poiID);
            MySql.Data.MySqlClient.MySqlDataReader r = cmd.ExecuteReader();
            CustomerInvoiceItem result = CustomerInvoiceItem.TransformReader(r);

            r.Close();
            result.EVENT = SalesOrderRepository.GetHeaderOnly(cmd, result.EVENT.ID);
            result.EVENT.EVENT_ITEMS.Add(result);
            return(result);
        }
Ejemplo n.º 2
0
        public SalesOrderItem FindSalesOrderItem(int soiID)
        {
            m_command.CommandText = SalesOrderItem.GetByIDSQL(soiID);
            MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader();
            SalesOrderItem result = SalesOrderItem.TransformReader(r);

            r.Close();
            result.EVENT = SalesOrderRepository.GetHeaderOnly(m_command, result.EVENT.ID);
            result.EVENT.EVENT_ITEMS.Add(result);
            return(result);
        }
Ejemplo n.º 3
0
 protected override void doRevise(Event events, Period p)
 {
     foreach (DeliveryOrderItem item in events.EVENT_ITEMS)
     {
         assertUsedDOItemBySRItem(item);
         assertInvoiceAlreadyGenerated(item);
         SalesOrder so = (SalesOrder)item.SO_ITEM.EVENT;
         SetStockCard(item, p);
         item.SO_ITEM.UnSetOSAgainstDOItem(item);
         SalesOrderRepository.UpdateAgainstStatus(m_command, so, item.SO_ITEM);
     }
 }
Ejemplo n.º 4
0
 protected override void doConfirm(Event events, Period p)
 {
     foreach (DeliveryOrderItem item in events.EVENT_ITEMS)
     {
         SalesOrder so = (SalesOrder)item.SO_ITEM.EVENT;
         assertConfirmedSO(so);
         assertValidDate(so, item.EVENT);
         SetStockCard(item, p);
         item.SO_ITEM.SetOSAgainstDOItem(item);
         SalesOrderRepository.UpdateAgainstStatus(m_command, so, item.SO_ITEM);
     }
 }
Ejemplo n.º 5
0
        public static SalesReturn GetSalesReturnForCreditNote(MySql.Data.MySqlClient.MySqlCommand cmd, SalesReturn p)
        {
            cmd.CommandText = SalesReturnItem.GetByEventIDSQL(p.ID);
            MySql.Data.MySqlClient.MySqlDataReader r = cmd.ExecuteReader();
            p.EVENT_ITEMS = SalesReturnItem.TransformReaderList(r);
            r.Close();

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


                cmd.CommandText = DeliveryOrderItem.GetByIDSQL(t.DO_ITEM.ID);
                r         = cmd.ExecuteReader();
                t.DO_ITEM = DeliveryOrderItem.TransformReader(r);
                r.Close();

                if ((t.DO_ITEM.SO_ITEM == null))
                {
                    continue;
                }
                if (t.DO_ITEM.SO_ITEM.ID == 0)
                {
                    continue;
                }

                cmd.CommandText = SalesOrderItem.GetByIDSQL(t.DO_ITEM.SO_ITEM.ID);
                r = cmd.ExecuteReader();
                t.DO_ITEM.SO_ITEM = SalesOrderItem.TransformReader(r);
                r.Close();

                t.DO_ITEM.PART = PartRepository.GetByID(cmd, t.DO_ITEM.PART.ID);
                t.DO_ITEM.PART.UNIT_CONVERSION_LIST = PartRepository.GetUnitConversionsStatic(cmd, t.DO_ITEM.SO_ITEM.PART.ID);
                t.PART = t.DO_ITEM.SO_ITEM.PART = t.DO_ITEM.PART;

                double subamount = (t.DO_ITEM.SO_ITEM.SUBTOTAL / t.DO_ITEM.SO_ITEM.GetAmountInSmallestUnit()) * t.GetAmountInSmallestUnit();
                p.TOTAL_AMOUNT_FROM_SO += subamount;

                t.DO_ITEM.SO_ITEM.EVENT = SalesOrderRepository.GetHeaderOnly(cmd, t.DO_ITEM.SO_ITEM.EVENT.ID);
                p.CURRENCY = ((SalesOrder)t.DO_ITEM.SO_ITEM.EVENT).CURRENCY;
            }
            return(p);
        }
Ejemplo n.º 6
0
        protected override Event doGet(int ID)
        {
            m_command.CommandText = DeliveryOrder.GetByIDSQL(ID);
            MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader();
            DeliveryOrder st = DeliveryOrder.TransformReader(r);

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

            r.Close();
            foreach (DeliveryOrderItem 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);
                sti.SO_ITEM          = SalesOrderRepository.FindSalesOrderItem(m_command, sti.SO_ITEM.ID);
                sti.SO_ITEM.PART     = PartRepository.GetByID(m_command, sti.SO_ITEM.PART.ID);
                st.EVENT_ITEMS.Add(sti);
            }
            return(st);
        }
Ejemplo n.º 7
0
        public IList FindSRForARCreditNote(string find, int supID, DateTime trdate, IList added)
        {
            m_command.CommandText = ARCreditNoteItem.GetSRUsedByARCR();
            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 = SalesReturn.GetSearchSRNoForARCR(find, supID, pois, trdate);
            r = m_command.ExecuteReader();
            IList result = SalesReturn.TransformReaderList(r);

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

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


                    m_command.CommandText = DeliveryOrderItem.GetByIDSQL(t.DO_ITEM.ID);
                    r         = m_command.ExecuteReader();
                    t.DO_ITEM = DeliveryOrderItem.TransformReader(r);
                    r.Close();

                    if ((t.DO_ITEM.SO_ITEM == null))
                    {
                        continue;
                    }
                    if (t.DO_ITEM.SO_ITEM.ID == 0)
                    {
                        continue;
                    }

                    m_command.CommandText = SalesOrderItem.GetByIDSQL(t.DO_ITEM.SO_ITEM.ID);
                    r = m_command.ExecuteReader();
                    t.DO_ITEM.SO_ITEM = SalesOrderItem.TransformReader(r);
                    r.Close();

                    t.DO_ITEM.PART = PartRepository.GetByID(m_command, t.DO_ITEM.PART.ID);
                    t.DO_ITEM.PART.UNIT_CONVERSION_LIST = PartRepository.GetUnitConversionsStatic(m_command, t.DO_ITEM.SO_ITEM.PART.ID);
                    t.PART = t.DO_ITEM.SO_ITEM.PART = t.DO_ITEM.PART;

                    double subamount = (t.DO_ITEM.SO_ITEM.SUBTOTAL / t.DO_ITEM.SO_ITEM.GetAmountInSmallestUnit()) * t.GetAmountInSmallestUnit();
                    p.TOTAL_AMOUNT_FROM_SO += subamount;

                    t.DO_ITEM.SO_ITEM.EVENT = SalesOrderRepository.GetHeaderOnly(m_command, t.DO_ITEM.SO_ITEM.EVENT.ID);
                    p.CURRENCY = ((SalesOrder)t.DO_ITEM.SO_ITEM.EVENT).CURRENCY;
                }
            }
            return(result);
        }
Ejemplo n.º 8
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);
        }