private void ButtonAgregarEliminar_Click(object sender, RoutedEventArgs e) { WorkoutModel workout = DataGridWorkout.SelectedItem as WorkoutModel; if (workout != null) { GRDialogConsultation _var = new GRDialogConsultation(); _var.Message = "Eliminar Registro Selecionado?"; if (_var.ShowDialog() == true) { int id = workout.Id; var result = _workout.DeleteUpdate(id); if (result) { MyCollection.Remove(workout); DataGridWorkout.ItemsSource = MyCollection.OrderBy(a => a.Name); DataGridWorkout.Items.Refresh(); lblTotalReg.Content = "Cantidad de Registro: " + MyCollection.Count; } } } else { GRDialogInformation _msg = new GRDialogInformation(); _msg.Message = "Debe Seleccionar un Registro"; _msg.ShowDialog(); } }
private void ButtonAgregarEliminar_Click(object sender, RoutedEventArgs e) { StaffModel staff = DataGridStaff.SelectedItem as StaffModel; if (staff != null) { GRDialogConsultation _var = new GRDialogConsultation(); _var.Message = "Eliminar Registro Selecionado?"; if (_var.ShowDialog() == true) { int id = staff.Id; var result = services.DeleteUpdate(id); if (result) { MyCollection.Remove(staff); DataGridStaff.ItemsSource = MyCollection; DataGridStaff.Items.Refresh(); lblTotalReg.Content = "Cantidad de Registro: " + MyCollection.Count; } } } else { GRDialogInformation _msg = new GRDialogInformation(); _msg.Message = "Debe Seleccionar un Registro"; _msg.ShowDialog(); } }
private void Button_Aplicar(object sender, RoutedEventArgs e) { int result = 0; StaffModel staff = new StaffModel(); staff.Name = TxtName.Text.Trim(); staff.Code = TxtCode.Text.Trim(); staff.Active = CmbActive.Text == "Activo"; staff.Huella1 = _huella1; staff.Huella2 = _huella2; if ((!string.IsNullOrEmpty(TxtName.Text.Trim())) || (!string.IsNullOrEmpty(TxtCode.Text.Trim()))) { if (LblId.Content == "0") //ADD { result = staffServices.Add(staff); //result = task0.Result; LblId.Content = result.ToString(); } else //EDIT { int _id = int.Parse(LblId.Content.ToString()); staff.Id = _id; var task = staffServices.Update(staff); result = task ? _id : 0; } if (result > 0) { GRDialogConsultation _var = new GRDialogConsultation(); _var.Message = "Registro Guardado, desea crear otro Registro?"; if (_var.ShowDialog() == true) { CleanControls(); TxtName.Focus(); } else { var window = new StaffList(); this.Close(); window.ShowDialog(); } } else { GRDialogError _error = new GRDialogError(); _error.Message = "Ocurrion un error al guardar el resgitro"; _error.ShowDialog(); } } else { GRDialogInformation _var = new GRDialogInformation(); _var.Message = "Verificar campos obligatorios"; _var.ShowDialog(); } }
private void Button_Cancel(object sender, RoutedEventArgs e) { GRDialogConsultation _var = new GRDialogConsultation(); _var.Message = "Desea Cancelar la clase?"; if (_var.ShowDialog() == true) { ClassScheduleReviewModel classScheduleReview = new ClassScheduleReviewModel(); if (!string.IsNullOrEmpty(TxtObservacion.Text.Trim())) { DateTime _date = DateTime.Now; int result = 0; // classScheduleReview.Id = int.Parse(LblId.Content.ToString()); classScheduleReview.IdClassSchedule = int.Parse(LblIdClass.Content.ToString()); classScheduleReview.Observation = TxtObservacion.Text; classScheduleReview.IdStaff = int.Parse(CmbStaf.SelectedValue.ToString()); classScheduleReview.IsTrainer = (LblIdTrainer.Content == CmbTrainer.SelectedValue); //if diferente Trainer then Susititute classScheduleReview.IdTrainer = int.Parse(CmbTrainer.SelectedValue.ToString()); classScheduleReview.Members = int.Parse(intMembers.Text); classScheduleReview.Start = new TimeSpan(_date.Hour, _date.Minute, _date.Second); classScheduleReview.End = new TimeSpan(_date.Hour, _date.Minute, _date.Second); classScheduleReview.Estatus = (int)Constants.StatusClass.CANCELED; result = services.Add(classScheduleReview); //result = task.Result; if (result > 0) { GRDialogInformation _msg = new GRDialogInformation(); _msg.Message = "Clase Cancelada"; _msg.ShowDialog(); this.Close(); } else { GRDialogError _err = new GRDialogError(); _err.Message = "Error guardando datos"; _err.ShowDialog(); } } else { GRDialogInformation _msg0 = new GRDialogInformation(); _msg0.Message = "Debe Ingresar una Observacion"; _msg0.ShowDialog(); TxtObservacion.Focus(); } } }
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(); } }
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(); } }
private void Button_Aplicar(object sender, RoutedEventArgs e) { int result = 0; bool ValidateCode = false; WorkoutModel _workout = new WorkoutModel(); _workout.CodigoWorkout = TxtCodigo.Text.Trim(); _workout.Name = TxtName.Text.Trim(); _workout.Description = TxtDescription.Text.Trim(); _workout.Parent = int.Parse(CmbParent.SelectedValue.ToString()); _workout.Color = CmbColor.brushSelectionBox.Text.Replace("System.Windows.Media.SolidColorBrush ", " ").Trim(); _workout.Active = CmbActive.Text == "Activo"; if ((!string.IsNullOrEmpty(TxtName.Text.Trim())) || (!string.IsNullOrEmpty(TxtCodigo.Text.Trim()))) { if (LblId.Content == "0") //ADD { var existCode = _workoutServices.GetByCode(TxtCodigo.Text.Trim()); if (existCode == null) { result = _workoutServices.Add(_workout); //result = task0.Result; LblId.Content = result.ToString(); } else { ValidateCode = true; GRDialogInformation _error01 = new GRDialogInformation(); _error01.Message = "El codigo ingresado pertenece a otro registro"; _error01.ShowDialog(); TxtCodigo.Focus(); } } else //EDIT { int _id = int.Parse(LblId.Content.ToString()); _workout.Id = _id; var task = _workoutServices.Update(_workout); result = task ? _id : 0; } if (result > 0) { GRDialogConsultation _var = new GRDialogConsultation(); _var.Message = "Registro Guardado, desea crear otro Registro?"; if (_var.ShowDialog() == true) { CleanControls(); TxtName.Focus(); } else { var window = new WorkoutList(); this.Close(); window.ShowDialog(); } } else { if (!ValidateCode) { GRDialogError _error = new GRDialogError(); _error.Message = "Ocurrion un error al guardar el resgitro"; _error.ShowDialog(); } } } else { GRDialogInformation _error1 = new GRDialogInformation(); _error1.Message = "Verificar campos obligatorios"; _error1.ShowDialog(); } }
private void Button_Aplicar(object sender, RoutedEventArgs e) { bool hourStart = Common.ValidateHour(mkbHoraInicio.Text); bool hourEnd = Common.ValidateHour(mkbHoraFin.Text); if (!string.IsNullOrEmpty(TxtSucursal.Text.Trim()) || !string.IsNullOrEmpty(TxtCodigo.Text.Trim())) { if ((hourStart) && (hourEnd)) { if (TimeSpan.Parse(mkbHoraInicio.Text) < TimeSpan.Parse(mkbHoraFin.Text)) { int result = 0; BranchOfficeModel _class = new BranchOfficeModel(); _class.Code = TxtCodigo.Text.Trim(); _class.Name = TxtSucursal.Text.Trim(); _class.Adress = TxtDir.Text.Trim(); _class.Observation = TxtObs.Text.Trim(); _class.StarHour = TimeSpan.Parse(mkbHoraInicio.Text); _class.EndHour = TimeSpan.Parse(mkbHoraFin.Text); _class.Active = CmbActive.Text == "Activo"; var existBranchOffice = branchOfficeServices.GetByCode(TxtCodigo.Text.Trim()); if (LblId.Content == "0") //ADD { if (existBranchOffice == null) { result = branchOfficeServices.Add(_class); LblId.Content = result.ToString(); } else { GRDialogInformation _error0 = new GRDialogInformation(); _error0.Message = "El Codigo ingresado ya esta en uso"; _error0.ShowDialog(); TxtCodigo.Focus(); } } else //EDIT { int _id = int.Parse(LblId.Content.ToString()); if ((existBranchOffice == null) || (existBranchOffice.Id == _id)) { _class.Id = _id; var task = branchOfficeServices.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(); TxtSucursal.Focus(); } else { var window = new BranchOfficeList(); this.Close(); window.ShowDialog(); } } else { GRDialogError _error = new GRDialogError(); _error.Message = "Ocurrion un error al guardar el resgitro"; _error.ShowDialog(); } } else { GRDialogInformation _error1 = new GRDialogInformation(); _error1.Message = "La Hora de Inicio no puede ser mayor a la Hora Fin"; _error1.ShowDialog(); } } else { GRDialogInformation _error2 = new GRDialogInformation(); _error2.Message = "Verificar campos Obligatorios / Formato de Horas"; _error2.ShowDialog(); } } else { GRDialogInformation _error2 = new GRDialogInformation(); _error2.Message = "Verificar campos Obligatorios"; _error2.ShowDialog(); } }
private void Button_Aplicar(object sender, RoutedEventArgs e) { int result = 0; bool ValidateCode = false; TrainerModel _trainer = new TrainerModel(); _trainer.Code = TxtCodigo.Text.Trim(); _trainer.Name = TxtName.Text.Trim(); _trainer.Description = TxtDescription.Text.Trim(); _trainer.Type = int.Parse(CmbType.SelectedValue.ToString()); _trainer.Active = CmbActive.Text == "Activo"; _trainer.Huella1 = _huella1; _trainer.Huella2 = _huella2; if (String.IsNullOrEmpty(TxtCosto.Text.Trim())) { _trainer.Price = 0; } else { _trainer.Price = Double.Parse(TxtCosto.Text.Trim()); } _trainer.PhotoLink = _photoLink == string.Empty? null: _photoLink; if ((!string.IsNullOrEmpty(TxtName.Text.Trim())) || (!string.IsNullOrEmpty(TxtCodigo.Text.Trim()))) { if (LblId.Content == "0") //ADD { var existCode = trainerServices.GetByCode(TxtCodigo.Text.Trim()); if (existCode == null) { result = trainerServices.Add(_trainer); //result = task0.Result; LblId.Content = result.ToString(); } else { ValidateCode = true; GRDialogInformation _error01 = new GRDialogInformation(); _error01.Message = "El codigo ingresado pertenece a otro registro"; _error01.ShowDialog(); TxtCodigo.Focus(); } } else //EDIT { int _id = int.Parse(LblId.Content.ToString()); _trainer.Id = _id; var task = trainerServices.Update(_trainer); result = task ? _id : 0; } if (result > 0) { GRDialogConsultation _var = new GRDialogConsultation(); _var.Message = "Registro Guardado, desea crear otro Registro?"; if (_var.ShowDialog() == true) { CleanControls(); TxtName.Focus(); } else { var window = new TrainerList(); this.Close(); window.ShowDialog(); } } else { if (!ValidateCode) { GRDialogError _error = new GRDialogError(); _error.Message = "Error"; _error.ShowDialog(); } } } else { GRDialogError _error = new GRDialogError(); _error.Message = "Verificar campos obligatorios"; _error.ShowDialog(); } }