/// <summary> /// Saves a new DN value to the database /// </summary> /// <param name="ident"></param> /// <param name="d"></param> /// <returns></returns> public DnCL saveDn(string ident, DnCL d) { DnCL resp = new DnCL(); resp.ErrCode = 0; resp.ErrMessage = ""; CReparator cr = new CReparator(); int identOK = cr.checkIdent(ident); if (identOK == -1) { resp.ErrCode = -10; resp.ErrMessage = "Ogiltigt login"; return(resp); } if (d.Dn == "") { resp.ErrCode = -1; resp.ErrMessage = "Dn mÄste anges"; return(resp); } string exists = dnExists(d.Dn); if (exists != "0" && exists != "1") { resp.ErrCode = -100; resp.ErrMessage = "Fel vid kontroll av DN. Felmeddelande : " + exists; if (resp.ErrMessage.Length > 2000) { resp.ErrMessage = resp.ErrMessage.Substring(1, 2000); } return(resp); } if (exists == "1") { resp.ErrCode = 100; resp.ErrMessage = "Dn finns redan registrerat"; return(resp); } string sSql = getInsertSql(); NxParameterCollection pc = new NxParameterCollection(); pc.Add("dn", d.Dn); pc.Add("reg", "System"); pc.Add("regdat", System.DateTime.Now); string errText = ""; int iRc = cdb.updateData(sSql, ref errText, pc); if (errText != "") { if (errText.Length > 2000) { errText = errText.Substring(1, 2000); } resp.ErrCode = -100; resp.ErrMessage = errText; return(resp); } CComboValues cbv = new CComboValues(); List <DnCL> respList = cbv.getDn("", d.Dn); if (respList.Count == 1) { return(respList[0]); } return(resp); }
/// <summary> /// Saves a new DN value to the database /// </summary> /// <param name="ident"></param> /// <param name="d"></param> /// <returns></returns> public DnCL saveDn(string ident, DnCL d) { Basdata.CDn dn = new Basdata.CDn(); return(dn.saveDn(ident, d)); }
public List <DnCL> getDn(string ident, string aDn) { List <DnCL> ld = new List <DnCL>(); if (ident != "") { CReparator cr = new CReparator(); int identOK = cr.checkIdent(ident); if (identOK == -1) { DnCL d = new DnCL(); d.ErrCode = -10; d.ErrMessage = "Ogiltigt login"; ld.Add(d); return(ld); } } string sSql = " select dn " + " from dn "; if (aDn != "") { sSql += " where dn = :dn "; } sSql += " order by dn "; string errText = ""; NxParameterCollection pc = new NxParameterCollection(); if (aDn != "") { pc.Add("dn", aDn); } DataTable dt = cdb.getData(sSql, ref errText, pc); int errCode = -100; if (errText == "" && dt.Rows.Count == 0) { errText = "Inga dn finns tillgÀngliga"; errCode = 0; } if (errText != "") { if (errText.Length > 2000) { errText = errText.Substring(1, 2000); } DnCL d = new DnCL(); d.ErrCode = errCode; d.ErrMessage = errText; ld.Add(d); return(ld); } foreach (DataRow dr in dt.Rows) { DnCL d = new DnCL(); d.Dn = dr["dn"].ToString(); d.ErrCode = 0; d.ErrMessage = ""; ld.Add(d); } return(ld); }