private void ButtonAgregarEliminar_Click(object sender, RoutedEventArgs e) { ClassScheduleModel classSchedule = DataGridClassSchedule.SelectedItem as ClassScheduleModel; if (classSchedule != null) { GRDialogConsultation _var = new GRDialogConsultation(); _var.Message = "Eliminar Registro Seleccionado?"; if (_var.ShowDialog() == true) { int id = classSchedule.Id; var result = _class.DeleteUpdate(id); if (result) { MyCollection.Remove(classSchedule); DataGridClassSchedule.ItemsSource = MyCollection; DataGridClassSchedule.Items.Refresh(); lblTotalReg.Content = "Cantidad de Registro: " + MyCollection.Count; } } } else { GRDialogInformation _msg = new GRDialogInformation(); _msg.Message = "Debe Seleccionar un Registro"; _msg.ShowDialog(); } }
public int Add(ClassScheduleModel aModel) { int result = 0; //await Task.Run(() => //{ try { ClassSchedule aNew = new ClassSchedule { Id = aModel.Id, IdBranchOficce = aModel.IdBranchOffice, IdWorkout = aModel.IdWorkout, DayWeek = aModel.WeekDay, StarTime = aModel.StarTime, EndTime = aModel.EndTime, IdTrainer = aModel.IdTrainer == 0 ? null : aModel.IdTrainer, Active = true, DateCreated = DateTime.Now, StartDate = aModel.StartDate, EndDate = aModel.EndDate }; fcontext.ClassSchedule.Add(aNew); fcontext.SaveChanges(); result = aNew.Id; } catch (Exception ex) { result = 0; } //}); return(result); }
public bool Update(ClassScheduleModel aModel) { bool result = false; //await Task.Run(() => //{ try { var getToUpdate = fcontext.ClassSchedule.First(a => a.Id == aModel.Id); // fClassScheduleFactoryAsync.GetById(aModel.Id); getToUpdate.Id = aModel.Id; getToUpdate.IdBranchOficce = aModel.IdBranchOffice; getToUpdate.IdWorkout = aModel.IdWorkout; getToUpdate.DayWeek = aModel.WeekDay; getToUpdate.StarTime = aModel.StarTime; getToUpdate.EndTime = aModel.EndTime; getToUpdate.IdTrainer = aModel.IdTrainer; getToUpdate.Active = aModel.Active; getToUpdate.DateUdated = aModel.DateUpdated; getToUpdate.StartDate = aModel.StartDate; getToUpdate.EndDate = aModel.EndDate; fcontext.Entry(getToUpdate).State = System.Data.Entity.EntityState.Modified; fcontext.SaveChanges(); //fClassScheduleFactoryAsync.Update(getToUpdate); //fGymUnitOfWork.Commit(); result = true; } catch (Exception ex) { result = false; } //}); return(result); }
private void WeekScheduler_OnEventDoubleClick(object sender, ClassScheduleModel e) { ScheduleViewModel vm = grid.DataContext as ScheduleViewModel; int id = e.Id; var _classScheduleReview = new ClassScheduleReview(id); _classScheduleReview.Show(); }
private int getIndex(ClassScheduleModel e, List <ClassScheduleModel> list) { for (int i = 0; i < list.Count; i++) { if (e.Id == list[i].Id) { return(i); } } return(-1); }
[Fact]//TODO: fazer ajustes Task_AbrirCalendarioAula_NotFoundResult public async void Task_AbrirCalendarioAula_NotFoundResult() { //Arrange var controller = new PlanejamentoController(_db); ClassScheduleModel model = new ClassScheduleModel(); //Act var resulTask = await controller.AbrirCalendarioAula(model); //Assert Assert.IsType <NotFoundResult>(resulTask.Result); }
private void WeekScheduler_SizeChanged(object sender, SizeChangedEventArgs e) { try { var ed = new ClassScheduleModel(); ResizeGrids(e.NewSize); PaintAllEvents(null, IDBranch, IDLivingroom, IDWorkout); //PaintAllDayEvents(); } catch (Exception ex) { throw; } }
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(); } }
public async void Task_AbrirCalendarioAula_OkObjectResult() { //Arrange var controller = new PlanejamentoController(_db); ClassScheduleModel model = new ClassScheduleModel(); model.Username = ""; model.School = ""; model.Year = DateTime.Now.Year; model.Classroom = ""; //Act var resulTask = await controller.AbrirCalendarioAula(model); //Assert Assert.IsType <OkObjectResult>(resulTask.Result); }
private void Button_Modificar(object sender, RoutedEventArgs e) { ClassScheduleModel classScheduleModel = DataGridClassSchedule.SelectedItem as ClassScheduleModel; if (classScheduleModel != null) { int?id = classScheduleModel.Id; this.Close(); var windowClassSchedule = new ClassScheduleImput(id); windowClassSchedule.Show(); } else { GRDialogInformation _msg = new GRDialogInformation(); _msg.Message = "Debe Seleccionar un Registro"; _msg.ShowDialog(); } }
public bool DeleteUpdate(int Id) { bool result = false; ClassScheduleModel aModel = new ClassScheduleModel(); try { ClassSchedule classSchedule = fcontext.ClassSchedule.Find(Id); fcontext.ClassSchedule.Remove(classSchedule); fcontext.SaveChanges(); result = true; } catch (Exception ex) { aModel = GetById(Id); aModel.Active = false; result = Update(aModel); //Update Change Estatus Active } return(result); }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { try { DependencyObject ucParent = (sender as WeekScheduler).Parent; while (!(ucParent is Scheduler)) { ucParent = LogicalTreeHelper.GetParent(ucParent); } _scheduler = ucParent as Scheduler; var ed = new ClassScheduleModel(); ResizeGrids(new Size(this.ActualWidth, this.ActualHeight)); PaintAllEvents(null, IDBranch, IDLivingroom, IDWorkout); } catch (Exception ex) { //throw; } }
public EventUserControl(ClassScheduleModel e, bool showTime) { InitializeComponent(); _e = e; this.VerticalAlignment = System.Windows.VerticalAlignment.Top; this.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; this.Subject = e.Subject; this.BorderElement.Background = e.BrushColor; if (!showTime) { this.DisplayDateText.Visibility = System.Windows.Visibility.Hidden; this.DisplayDateText.Height = 0; this.DisplayDateText.Text = String.Format("{0} - {1}", e.Start.ToShortDateString(), e.End.ToShortDateString()); } else { this.DisplayDateText.Text = String.Format("{0} - {1}", e.Start.ToString("HH:mm"), e.End.ToString("HH:mm")); } DisplayTextTrainer.Text = e.TrainerName; this.BorderElement.ToolTip = this.DisplayDateText.Text + System.Environment.NewLine + this.DisplayText.Text + System.Environment.NewLine + DisplayTextTrainer.Text; }
public ClassScheduleView() { InitializeComponent(); DataContext = new ClassScheduleModel(this); }
public CustomEventArgsClassSchedule(ClassScheduleModel s) { message = s; }
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(); } }
public ClassScheduleModel GetById(int Id) { var data = new ClassScheduleModel(); try { string trainerName = string.Empty; TrainerModel _trainer = new TrainerModel(); string _color = string.Empty; var _lista = fcontext.ClassSchedule.Where(a => a.Id == Id).Select(b => new ClassScheduleModel { Id = b.Id, IdBranchOffice = b.IdBranchOficce, IdWorkout = b.IdWorkout, NameWorkout = b.Workout.Name, WeekDay = b.DayWeek, StarTime = b.StarTime, EndTime = b.EndTime, IdTrainer = b.IdTrainer, Active = b.Active, DateCreated = b.DateCreated, DateUpdated = b.DateUdated, NameBranchOffice = b.BranchOffice.Name, Subject = b.Workout.Name, Color = b.Workout.Color ?? DefaultColor, IdParent = b.Workout.Parent != null ? (int)b.Workout.Parent : b.Workout.Id, StarBranchOffice = b.BranchOffice.StarHour, EndBranchOffice = b.BranchOffice.EndHour, StartDate = b.StartDate, EndDate = b.EndDate }).First(); //var _lista = // fClassScheduleFactoryAsync.Find( // new List<Expression<Func<ClassSchedule, object>>> // { // aUser => aUser.BranchOffice, // aUser => aUser.Workout // }, a => a.Id == Id).Select(b => new ClassScheduleModel // { // Id = b.Id, // IdBranchOffice = b.IdBranchOficce, // IdWorkout = b.IdWorkout, // NameWorkout = b.Workout.Name, // WeekDay = b.DayWeek, // StarTime = b.StarTime, // EndTime = b.EndTime, // IdTrainer = b.IdTrainer, // Active = b.Active, // DateCreated = b.DateCreated, // DateUpdated = b.DateUdated, // NameBranchOffice = b.BranchOffice.Name, // Subject = b.Workout.Name, // Color = b.Workout.Color ?? DefaultColor, // IdParent = b.Workout.Parent != null ? (int)b.Workout.Parent : b.Workout.Id // }).First(); if (!string.IsNullOrEmpty(_lista.IdTrainer.ToString())) { _trainer = trainer.GetByID((int)_lista.IdTrainer); } if (string.IsNullOrEmpty(_lista.Color)) { _color = "Aqua"; } else { _color = _lista.Color; } var _day = new DayofWeek(); _lista.Day = _day.GetAll().First(a => a.Day == (int)_lista.WeekDay).Name; _lista.TrainerName = _trainer != null ? _trainer.Name: string.Empty; _lista.HuellaTrainer1 = _trainer != null ? _trainer.Huella1 : new byte[2]; _lista.HuellaTrainer2 = _trainer != null ? _trainer.Huella2 : new byte[2]; _lista.BrushColor = new BrushConverter().ConvertFromString(_color) as Brush; //new BrushConverter().ConvertFromString(_lista.Color) as Brush; _lista.StartHour = _lista.StarTime.ToString().Remove(_lista.StarTime.ToString().Length - 3); _lista.EndHour = _lista.EndTime.ToString().Remove(_lista.EndTime.ToString().Length - 3); return(_lista); } catch (Exception ex) { return(data); } }