public int Add(ClassScheduleReviewModel aModel) { int result = 0; //await Task.Run(() => //{ try { ReviewClassSchedule aNew = new ReviewClassSchedule { IdClassSchedule = aModel.IdClassSchedule, Observation = aModel.Observation, IdStaff = aModel.IdStaff, IsTrainer = aModel.IsTrainer, IdTrainer = aModel.IdTrainer, Members = aModel.Members, Status = aModel.Estatus, StartTime = aModel.Start, EndTime = aModel.End, DateCreated = DateTime.Now }; context.ReviewClassSchedule.Add(aNew); context.SaveChanges(); result = aNew.Id; } catch (Exception ex) { result = 0; } //}); return(result); }
public bool Update(ClassScheduleReviewModel aModel) { bool result = false; //await Task.Run(() => //{ try { var getToUpdate = fcontext.ReviewClassSchedule.First(a => a.Id == aModel.Id); getToUpdate.Observation = aModel.Observation; getToUpdate.IdStaff = aModel.IdStaff; getToUpdate.IsTrainer = aModel.IsTrainer; getToUpdate.Status = aModel.Estatus; getToUpdate.Members = aModel.Members; getToUpdate.DateUpdated = DateTime.Now; getToUpdate.EndTime = aModel.End; fcontext.Entry(getToUpdate).State = System.Data.Entity.EntityState.Modified; fcontext.SaveChanges(); result = true; } catch (Exception ex) { result = false; } //}); return(result); }
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 Button_Apertura(object sender, RoutedEventArgs e) { ClassScheduleReviewModel classScheduleReview = new ClassScheduleReviewModel(); if (DigitalPersona4500.Instance.Validate(new DigitalPersona4500Template(new System.IO.MemoryStream(_huella1)), new DigitalPersona4500Template(new System.IO.MemoryStream(_huella2)))) { DateTime _date = DateTime.Now; int result = 0; 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.Estatus = (int)Constants.StatusClass.OPEN; result = services.Add(classScheduleReview); if (result > 0) { GRDialogInformation _msg = new GRDialogInformation(); _msg.Message = "Huella Registrada"; _msg.ShowDialog(); this.Close(); } else { GRDialogError _err = new GRDialogError(); _err.Message = "Error guardando datos"; _err.ShowDialog(); } } else { GRDialogError _err0 = new GRDialogError(); _err0.Message = "Error, Verificando huella"; _err0.ShowDialog(); } }
private void Button_Cierre(object sender, RoutedEventArgs e) { ClassScheduleReviewModel classScheduleReview = new ClassScheduleReviewModel(); if (!string.IsNullOrEmpty(TxtObservacion.Text.Trim())) { if (int.Parse(intMembers.Text.ToString()) > 0) { #region Validar Huella Staff / Cerrar Clase if ( DigitalPersona4500.Instance.Validate( new DigitalPersona4500Template(new System.IO.MemoryStream(_huellaStaff1)), new DigitalPersona4500Template(new System.IO.MemoryStream(_huellaStaff2)))) { DateTime _date = DateTime.Now; bool result = false; 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.End = new TimeSpan(_date.Hour, _date.Minute, _date.Second); classScheduleReview.Estatus = (int)Constants.StatusClass.CLOSE; result = services.Update(classScheduleReview); //result = task.Result; if (result) { GRDialogInformation _msg = new GRDialogInformation(); _msg.Message = "Clase Cerrada"; _msg.ShowDialog(); this.Close(); } else { GRDialogError _err = new GRDialogError(); _err.Message = "Error guardando datos"; _err.ShowDialog(); } } else { GRDialogError _err0 = new GRDialogError(); _err0.Message = "Error, Verificando huella"; _err0.ShowDialog(); } #endregion } else { GRDialogInformation _msg1 = new GRDialogInformation(); _msg1.Message = "Debe Ingresar en número de asistentes a la clase"; _msg1.ShowDialog(); intMembers.Focus(); } } else { GRDialogInformation _msg1 = new GRDialogInformation(); _msg1.Message = "Debe Ingresar una Observacion"; _msg1.ShowDialog(); TxtObservacion.Focus(); } }