public static Boolean DeleteDoorAccess(DoorAccess composite) { using (SqlConnection connectionstring = new SqlConnection(cstring)) { using (SqlCommand cmd = new SqlCommand()) { connectionstring.Open(); cmd.CommandText = "DELETE FROM DoorAccess WHERE CardID = @p1"; cmd.Parameters.AddWithValue("@p1", composite.CardId); cmd.CommandType = CommandType.Text; cmd.Connection = connectionstring; try { cmd.ExecuteNonQuery(); return(true); } catch { return(false); } finally { connectionstring.Close(); } } } }
public static Boolean AddDoorAccess(DoorAccess composite) { using (SqlConnection connectionstring = new SqlConnection(cstring)) { using (SqlCommand cmd = new SqlCommand()) { connectionstring.Open(); cmd.CommandText = "INSERT INTO DoorAccess(CardID, DoorID) VALUES(@p1, @p2)"; cmd.Parameters.AddWithValue("@p1", composite.CardId); cmd.Parameters.AddWithValue("@p2", composite.DoorId); cmd.CommandType = CommandType.Text; cmd.Connection = connectionstring; try { cmd.ExecuteNonQuery(); return(true); } catch { return(false); } finally { connectionstring.Close(); } } } }
public static List <DoorAccess> AccessList() { using (SqlConnection connectionstring = new SqlConnection(cstring)) { List <DoorAccess> returnList = new List <DoorAccess>(); connectionstring.Open(); string sql = "SELECT * FROM DoorAccess"; SqlCommand cmd = new SqlCommand(sql, connectionstring); var reader = cmd.ExecuteReader(); while (reader.Read()) { DoorAccess c = new DoorAccess(); c.DoorId = reader.GetInt32(0); c.CardId = reader.GetString(1); returnList.Add(c); } return(returnList); } }
public bool DeleteDoorAccess(DoorAccess composite) { return(DataHelper.DeleteDoorAccess(composite)); }
public bool AddDoorAccess(DoorAccess composite) { return(DataHelper.AddDoorAccess(composite)); }
public void DeleteDoorAccess(DoorAccess composite) { DataHelper.DeleteDoorAccess(composite); }
public void AddDoorAccess(DoorAccess composite) { DataHelper.AddDoorAccess(composite); }