Пример #1
0
        public List<Aid> getAllAid(string onr)
        {
            List<Aid> lst = new List<Aid>();
            Aid aid;

            mOGR.find(onr);
            mOGR.next();

            while (mOGR.getValue("ONR").Equals(onr) && !mOGR.EOF)
            {
                OrderRowDefinitions.OrderRow or = fillOrderRow(ref mOGR);

                // Check if we alreade have aid in list
                if (lst.Exists(o => o.AidNr == or.AidNr))
                    aid = lst.Find(o => o.AidNr == or.AidNr);
                else
                {
                    aid = new Aid();
                    aid.OrderRows = new List<OrderRowDefinitions.OrderRow>();
                    aid.AidNr = or.AidNr;

                    if (mOGA.find(onr))
                        aid.PaymentTerms = mOGA.getValue("BVK");

                    lst.Add(aid);
                }

                if (!isEgenAvgift(mOGR.getValue("ANR")))
                {
                    if (or.ViewInList)
                    {
                        aid.Product = or;
                        aid.Text = oOrText.getAidsText(or.OrderNo, or.Rad);
                    }

                    try
                    {
                        Log4Net.Logger.loggInfo("STEP 9.1.01", "", "");

                        if (isInternalProduct(or.Artikel))
                            aid.SumInternalProducts += Convert.ToDouble(or.APris.Replace(".", ",")) * Convert.ToDouble(or.Antal.Replace(".", ","));
                        else
                            aid.SumExternalProducts += Convert.ToDouble(or.APris.Replace(".", ",")) * Convert.ToDouble(or.Antal.Replace(".", ","));
                    }
                    catch (Exception e)
                    {
                        Log4Net.Logger.loggError(e, "Error in getAid while determine internal or external product", "", "");
                    }

                    aid.OrderRows.Add(or);
                }
                else
                {
                    try
                    {
                        aid.OwnFee += Convert.ToDouble(or.APris.Replace(".", ","));
                    }
                    catch (Exception e)
                    {
                        aid.OwnFee += 0;
                        Log4Net.Logger.loggError(e, "Error in getAid while determine internal or external product", "", "");
                    }
                }

                mOGR.next();
            }

            foreach (Aid a in lst)
            {
                if (GCF.noNULL(a.Product.OrderNo).Equals(""))
                {
                    try
                    {
                        a.Product = a.OrderRows[0];
                    }
                    catch { }
                }
            }
            return lst;
        }
Пример #2
0
        public Aid getAid(string onr, string aidid, bool includeOwnFeeRow)
        {
            ArrayList s = new ArrayList();
            Aid aid = new Aid();
            aid.OrderRows = new System.Collections.Generic.List<OrderRowDefinitions.OrderRow>();
            aid.AidNr = aidid;

            mOGR.find(onr);
            mOGR.next();

            if (mOGA.find(onr))
                aid.PaymentTerms = mOGA.getValue("BVK");

            aid.OrderNo = mOGR.getValue("ONR");

            while (mOGR.getValue("ONR").Equals(onr) && !mOGR.EOF)
            {
                OrderRowDefinitions.OrderRow or = fillOrderRow(ref mOGR);

                if ((or.AidNr == aidid.Trim()))
                {
                    if (!isEgenAvgift(mOGR.getValue("ANR")))
                    {
                        if (or.ViewInList)
                        {
                            aid.Product = or;
                            aid.Text = oOrText.getAidsText(or.OrderNo, or.Rad);
                        }

                        try
                        {
                            if (isInternalProduct(or.Artikel))
                                aid.SumInternalProducts += Convert.ToDouble(or.APris.Replace(".", ",")) * Convert.ToDouble(or.Antal.Replace(".", ","));
                            else
                                aid.SumExternalProducts += Convert.ToDouble(or.APris.Replace(".", ",")) * Convert.ToDouble(or.Antal.Replace(".", ","));
                        }
                        catch (Exception e)
                        {
                            Log4Net.Logger.loggError(e, "Error in getAid while determine internal or external product", "", "");

                        }

                        aid.OrderRows.Add(or);
                    }
                    else
                    {
                        try
                        {
                            aid.OwnFee += Convert.ToDouble(or.APris.Replace(".", ","));

                        }
                        catch (Exception e)
                        {
                            aid.OwnFee += 0;
                            Log4Net.Logger.loggError(e, "Error in getAid while determine internal or external product", "", "");
                        }

                        if (includeOwnFeeRow)
                            aid.OrderRows.Add(or);

                    }
                }

                mOGR.next();
            }

            if (GCF.noNULL(aid.Product.OrderNo).Equals(""))
            {
                try
                {
                    aid.Product = aid.OrderRows[0];
                }
                catch { }
            }

            return aid;
        }