private static string CheckIfExists(SIMcard simcard, 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("@SIMcardnr", simcard.SIMcardnr, System.Data.DbType.String); dal.AddParameter("@Phonenr", simcard.Phonenr, System.Data.DbType.String); error = dal.ExecuteScalar(@" DECLARE @error varchar(50) SET @error = '' IF EXISTS (SELECT * FROM [SIMcard] WHERE [Deleted] = 0 AND UPPER([SIMcardnr]) = UPPER(@SIMcardnr)" + addID + @") SET @error += '3' IF EXISTS (SELECT * FROM [SIMcard] WHERE [Deleted] = 0 AND UPPER([Phonenr]) = UPPER(@Phonenr) AND [Phonenr] <> ''" + addID + @") SET @error += '4' SELECT @error ").ToString(); dal.ClearParameters(); return(error); }
public static string CheckIfExists(SIMcard simcard, string ID) { return(CheckIfExists(simcard, ID, true)); }
/// <summary> /// SIMcard /// </summary> /// <param name="simcard">The SIMcard to check</param> /// <returns></returns> public static string CheckIfExists(SIMcard simcard) { return(CheckIfExists(simcard, "", false)); }