protected void tkrsVacations_AppointmentUpdate(object sender, AppointmentUpdateEventArgs e) { Page.Validate(); if (Page.IsValid) { int vacationId = Convert.ToInt32(e.ModifiedAppointment.ID); double takenDay = 0; VacationsAddDaysInformationGateway vacationsAddDaysInformationGateway = new VacationsAddDaysInformationGateway(vacationsAddTDS); string oldPaymentType = vacationsAddDaysInformationGateway.GetPaymentType(vacationId); switch (e.ModifiedAppointment.Subject) { case "Half Vacation Day": if (oldPaymentType == "Full Vacation Day") { takenDay = -0.5; } else { if (oldPaymentType == "Unpaid Leave Full Day") { takenDay = 0.5; } } break; case "Full Vacation Day": if (oldPaymentType == "Half Vacation Day") { takenDay = 0.5; } else { if (oldPaymentType == "Unpaid Leave Full Day") { takenDay = 1; } } break; case "Unpaid Leave Full Day": if (oldPaymentType == "Full Vacation Day") { takenDay = -1; } else { if (oldPaymentType == "Half Vacation Day") { takenDay = -0.5; } } break; case "Unpaid Leave Half Day": if (oldPaymentType == "Full Vacation Day") { takenDay = -1; } else { if (oldPaymentType == "Half Vacation Day") { takenDay = -0.5; } } break; } VacationsAddDaysInformation vacationsAddDaysInformation = new VacationsAddDaysInformation(vacationsAddTDS); vacationsAddDaysInformation.Update(vacationId, e.ModifiedAppointment.Subject); // Store dataset Session["vacationsAddTDS"] = vacationsAddTDS; Session["vacationDaysInformation"] = vacationsAddTDS.DaysInformation; tkrsVacations.DataBind(); double newRemainingVacationDays = double.Parse(tbxRemaining.Text) - takenDay; tbxRemaining.Text = newRemainingVacationDays.ToString(); if (double.Parse(tbxRemaining.Text) < 0) { ScriptManager.RegisterStartupScript(Page, GetType(), "alert", "alert('You are requesting more vacation than the entitlement. If you continue these days will be discounted from next years total .');", true); } } else { e.Cancel = true; } }