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; } }
protected void tkrsVacations_FormCreated(object sender, SchedulerFormCreatedEventArgs e) { if (e.Container.Mode == SchedulerFormMode.Edit) { int vacationId = Convert.ToInt32(e.Appointment.ID); vacationsAddTDS = (VacationsAddTDS)Session["vacationsAddTDS"]; vacationDaysInformation = (VacationsAddTDS.DaysInformationDataTable)Session["vacationDaysInformation"]; VacationsAddDaysInformationGateway vacationsAddDaysInformationGateway = new VacationsAddDaysInformationGateway(vacationsAddTDS); string paymentType = vacationsAddDaysInformationGateway.GetPaymentType(vacationId); RadioButtonList rbtnPaymentType = (RadioButtonList)e.Container.FindControl("rbtnPaymentType"); rbtnPaymentType.SelectedValue = paymentType; } }
protected void tkrsVacations_AppointmentDelete(object sender, SchedulerCancelEventArgs e) { Page.Validate(); if (Page.IsValid) { int vacationId = Convert.ToInt32(e.Appointment.ID); double takenDay = 0; VacationsAddDaysInformationGateway vacationsAddDaysInformationGateway = new VacationsAddDaysInformationGateway(vacationsAddTDS); string oldPaymentType = vacationsAddDaysInformationGateway.GetPaymentType(vacationId); switch (oldPaymentType) { case "Half Vacation Day": takenDay = 0.5; break; case "Full Vacation Day": takenDay = 1; break; } VacationsAddDaysInformation vacationsAddDaysInformation = new VacationsAddDaysInformation(vacationsAddTDS); vacationsAddDaysInformation.Delete(vacationId); double newRemainingVacationDays = double.Parse(tbxRemaining.Text) + takenDay; tbxRemaining.Text = newRemainingVacationDays.ToString(); // Store dataset Session["vacationsAddTDS"] = vacationsAddTDS; Session["vacationDaysInformation"] = vacationsAddTDS.DaysInformation; tkrsVacations.DataBind(); } else { e.Cancel = true; } }
protected void tkrsVacations_AppointmentDataBound(object sender, SchedulerEventArgs e) { // For old vacations if (e.Appointment.ToolTip != "") { int vacationId = Int32.Parse(e.Appointment.ID.ToString()); int companyId = Int32.Parse(hdfCompanyId.Value); VacationsAddDaysInformationGateway vacationsAddDaysInformationGatewayForReview = new VacationsAddDaysInformationGateway(vacationsAddTDS); string paymentType = vacationsAddDaysInformationGatewayForReview.GetPaymentType(vacationId); bool inDataBase = vacationsAddDaysInformationGatewayForReview.GetInDatabase(vacationId); e.Appointment.ToolTip = paymentType; switch (paymentType) { case "Unpaid Leave Full Day": if (!inDataBase) { e.Appointment.CssClass = "rsCategorySkyBlue2"; } else { e.Appointment.CssClass = "rsCategoryRed2"; e.Appointment.AllowDelete = false; e.Appointment.AllowEdit = false; } break; case "Unpaid Leave Half Day": if (!inDataBase) { e.Appointment.CssClass = "rsCategorySkyBlue2"; } else { e.Appointment.CssClass = "rsCategoryRed2"; e.Appointment.AllowDelete = false; e.Appointment.AllowEdit = false; } break; case "Full Vacation Day": if (!inDataBase) { e.Appointment.CssClass = "rsCategoryBlue2"; } else { e.Appointment.CssClass = "rsCategoryGreen2"; e.Appointment.AllowDelete = false; e.Appointment.AllowEdit = false; } break; case "Half Vacation Day": if (!inDataBase) { e.Appointment.CssClass = "rsCategoryBlue2"; } else { e.Appointment.CssClass = "rsCategoryGreen2"; e.Appointment.AllowDelete = false; e.Appointment.AllowEdit = false; } break; default: e.Appointment.CssClass = "rsCategoryGray2"; e.Appointment.AllowDelete = false; e.Appointment.AllowEdit = false; break; } } else { // For new vacations switch (e.Appointment.Subject) { case "Unpaid Leave Full Day": e.Appointment.CssClass = "rsCategorySkyBlue2"; break; case "Unpaid Leave Half Day": e.Appointment.CssClass = "rsCategorySkyBlue2"; break; case "Full Vacation Day": e.Appointment.CssClass = "rsCategoryBlue2"; break; case "Half Vacation Day": e.Appointment.CssClass = "rsCategoryBlue2"; break; default: e.Appointment.CssClass = "rsCategoryGray2"; e.Appointment.AllowDelete = false; e.Appointment.AllowEdit = false; break; } } }
/// <summary> /// LoadNonWorkingDays /// </summary> /// <param name="companyId">companyId</param> public void LoadNonWorkingDays(int companyId) { VacationsAddDaysInformationGateway vacationsAddDaysInformationGateway = new VacationsAddDaysInformationGateway(Data); vacationsAddDaysInformationGateway.ClearBeforeFill = false; vacationsAddDaysInformationGateway.LoadNonWorkingDays(companyId); vacationsAddDaysInformationGateway.ClearBeforeFill = true; }
// //////////////////////////////////////////////////////////////////////// // PUBLIC METHODS // /// <summary> /// LoadDataForVacationsAdd /// </summary> /// <param name="companyLevelId">companyLevelId</param> /// <param name="employeeId">employeeId</param> /// <param name="companyId">companyId</param> public void LoadDataForVacationsAdd(int companyLevelId, int employeeId, int companyId) { VacationsAddDaysInformationGateway vacationsAddDaysInformationGateway = new VacationsAddDaysInformationGateway(Data); vacationsAddDaysInformationGateway.ClearBeforeFill = false; vacationsAddDaysInformationGateway.LoadNonWorkingDaysByCompanyLevelId(companyLevelId, companyId); vacationsAddDaysInformationGateway.LoadPreviousVacations(employeeId, companyId); vacationsAddDaysInformationGateway.ClearBeforeFill = true; }
/// <summary> /// LoadPreviousVacations /// </summary> /// <param name="employeeId">employeeId</param> /// <param name="companyId">companyId</param> public void LoadPreviousVacations(int employeeId, int companyId) { VacationsAddDaysInformationGateway vacationsAddDaysInformationGateway = new VacationsAddDaysInformationGateway(Data); vacationsAddDaysInformationGateway.ClearBeforeFill = false; vacationsAddDaysInformationGateway.LoadPreviousVacations(employeeId, companyId); vacationsAddDaysInformationGateway.ClearBeforeFill = true; }