/// <summary>
        /// Get all articles that are handled by
        /// pyramid as stock articles
        /// </summary>
        /// <param name="ident"></param>
        /// <returns></returns>
        private List <OrderArtCL> getCheckoutableArticles(string artnr, int getStock)
        {
            List <OrderArtCL> orderArts = new List <OrderArtCL>();
            string            sSql      = "SELECT a.artnr,  a.artnamn, a.artikelkod "
                                          + " from artikel a "
                                          + " where a.artikelkod is not null "
                                          + " and a.kategori = 1 ";

            if (artnr != "")
            {
                sSql += " and a.artnr = :artnr ";
            }
            // sSql += " order by a.artnamn ";

            NxParameterCollection pc = new NxParameterCollection();

            if (artnr != "")
            {
                pc.Add("artnr", artnr);
            }
            string    errText = "";
            DataTable dt      = cdb.getData(sSql, ref errText, pc);

            if (errText != "")
            {
                OrderArtCL oa = new OrderArtCL();
                if (errText.Length > 2000)
                {
                    errText = errText.Substring(1, 2000);
                }
                oa.ErrCode    = -100;
                oa.ErrMessage = errText;
                orderArts.Add(oa);
                return(orderArts);
            }
            // 2018-05-22 KJBO
            PyramidServ.ServiceSoapClient client = new PyramidServ.ServiceSoapClient();
            foreach (DataRow dr in dt.Rows)
            {
                OrderArtCL oa = new OrderArtCL();
                oa.Artnr      = dr["artnr"].ToString();
                oa.ArtNamn    = dr["artnamn"].ToString();
                oa.Artikelkod = dr["artikelkod"].ToString();
                // 2018-05-22 KJBO
                if (getStock == 1)
                {
                    oa.Stock = getPyramidArtStock(dr["artikelkod"].ToString(), client);
                }
                orderArts.Add(oa);
            }
            client.Close();
            return(orderArts);
        }
        /// <summary>
        /// Returns a list of ordered arts for a given order
        /// </summary>
        /// <param name="orderArtId"></param>
        /// <param name="vartOrdernr"></param>
        /// <param name="ident"></param>
        /// <returns></returns>
        private List <OrderArtCL> getOrderArt(int orderArtId, string vartOrdernr, bool getStock)
        {
            List <OrderArtCL> orderArts = new List <OrderArtCL>();

            if (orderArtId == 0 && vartOrdernr == "")
            {
                OrderArtCL oa = new OrderArtCL();
                oa.ErrCode    = -101;
                oa.ErrMessage = "Felaktigt argument";
                orderArts.Add(oa);
                return(orderArts);
            }



            string sSql = "SELECT oa.orderArtId, oa.vart_ordernr, oa.artnr, oa.coAntal, oa.ciAntal, sum(coalesce(r.antal,0)) ordAntal, a.artnamn, a.artikelkod, coalesce(oa.tempCiAntal,0) tempCiAntal "
                          + " FROM orderArt oa "
                          + " join artikel a on oa.artnr = a.artnr "
                          + " left outer join reservdel r on (oa.vart_ordernr = r.vart_ordernr and oa.artnr = r.artnr) ";

            if (orderArtId > 0)
            {
                sSql += " where oa.orderArtId = :orderArtId ";
            }
            else
            {
                sSql += " where oa.vart_ordernr = :vart_ordernr ";
            }
            sSql += " group by oa.orderArtId, oa.vart_ordernr, oa.artnr, oa.coAntal, oa.ciAntal, a.artnamn, a.artikelkod, oa.tempCiAntal ";
            NxParameterCollection np = new NxParameterCollection();

            if (orderArtId > 0)
            {
                np.Add("orderArtId", orderArtId);
            }
            else
            {
                np.Add("vart_ordernr", vartOrdernr);
            }
            string    errText = "";
            DataTable dt      = cdb.getData(sSql, ref errText, np);

            if (errText != "")
            {
                OrderArtCL oa = new OrderArtCL();
                if (errText.Length > 2000)
                {
                    errText = errText.Substring(1, 2000);
                }
                oa.ErrCode    = -100;
                oa.ErrMessage = errText;
                orderArts.Add(oa);
                return(orderArts);
            }
            // 2018-05-22 KJBO
            PyramidServ.ServiceSoapClient client = new PyramidServ.ServiceSoapClient();
            foreach (DataRow dr in dt.Rows)
            {
                OrderArtCL oa = new OrderArtCL();
                oa.OrderArtId  = Convert.ToInt32(dr["orderArtId"]);
                oa.VartOrdernr = dr["vart_ordernr"].ToString();
                oa.Artnr       = dr["artnr"].ToString();
                oa.ArtNamn     = dr["artnamn"].ToString();
                oa.Artikelkod  = dr["artikelkod"].ToString();
                oa.CoAntal     = Convert.ToDecimal(dr["coAntal"]);
                oa.CiAntal     = Convert.ToDecimal(dr["ciAntal"]);
                oa.OrdAntal    = Convert.ToDecimal(dr["ordAntal"]);
                // 2018-05-02 KJBO
                oa.TempCiAntal = Convert.ToDecimal(dr["tempCiAntal"]);
                oa.Stock       = 0;
                if (getStock)
                {
                    oa.Stock = getPyramidArtStock(oa.Artikelkod, client);
                }
                orderArts.Add(oa);
            }
            client.Close();
            return(orderArts);
        }