Всем привет!
Нужна помощь профессионалов , ибо не хватает опыта пока в этом.
Во-первых как вывести время конкретного “Доктора” в поле:
Во-вторых как реализовать чтобы при нажатии кнопки “Add new appointement” сохранялись записи и выводились в таблице :
Вот код
Контроллер
public with sharing class AppointmentController {
public Appointment_Name__c bAppointment{get;set;}
private final Appointment_Name__c saveAppointment;
public Doctor_Name__c bDoctor {get;set;}
public Appointment_Name__c addAppointment;
public List<Doctor_Name__c> doctorList{get;set;}
public List<Appointment_Name__c> appointmentTable {get;set;}
public List<Patient_Name__c> patientList{get;set;}
public String listId{get;set;}
public String selectedDoctor{get;set;}
public String selectedPatinet{get;set;}
public String setappointmenTable{get;set;}
public Appointment_Name__c getAppointment(){
if(bAppointment == null)
bAppointment = [SELECT id, Name ,Doctor__c ,Patient__c , Duration_in_minutes__c,Appointment_Date__c FROM Appointment_Name__c where id = :ApexPages.currentPage().getParameters().get('id')];
return bAppointment;
}
public AppointmentController(){
bAppointment = new Appointment_Name__c();
bDoctor = new Doctor_Name__c();
doctorList = getDoctorName();
patientList = getPatientName();
getAppointmentData();
getAppointment();
}
public PageReference save() {
update bAppointment;
PageReference savePage = Page.AppointmentInfo;
savePage.setRedirect(true);
//savePage.getParameters().put('id',bAppointment.Id);
//try {
// bAppointment.Doctor__c = selectedDoctor;
// bAppointment.Patient__c = selectedPatinet;
// }
// catch (Exception ex) {
// ApexPages.addMessages(ex);
// }
return savePage;
}
private List<Doctor_Name__c> getDoctorName(){
List<Doctor_Name__c> listName = [SELECT id,Name ,WorkingHoursStart__c, WorkingHoursEnd__c FROM Doctor_Name__c ];
return listName;
}
private List<Patient_Name__c> getPatientName(){
List<Patient_Name__c> listName = [SELECT id, Name FROM Patient_Name__c ];
return listName;
}
public void getTime(){
}
public void getAppointmentData(){
appointmentTable = [SELECT id, Name ,Doctor__c ,Patient__c , Duration_in_minutes__c,Appointment_Date__c FROM Appointment_Name__c ];
}
public List<SelectOption> getselectPatient(){
List<SelectOption> lOptions = new List<SelectOption>();
for (Patient_Name__c pat : patientList){
lOptions.add(new SelectOption(pat.Id, pat.Name));
}
return lOptions;
}
public List<SelectOption> getselectDoctor(){
List<SelectOption> lOptions = new List<SelectOption>();
for (Doctor_Name__c doc : doctorList){
lOptions.add(new SelectOption(doc.Id, doc.Name));
}
return lOptions;
}
}
Сама страница
<apex:page id="AppointmentInfo" Controller="AppointmentController" >
<apex:form >
<apex:pageBlock title="Appointment Table" id="table" >
<apex:pageBlockSection columns="1" >
<apex:selectList label="Select a doctor" value="{!doctorList}" size="1" multiselect="false" >
<apex:selectOptions value="{!selectDoctor}" />
</apex:selectList>
<apex:commandButton value="Add New Doctor" />
<apex:outputField value="{!bDoctor.WorkingHoursStart__c}">
</apex:outputField>
<apex:outputText label="Working Hours End " value="{!bDoctor.WorkingHoursEnd__c}">
</apex:outputText>
<apex:selectList label="Select a patient" value="{!patientList}" size="1" multiselect="false">
<apex:selectOptions value="{!selectPatient}" rendered="true"/>
</apex:selectList>
<apex:commandButton value="Add New Patient" title="Add New Patient"/>
<apex:inputField label="Appointment date" value="{!bAppointment.Appointment_Date__c}" required="false"/>
<apex:inputField label="Duration in minutes" value="{!bAppointment.Duration_in_minutes__c}" required="false"/>
<apex:commandButton title="Add New Appointment" action="{!save}" value="Add New Appointment" reRender="updateAppoint"/>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock >
<apex:pageBlockTable value="{!appointmentTable}" var="doc">
<apex:column headerValue="Action">
<apex:commandLink title="View" value="{!bAppointment}">
<apex:param value="{!URLFOR('/'+ bAppointment.Name)}" />
View
</apex:commandLink>
</apex:column>
<apex:column headerValue="Doctor's Name" value="{!doc.Doctor__c}" />
<apex:column headerValue="Patient's Name" value="{!doc.Patient__c}"/>
<apex:column headerValue="Date" value="{!doc.Appointment_Date__c}"/>
<apex:column headerValue="Duration" value="{!doc.Duration_in_minutes__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>