/// <summary> /// Deletes a reservdel identified by primary key /// </summary> /// <param name="ident">identity string</param> /// <param name="reservdel">One valid reservdel</param> /// <returns>Empty string if OK otherwise error message</returns> public string deleteReservdel(string ident, ReservdelCL reservdel) { CReparator cr = new CReparator(); int identOK = cr.checkIdent(ident); ReservdelCL retRes = new ReservdelCL(); if (identOK == -1) { return("Ogiltigt login"); } // 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") { return("Order är stängd för inmatning"); } else { return(sOpen); } } } int exists = validateReservdelExists(reservdel); if (exists == 0) { return("Reservdel finns ej"); } string sSql = ""; sSql = getDeleteSQL(); NxParameterCollection np = new NxParameterCollection(); setParameters(np, reservdel, ""); string errText = ""; AddOrDeleteReservdelPyr(reservdel, true, ref errText); if (errText == "") { cdb.updateData(sSql, ref errText, np); } if (errText != "") { if (errText.Length > 2000) { errText = errText.Substring(1, 2000); } return(errText); } return(""); }
/// <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)); }
public List <ServiceHuvudCL> getServHuvForUser(string ident) { CServiceHuvud cs = new CServiceHuvud(); return(cs.getServHuvForUser(ident)); }
public ServiceHuvudCL getServHuv(string ident, string vartOrdernr) { CServiceHuvud cs = new CServiceHuvud(); return(cs.getServHuv(ident, vartOrdernr)); }
/// <summary> /// Check if an order is open for editing /// The return value is a string, 1 = open, -1 = closed or an error message /// </summary> /// <param name="ident"></param> /// <param name="VartOrdernr"></param> /// <returns>1 - Open -1 - Closed or an error message</returns> public string isOpen(string ident, string VartOrdernr) { CServiceHuvud cs = new CServiceHuvud(); return(cs.isOpen(ident, VartOrdernr)); }
public List <ListServHuvCL> getServHuv(string ident, int selType) { CServiceHuvud csh = new CServiceHuvud(); return(csh.getServHuv(ident, selType)); }
/// <summary> /// Count reparators for a certain order /// Returns number of reparators or -1 for error /// </summary> /// <param name="vart_ordernr"></param> /// <param name="ident"></param> /// <returns></returns> public int countReparator(string vart_ordernr, string ident) { CServiceHuvud ch = new CServiceHuvud(); return(ch.countReparator(vart_ordernr, ident)); }
/// <summary> /// Delete a picture from the database identified by /// values provided in the PictureCL parameter /// vartOrdernr /// radnr /// bildNr /// /// Note that the pictIdent parameter doesnt need to /// be filled in this case. /// /// /// The method returns an empty picture class if /// everything is OK /// If anything goes wrong the errCode and the errMessage /// will give further information. /// </summary> /// <param name="ident"></param> /// <param name="p"></param> /// <returns></returns> /// 2016-03-11 Pergas AB KJBO public PictureCL deletePicture(string ident, PictureCL p) { CReparator cr = new CReparator(); int identOK = cr.checkIdent(ident); // Creates a class to return an error PictureCL pN = new PictureCL(); if (identOK == -1) { pN.ErrCode = -10; pN.ErrMessage = "Ogiltigt login"; return(pN); } // Init variable string err = ""; int valid = validatePicture(p, true, false, ref err); if (valid == -4 || valid == -3) { pN.ErrCode = -1; pN.ErrMessage = "Det finns ingen bild lagrad för vårt ordernr : " + p.VartOrdernr + ", radnr : " + p.Radnr.ToString() + " bild nr : " + p.BildNr.ToString(); return(pN); } CServiceHuvud ch = new CServiceHuvud(); string sOpen = ch.isOpen(ident, p.VartOrdernr); if (sOpen != "1") { { deletePict(p.PictIdent); pN.ErrCode = -10; if (sOpen == "-1") { pN.ErrMessage = "Order är stängd för inmatning"; } else { pN.ErrMessage = sOpen; } return(pN); } } string sSql = ""; sSql = " delete from servrad_bild " + " where vart_ordernr = :vart_ordernr " + " and radnr = :radnr " + " and bild_nr = :bild_nr "; NxParameterCollection np = new NxParameterCollection(); setParameters(np, p, false); string errText = ""; int iRc = cdb.updateData(sSql, ref errText, np); if (errText != "") { if (errText.Length > 2000) { errText = errText.Substring(1, 2000); } pN.ErrCode = -100; pN.ErrMessage = errText; return(pN); } p.VartOrdernr = ""; p.Radnr = 0; p.BildNr = 0; p.PictIdent = ""; p.ErrCode = 0; p.ErrMessage = ""; p.Description = ""; p.PictCatID = 0; return(p); }
/// <summary> /// Saves a picture to the database /// This method shall be called directory after /// a call to UploadPict /// The UploadPict gives you (upon success) /// an identity (=filename) to the upoaded file /// This identity is provided to this function /// in the PictureCL class /// If PictureCL.bildnr = 0 indicates new picture /// Otherwise providing picture number indicates update /// /// </summary> /// <param name="ident"></param> /// <param name="p"></param> /// <returns></returns> // 2016-03-07 KJBO public PictureCL savePicture(string ident, PictureCL p) { CReparator cr = new CReparator(); int identOK = cr.checkIdent(ident); // Creates a class to return an error PictureCL pN = new PictureCL(); if (identOK == -1) { deletePict(p.PictIdent); pN.ErrCode = -10; pN.ErrMessage = "Ogiltigt login"; return(pN); } // Init variable string err = ""; int valid = validatePicture(p, false, false, ref err); if (valid == -1 || valid == -2 || valid == -5) { deletePict(p.PictIdent); pN.ErrCode = -1; pN.ErrMessage = "Kan ej hitta order"; return(pN); } if (valid == -4) { deletePict(p.PictIdent); pN.ErrCode = -1; pN.ErrMessage = "Bildnummer saknas för aktuell servicerad"; return(pN); } if (valid == -6) { pN.ErrCode = -1; pN.ErrMessage = "Bild saknas i uppladdningbiblioteket"; return(pN); } if (valid == -7) { pN.ErrCode = -1; pN.ErrMessage = "Felaktig bildkategori (PictCatID) "; return(pN); } CServiceHuvud ch = new CServiceHuvud(); string sOpen = ch.isOpen(ident, p.VartOrdernr); if (sOpen != "1") { { deletePict(p.PictIdent); pN.ErrCode = -10; if (sOpen == "-1") { pN.ErrMessage = "Order är stängd för inmatning"; } else { pN.ErrMessage = sOpen; } return(pN); } } string sSql = ""; if (p.BildNr == 0) { // This is a new bild p.BildNr = getNextBildNr(p); sSql = getInsertSQL(); } else { sSql = getUpdateSQL(true); } NxParameterCollection np = new NxParameterCollection(); setParameters(np, p, true); string errText = ""; int iRc = cdb.updateData(sSql, ref errText, np); if (errText != "") { if (errText.Length > 2000) { errText = errText.Substring(1, 2000); } pN.ErrCode = -100; pN.ErrMessage = errText; return(pN); } deletePict(p.PictIdent); return(p); }