// 2018-08-30 KJBO public ErrorCL updateCiAntal(int orderArtId, Decimal antal) { ErrorCL err = new ErrorCL(); err.ErrCode = 0; err.ErrMessage = ""; string sSql = " update orderArt " + " set ciAntal = :ciAntal " + " where orderArtId = :orderArtId "; NxParameterCollection pc = new NxParameterCollection(); pc.Add("ciAntal", antal); pc.Add("orderArtId", orderArtId); string errText = ""; cdb.updateData(sSql, ref errText, pc); if (errText != "") { if (errText.Length > 2000) { errText = errText.Substring(1, 2000); } err.ErrCode = -100; err.ErrMessage = errText; } return(err); }
public ErrorCL generateFile(List <CArticleCommitData> data, string aExtens) { ErrorCL err = new ErrorCL(); err.ErrCode = 0; err.ErrMessage = ""; if (data.Count == 0) { return(err); } extens = aExtens; string error = ""; string tempDir = getTempPath(ref error); if (error == "") { error = createFile(data); } if (error != "") { err.ErrCode = -1210; err.ErrMessage = error; } return(err); }
/// <summary> /// Set a new value to column tempCiAntal on table orderArt /// This is a temporary value (to be committed later) for /// how many items that will be inserted into CompactStore /// after a serviceorder session /// </summary> /// <param name="ident"></param> /// <param name="orderArtId"></param> /// <param name="newValue"></param> /// <returns></returns> /// 2018-05-02 KJBO Indentive AB public ErrorCL setTempCiAntal(string ident, int orderArtId, decimal newValue) { CReparator cr = new CReparator(); int identOK = cr.checkIdent(ident); if (identOK == -1) { ErrorCL err = new ErrorCL(); err.ErrCode = -10; err.ErrMessage = "Ogiltigt login"; return(err); } return(setTempCiAntal(orderArtId, "", "", newValue)); }
private ErrorCL setTempCiAntal(int orderArtId, string vartOrdernr, string artnr, decimal tempCiAntal) { ErrorCL errCl = new ErrorCL(); errCl.ErrCode = 0; errCl.ErrMessage = ""; string sSql = " update orderArt " + " set tempCiAntal = :tempCiAntal "; if (orderArtId != 0) { sSql += " where orderArtId = :orderArtId "; } else { sSql += " where vart_ordernr = :vart_ordernr " + " and artnr = :artnr "; } NxParameterCollection pc = new NxParameterCollection(); pc.Add("tempCiAntal", tempCiAntal); if (orderArtId != 0) { pc.Add("orderArtId", orderArtId); } else { pc.Add("vart_ordernr", vartOrdernr); pc.Add("artnr", artnr); } string errText = ""; cdb.updateData(sSql, ref errText, pc); if (errText != "") { errCl.ErrCode = -100; errText = "Error when updating tempCiAntal on orderArt table. Message : " + errText; if (errText.Length > 2000) { errText = errText.Substring(1, 2000); } errCl.ErrMessage = errText; return(errCl); } return(errCl); }
private ErrorCL resendServHuv(string ident) { ErrorCL err = new ErrorCL(); err.ErrCode = 0; err.ErrMessage = ""; ServHuvCL sh = new ServHuvCL(); CMServHuv csh = new CMServHuv(); sh.Vart_ordernr = vart_ordernr; sh = csh.getServiceHuvud(sh, ident); if (sh.ErrCode != 0) { err.ErrCode = sh.ErrCode; err.ErrMessage = sh.ErrMessage; return(err); } err = pyrExp.exportOrder(sh); return(err); }
/// <summary> /// Generate file for lagerautomat /// </summary> /// <param name="vartOrdernr"></param> /// <returns></returns> /// 2018-04-24 Indentive AB public ErrorCL genCompStoreData(string ident, string vartOrdernr) { ErrorCL err = new ErrorCL(); err.ErrCode = 0; err.ErrMessage = ""; CReparator cr = new CReparator(); int identOK = cr.checkIdent(ident); if (identOK == -1) { err.ErrCode = -100; err.ErrMessage = "Ogiltigt login"; return(err); } Decimal countArticles = countArtForStorageAut(vartOrdernr); if (countArticles > -0.001M && countArticles < 0.001M) { err.ErrCode = 1; err.ErrMessage = "Inga artiklar att skicka till lageraut. Order number : " + vartOrdernr; return(err); } string error = ""; string tempDir = getTempPath(ref error); if (error == "") { error = createFile(tempDir, vartOrdernr); } if (error != "") { err.ErrCode = -1207; err.ErrMessage = error; } return(err); }
/// <summary> /// Commits the temporary temCiAntal to /// the real ciAntal in the orderArt table /// </summary> /// <param name="ident"></param> /// <param name="vartOrdernr"></param> /// <returns></returns> /// 2018-05-02 KJBO Indentive AB public ErrorCL commitTempCiAntal(string ident, string vartOrdernr) { ErrorCL err = new ErrorCL(); err.ErrCode = 0; err.ErrMessage = ""; CReparator cr = new CReparator(); int identOK = cr.checkIdent(ident); if (identOK == -1) { err.ErrCode = -10; err.ErrMessage = "Ogiltigt login"; return(err); } string sSql = " update orderArt " + " set ciAntal = ciAntal + coalesce(tempCiAntal, 0) " + " where vart_ordernr = :vart_ordernr "; string error = ""; NxParameterCollection pc = new NxParameterCollection(); pc.Add("vart_ordernr", vartOrdernr); cdb.updateData(sSql, ref error, pc); if (error != "") { err.ErrCode = -100; if (error.Length > 2000) { error = error.Substring(1, 2000); } err.ErrMessage = error; return(err); } return(err); }
/// <summary> /// Delete a registered gasket /// </summary> /// <param name="ident"></param> /// <param name="gasketId"></param> /// <returns>Error class.</returns> /// 2018-08-21 KJBO Indentive AB public ErrorCL deleteGasket(string ident, int gasketId) { ErrorCL err = new ErrorCL(); err.ErrCode = 0; err.ErrMessage = ""; CReparator cr = new CReparator(); int identOK = cr.checkIdent(ident); if (identOK == -1) { err.ErrCode = -10; err.ErrMessage = "Ogiltigt login"; return(err); } string sSql = " delete from gGasket where gasketId = :gasketId "; NxParameterCollection pc = new NxParameterCollection(); pc.Add("gasketId", gasketId); string errTxt = ""; int rc = cdb.updateData(sSql, ref errTxt, pc); if (errTxt != "") { if (errTxt.Length > 2000) { errTxt = errTxt.Substring(1, 2000); } err.ErrCode = -100; err.ErrMessage = errTxt; return(err); } return(err); }
/// <summary> /// Calculate how many artikel that shall remain /// on a service order and suggest the checkin /// value by calling setTemCiAntal /// </summary> /// <param name="ident"></param> /// <param name="vartOrdernr"></param> /// <returns>Error class</returns> /// 2018-05-02 KJBO Indentive AB public ErrorCL calculateCiOrderArt(string ident, string vartOrdernr) { ErrorCL errCl = new ErrorCL(); string sSql = " SELECT artnr, coAntal - ciAntal netto " + " FROM orderArt " + " where vart_ordernr = :vart_ordernr "; NxParameterCollection pc = new NxParameterCollection(); pc.Add("vart_ordernr", vartOrdernr); string sSqlReservdel = " select coalesce(sum(antal),0) sum_antal " + " from reservdel " + " where vart_ordernr = :vart_ordernr " + " and artnr = :artnr "; NxParameterCollection pcReserv = new NxParameterCollection(); NxCommand cmReserv = new NxCommand(sSqlReservdel, cdb.getConn()); NxDataAdapter daReserv = new NxDataAdapter(cmReserv); cmReserv.Parameters.Add("vart_ordernr", vartOrdernr); cmReserv.Parameters.Add("artnr", ""); DataTable dtReserv = new DataTable(); string errText = ""; DataTable dt = cdb.getData(sSql, ref errText, pc); if (errText != "") { errText = "Error when retrieving data from orderArt table. Message : " + errText; if (errText.Length > 2000) { errText = errText.Substring(1, 2000); } errCl.ErrCode = -100; errCl.ErrMessage = errText; return(errCl); } foreach (DataRow dr in dt.Rows) { string artnr = dr["artnr"].ToString(); Decimal ciNetto = Convert.ToDecimal(dr["netto"]); Decimal countReserv = 0; try { cmReserv.Parameters["artnr"].Value = artnr; dtReserv.Rows.Clear(); daReserv.Fill(dtReserv); if (dtReserv.Rows.Count > 0) { countReserv = Convert.ToDecimal(dtReserv.Rows[0]["sum_antal"]); } } catch (Exception ex) { errCl.ErrCode = -100; errText = "Error when retrieving data from reservdel table. Message : " + ex.Message; if (errText.Length > 2000) { errText = errText.Substring(1, 2000); } errCl.ErrMessage = errText; return(errCl); } ciNetto -= countReserv; ciNetto = Math.Round(ciNetto * 100) / 100; errCl = setTempCiAntal(0, vartOrdernr, artnr, ciNetto); if (errCl.ErrCode != 0) { return(errCl); } } errCl.ErrCode = 0; errCl.ErrMessage = ""; return(errCl); }
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]); }
/// <summary> /// Reset export all Pyramid export /// settings for an order /// </summary> /// <param name="aVart_ordernr"></param> /// <param name="ident"></param> /// <returns>ErrorCL</returns> /// 2018-11-02 KJBO public ErrorCL resetExport(string aVart_ordernr, string ident) { ErrorCL err = new ErrorCL(); CReparator cr = new CReparator(); int identOK = cr.checkIdent(ident); if (identOK == -1) { err.ErrCode = -10; err.ErrMessage = "Ogiltigt login"; return(err); } ReparatorCL reparator = cr.getReparator(ident); vart_ordernr = aVart_ordernr; err = resendServHuv(ident); if (err.ErrCode != 0) { return(err); } err.ErrMessage = resetOrderArt(); if (err.ErrMessage != "") { err.ErrCode = -36102; return(err); } err.ErrMessage = resetReservdel(); if (err.ErrMessage != "") { err.ErrCode = -36103; return(err); } err.ErrMessage = resetServHuvRepTid(); if (err.ErrMessage != "") { err.ErrCode = -36104; return(err); } err.ErrMessage = resetServRadRepTid(); if (err.ErrMessage != "") { err.ErrCode = -36105; return(err); } // 2018-12-03 KJBO err.ErrMessage = pyrExp.resetPyramidExport(vart_ordernr); if (err.ErrMessage != "") { err.ErrCode = -36106; return(err); } pyrExp.addToPyramidChange(vart_ordernr, reparator.AnvID, 3); return(err); }