/// <summary> /// Saves a reservdel to database. /// If ReservNr = 0 then the method /// assumes that this is a new row to be added /// Otherwise an update is issued /// </summary> /// <param name="ident">Identity</param> /// <param name="reservdel">ReservdelCL</param> /// <returns>The new created or updated reservdel</returns> // 2016-02-10 KJBO public ReservdelCL saveReservdel(string ident, ReservdelCL reservdel) { CReparator cr = new CReparator(); int identOK = cr.checkIdent(ident); ReservdelCL retRes = new ReservdelCL(); if (identOK == -1) { retRes.ErrCode = -10; retRes.ErrMessage = "Ogiltigt login"; return(retRes); } // Validate that order is open for editing CServiceHuvud ch = new CServiceHuvud(); string sOpen = ch.isOpen(ident, reservdel.VartOrdernr); if (sOpen != "1") { { retRes.ErrCode = -10; if (sOpen == "-1") { retRes.ErrMessage = "Order är stängd för inmatning"; } else { retRes.ErrMessage = sOpen; } return(retRes); } } int valid = validateReservdel(reservdel); if (valid == -1) { retRes.ErrCode = -1; retRes.ErrMessage = "Felaktig serviceorder"; return(retRes); } if (valid == -10) { retRes.ErrCode = -1; retRes.ErrMessage = "Fel vid kontroll av reservdel"; return(retRes); } if (valid == -2) { retRes.ErrCode = -1; retRes.ErrMessage = "Reservdel finns inte"; return(retRes); } if (valid == -3) { retRes.ErrCode = -1; retRes.ErrMessage = "Egen reservdel måste ha en benämning"; return(retRes); } if (valid == -4) { retRes.ErrCode = -1; retRes.ErrMessage = "Det finns ingen reservdel på ordernr : " + reservdel.VartOrdernr + "rad : " + reservdel.Radnr.ToString() + " reservdelsrad : " + reservdel.ReservNr.ToString(); return(retRes); } string sSql = ""; string errText = ""; int errCode = 0; // This is a new reservdel if (reservdel.ReservNr == 0) { reservdel.ReservNr = getNextReservNr(reservdel); sSql = getInsertSQL(); } else { sSql = getUpdateSQL(); } AddOrDeleteReservdelPyr(reservdel, true, ref errText); ReparatorCL rep = cr.getReparator(ident); NxParameterCollection np = new NxParameterCollection(); setParameters(np, reservdel, rep.AnvID); int iRc = cdb.updateData(sSql, ref errText, np); if (errText == "") { AddOrDeleteReservdelPyr(reservdel, false, ref errText); if (errText != "") { errText = "Fel vid anrop till addToReservdelPyr. Felmeddelande : " + errText; errCode = -1303; } } if (errText != "") { if (errText.Length > 2000) { errText = errText.Substring(1, 2000); } if (errCode == 0) { retRes.ErrCode = -100; } else { retRes.ErrCode = errCode; } retRes.ErrMessage = errText; return(retRes); } // 2018-05-17 KJBO Check if this is a pyramidOrder CMServHuv shuv = new CMServHuv(); if (shuv.isPyramidOrder(reservdel.VartOrdernr)) { ErrorCL errCl = checkOutIfNeeded(ident, reservdel); if (errCl.ErrMessage != "") { if (errText.Length > 2000) { errText = errText.Substring(1, 2000); } retRes.ErrCode = errCl.ErrCode; retRes.ErrMessage = errCl.ErrMessage; return(retRes); } CompactStore.CCompactStore store = new CompactStore.CCompactStore(); errCl = store.genCompStoreData(ident, reservdel.VartOrdernr); if (errCl.ErrMessage != "" && errCl.ErrCode != 1) { if (errText.Length > 2000) { errText = errText.Substring(1, 2000); } retRes.ErrCode = errCl.ErrCode; retRes.ErrMessage = errCl.ErrMessage; return(retRes); } } return(getReservdel(ident, reservdel.VartOrdernr, reservdel.Radnr, reservdel.ReservNr)); }
/// <summary> /// Generate file for lagerautomat /// </summary> /// <param name="vartOrdernr"></param> /// <returns></returns> /// 2018-04-24 Indentive AB public ErrorCL genCompStoreData(string ident, string vartOrdernr) { CompactStore.CCompactStore cs = new CompactStore.CCompactStore(); return(cs.genCompStoreData(ident, vartOrdernr)); }