Example #1
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);
        }
Example #2
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);
        }
Example #3
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);
        }