Exemplo n.º 1
0
        private void ButtonExportar_Click(object sender, RoutedEventArgs e)
        {
            ClassScheduleServices services = new ClassScheduleServices();

            if (_excelFile != null)
            {
                int _message = 0, _cont = 0;

                GRDialogConsultation _var = new GRDialogConsultation();
                _var.Message = "Desea crear las Clases?";
                if (_var.ShowDialog() == true)
                {
                    foreach (var item in _excelFile)
                    {
                        var _item = new ClassScheduleModel();

                        _item.IdBranchOffice = int.Parse(item.CodigoSucursal);
                        _item.IdWorkout      = int.Parse(item.CodigoDisciplina);
                        _item.WeekDay        = item.NumeroDia;
                        _item.StarTime       = TimeSpan.Parse(item.HoraInicio);
                        _item.EndTime        = TimeSpan.Parse(item.HoraFin);
                        _item.IdTrainer      = item.IdTrainer;
                        _item.StartDate      = DateTime.Parse(item.FechaInicio);
                        _item.EndDate        = DateTime.Parse(item.FechaFin);

                        if (item.MensajeFila == "OK")
                        {
                            _message = services.Add(_item);
                            if (_message > 0)
                            {
                                _cont += 1;
                            }
                        }
                    }
                    GRDialogInformation _var0 = new GRDialogInformation();
                    _var0.Message = "Total Regisros Exportados : " + _cont.ToString();
                    _var0.ShowDialog();

                    DataGridExportFile.ItemsSource = new ObservableCollection <ExcelFileModel>(new List <ExcelFileModel>());
                    TxtPath.Text = "";
                }
            }
            else
            {
                GRDialogInformation _var = new GRDialogInformation();
                _var.Message = "Debe Seleccionar un Registro";
                _var.ShowDialog();
            }
        }
Exemplo n.º 2
0
        private void Button_Aplicar(object sender, RoutedEventArgs e)
        {
            bool hourStart = Common.ValidateHour(mkbHoraInicio.Text);
            bool hourEnd   = Common.ValidateHour(mkbHoraFin.Text);


            if (!((CmbBranchOffice.SelectedIndex == 0) || (CmbWorkout.SelectedIndex == 0)))
            {
                if ((hourStart) && (hourEnd))
                {
                    if (TimeSpan.Parse(mkbHoraInicio.Text) < TimeSpan.Parse(mkbHoraFin.Text))
                    {
                        if (((TimeSpan.Parse(mkbHoraInicio.Text) >= HourStart) && (TimeSpan.Parse(mkbHoraFin.Text) <= HourEnd)))
                        {
                            int result = 0;
                            ClassScheduleModel _class = new ClassScheduleModel();
                            _class.IdBranchOffice = int.Parse(CmbBranchOffice.SelectedValue.ToString());
                            _class.IdWorkout      = int.Parse(CmbWorkout.SelectedValue.ToString());
                            _class.WeekDay        = int.Parse(CmbDia.SelectedValue.ToString());
                            _class.StarTime       = TimeSpan.Parse(mkbHoraInicio.Text);
                            _class.EndTime        = TimeSpan.Parse(mkbHoraFin.Text);
                            _class.IdTrainer      = int.Parse(CmbTrainer.SelectedValue.ToString());
                            _class.Active         = CmbActive.Text == "Activo";

                            if (LblId.Content == "0") //ADD
                            {
                                result = _services.Add(_class);
                            }
                            else //EDIT
                            {
                                int _id = int.Parse(LblId.Content.ToString());
                                _class.Id = _id;
                                var task = _services.Update(_class);
                                result = task ? _id : 0;
                            }


                            if (result > 0)
                            {
                                GRDialogConsultation _var = new GRDialogConsultation();
                                _var.Message = "Registro Guardado, desea crear otro Registro?";
                                if (_var.ShowDialog() == true)
                                {
                                    CleanControls();
                                }
                                else
                                {
                                    var window = new ClassScheduleList();
                                    this.Close();
                                    window.ShowDialog();
                                }
                            }
                            else
                            {
                                GRDialogError _err = new GRDialogError();
                                _err.Message = "Error guardando datos";
                                _err.ShowDialog();
                            }
                        }
                        else
                        {
                            var h0 = HourStart.ToString().Remove(HourStart.ToString().Length - 3);
                            var h1 = HourEnd.ToString().Remove(HourEnd.ToString().Length - 3);

                            GRDialogInformation _var0 = new GRDialogInformation();
                            _var0.Message = "Hora Sucursal fuera de Rango , Hora Apertura (" + h0 + ") Hora Cierre (" + h1 + ")";
                            _var0.ShowDialog();
                        }
                    }
                    else
                    {
                        GRDialogInformation _var1 = new GRDialogInformation();
                        _var1.Message = "La Hora de Inicio no puede ser mayor a la Hora Fin";
                        _var1.ShowDialog();
                    }
                }
                else
                {
                    GRDialogInformation _var2 = new GRDialogInformation();
                    _var2.Message = "Verificar campos Obligatorios / Formato de Horas";
                    _var2.ShowDialog();
                }
            }
            else
            {
                GRDialogInformation _var3 = new GRDialogInformation();
                _var3.Message = "Validar campos obligatorios";
                _var3.ShowDialog();
            }
        }