/// <summary>
 ///     Recibe la lista de ciclos del cliente http
 /// </summary>
 private async Task GetAllCycles()
 {
     try
     {
         cycles = await CycleHttpService.GetAll();
     }
     catch (ServerErrorException ex)
     {
         new CustomErrorMessageWindow(ex.Message).ShowDialog();
     }
 }
Esempio n. 2
0
        /// <summary>
        ///     Evento al pulsar Modificar:
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void ButtonModifyCycle_Click(object sender, EventArgs e)
        {
            string cycleName = this.tbCycleName.Text;

            if (cycleName.Length > 0)
            {
                this.btnModifyCycle.Enabled = false;

                try
                {
                    bool confirmed = true;

                    int shiftId = (int)this.cbShiftes.SelectedValue;
                    //Si se cambia el turno -> mensaje de confirmacion con aviso
                    if (shiftId != this.defaultShiftid)
                    {
                        string message = "Si cambias el turno, se cancelaran todas las clases del ciclo," +
                                         " ¿Estás seguro de querer cambiar el turno?";
                        CustomConfirmDialogForm dialog = new CustomConfirmDialogForm(message);
                        dialog.ShowDialog();

                        if (!dialog.Confirmed)
                        {
                            confirmed = false;
                            this.btnModifyCycle.Enabled = true;
                        }
                    }

                    if (confirmed)
                    {
                        cycle.Name  = cycleName;
                        cycle.Shift = this.shifts.Find(s => s.Id == shiftId);

                        await CycleHttpService.Update(cycle);

                        this.OnCycleUpdatedDelegate(cycle);

                        //Ventanita con mensaje de éxito
                        string message = "Se han guardado los cambios del ciclo formativo.";
                        new CustomSuccesMessageWindow(message).ShowDialog();

                        this.Close();
                    }
                }
                catch (ServerErrorException ex)
                {
                    new CustomErrorMessageWindow(ex.Message).ShowDialog();

                    this.btnModifyCycle.Enabled = true;
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        ///     Evento al pulsar crear :
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void ButtonCreateCycle_Click(object sender, EventArgs e)
        {
            string cycleName    = this.tbCycleName.Text;
            int    totalCourses = this.cbCourses.SelectedIndex + 1;

            if (cycleName.Length > 0 && cbShiftes.SelectedValue != null)
            {
                this.btnCreateCycle.Enabled = false;

                //Crea la lista de cursos segun la cantidad elegida
                List <Course> courses = new List <Course>();
                for (int i = 1; i <= totalCourses; i++)
                {
                    courses.Add(new Course
                    {
                        Year = i
                    });
                }
                //Instancia un ciclo
                Cycle cycle = new Cycle()
                {
                    Name    = cycleName,
                    Shift   = shifts.FirstOrDefault(s => s.Id == (int)cbShiftes.SelectedValue),
                    Courses = courses
                };

                try
                {
                    //El ciclo pasa a ser el ciclo retornado por el servicio http
                    cycle = await CycleHttpService.Save(cycle);

                    //Ventanita con mensaje de éxito
                    string message = string.Format("Has registrado el ciclo formativo de {0}.",
                                                   cycle.Name);
                    new CustomSuccesMessageWindow(message).ShowDialog();

                    this.OnCycleCreatedDelegate(cycle);//Callback con el ciclo creado

                    this.Close();
                }
                catch (ServerErrorException ex)
                {
                    new CustomErrorMessageWindow(ex.Message).ShowDialog();
                    this.btnCreateCycle.Enabled = true;
                }
            }
        }