public override void Refresh() { if (this.DesignMode) { return; } this.Date = Fwk.HelperFunctions.DateFunctions.GetStartDateTime(this.Date); _TimespamViewList = Get_ArrayOfTimes(); TimespamView wTimespamView = null; if (AppointmentList != null) { //Recorrer todos los turnos a partir de Date foreach (AppointmentBE a in AppointmentList.Where <AppointmentBE>(p => DateFunctions.GetStartDateTime(p.Start.Value).Equals(this.Date) && !p.IsExceptional)) { TimeSpan t = a.TimeStart_timesp; //Este cilo permite pintar Varios appointments como uno solo //El caso se da cuando el usuario selecciona varios concecutivos y los asigna a un TURNO. Por lo tanto se crea un //solo Appoiment en la bace de datos donde TimeStart_timesp y TimeEnd_timesp incluira todos los turnos seleccionados while (true) { //Creo ej: 10:15 para buscarlo dentro de los TimesView de la Grilla string wTimeStart = String.Concat(t.ToString("hh"), ":", t.ToString("mm")); wTimespamView = _TimespamViewList.Where <TimespamView>(p => p.TimeString.Equals(wTimeStart)).FirstOrDefault <TimespamView>(); if (wTimespamView != null) { wTimespamView.Appointment = a; } t = t.Add(TimeSpan.FromMinutes(a.Duration.Value)); //Revisar que pasa si t > a.TimeEnd_timesp if (t >= a.TimeEnd_timesp) { break; } } } } #region sobreturnos //Si existen sobreturnos agregarlos al la lista de timelines var sobreturnos = AppointmentList.Where <AppointmentBE>(p => p.IsExceptional); Insert_Sobreturnos(sobreturnos.ToList()); #endregion _TimespamViewList.Sort(new TimeSpanComparer()); //_TimespamViewList = _TimespamViewList.OrderBy(p => p.Time).ToList<TimespamView>(); timespamViewBindingSource.DataSource = _TimespamViewList; gridControl2.RefreshDataSource(); gridView2.RefreshData(); base.Refresh(); }
/// <summary> /// Sobreturnos /// </summary> /// <param name="list"></param> void Insert_Sobreturnos(List <AppointmentBE> list) { TimespamView wTimespamView = null; foreach (AppointmentBE appointment in list) { wTimespamView = new TimespamView(); wTimespamView.Appointment = appointment; wTimespamView.Time = TimeSpan.Parse(appointment.TimeStart); wTimespamView.Duration = appointment.Duration.Value; wTimespamView.Name = "Excepsional"; _TimespamViewList.Add(wTimespamView); } }
private void gridView2_MouseDown(object sender, MouseEventArgs e) { _HitInfo = gridView2.CalcHitInfo(new Point(e.X, e.Y)); SelectedTimespamView = ((TimespamView)gridView2.GetRow(_HitInfo.RowHandle)); if (SelectedTimespamView == null) return; if (e.Button != System.Windows.Forms.MouseButtons.Right) return; //double hora = SelectedTimespamView.Time.TotalHours; DateTime selectedTime = new DateTime(Date.Year, Date.Month, Date.Day, SelectedTimespamView.Time.Hours, SelectedTimespamView.Time.Minutes, 0); //TimeSpan tNow = new TimeSpan( System.DateTime.Now.Hour); //double hora2 = tNow.TotalHours; //Si ya paso if (DateTime.Compare(selectedTime, System.DateTime.Now) < 0) { mAsignarToolStripMenuItem.Enabled = false; mSetCanceled.Enabled = false; mCerrarTurnoToolStripMenuItem.Enabled = false; m_sobreturnoToolStripMenuItem.Enabled = false; return; } if (SelectedTimespamView.Appointment == null) { mAsignarToolStripMenuItem.Enabled = true; mCerrarTurnoToolStripMenuItem.Enabled = false; mSetCanceled.Enabled = false; m_sobreturnoToolStripMenuItem.Enabled = false; return; } //Si se selecciona el ultimo if (SelectedTimespamView == _TimespamViewList[_TimespamViewList.Count - 1]) { m_sobreturnoToolStripMenuItem.Text = "Sobreturno";// Enum.GetName(typeof(AppoimantsStatus_SP), AppoimantsStatus_SP.Sobreturno); m_sobreturnoToolStripMenuItem.Tag = AppoimantsStatus_SP_type.Sobreturno; } else { m_sobreturnoToolStripMenuItem.Text = "Entreturno";// Enum.GetName(typeof(AppoimantsStatus_SP), AppoimantsStatus_SP.Entreturno); m_sobreturnoToolStripMenuItem.Tag = AppoimantsStatus_SP_type.Entreturno; } if (gridView2.SelectedRowsCount > 1) { mAsignarToolStripMenuItem.Enabled = false; mSetCanceled.Enabled = false; mCerrarTurnoToolStripMenuItem.Enabled = false; m_sobreturnoToolStripMenuItem.Enabled = false; } else { if (SelectedTimespamView.Appointment.IsExceptional) { mAsignarToolStripMenuItem.Enabled = false; mCerrarTurnoToolStripMenuItem.Enabled = false; mSetCanceled.Enabled = true; mEnEsperaToolStripMenuItem.Enabled = false; m_atenderToolStripMenuItem.Enabled = true; m_sobreturnoToolStripMenuItem.Enabled = false; } if (SelectedTimespamView.Appointment.Status == (int)AppoimantsStatus_SP.EnEspera) { mAsignarToolStripMenuItem.Enabled = false; mSetCanceled.Enabled = true; mCerrarTurnoToolStripMenuItem.Enabled = false; mEnEsperaToolStripMenuItem.Enabled = false ; m_sobreturnoToolStripMenuItem.Enabled = true; m_atenderToolStripMenuItem.Enabled = true; } if (SelectedTimespamView.Appointment.Status == (int)AppoimantsStatus_SP.Reservado) { mAsignarToolStripMenuItem.Enabled = false; mSetCanceled.Enabled = true; mCerrarTurnoToolStripMenuItem.Enabled = false; mEnEsperaToolStripMenuItem.Enabled = true; m_atenderToolStripMenuItem.Enabled = true; m_sobreturnoToolStripMenuItem.Enabled = true ; } if (SelectedTimespamView.Appointment.Status == (int)AppoimantsStatus_SP.EnAtencion) { mAsignarToolStripMenuItem.Enabled = false; mCerrarTurnoToolStripMenuItem.Enabled = true; mSetCanceled.Enabled = false; mEnEsperaToolStripMenuItem.Enabled = false; m_atenderToolStripMenuItem.Enabled = false; m_sobreturnoToolStripMenuItem.Enabled = false; } if (SelectedTimespamView.Appointment.Status == (int)AppoimantsStatus_SP.Cerrado) { mAsignarToolStripMenuItem.Enabled = false; mCerrarTurnoToolStripMenuItem.Enabled = false; mSetCanceled.Enabled = false; mEnEsperaToolStripMenuItem.Enabled = false; m_atenderToolStripMenuItem.Enabled = false; m_sobreturnoToolStripMenuItem.Enabled = false; } if (SelectedTimespamView.Appointment.Status == (int)AppoimantsStatus_SP.Cancelado) { mAsignarToolStripMenuItem.Enabled = true; mCerrarTurnoToolStripMenuItem.Enabled = false; mSetCanceled.Enabled = false; mEnEsperaToolStripMenuItem.Enabled = false; m_atenderToolStripMenuItem.Enabled = false; m_sobreturnoToolStripMenuItem.Enabled = true; } } }
/// <summary> /// Sobreturnos /// </summary> /// <param name="list"></param> void Insert_Sobreturnos(List<AppointmentBE> list) { TimespamView wTimespamView =null; foreach(AppointmentBE appointment in list) { wTimespamView = new TimespamView(); wTimespamView.Appointment = appointment; wTimespamView.Time = TimeSpan.Parse(appointment.TimeStart); wTimespamView.Duration = appointment.Duration.Value; wTimespamView.Name = "Excepsional"; _TimespamViewList.Add(wTimespamView); } }
private void gridView2_MouseDown(object sender, MouseEventArgs e) { _HitInfo = gridView2.CalcHitInfo(new Point(e.X, e.Y)); SelectedTimespamView = ((TimespamView)gridView2.GetRow(_HitInfo.RowHandle)); if (SelectedTimespamView == null) { return; } if (e.Button != System.Windows.Forms.MouseButtons.Right) { return; } //double hora = SelectedTimespamView.Time.TotalHours; DateTime selectedTime = new DateTime(Date.Year, Date.Month, Date.Day, SelectedTimespamView.Time.Hours, SelectedTimespamView.Time.Minutes, 0); //TimeSpan tNow = new TimeSpan( System.DateTime.Now.Hour); //double hora2 = tNow.TotalHours; //Si ya paso if (DateTime.Compare(selectedTime, System.DateTime.Now) < 0) { mAsignarToolStripMenuItem.Enabled = false; mSetCanceled.Enabled = false; mCerrarTurnoToolStripMenuItem.Enabled = false; m_sobreturnoToolStripMenuItem.Enabled = false; return; } if (SelectedTimespamView.Appointment == null) { mAsignarToolStripMenuItem.Enabled = true; mCerrarTurnoToolStripMenuItem.Enabled = false; mSetCanceled.Enabled = false; m_sobreturnoToolStripMenuItem.Enabled = false; return; } //Si se selecciona el ultimo if (SelectedTimespamView == _TimespamViewList[_TimespamViewList.Count - 1]) { m_sobreturnoToolStripMenuItem.Text = "Sobreturno";// Enum.GetName(typeof(AppoimantsStatus_SP), AppoimantsStatus_SP.Sobreturno); m_sobreturnoToolStripMenuItem.Tag = AppoimantsStatus_SP_type.Sobreturno; } else { m_sobreturnoToolStripMenuItem.Text = "Entreturno";// Enum.GetName(typeof(AppoimantsStatus_SP), AppoimantsStatus_SP.Entreturno); m_sobreturnoToolStripMenuItem.Tag = AppoimantsStatus_SP_type.Entreturno; } if (gridView2.SelectedRowsCount > 1) { mAsignarToolStripMenuItem.Enabled = false; mSetCanceled.Enabled = false; mCerrarTurnoToolStripMenuItem.Enabled = false; m_sobreturnoToolStripMenuItem.Enabled = false; } else { if (SelectedTimespamView.Appointment.IsExceptional) { mAsignarToolStripMenuItem.Enabled = false; mCerrarTurnoToolStripMenuItem.Enabled = false; mSetCanceled.Enabled = true; mEnEsperaToolStripMenuItem.Enabled = false; m_atenderToolStripMenuItem.Enabled = true; m_sobreturnoToolStripMenuItem.Enabled = false; } if (SelectedTimespamView.Appointment.Status == (int)AppoimantsStatus_SP.EnEspera) { mAsignarToolStripMenuItem.Enabled = false; mSetCanceled.Enabled = true; mCerrarTurnoToolStripMenuItem.Enabled = false; mEnEsperaToolStripMenuItem.Enabled = false; m_sobreturnoToolStripMenuItem.Enabled = true; m_atenderToolStripMenuItem.Enabled = true; } if (SelectedTimespamView.Appointment.Status == (int)AppoimantsStatus_SP.Reservado) { mAsignarToolStripMenuItem.Enabled = false; mSetCanceled.Enabled = true; mCerrarTurnoToolStripMenuItem.Enabled = false; mEnEsperaToolStripMenuItem.Enabled = true; m_atenderToolStripMenuItem.Enabled = true; m_sobreturnoToolStripMenuItem.Enabled = true; } if (SelectedTimespamView.Appointment.Status == (int)AppoimantsStatus_SP.EnAtencion) { mAsignarToolStripMenuItem.Enabled = false; mCerrarTurnoToolStripMenuItem.Enabled = true; mSetCanceled.Enabled = false; mEnEsperaToolStripMenuItem.Enabled = false; m_atenderToolStripMenuItem.Enabled = false; m_sobreturnoToolStripMenuItem.Enabled = false; } if (SelectedTimespamView.Appointment.Status == (int)AppoimantsStatus_SP.Cerrado) { mAsignarToolStripMenuItem.Enabled = false; mCerrarTurnoToolStripMenuItem.Enabled = false; mSetCanceled.Enabled = false; mEnEsperaToolStripMenuItem.Enabled = false; m_atenderToolStripMenuItem.Enabled = false; m_sobreturnoToolStripMenuItem.Enabled = false; } if (SelectedTimespamView.Appointment.Status == (int)AppoimantsStatus_SP.Cancelado) { mAsignarToolStripMenuItem.Enabled = true; mCerrarTurnoToolStripMenuItem.Enabled = false; mSetCanceled.Enabled = false; mEnEsperaToolStripMenuItem.Enabled = false; m_atenderToolStripMenuItem.Enabled = false; m_sobreturnoToolStripMenuItem.Enabled = true; } } }