in

C1 Community

ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

using ObjectDataSource can not delete appointment just created

Last post 08-05-2008 8:49 AM by Karn071. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 01-16-2008 8:56 PM

    • Dan McCann
    • Not Ranked
    • Joined on 09-21-2007
    • Pittsburgh, PA
    • Posts 5

    using ObjectDataSource can not delete appointment just created

    Using an ObjectDataSource I have all of my methods working (Select, Insert, Update, Delete). The only thing that doesn't work is if a user creates an appointment and then attempts to change it without reloading the page my Update method is never gets called. If I switch to the default AppointmentStorage (using the C1WebScheduleData.xml file) it works just fine. I have a gut feeling this is related to using an integer key instead of a GUID.
     
    Is this a bug in C1WebSchedule? I am currently using version 2.0.20073.232.
     
    Here are some relevant snippets:
     
    <C1WebSchedule:C1WebSchedule>
        <DataStorage>
            <AppointmentStorage DataSourceID="AppointmentDataStorage">
                <Mappings>
                    <SubjectMapping MappingName="Subject" />
                    <LocationMapping MappingName="Location" />
                    <StartMapping MappingName="Start" />
                    <EndMapping MappingName="End" />
                    <BodyMapping MappingName="Body" />
                    <IndexMapping MappingName="Index" />
                </Mappings>
            </AppointmentStorage>
        </DataStorage>
    </C1WebSchedule:C1WebSchedule>
    <asp:ObjectDataSource ID="AppointmentDataStorage" runat="server" OldValuesParameterFormatString="original_{0}"
                            SelectMethod="GetAppointments"
                            TypeName="AppointmentStorage" DataObjectTypeName="AppointmentStorage+C1ScheduleAppointment"
                            DeleteMethod="DeleteAppointment" InsertMethod="InsertAppointment" UpdateMethod="UpdateAppointment">
         <SelectParameters>
             <asp:Parameter DefaultValue="<%$ Code:HttpContext.Current.User.Identity.Name %>"
                                    Name="userId" Type="String" />
         </SelectParameters>
    </asp:ObjectDataSource>

     
    [System.ComponentModel.DataObject]
    public class AppointmentStorage
    {
        public class C1ScheduleAppointment
        {
            // stuff deleted
        }
     
        public List<C1ScheduleAppointment> GetAppointments(string userId)
        {
            using (iRsDatabaseHandler dbh = new iRsDatabaseHandler())
            {
                List<Appointment> iRsAppts = dbh.GetAppointments(userId);
                List<C1ScheduleAppointment> c1Appts = new List<C1ScheduleAppointment>();
                foreach (Appointment iRsA in iRsAppts)
                {
                    C1ScheduleAppointment c1A = new C1ScheduleAppointment();
                    c1A.Index = int.Parse(iRsA.Id);
                    c1A.Start = iRsA.Start;
                    c1A.End = iRsA.Start.AddHours(1);
                    c1A.Subject = "";
                    c1A.Location = "";
                    c1A.Body = "";
                    c1Appts.Add(c1A);
                }
                return c1Appts;
            }
        }
     
        public void UpdateAppointment(C1ScheduleAppointment appt)
        {
            using (iRsDatabaseHandler dbh = new iRsDatabaseHandler())
            {
                dbh.UpdateAppointment(appt.Index.ToString(), appt.Start);
            }
        }
     
        public int InsertAppointment(C1ScheduleAppointment appt)
        {
            using (iRsDatabaseHandler dbh = new iRsDatabaseHandler())
            {
                // returning and id as an integer doesn't seem to help anything
                // neither does placing into the object
                appt.Index = int.Parse(dbh.AddAppointment(appt.Start));
                return appt.Index;
            }
        }
     
        public void DeleteAppointment(C1ScheduleAppointment appt)
        {
            using (iRsDatabaseHandler dbh = new iRsDatabaseHandler())
            {
                dbh.RemoveAppointment(appt.Index.ToString());
            }
        }
    }
  • 01-16-2008 10:34 PM In reply to

    • Dan McCann
    • Not Ranked
    • Joined on 09-21-2007
    • Pittsburgh, PA
    • Posts 5

    Re: using ObjectDataSource can not delete appointment just created

    The same thing happens if a user creates a new appointment, and then deletes it, without reloading the page. The appointment is removed from view, but the DeleteMethod is never called.

  • 02-15-2008 7:35 AM In reply to

    Re: using ObjectDataSource can not delete appointment just created

    Hi.

    I have this problem, you solved this?

    Thx

  • 02-21-2008 1:30 PM In reply to

    Re: using ObjectDataSource can not delete appointment just created

    I'm reproducing this behavior as well. We're using a SQL Server datasource and everything works while creating the appointment. If the page is not refreshed, that appointment cannot be edited or deleted (well, it can on the screen but it doesn't save to the DB). If the page is refreshed first, then everything works as expected.

     Has anyone found a workaround for this? Is there a bug fix in the works? The default xml file isn't really an option for us.

  • 07-03-2008 9:20 AM In reply to

    Re: using ObjectDataSource can not delete appointment just created

    I have the same problem..
  • 08-05-2008 8:49 AM In reply to

    Re: using ObjectDataSource can not delete appointment just created

    i had the same problem. I solved it in this way: u can define javascript event for a schedule, which will called before update.This event receives Appointment object as an input parameter with new value. I used an asynchronious callback to the server to update/delete my storage

    smth like this:

    .aspx:

    function C1WebSchedule1_OnClientBeforeAppointmentUpdate(oWebSchedule, oAppointment, oEventArgs){

    // Put you code here. Quick Examples: oEventArgs.cancelEvent = true; alert("New appointment subject is " + oAppointment.Subject); var jsDt = oWebSchedule.get_selectedDate();// --see documentation for more examples

    var data;

    data = '<Appointment>';

    data += '<Id>' + oAppointment.Id + '</Id>';

    data += '<Action>Update</Action>';

    data += '<Start>' + oAppointment.Start + '</Start>';

    data += '<End>' + oAppointment.End + '</End>';

    data += '<Subject>' + oAppointment.Subject + '</Subject>';

    data += '<Body>' + oAppointment.Body + '</Body>';

    data += '<Location>' + oAppointment.Location + '</Location>';

    data += '<Links>' + oAppointment.Links + '</Links>';

    data += '</Appointment>';

    DoTheCallback(data);

    };

    function ClientCallback()

    {

     

    }

     

    function C1WebSchedule1_OnClientBeforeAppointmentDelete(oWebSchedule, oAppointment, oEventArgs){

    // Put you code here. Quick Examples: oEventArgs.cancelEvent = true; alert("New appointment subject is " + oAppointment.Subject); var jsDt = oWebSchedule.get_selectedDate();// --see documentation for more examples

    var data;

    data = '<Appointment>';

    data += '<Id>' + oAppointment.Id + '</Id>';

    data += '<Action>Delete</Action>';

    data += '</Appointment>';

    DoTheCallback(data);

    };

     

     

    .aspx.cs:

    string js = Page.ClientScript.GetCallbackEventReference(this,

    "data", "ClientCallback", null, true);

    StringBuilder sb = new StringBuilder();

    sb.Append("function DoTheCallback(data) {");

    sb.Append(js + ";");

    sb.Append("}");

    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "callbackkey", sb.ToString(), true);

     

    after that u need to implement

    ICallbackEventHandler at your page and parse there your incoming "data" XML

Page 1 of 1 (6 items)
Contact ComponentOne: 1.800.858.2739 ©1987-2008 ComponentOne LLC All Rights Reserved.