Exemple #1
0
        private void resendToPyramid()
        {
            String sSql = " select vart_ordernr "
                          + " from serviceHuvud "
                          + " where SentToPyramid = false ";
            String    errStr = "";
            DataTable dt     = cdb.getData(sSql, ref errStr);

            ExportToPyramid.CExportToPyramid expPyr = new ExportToPyramid.CExportToPyramid();
            foreach (DataRow dr in dt.Rows)
            {
                ServHuvCL sh = new ServHuvCL();
                sh.Vart_ordernr = dr["vart_ordernr"].ToString();
                sh = getServiceHuvud(sh);
                ErrorCL errCl = expPyr.exportOrder(sh);
            }
        }
        public OrderArtCL checkoutOrderArt(OrderArtCL oa, string id, bool acceptGodkand)
        {
            ExportToPyramid.CExportToPyramid pyExport = new ExportToPyramid.CExportToPyramid();
            string exportErr = pyExport.checkPyramidAPIAvailable();

            if (exportErr != "")
            {
                OrderArtCL oacl = new OrderArtCL();
                oacl.ErrCode    = -18250;
                oacl.ErrMessage = exportErr;
                return(oacl);
            }

            ReparatorCL rep = null;

            if (id == "")
            {
                rep       = new ReparatorCL();
                rep.AnvID = "Pyramid";
            }
            else
            {
                CReparator cr = new CReparator();
                rep = cr.getReparator(id);
            }
            // 2018-04-23 KJBO
            // Special handling due to gui limitations
            //if (oa.OrderArtId != 0 && oa.Artnr == null)
            //{
            //    oa.Artnr = getArtnrForOrderArt(oa.OrderArtId);
            //}


            if (oa.VartOrdernr == "")
            {
                OrderArtCL oaRet = new OrderArtCL();
                oaRet.ErrCode    = -103;
                oaRet.ErrMessage = "Ordernummer måste anges";
                return(oaRet);
            }

            if (oa.Artnr == "")
            {
                OrderArtCL oaRet = new OrderArtCL();
                oaRet.ErrCode    = -104;
                oaRet.ErrMessage = "Artikelnummer måste anges";
                return(oaRet);
            }


            string errTxt = "";
            int    rc     = validateOa(oa, ref errTxt);

            if (rc == -1)
            {
                OrderArtCL oaRet = new OrderArtCL();
                oaRet.ErrCode    = -106;
                oaRet.ErrMessage = "Felaktigt ordernr";
                return(oaRet);
            }

            if (rc == -2)
            {
                OrderArtCL oaRet = new OrderArtCL();
                oaRet.ErrCode = -107;
                if (errTxt == "")
                {
                    oaRet.ErrMessage = "Felaktigt ordernr";
                }
                else
                {
                    oaRet.ErrMessage = errTxt;
                }
                return(oaRet);
            }

            if (!acceptGodkand)
            {
                if (rc == -3)
                {
                    OrderArtCL oaRet = new OrderArtCL();
                    oaRet.ErrCode = -108;
                    if (errTxt == "")
                    {
                        oaRet.ErrMessage = "Ordern är godkänd. Ändringar ej tillåtna";
                    }
                    else
                    {
                        oaRet.ErrMessage = errTxt;
                    }
                    return(oaRet);
                }
            }

            string sSql = "";

            // 2018-04-30 KJBO
            if (oa.OrderArtId == 0)
            {
                decimal toBeAdded = 0;
                oa.OrderArtId = reuseOrderArtId(oa, ref toBeAdded);
                if (oa.OrderArtId != 0)
                {
                    oa.CoAntal += toBeAdded;
                }
            }
            if (oa.OrderArtId == 0)
            {
                sSql = getOaInsertSql();
            }
            else
            {
                sSql = getOaUpdateSql();
            }
            NxParameterCollection pc = new NxParameterCollection();

            setOaParameters(pc, oa, oa.OrderArtId == 0, rep.AnvID);

            int li_rc = cdb.updateData(sSql, ref errTxt, pc);

            if (errTxt != "")
            {
                OrderArtCL oaRet = new OrderArtCL();
                if (errTxt.Length > 2000)
                {
                    errTxt = errTxt.Substring(1, 2000);
                }
                oaRet.ErrCode    = -100;
                oaRet.ErrMessage = errTxt;
                return(oaRet);
            }

            if (oa.OrderArtId == 0)
            {
                sSql = "SELECT MAX(orderArtId) orderArtId FROM orderArt ";
                DataTable dt = cdb.getData(sSql, ref errTxt);


                if (errTxt != "")
                {
                    OrderArtCL oaRet = new OrderArtCL();
                    if (errTxt.Length > 2000)
                    {
                        errTxt = errTxt.Substring(1, 2000);
                    }
                    oaRet.ErrCode    = -100;
                    oaRet.ErrMessage = errTxt;
                    return(oaRet);
                }
                oa.OrderArtId = Convert.ToInt32(dt.Rows[0][0]);
            }



            List <OrderArtCL> oaList = getOrderArt(oa.OrderArtId, "");

            if (oaList.Count != 1)
            {
                OrderArtCL oaRet = new OrderArtCL();
                if (errTxt.Length > 2000)
                {
                    errTxt = errTxt.Substring(1, 2000);
                }
                oaRet.ErrCode    = -110;
                oaRet.ErrMessage = "Error when retrieving orderArt";
                return(oaRet);
            }

            ErrorCL errCl = pyExport.reserveArticle(oaList[0].OrderArtId);

            //pyExport.retryAllOrders();
            return(oaList[0]);
        }
Exemple #3
0
 /// <summary>
 /// Retuns a key-value list of available selection
 /// for the below getExportFullList
 /// </summary>
 /// <param name="ident"></param>
 /// <returns></returns>
 /// 2018-05-31 KJBO
 public List <KeyValuePair <int, string> > getExportListSelection(string ident)
 {
     ExportToPyramid.CExportToPyramid pExp = new ExportToPyramid.CExportToPyramid();
     return(pExp.getExportListSelection(ident));
 }
Exemple #4
0
 /// <summary>
 /// Get a full export list for one order. This list can reflect all items that will be exported
 /// or all items that is already exported by setting the exported boolean flag.
 /// </summary>
 /// <param name="ident"></param>
 /// <param name="vartOrdernr"></param>
 /// <param name="exported"></param>
 /// <returns>A list of orderArtCL type</returns>
 /// 2018-05-30 KJBO Indentive AB
 public List <OrderArtCL> getExportFullList(string ident, string vartOrdernr, int listType)
 {
     ExportToPyramid.CExportToPyramid pExp = new ExportToPyramid.CExportToPyramid();
     return(pExp.getExportFullList(ident, vartOrdernr, listType));
 }
Exemple #5
0
 /// <summary>
 /// Exports all timerecords to Pyramid by
 /// aggregating on konto (=artikel)
 /// </summary>
 /// <param name="vartOrdernr"></param>
 /// <returns></returns>
 /// 2018-05-03 KJBO Indentive AB
 public ErrorCL exportTime(string vartOrdernr)
 {
     ExportToPyramid.CExportToPyramid cexp = new ExportToPyramid.CExportToPyramid();
     return(cexp.exportTime(vartOrdernr));
 }