Sample Code:
Employee__c e = [SELECT Name from Employee__c WHERE Id = : eid];
Attachment a = new Attachment();
a.ParentId = eid;
a.Name = e.Name + Date.Today();
a.ContentType = ‘text/plain’;
a.Body = Blob.valueOf(e.Name);
insert a;
Employee__c e = [SELECT Name from Employee__c WHERE Id = : eid];
Attachment a = new Attachment();
a.ParentId = eid;
a.Name = e.Name + Date.Today();
a.ContentType = ‘text/plain’;
a.Body = Blob.valueOf(e.Name);
insert a;
Cheers!!!