/// <summary> /// Login function /// Also takes care of handling guids for the anvandare /// </summary> /// <param name="AnvID">Userid</param> /// <param name="pwd">Password</param> /// <returns>A guid valid in 24 hours to identify the reparator/user</returns> public string login(string AnvID, string pwd) { // Create parameter collection NxParameterCollection pc = new NxParameterCollection(); // Add anvandID and pwd as parameters pc.Add("pAnvID", AnvID); pc.Add("pPwd", pwd); // Create SQL clause string sSql = " select reparator from reparator " + " where anvID = :pAnvID " + " and pwd = :pPwd " + " and visas = true "; string errSt = ""; DataTable dt = cdb.getData(sSql, ref errSt, pc); if (errSt != "") { return("-1" + errSt); } if (dt.Rows.Count == 1) { return(UpdateAuthenticate(AnvID)); } return(""); }
/// <summary> /// Check if a user has a valid authentication /// </summary> /// <param name="ident">Identity GUID</param> /// <returns>1 = OK, -1 doesnt exist</returns> public int checkIdent(string ident) { string sSql = " select AnvID " + " from Authenticate " + " where ident = :pIdent " + " and validUntil >= :pValidUntil "; NxParameterCollection pColl = new NxParameterCollection(); DateTime validUntil = DateTime.Now; pColl.Add("pIdent", ident); pColl.Add("pValidUntil", validUntil); string errSt = ""; DataTable dt = cdb.getData(sSql, ref errSt, pColl); CLog cl = new CLog(); if (dt.Rows.Count > 0) { string anvID = dt.Rows[0]["AnvID"].ToString(); cl.log("Authenticating identity : " + anvID + " (" + ident + ")", "1"); return(1); } cl.log("Authenticating identity : " + ident, "-1"); return(-1); }
private void addToReservdelPyr(ReservdelCL r, ref string error) { string sSql = " update reservdelPyr " + " set antal = antal + :antal " + " where vart_ordernr = :vart_ordernr " + " and artnr = :artnr " + " and artnamn = :artnamn " + " and PyramidExport is null "; error = ""; NxParameterCollection pc = new NxParameterCollection(); pc.Add("vart_ordernr", r.VartOrdernr); pc.Add("artnr", r.Artnr); pc.Add("antal", r.Antal); pc.Add("artnamn", r.ArtNamn); int updated = cdb.updateData(sSql, ref error, pc); if (error != "") { return; } if (updated < 1) { sSql = " insert into reservdelPyr(vart_ordernr, artnr, artnamn, antal) " + " values (:vart_ordernr, :artnr, :artnamn, :antal) "; cdb.updateData(sSql, ref error, pc); } return; }
/// <summary> /// Updates the AllRep flag on an order /// (This flag indicates that all reparators /// can log in. The normal process is that /// there is a list (in the shReparator table) with /// the reparators that can log in on a certain order). /// </summary> /// <param name="VartOrdernr"></param> /// <param name="allRep"></param> /// <param name="ident"></param> /// <returns></returns> /// 2018-02-08 KJBO public ServHuvCL updateAllRep(string VartOrdernr, bool allRep, string ident) { ServHuvCL shc = new ServHuvCL(); CReparator cr = new CReparator(); ReparatorCL repIdent = cr.getReparator(ident); string sSql = " update servicehuvud " + " set AllRep = :AllRep " + " where vart_ordernr = :vart_ordernr "; NxParameterCollection np = new NxParameterCollection(); np.Add("AllRep", allRep); np.Add("vart_ordernr", VartOrdernr); string errText = ""; int iRc = cdb.updateData(sSql, ref errText, np); if (errText != "") { if (errText.Length > 2000) { errText = errText.Substring(1, 2000); } shc.ErrCode = -100; shc.ErrMessage = errText; return(shc); } shc.Vart_ordernr = VartOrdernr; return(getServiceHuvud(shc, ident)); }
// 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); }
private int checkUniqueMaterialShort(gMaterialCL m, ref string errTxt) { string sSql = " SELECT count(*) countRows " + " FROM gMaterial " + " where materialShort = :materialShort "; if (m.materialId != 0) { sSql += " and materialId <> :materialId"; } NxParameterCollection pc = new NxParameterCollection(); pc.Add("materialShort", m.materialShort); if (m.materialId != 0) { pc.Add("materialId", m.materialId); } errTxt = ""; DataTable dt = cdb.getData(sSql, ref errTxt, pc); if (errTxt != "") { return(-1); } if (dt.Rows.Count == 0) { return(-1); } DataRow dr = dt.Rows[0]; return(Convert.ToInt32(dr["countRows"])); }
private bool checkUniqueThicknShort(gMaterialThicknCL mt, ref string errTxt) { string sSql = " select count(*) countThicknShort " + " from gMaterialThickn " + " where thicknShort = :thicknShort " + " and materialSizeId = :materialSizeId "; if (mt.materialThicknId > 0) { sSql += " and materialThicknId <> :materialThicknId "; } NxParameterCollection pc = new NxParameterCollection(); pc.Add("thicknShort", mt.thicknShort); pc.Add("materialSizeId", mt.materialSizeId); if (mt.materialThicknId > 0) { pc.Add("materialThicknId", mt.materialThicknId); } DataTable dt = cdb.getData(sSql, ref errTxt, pc); if (errTxt != "") { return(false); } if (dt.Rows.Count == 0) { return(false); } DataRow dr = dt.Rows[0]; return(Convert.ToInt32(dr["countThicknShort"]) == 0); }
private DataTable getOrderArtRows(string vartOrdernr, ref string error) { String sSql = "select oa.orderArtId, a.artnamn, a.artikelkod, coalesce(sum(oa.coAntal),0) - coalesce(sum(oa.ciAntal),0) sum_antal " + " from orderArt oa " + " join artikel a on oa.artnr = a.artnr " + " where oa.vart_ordernr = :vart_ordernr " + " group by oa.orderArtId, a.artnamn, a.artikelkod "; String sSqlOa = "select coalesce(sum(oas.antal),0) oa_sum " + " from oaStorage oas " + " where oas.orderArtId = :orderArtId "; NxParameterCollection pc = new NxParameterCollection(); pc.Add("vart_ordernr", vartOrdernr); pc.Add("orderArtId", DbType.Int32); error = ""; DataTable dt = cdb.getData(sSql, ref error, pc); dt.Columns.Add("oa_sum", Type.GetType("System.Decimal")); DataTable dt2 = null; foreach (DataRow dr in dt.Rows) { int orderArtId = Convert.ToInt32(dr["orderArtId"]); pc["orderArtId"].Value = orderArtId; dt2 = cdb.getData(sSqlOa, ref error, pc); if (dt2.Rows.Count > 0) { dr["oa_sum"] = Convert.ToDecimal(dt2.Rows[0]["oa_sum"]); } } return(dt); }
/// <summary> /// This is the login function for SmManager service /// The reparator has to be in the category of AL_ST /// in order to be accepted /// </summary> /// <param name=Login parameters></param> /// <returns>Login parameters with reparator name and ident added</returns> public LoginAdm loginAdmin(LoginAdm login) { // Create parameter collection NxParameterCollection pc = new NxParameterCollection(); // Add anvandID and pwd as parameters pc.Add("pAnvID", login.AnvID); pc.Add("pPwd", login.pwd); // Create SQL clause string sSql = " select reparator, rep_kat_id, coalesce(canResetPyramid,false) canResetPyramid from reparator " + " where anvID = :pAnvID " + " and pwd = :pPwd " + " and visas = true "; string errSt = ""; DataTable dt = cdb.getData(sSql, ref errSt, pc); LoginAdm la = new LoginAdm(); if (errSt != "") { la.ErrCode = -1; la.ErrMessage = errSt; return(la); } if (dt.Rows.Count == 0) { la.ErrCode = 1001; la.ErrMessage = "Felaktigt användarnamn eller lösenord"; return(la); } DataRow dr = dt.Rows[0]; if (dr["rep_kat_id"].ToString() != "AL_ST") { la.ErrCode = 1002; la.ErrMessage = "Rättigheter saknas till denna app"; return(la); } la.AnvID = login.AnvID; la.ident = UpdateAuthenticate(login.AnvID); la.pwd = ""; la.reparator = dr["reparator"].ToString(); la.canResetPyramid = Convert.ToBoolean(dr["canResetPyramid"]); la.ErrCode = 0; la.ErrMessage = ""; return(la); }
private NxParameterCollection setParameters(gReuseMatCL mat, ReparatorCL rep) { NxParameterCollection pc = new NxParameterCollection(); pc.Add("reuseMatId", mat.reuseMatId); pc.Add("minDiam", mat.minDiam); pc.Add("reusePercentage", mat.reusePercentage); pc.Add("reg", rep.AnvID); pc.Add("regdate", DateTime.Now); return(pc); }
private void setParameters(NxParameterCollection np, gWorkingCostCL wc, ReparatorCL rep) { DateTime now = DateTime.Now; np.Add("workingCostId", wc.workingCostId); np.Add("cuttingHourNet", wc.cuttingHourNet); np.Add("cuttingHourSales", wc.cuttingHourSales); np.Add("handlingHourNet", wc.handlingHourNet); np.Add("handlingHourSales", wc.handlingHourSales); np.Add("cuttingMargin", wc.cuttingMargin); np.Add("reg", rep.AnvID); np.Add("regdate", now); np.Add("updat", rep.AnvID); np.Add("updatDat", now); }
public int validateRepKat(string repKatID) { string sSql = " SELECT count(*) countRepKat " + " FROM rep_kat " + " where rep_kat_id = :rep_kat_id "; NxParameterCollection pc = new NxParameterCollection(); pc.Add("rep_kat_id", repKatID); string errText = ""; DataTable dt = cdb.getData(sSql, ref errText, pc); int errCode = -100; if (errText == "" && dt.Rows.Count == 0) { return(-1); } if (dt.Rows.Count == 1) { int count = Convert.ToInt32(dt.Rows[0]["countRepKat"]); if (count == 1) { return(1); } else { return(-1); } } return(-1); }
/// <summary> /// Get a reparator class from anvID /// </summary> /// <param name="AnvID">ID=PK</param> /// <returns>One reparator</returns> /// public ReparatorCL getReparatorFromID(string anvID) { NxParameterCollection pc = new NxParameterCollection(); pc.Add("pAnvID", anvID); string sSql = "SELECT r.reparator, r.rep_kat_id, r.AnvID " + " FROM reparator r" + " where r.AnvID = :pAnvID " + " and r.visas = true "; string errTxt = ""; DataTable dt = cdb.getData(sSql, ref errTxt, pc); if (errTxt != "") { ReparatorCL r = new ReparatorCL(); r.Reparator = ""; r.AnvID = ""; r.RepKatID = ""; r.ErrCode = -1; r.ErrMessage = "Databasfel : " + errTxt; return(r); } if (dt.Rows.Count == 1) { ReparatorCL r = new ReparatorCL(); r.Reparator = dt.Rows[0]["reparator"].ToString(); r.AnvID = dt.Rows[0]["AnvID"].ToString(); r.RepKatID = dt.Rows[0]["rep_kat_id"].ToString(); return(r); } return(null); }
private bool validatePictCategory(PictureCL p) { if (p.PictCatID == 0) { return(false); } string sSql = " select count(*) antal " + " from PictCategory " + " where pictCatID = :pictCatID "; NxParameterCollection pc = new NxParameterCollection(); pc.Add("pictCatID", p.PictCatID); string err = ""; DataTable dt = cdb.getData(sSql, ref err, pc); if (dt.Rows.Count == 0) { return(false); } return(Convert.ToInt32(dt.Rows[0]["antal"]) == 1); }
private bool validateGasketAgainstMaterialSize(gGasketCL g) { string sSql = " SELECT ms.materialLength * 1000 materialLengthMm, ms.materialWidth * 1000 materialWidthMm " + " FROM gMaterialThickn mt " + " join gMaterialSize ms on mt.materialSizeId = ms.materialSizeId " + " where mt.materialThicknId = :materialThicknId "; string dummy = ""; NxParameterCollection pc = new NxParameterCollection(); pc.Add("materialThicknId", g.materialThicknId); DataTable dt = cdb.getData(sSql, ref dummy, pc); if (dt.Rows.Count > 0) { Decimal materialLength = Convert.ToDecimal(dt.Rows[0]["materialLengthMm"]); Decimal materialWidth = Convert.ToDecimal(dt.Rows[0]["materialWidthMm"]); if (g.outerDiam > materialLength || g.innerDiam > materialWidth) { return(false); } } else { return(false); } return(true); }
public DataRow getDeliveryAddress(string kund_id, ref string err) { String sSql = "SELECT coalesce(lev_adress1,'') lev_adress1 , " + " coalesce(lev_adress2, '') lev_adress2, " + " coalesce(lev_postnr, '') + ' ' + coalesce(lev_stad, '') lev_adress3 " + " , foretagskod " + " , kund " + " , coalesce(lev_postnr, '') + ' ' + coalesce(lev_stad, '') lev_adress4 " + " , coalesce(land, '') land " + " FROM kund " + " where kund_id = :kund_id "; NxParameterCollection pc = new NxParameterCollection(); pc.Add("kund_id", kund_id); err = ""; DataTable dt = cdb.getData(sSql, ref err, pc); if (dt.Rows.Count == 0) { err = "Adressuppgifter saknas för kund : " + kund_id; log.log("Adressuppgifter saknas för kund : " + kund_id, "0"); return(null); } return(dt.Rows[0]); }
/// <summary> /// Count how many articles that are du to /// be sent to CompactStore /// </summary> /// <param name="ident"></param> /// <param name="vartOrdernr"></param> /// <returns>No of items or -1 if error (ident fails)</returns> /// 2018-04-22 private Decimal countArtForStorageAut(string vartOrdernr) { string sSql = "SELECT coalesce(sum(oa.coAntal),0) - coalesce(sum(oa.ciAntal),0) sum_antal " + " FROM orderArt oa " + " where oa.vart_ordernr = :vart_ordernr "; NxParameterCollection pc = new NxParameterCollection(); pc.Add("vart_ordernr", vartOrdernr); string error = ""; DataTable dt = cdb.getData(sSql, ref error, pc); Decimal orderArtSum = 0; if (dt.Rows.Count > 0) { orderArtSum = Convert.ToDecimal(dt.Rows[0]["sum_antal"]); } sSql = "select coalesce(sum(oas.antal),0) sum_oas " + " from oaStorage oas " + " join orderArt oa on oas.orderArtId = oa.orderArtId " + " where oa.vart_ordernr = :vart_ordernr "; error = ""; dt = cdb.getData(sSql, ref error, pc); Decimal sum_oas = 0; if (dt.Rows.Count > 0) { sum_oas = Convert.ToDecimal(dt.Rows[0]["sum_oas"]); } return(orderArtSum - sum_oas); }
public int validateSalart(int salartID, bool forServiceDetalj, ref int salartCatID) { string sSql = " select st.SalartCatID " + " FROM Salart s " + " join SalartType st on s.salartTypeID = st.SalartTypeID "; if (forServiceDetalj) { sSql += "where s.SalartTypeID = 1"; } else { sSql += "where s.SalartTypeID > 1"; } sSql += " and s.SalartId = :salartID "; NxParameterCollection pc = new NxParameterCollection(); pc.Add("salartID", salartID); string errText = ""; DataTable dt = cdb.getData(sSql, ref errText, pc); int rc = -1; salartCatID = 0; if (dt.Rows.Count == 1) { rc = 1; salartCatID = Convert.ToInt32(dt.Rows[0]["SalartCatID"]); } return(rc); }
/// <summary> /// Get a list of all reparators connected to an order /// </summary> /// <param name="VartOrdernr"></param> /// <param name="ident"></param> /// <returns></returns> /// 2018-02-02 KJBO public List <ShReparatorCL> getShReparatorList(string VartOrdernr, string ident) { List <ShReparatorCL> shRepList = new List <ShReparatorCL>(); string sSql = "SELECT id, vart_ordernr, AnvID " + " FROM shReparator " + " where vart_ordernr = :vart_ordernr "; NxParameterCollection pc = new NxParameterCollection(); pc.Add("vart_ordernr", VartOrdernr); ErrorCL err = new ErrorCL(); DataTable dt = cdb.getData(sSql, ident, ref err, pc); if (err.ErrCode != 0) { ShReparatorCL shRep = new ShReparatorCL(); shRep.ErrCode = err.ErrCode; shRep.ErrMessage = err.ErrMessage; shRepList.Add(shRep); return(shRepList); } foreach (DataRow dr in dt.Rows) { ShReparatorCL shRep = new ShReparatorCL(); shRep.Id = Convert.ToInt32(dr["id"]); shRep.VartOrdernr = dr["vart_ordernr"].ToString(); shRep.AnvID = dr["AnvID"].ToString(); shRepList.Add(shRep); } return(shRepList); }
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); }
public void logMessage(int logLevel, string message, string messageDescr = "") { if (logLevel <= CConfig.devLogLevel) { string sSql = " insert into devLog (logDate, logLevel, message, messageDescr) " + " values(:logDate, :logLevel, :message, :messageDescr) "; NxParameterCollection pc = new NxParameterCollection(); pc.Add("logDate", DateTime.Now); pc.Add("logLevel", logLevel); pc.Add("message", message); pc.Add("messageDescr", messageDescr); string err = ""; cdb.updateData(sSql, ref err, pc); } }
/// <summary> /// Get a list of all reuse material sizes /// Set reuseMatId to 0 to get all objects /// Otherwise return only the object matching the /// Id number /// </summary> /// <param name="ident"></param> /// <param name="reuseMatId"></param> /// <returns></returns> /// 2018-08-31 KJBO public List <gReuseMatCL> getReuseMaterial(string ident, int reuseMatId) { List <gReuseMatCL> rmList = new List <gReuseMatCL>(); CReparator cr = new CReparator(); int identOK = cr.checkIdent(ident); if (identOK == -1) { gReuseMatCL gm = new gReuseMatCL(); gm.ErrCode = -10; gm.ErrMessage = "Ogiltigt login"; rmList.Add(gm); return(rmList); } NxParameterCollection pc = new NxParameterCollection(); string sSql = " SELECT gm.reuseMatId, gm.minDiam, gm.reusePercentage, coalesce(min(gmNext.minDiam), 1500) gmMaxDiam " + " FROM gReuseMat gm " + " left outer join gReuseMat gmNext on gm.minDiam < gmNext.minDiam "; if (reuseMatId > 0) { sSql += "where gm.reuseMatId = :reuseMatId "; pc.Add("reuseMatId", reuseMatId); } sSql += " group by gm.reuseMatId, gm.minDiam, gm.reusePercentage "; string errText = ""; DataTable dt = cdb.getData(sSql, ref errText, pc); int errCode = -100; if (errText != "") { gReuseMatCL gm = new gReuseMatCL(); if (errText.Length > 2000) { errText = errText.Substring(1, 2000); } gm.ErrCode = errCode; gm.ErrMessage = errText; rmList.Add(gm); return(rmList); } foreach (DataRow dr in dt.Rows) { gReuseMatCL gm = new gReuseMatCL(); gm.ErrCode = 0; gm.ErrMessage = ""; gm.reuseMatId = Convert.ToInt32(dr["reuseMatId"]); gm.minDiam = Convert.ToDecimal(dr["minDiam"]); gm.maxDiam = Convert.ToDecimal(dr["gmMaxDiam"]); gm.reusePercentage = Convert.ToDecimal(dr["reusePercentage"]); rmList.Add(gm); } return(rmList); }
/// <summary> /// Calculates the next "free" picture number /// </summary> /// <param name="p"></param> /// <returns></returns> private int getNextBildNr(PictureCL p) { string sSql = " select coalesce(max(bild_nr),0) as bild_nr " + " from servrad_bild " + " where vart_ordernr = :vart_ordernr " + " and radnr = :radnr "; NxParameterCollection pc = new NxParameterCollection(); pc.Add("vart_ordernr", p.VartOrdernr); pc.Add("radnr", p.Radnr); string err = ""; DataTable dt = cdb.getData(sSql, ref err, pc); return(Convert.ToInt32(dt.Rows[0]["bild_nr"]) + 1); }
private int validateServiceRow(ReservdelCL r) { string sSql = " select count(*) as antal " + " from servicerad " + " where vart_ordernr = :vart_ordernr " + " and radnr = :radnr "; NxParameterCollection pc = new NxParameterCollection(); pc.Add("vart_ordernr", r.VartOrdernr); pc.Add("radnr", r.Radnr); string errText = ""; DataTable dt = cdb.getData(sSql, ref errText, pc); return(Convert.ToInt16(dt.Rows[0][0])); }
/// <summary> /// Count the number of this article on this order /// </summary> /// <param name="r"></param> /// <param name="err"></param> /// <returns></returns> // 2018-04-30 Indentive AB Kjbo private Decimal countArtOnOrder(ReservdelCL r, ref String err) { String sSql = "select coalesce(sum(antal),0) sum_antal " + " from reservdel " + " where vart_ordernr = :vart_ordernr " + " and artnr = :artnr "; NxParameterCollection pc = new NxParameterCollection(); pc.Add("vart_ordernr", r.VartOrdernr); pc.Add("artnr", r.Artnr); err = ""; DataTable dt = cdb.getData(sSql, ref err, pc); if (err != "") { return(-1); } return(Convert.ToDecimal(dt.Rows[0]["sum_antal"])); }
private bool drawingExists(string ventil_id, int drawingNo) { string sSql = " select count(*) countDrawing " + " from valveDrawing " + " where ventil_id = :ventil_id " + " and drawingNo = :drawingNo "; NxParameterCollection pc = new NxParameterCollection(); pc.Add("ventil_id", ventil_id); pc.Add("drawingNo", drawingNo); string err = ""; DataTable dt = cdb.getData(sSql, ref err, pc); if (dt.Rows.Count == 0) { return(false); } return(Convert.ToInt32(dt.Rows[0]["countDrawing"]) > 0); }
/// <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) { CReparator cr = new CReparator(); int identOK = cr.checkIdent(ident); if (identOK == -1) { return("Ogiltigt login"); } string sSql = " select Coalesce(OpenForApp, false) as OpenForApp, " + " Coalesce(Godkand, true) as Godkand " + " from servicehuvud " + " where vart_ordernr = :vart_ordernr "; NxParameterCollection pc = new NxParameterCollection(); pc.Add("vart_ordernr", VartOrdernr); string errText = ""; DataTable dt = cdb.getData(sSql, ref errText, pc); int errCode = -100; if (errText == "" && dt.Rows.Count == 0) { errText = "Det finns ingen order med aktuellt ordernr"; errCode = -10; return(errText); } if (errText != "") { if (errText.Length > 2000) { errText = errText.Substring(1, 2000); } ServiceHuvudCL sh = new ServiceHuvudCL(); sh.ErrCode = errCode; sh.ErrMessage = errText; } DataRow dr = dt.Rows[0]; Boolean bOpenForApp = Convert.ToBoolean(dr["OpenForApp"]); Boolean bGodkand = Convert.ToBoolean(dr["Godkand"]); if (bOpenForApp && !bGodkand) { return("1"); } return("-1"); }
private int duplicateExists(VentilCL v) { // 2019-04-29 KJBO // Problems when other properties has changed than position // Only do a duplicate check if position has changed if (v.VentilID != "") { if (!positionHasChanged(v)) { return(0); } } string sSql = " select count(*) as antal " + " from ventil " + " where kund_id = :kund_id " + " and \"position\" = :position "; if (v.VentilID != null) { sSql += " and ventil_id <> :ventil_id "; } NxParameterCollection np = new NxParameterCollection(); np.Add("kund_id", v.KundID); np.Add("position", v.Position); if (v.VentilID != null) { np.Add("ventil_id", v.VentilID); } string err = ""; DataTable dt = cdb.getData(sSql, ref err, np); if (dt.Rows.Count == 0) { return(0); } return(Convert.ToInt32(dt.Rows[0]["antal"])); }
/// <summary> /// Save access level for gasket handling /// </summary> /// <param name="ident"></param> /// <param name="reparator"></param> /// <returns></returns> /// 2018-08-21 KJBO public ReparatorCL saveGasketLevel(string ident, ReparatorCL reparator) { ReparatorCL rep = new ReparatorCL(); int identOK = checkIdent(ident); if (identOK == -1) { rep.ErrCode = -10; rep.ErrMessage = "Ogiltigt login"; return(rep); } if (reparator.AnvID == "") { rep.ErrCode = -1; rep.ErrMessage = "Reparatör måste väljas"; return(rep); } string sSql = " update reparator " + " set gasketLevel = :gasketLevel " + " where AnvID = :AnvID "; NxParameterCollection pc = new NxParameterCollection(); pc.Add("AnvID", reparator.AnvID); pc.Add("gasketLevel", reparator.gasketLevel); string errSt = ""; int rc = cdb.updateData(sSql, ref errSt, pc); if (errSt != "") { if (errSt.Length > 2000) { errSt = errSt.Substring(1, 2000); } rep.ErrCode = -10; rep.ErrMessage = errSt; return(rep); } return(getReparators(ident, reparator.AnvID)[0]); }
private int getNextReservNr(ReservdelCL r) { string sSql = " SELECT coalesce(max(reserv_nr),0) as maxRow " + " from reservdel " + " where vart_ordernr = :vart_ordernr " + " and radnr = :radnr "; NxParameterCollection pc = new NxParameterCollection(); pc.Add("vart_ordernr", r.VartOrdernr); pc.Add("radnr", r.Radnr); string err = ""; DataTable dt = cdb.getData(sSql, ref err, pc); int maxrow = Convert.ToInt32(dt.Rows[0][0]); maxrow++; return(maxrow); }