Exemple #1
0
        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();
                    }
                }
            }
        }
Exemple #2
0
        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();
                    }
                }
            }
        }
Exemple #3
0
 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);
     }
 }
Exemple #4
0
 public bool DeleteDoorAccess(DoorAccess composite)
 {
     return(DataHelper.DeleteDoorAccess(composite));
 }
Exemple #5
0
 public bool AddDoorAccess(DoorAccess composite)
 {
     return(DataHelper.AddDoorAccess(composite));
 }
Exemple #6
0
 public void DeleteDoorAccess(DoorAccess composite)
 {
     DataHelper.DeleteDoorAccess(composite);
 }
Exemple #7
0
 public void AddDoorAccess(DoorAccess composite)
 {
     DataHelper.AddDoorAccess(composite);
 }