private static string CheckIfExists(Modem modem, string ID, bool WithID) { DataAccessLayer dal = new DataAccessLayer(); string error = ""; string addID = ""; if (WithID) { dal.AddParameter("@ID", ID, System.Data.DbType.String); addID = " AND [ID] <> @ID"; } dal.AddParameter("@IMEI", modem.IMEI, System.Data.DbType.String); error = dal.ExecuteScalar("IF EXISTS (SELECT * FROM [Modem] WHERE [Deleted] = 0 AND UPPER([IMEI]) = UPPER(@IMEI)" + addID + ") SELECT '2' ELSE SELECT ''").ToString(); dal.ClearParameters(); return(error); }
/// <summary> /// Checks if a 3G Modem already exists in the database based on Serialnumber, IMEI, /// SIMcard and Phonenr and excludes the ID given. /// Returns an empty string "" if there are no errors or returns a string with the /// numbers representing each error: /// 2: IMEI /// 3: SIMcard /// 4: Phonenr /// Fx. it returns "24" meaning that IMEI and Phonenr already exists. /// </summary> /// <param name="modem">The Modem to check</param> /// <param name="ID">The ID of the modem wanting to edit</param> /// <returns></returns> public static string CheckIfExists(Modem modem, string ID) { return(CheckIfExists(modem, ID, true)); }
/// <summary> /// Checks if a 3G Modem already exists in the database based on Serialnumber, IMEI, /// SIMcard and Phonenr. /// Returns an empty string "" if there are no errors or returns a string with the /// numbers representing each error: /// 2: IMEI /// 3: SIMcard /// 4: Phonenr /// Fx. it returns "24" meaning that IMEI and Phonenr already exists. /// </summary> /// <param name="modem">The Modem to check</param> /// <returns></returns> public static string CheckIfExists(Modem modem) { return(CheckIfExists(modem, "", false)); }