hussein87gabriel

WucCalendarioA.cs

Feb 25th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 9.27 KB | None | 0 0
  1. using PhuyuSalud.Entidad.ComplexTypes;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.UI;
  7. using System.Web.UI.WebControls;
  8. using Telerik.Web.UI;
  9. using Phuyu.Utilidades.Enumerados;
  10. using PhuyuSalud.Aplicacion.Utilitarios;
  11. using Resources;
  12. using System.Drawing;
  13.  
  14. namespace PhuyuSalud.ClienteWeb.UserControls.Agendamiento
  15. {
  16.     public partial class WucCalendario : System.Web.UI.UserControl
  17.     {
  18.         //Image _headerImage = null;
  19.         //Image _footerImage = null;
  20.  
  21.         //DateTime MinDisabledDate = new DateTime(2018, 2, 15);
  22.         //DateTime MaxDisabledDate = new DateTime(2018, 3, 15);
  23.  
  24.         protected void Page_Load(object sender, EventArgs e)
  25.         {
  26.             //_headerImage = (Image)RadCalendar1.FindControl("HeaderImage");
  27.             //_footerImage = (Image)RadCalendar1.FindControl("FooterImage");
  28.             //AddImages(RadCalendar1.CalendarView);
  29.         }
  30.  
  31.         //protected void RadCalendar1_DefaultViewChanged(object sender, Telerik.Web.UI.Calendar.DefaultViewChangedEventArgs e)
  32.         //{
  33.         //    AddImages(e.NewView);
  34.         //}
  35.  
  36.         //private void AddImages(Telerik.Web.UI.Calendar.View.CalendarView inputView)
  37.         //{
  38.         //    switch (inputView.ViewStartDate.Month)
  39.         //    {
  40.         //        case 1:
  41.         //        case 11:
  42.         //        case 12:
  43.         //            _headerImage.ImageUrl = "../../Images/header_winter.jpg";
  44.         //            _footerImage.ImageUrl = "../../Images/footer_winter.jpg";
  45.         //            _headerImage.AlternateText = _footerImage.AlternateText = "Winter";
  46.         //            break;
  47.         //        case 2:
  48.         //        case 3:
  49.         //        case 4:
  50.         //            _headerImage.ImageUrl = "../../Images/header_spring.jpg";
  51.         //            _footerImage.ImageUrl = "../../Images/footer_spring.jpg";
  52.         //            _headerImage.AlternateText = _footerImage.AlternateText = "Spring";
  53.         //            break;
  54.         //        case 5:
  55.         //        case 6:
  56.         //        case 7:
  57.         //            _headerImage.ImageUrl = "../../Images/header_summer.jpg";
  58.         //            _footerImage.ImageUrl = "../../Images/footer_summer.jpg";
  59.         //            _headerImage.AlternateText = _footerImage.AlternateText = "Summer";
  60.         //            break;
  61.         //        case 8:
  62.         //        case 9:
  63.         //        case 10:
  64.         //            _headerImage.ImageUrl = "../../Images/header_autumn.jpg";
  65.         //            _footerImage.ImageUrl = "../../Images/footer_autumn.jpg";
  66.         //            _headerImage.AlternateText = _footerImage.AlternateText = "Autumn";
  67.         //            break;
  68.         //    }
  69.         //}
  70.  
  71.         //protected void RadCalendar1_DayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e)
  72.         //{
  73.         //    if (e.Day.Date > MinDisabledDate && e.Day.Date < MaxDisabledDate)
  74.         //    {
  75.         //        RadCalendarDay day = new RadCalendarDay()
  76.         //        {
  77.         //            Date = e.Day.Date,
  78.         //            IsDisabled = true,
  79.         //            IsSelectable = false,
  80.         //        };
  81.         //        e.Cell.CssClass = "rcDisabled";
  82.         //        RadCalendar1.SpecialDays.Add(day);
  83.         //    }
  84.         //}
  85.  
  86.         //protected void btnTiempoCita_Click(object sender, EventArgs e)
  87.         //{
  88.         //    var logicaAgendamiento = new Logica.LogicaAgendamiento();
  89.         //    var tiempoCita = new TiempoCita()
  90.         //    {
  91.         //        EnumPrioridadCita = EnumPrioridadCita.Prioridad_A,
  92.         //        EnumTipoCita = EnumTipoCita.PrimeraVez,
  93.         //        EstablecimientoId = 1,
  94.         //        MotivoId = 1,
  95.         //        ServicioId = 1
  96.         //    };
  97.  
  98.         //    var result = logicaAgendamiento.TiempoCitaObtener(tiempoCita);
  99.         //    lblTiempoCita.Text = result.Tiempo.ToString();
  100.  
  101.         //}
  102.  
  103.         //private List<AppointmentInfo> Appointments
  104.         //{
  105.         //    get
  106.         //    {
  107.         //        List<AppointmentInfo> sessApts = Session["AppointmentsKey"] as List<AppointmentInfo>;
  108.         //        if (sessApts == null)
  109.         //        {
  110.         //            sessApts = new List<AppointmentInfo>();
  111.         //            Session["AppointmentsKey"] = sessApts;
  112.         //        }
  113.  
  114.         //        return sessApts;
  115.         //    }
  116.         //}
  117.  
  118.         //===== NUEVO CALENDARIO=========================
  119.  
  120.         #region Variables
  121.  
  122.         //Colores de prioridad
  123.         Color colorVerde = Color.FromArgb(1, 129, 1);
  124.         Color colorAmarillo = Color.FromArgb(237, 240, 1);
  125.         Color colorNaranja = Color.FromArgb(243, 170, 82);
  126.         Color colorRojo = Color.FromArgb(208, 5, 6);
  127.  
  128.         private List<PrioridadesInfo> lstPrioridades = new List<PrioridadesInfo>();
  129.  
  130.         #endregion Variables
  131.  
  132.         #region Metodos
  133.  
  134.         private Color ObtenerColorPorPorcentaje(double porcentaje)
  135.         {
  136.  
  137.             Color color = Color.White;
  138.             if (porcentaje >= 50 && porcentaje <= 100)
  139.             {
  140.                 color = colorVerde;
  141.             }
  142.             else if (porcentaje > 25 && porcentaje <= 50)
  143.             {
  144.                 color = colorAmarillo;
  145.             }
  146.             else if (porcentaje > 0 && porcentaje <= 25)
  147.             {
  148.                 color = colorNaranja;
  149.             }
  150.             else if (porcentaje == 0)
  151.             {
  152.                 color = colorRojo;
  153.             }
  154.             return color;
  155.         }
  156.  
  157.         private void AgregarFranja(int id, DateTime dia, double porcentaje, string nombrePrioridad)
  158.         {
  159.  
  160.             DateTime start = dia.Date;
  161.             DateTime end = start.AddDays(1);
  162.  
  163.             RadScheduler1.InsertAppointment(new Appointment
  164.             {
  165.                 ID = id,
  166.                 Subject = nombrePrioridad + " - " + porcentaje + "%",
  167.                 Start = start,
  168.                 End = end,
  169.                 Description = porcentaje.ToString(),
  170.                 BackColor = ObtenerColorPorPorcentaje(porcentaje),
  171.                 ForeColor = Color.Black
  172.             });
  173.  
  174.         }
  175.  
  176.         private void AgregarFranjasCalendario()
  177.         {
  178.             //Datos de prueba simulando una Entidad con ciertos datos para mostrar
  179.             lstPrioridades.Add(new PrioridadesInfo(1, "Prioridad A", DateTime.Now.AddDays(1), 0));
  180.             lstPrioridades.Add(new PrioridadesInfo(2, "Prioridad B", DateTime.Now.AddDays(1), 10));
  181.             lstPrioridades.Add(new PrioridadesInfo(3, "Subsecuente A", DateTime.Now.AddDays(1), 75));
  182.             lstPrioridades.Add(new PrioridadesInfo(4, "Subsecuente B", DateTime.Now.AddDays(1), 15));
  183.             lstPrioridades.Add(new PrioridadesInfo(5, "Prioridad A", DateTime.Now.AddDays(2), 50));
  184.             lstPrioridades.Add(new PrioridadesInfo(6, "Prioridad B", DateTime.Now.AddDays(2), 100));
  185.             lstPrioridades.Add(new PrioridadesInfo(7, "Subsecuente A", DateTime.Now.AddDays(2), 40));
  186.             lstPrioridades.Add(new PrioridadesInfo(8, "Subsecuente B", DateTime.Now.AddDays(2), 15));
  187.             lstPrioridades.Add(new PrioridadesInfo(9, "Prioridad A", DateTime.Now.AddDays(3), 10));
  188.             lstPrioridades.Add(new PrioridadesInfo(10, "Prioridad B", DateTime.Now.AddDays(3), 35));
  189.             lstPrioridades.Add(new PrioridadesInfo(11, "Subsecuente A", DateTime.Now.AddDays(3), 100));
  190.             lstPrioridades.Add(new PrioridadesInfo(12, "Subsecuente B", DateTime.Now.AddDays(3), 0));
  191.  
  192.             foreach (var item in lstPrioridades)
  193.             {
  194.                 AgregarFranja(item.PrioridadesId, item.Dia, item.Porcentaje, item.Nombre);
  195.             }
  196.         }
  197.  
  198.         #endregion Metodos
  199.  
  200.         #region Eventos
  201.  
  202.         protected override void OnInit(EventArgs e)
  203.         {
  204.             base.OnInit(e);
  205.  
  206.             if (!IsPostBack)
  207.             {
  208.                 //Se muestran solo 3 dias
  209.                 RadScheduler1.MultiDayView.NumberOfDays = 3;
  210.                 //Desde el siguiente dia al actual
  211.                 RadScheduler1.SelectedDate = DateTime.Now.AddDays(1);
  212.  
  213.                 //Datos iniciales de prueba
  214.                 AgregarFranjasCalendario();
  215.             }
  216.  
  217.         }
  218.  
  219.         protected void RadScheduler1_AppointmentClick(object sender, SchedulerEventArgs e)
  220.         {
  221.             var porcentaje = Convert.ToDouble(e.Appointment.Description);
  222.             if (porcentaje == 100)
  223.             {
  224.                 UtilitarioAplicacion.AbrirModalMensajes(Page, Page.GetType(), GrsMensajes.MensajeTipoWucs, GrsMensajes.alertaTipoOk, GrsMensajes.tituloOk, "Franja al 100%");
  225.             }
  226.             else
  227.             {
  228.                 //Realizar la accion necesaria
  229.             }
  230.         }
  231.  
  232.         #endregion Eventos
  233.     }
  234.  
  235.     public class PrioridadesInfo
  236.     {
  237.  
  238.         public int PrioridadesId { get; set; }
  239.  
  240.         public string Nombre { get; set; }
  241.  
  242.         public DateTime Dia { get; set; }
  243.  
  244.         public double Porcentaje { get; set; }
  245.  
  246.         public PrioridadesInfo(int prioridadesId, string nombre, DateTime dia, double porcentaje)
  247.         {
  248.             PrioridadesId = prioridadesId;
  249.             Nombre = nombre;
  250.             Dia = dia;
  251.             Porcentaje = porcentaje;
  252.         }
  253.  
  254.     }
  255. }
Add Comment
Please, Sign In to add comment