Exemple #1
0
        public OfficialFile GetOfficialFileByID(int Id)
        {
            OfficialFile officialFile = null;

            using (SqlConnection connection = GetConnection())
            {
                SqlCommand command = new SqlCommand("_OfficialFileGetByID", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@OfficialFileID", Id);
                connection.Open();
                using (SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection))
                {
                    if (reader.Read())
                    {
                        officialFile = OfficialFileReader(reader);
                    }
                    else
                    {
                        throw new DataAccessException("Không tìm thấy tin");
                    }
                }
                command.Dispose();
            }
            return(officialFile);
        }
Exemple #2
0
        private OfficialFile OfficialFileReader(SqlDataReader reader)
        {
            OfficialFile officialFile = new OfficialFile();

            officialFile.OfficialFileID = (int)reader["OfficialFileID"];
            officialFile.OfficialID     = (int)reader["OfficialID"];
            officialFile.FileName       = (string)reader["FileName"];
            officialFile.Title          = (string)reader["Title"];

            return(officialFile);
        }
Exemple #3
0
 public void UpdateOfficialFile(OfficialFile officialFile)
 {
     using (SqlConnection connection = GetConnection())
     {
         SqlCommand command = new SqlCommand("_OfficialFileUpdate", connection);
         command.CommandType = CommandType.StoredProcedure;
         command.Parameters.AddWithValue("@Type", 1);
         command.Parameters.AddWithValue("@OfficialFileID", officialFile.OfficialFileID);
         command.Parameters.AddWithValue("@OfficialID", officialFile.OfficialID);
         command.Parameters.AddWithValue("@FileName", officialFile.FileName);
         command.Parameters.AddWithValue("@Title", officialFile.Title);
         connection.Open();
         if (command.ExecuteNonQuery() <= 0)
         {
             throw new DataAccessException("Không thể cập nhật hình ảnh");
         }
         else
         {
             command.Dispose();
         }
     }
 }
Exemple #4
0
        public void UpdateOfficialFile(OfficialFile officialFile)
        {
            OfficialFileDAO officialFileDAO = new OfficialFileDAO();

            officialFileDAO.UpdateOfficialFile(officialFile);
        }
Exemple #5
0
        public void CreateOfficialFile(OfficialFile officialFile)
        {
            OfficialFileDAO officialFileDAO = new OfficialFileDAO();

            officialFileDAO.CreateOfficialFile(officialFile);
        }