This is a migrated thread and some comments may be shown as answers.

[Solved] problem with AppointmentUpdate

7 Answers 342 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 16 Oct 2007, 01:45 PM
Hello,
I have Scheduler(rdsch) with parameter:
rdsch.DataStartField = "startDate";
rdsch.DataEndField = "endDate";
rdsch.DataSubjectField = "nameEvent";
rdsch.DataKeyField = "id";

How can I get (real, database ID,that I set in rdsch.DataKeyField = "id") from event AppointmentUpdate, which it has method: void rdsch_AppointmentUpdate(object sender, AppointmentUpdateEventArgs e).
e.ModifiedAppointment.ID returns me value, that I don't know what it is??

Please help me

7 Answers, 1 is accepted

Sort by
0
Mark
Top achievements
Rank 1
answered on 16 Oct 2007, 02:17 PM
I have:
<telerik:RadScheduler ID="RadScheduler1" runat="server" DataKeyField="ID" DataSubjectField="Subject" DataStartField="Start" DataEndField="End" Width="100%">  
<AppointmentTemplate>  
<asp:Label ID="lblSubject" runat="server"/>  
</AppointmentTemplate>  
</telerik:RadScheduler>  

I want to be able to change dynamically description of this label during RadScheduler1's  databound.
How can I do it??

0
Dimitar Milushev
Telerik team
answered on 16 Oct 2007, 03:21 PM
Hi Mark,

In the AppointmentDataBound event, you can use e.Appointment to get the appointment that was created.

What is the value that you are getting from e.ModifiedAppointment.ID? Instances of recurring appointments are not persisted as a separate entry in the database and do not have IDs. If you modify an instance, creating an exception for the recurrence, the new appointment receives an ID after it is inserted in the database.

Maybe if you provide details on what you are trying to achieve, we can recommend you a better approach.

Dimitar Milushev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Mark
Top achievements
Rank 1
answered on 16 Oct 2007, 07:20 PM
Dear  Dimitar, thank you for replay.
I want to update a  appointment(it is not recurring appointment) in scheduler. But I use T-sql procedure to update, which  gets parameters: 'ID' - appointment ID  (like field in database) and  five parameters that define properties of appointment. When I update appointment, it rises event  AppointmentUpdate(object sender, AppointmentUpdateEventArgs e) and I would like to get value of 'ID', that is inserted during Scheduler's databind.
How can I do it?
I define my Scheduler:
Scheduler1.DataStartField = "startDate";
Scheduler1.DataEndField = "endDate";
Scheduler1.DataSubjectField = "nameEvent";
Scheduler1.DataKeyField = "ID";
Scheduler1.DataSource=DataSet.Table[0];
Scheduler1.DataBind();


0
Peter
Telerik team
answered on 17 Oct 2007, 11:10 AM
Hi Mark,

I might be misunderstanding what you want to achieve but have you tried:

protected void RadScheduler1_AppointmentUpdate(object sender, Telerik.Web.UI.AppointmentUpdateEventArgs e)  
    {  
       Response.Write(e.Appointment.ID);  
    } 

On a side note, what data type is the ID in your database?

Cheers,
Peter
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Mark
Top achievements
Rank 1
answered on 17 Oct 2007, 12:43 PM
Sorry, VERY SORRY. I apologize for my mistake, I have block of code, which changes my "id" of appointments.

I have anoder the problem, while during ItemDataBound event I cann't access to dataitem property(becouse there isn't).
0
jeremy
Top achievements
Rank 1
answered on 17 Oct 2007, 02:10 PM

Mark,

Let me confirm.  You are trying to update the appointments table in your database correct?  If so, you will need to pass the 4 parameters.

First, your stored procedure could be something like this:
create procedure usp_UpdateAppointment
    (        
        @appointmentID                    int,    
        @appointmentStartTime         datetime,
        @appointmentEndTime           datetime,
        @appointmentSubject            varchar(250)
    )
as
update appointments
set appointmentStartTime = @appointmentStartTime,
     appointmentEndTime = @appointmentEndTime,
     appointmentSubject = @appointmentSubject
where
     appointmentID = @appointmentID

this will update the appointments table where the appointmentID is equal to the appointmentID you passed from the application.

Second,  your code c# for updating should be along the lines of:

public static void UpdateAppointment(DateTime startTime, DateTime endTime, string subject, int appointmentID)
{
    using (SqlConnection connection = New SqlConnection(ConfigurationManager.ConnectionStrings["csScheduler"].ConnectionString))
    {
        SqlCommand command = new SqlCommand("usp_UpdateAppointment", connection);
        command.CommandType = CommandType.StoredProcedure;
        command.Parameters.Add("@appointmentID",SqlDbType.Int).Value = appointmentID;
        command.Parameters.Add
("@appointmentStartTime",SqlDbType.DateTime).Value = startTime;
        command.Parameters.Add
("@appointmentEndTime",SqlDbType.DatetTime).Value = endTime;
        command.Parameters.Add
("@appointmentSubject",SqlDbType.VarChar, 250).Value = subject;
        connection.Open();
        command.ExecuteNonQuery();
        connection.Close();
    }
}

Obviously you could throw it in a try/catch or do some output value here to check that it was a successful update but this is short and to the point.

Then finally you add your code in the AppointmentDelete event for calling the UpdateAppointment code above.

protected void RadScheduler1_AppointmentUpdate(object sender, Telerik.Web.UI.AppointmentUpdateEventArgs e)

{
    //code here to verify you can update etc etc
    //    then:
    UpdateAppointment(e.ModifiedAppointment.Start, e.ModifiedAppointment.End, e.Appointment.Subject, e.Appointment.ID)
}

Please forgive me for any formatting or spelling mistakes in all my code, I typed it rather that cut and paste.

I hope this helps Mark. 

Thanks,
Jeremy

0
Mark
Top achievements
Rank 1
answered on 17 Oct 2007, 02:25 PM
Jeremy thank You very much.
Tags
Scheduler
Asked by
Mark
Top achievements
Rank 1
Answers by
Mark
Top achievements
Rank 1
Dimitar Milushev
Telerik team
Peter
Telerik team
jeremy
Top achievements
Rank 1
Share this question
or