Hi, I want to filter appointments for subject. So I use Visible property for appointment. And it works. The only problem is when I set appointment's Visible to false, it saves changes in database, so that appointment is no more visible. How can I avoid saving Visible property for appointment ???
Hello Ivan,
If you need any additional assistance don’t hesitate to ask.
Regards
Here is the sample
Thanks for the details. If I understand well your scenario, then I think that we have better solution for you. There are different approaches to solve this task, but I think that the easiest way will be if we are using query with parameters (in our case it is your DataKey). By this way we will be able to load and update only the appointments for specific customer. Also using this approach we will improve the performance of your application, because we will load only these appointments which are important at that moment. Please take a look at the attached video file (with details for database) and sample for more details.
If you have any questions feel free to write me
Thanks for quick response.
I have one calendar with all appointments which are connected to customers (by datakey property). And in customer forms, I want to see only appointments for selected customer (i.e. hide all others). So if user add new appointment in customers form, system saves all appointments which are hidden (that's the problem).
So, yes, I thought of all three ways you suggested, but I was interested if there is some easier way to do it (ie remove Visible property from AllProperties). The best I can do is to go through all Appointment collection every time I save appointment, and make them visible, save, and hide them again. I can also load appointments only for that customer. So I have solutions for this problem, but wanted to avoid load from database, or two times to use for loop.
Hello Divac,
divac said: How can I avoid saving Visible property for appointment ???
Option 1: I`m not familiar with your scenario and I don`t know the exact moment, when you stored your appointments in database, but maybe you could set Visible property to True, just before to save changes in database.
Option 2: If it is not possible to use option 1, you could skip the data binding of ultraCalendarInfo1.DataBindingsForAppointments.AllPropertiesMember. By this way the changes in Visible property could not be stored in database. This approach has a big disadvantage, because you will skip many of appointments settings to be stored in database
Option 3: This approach is complicate, but I think that will solve your task. Using this approach you will be able to read your binary array from AllProperties, to modify Visible property and stored back your binary array in the database. For example:
public void MyMethod()
{
SqlConnection conn = new SqlConnection("Data Source=IGBGSOFDS22;Initial Catalog=Test;Integrated Security=True"); SqlCommand command = new SqlCommand("SELECT AllProperties FROM [dbAppointments] WHERE [AppointmentID] = '2d43b92c-9f7e-474b-88dc-87d54649fcdf'", conn);
conn.Open();
SqlDataReader myReader = command.ExecuteReader(); byte[] BinaryAppData = null;
while (myReader.Read())
// Deserialize the Appointment from Binary data using AllProperties column
Appointment MyApp = Appointment.FromBytes((byte[])myReader[0]);
// Make changes in the Appointment
MyApp.Subject = "New Subject for Appointment";
MyApp.Visible = true;
//Save chages in the Appointment in Binary format;
BinaryAppData = MyApp.Save();
}
myReader.Close();
// Save changes in the database usign Binary data and AllProperties column
SqlCommand command2 = new SqlCommand("UPDATE [dbAppointments] set AllProperties = @AllProperties WHERE [AppointmentID] = '2d43b92c-9f7e-474b-88dc-87d54649fcdf'", conn);
command2.Parameters.Add("@AllProperties", SqlDbType.Binary);
command2.Parameters["@AllProperties"].SqlValue = BinaryAppData;
command2.ExecuteNonQuery();
conn.Close();
Let me know if you have any questions.