void Set_Controls(ResourceSchedulingBE schedulerShift) { txtNombre.Text = schedulerShift.Description; durationEdit1.Duration = TimeSpan.FromMinutes(schedulerShift.Duration.Value); weekDaysCheckEdit1.WeekDays = (WeekDays) schedulerShift.WeekDays; cmbTimeStart.Text = schedulerShift.TimeStart; cmbTimeEnd.Text = schedulerShift.TimeEnd; }
void Set_SchedulerShift( ResourceSchedulingBE schedulerShift ) { if (this.State == Fwk.Bases.EntityUpdateEnum.NEW && schedulerShift == null) { //schedulerShift = new ResourceSchedulingBE(); schedulerShift.ResourceId = ResourceId; } schedulerShift.Description = txtNombre.Text; schedulerShift.Duration = durationEdit1.Duration.TotalMinutes; schedulerShift.WeekDays = (int)weekDaysCheckEdit1.WeekDays; schedulerShift.TimeStart = cmbTimeStart.Text; schedulerShift.TimeEnd = cmbTimeEnd.Text; }
void Set_SchedulerShift(ResourceSchedulingBE schedulerShift) { if (this.State == Fwk.Bases.EntityUpdateEnum.NEW && schedulerShift == null) { //schedulerShift = new ResourceSchedulingBE(); schedulerShift.ResourceId = ResourceId; } schedulerShift.Description = txtNombre.Text; schedulerShift.Duration = durationEdit1.Duration.TotalMinutes; schedulerShift.WeekDays = (int)weekDaysCheckEdit1.WeekDays; schedulerShift.TimeStart = cmbTimeStart.Text; schedulerShift.TimeEnd = cmbTimeEnd.Text; }
void ValidateControls(ResourceSchedulingBE pResourceSchedulingBE) { dxErrorProvider1.ClearErrors(); if (String.IsNullOrEmpty(pResourceSchedulingBE.Description)) { dxErrorProvider1.SetErrorType(txtNombre, DevExpress.XtraEditors.DXErrorProvider.ErrorType.Critical); dxErrorProvider1.SetError(txtNombre, "Valor requerido"); } if (pResourceSchedulingBE.TimeStart_timesp > pResourceSchedulingBE.TimeEnd_timesp) { dxErrorProvider1.SetErrorType(cmbTimeStart, DevExpress.XtraEditors.DXErrorProvider.ErrorType.Critical); dxErrorProvider1.SetError(cmbTimeStart, "La hora de inicio debe ser anterior a la hora de finalización del turno"); } }
/// <summary> /// Retorna la programacion de turnos de un determinado recurso para una institucion determinada /// </summary> /// <param name="resourceId">Recurso</param> /// <param name="healthInstId">Opcional</param> /// <returns></returns> public static ResourceSchedulingList RetriveBy_ResourceId(int resourceId, Guid?healthInstId) { ResourceSchedulingList list = new ResourceSchedulingList(); using (Health.Back.BE.HealthEntities dc = new Health.Back.BE.HealthEntities(Common.CnnString_Entities)) { var resourceScheduling_db = dc.ResourceSchedulings.Where <ResourceScheduling>(p => p.ResourceId.Value.Equals(resourceId) && (!healthInstId.HasValue || p.HealthInstitutionId.Value.Equals(healthInstId.Value))); foreach (ResourceScheduling r in resourceScheduling_db) { ResourceSchedulingBE wResourceScheduling = (ResourceSchedulingBE)r; list.Add(wResourceScheduling); } } return(list); }
private void aceptCancelButtonBar1_ClickOkCancelEvent(object sender, DialogResult result) { if (result == System.Windows.Forms.DialogResult.OK) { if (this.State == Fwk.Bases.EntityUpdateEnum.NEW) { _SchedulerShiftOriginal = new ResourceSchedulingBE(); Set_SchedulerShift(_SchedulerShiftOriginal); ValidateControls(_SchedulerShiftOriginal); if (dxErrorProvider1.HasErrors) { return; } if (!ValidateIntersection(_SchedulerShiftOriginal)) { MessageBox.Show("Esta programación de turnos se superpone con turnos existentes", "Programación de turnos del profesional"); return; } } if (this.State == Fwk.Bases.EntityUpdateEnum.UPDATED) { Set_SchedulerShift(_SchedulerShiftCopy); if (HasChanges()) { ValidateControls(_SchedulerShiftCopy); if (dxErrorProvider1.HasErrors) { return; } if (!ValidateIntersection(_SchedulerShiftCopy)) { MessageBox.Show("Esta programacion de turnos se superpone con turnos existentes", "Programación de turnos del profesional"); return; } Set_SchedulerShift(_SchedulerShiftOriginal); } } } this.DialogResult = result; this.Close(); }
void UpdateCombo(double duration, bool maintainingPosition) { var x = ResourceSchedulingBE.Get_ArrayOfTimes(DateTime.Now, TimeSpan.Parse("00:00"), TimeSpan.Parse("24:0:0"), duration, "Turno tarde"); timespamViewBindingSource.DataSource = x; bindingSource1.DataSource = x; cmbTimeStart.Refresh(); cmbTimeEnd.Refresh(); if (maintainingPosition) { return; } int index = cmbTimeStart.Properties.GetDataSourceRowIndex("TimeString", "09:00"); cmbTimeStart.ItemIndex = index; index = cmbTimeEnd.Properties.GetDataSourceRowIndex("TimeString", "18:00"); cmbTimeEnd.ItemIndex = index; }
private void CreateResourceScheduling(ResourceSchedulingBE currentShiftSheduling) { using (frmResouceScheduling frm = new frmResouceScheduling(profesionalBE.IdProfesional)) { if (this.resourceSchedulingList == null) { this.resourceSchedulingList = new ResourceSchedulingList(); } if (currentShiftSheduling != null) { frm.SchedulerShift = currentShiftSheduling; frm.State = Fwk.Bases.EntityUpdateEnum.UPDATED; } else { frm.State = Fwk.Bases.EntityUpdateEnum.NEW; } frm.ResourceSchedulingList = resourceSchedulingList; if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { frm.SchedulerShift.EntityState = Fwk.Bases.EntityState.Added; if (frm.State == Fwk.Bases.EntityUpdateEnum.NEW) { frm.SchedulerShift.ResourceId = profesionalBE.IdProfesional; resourceSchedulingList.Add(frm.SchedulerShift); schedulerShiftBindingSource.DataSource = resourceSchedulingList; } gridControl1.RefreshDataSource(); } } }
private void gridView1_MouseDown(object sender, MouseEventArgs e) { // if (e.Button != MouseButtons.Right) return; _HitInfo = gridView1.CalcHitInfo(new Point(e.X, e.Y)); currentShiftSheduling = ((ResourceSchedulingBE)gridView1.GetRow(_HitInfo.RowHandle)); }
private void CreateResourceScheduling(ResourceSchedulingBE currentShiftSheduling) { using (frmResouceScheduling frm = new frmResouceScheduling(profesionalBE.IdProfesional)) { if (this.resourceSchedulingList == null) this.resourceSchedulingList = new ResourceSchedulingList(); if (currentShiftSheduling != null) { frm.SchedulerShift = currentShiftSheduling; frm.State = Fwk.Bases.EntityUpdateEnum.UPDATED; } else frm.State = Fwk.Bases.EntityUpdateEnum.NEW; frm.ResourceSchedulingList = resourceSchedulingList; if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { frm.SchedulerShift.EntityState = Fwk.Bases.EntityState.Added; if( frm.State == Fwk.Bases.EntityUpdateEnum.NEW) { frm.SchedulerShift.ResourceId = profesionalBE.IdProfesional; resourceSchedulingList.Add(frm.SchedulerShift); schedulerShiftBindingSource.DataSource = resourceSchedulingList; } gridControl1.RefreshDataSource(); } } }
public static void UpdateResourceSheduling(ResourceSchedulingBE resourceSchedulingBE, Guid healthInstId) { ResourceSchedulingList list = new ResourceSchedulingList(); list.Add(resourceSchedulingBE); UpdateResourceScheduling(list, healthInstId); }
public static void CreateResourceScheduling(ResourceSchedulingBE pResourceScheduling, Guid healthInstId) { ResourceSchedulingList list = new ResourceSchedulingList(); pResourceScheduling.HealthInstitutionId = healthInstId; list.Add(pResourceScheduling); CreateResourceScheduling(list, healthInstId); }
private void aceptCancelButtonBar1_ClickOkCancelEvent(object sender, DialogResult result) { if (result == System.Windows.Forms.DialogResult.OK) { if ( this.State == Fwk.Bases.EntityUpdateEnum.NEW) { _SchedulerShiftOriginal = new ResourceSchedulingBE(); Set_SchedulerShift(_SchedulerShiftOriginal); ValidateControls(_SchedulerShiftOriginal); if (dxErrorProvider1.HasErrors) return; if (!ValidateIntersection(_SchedulerShiftOriginal)) { MessageBox.Show("Esta programación de turnos se superpone con turnos existentes", "Programación de turnos del profesional"); return; } } if (this.State == Fwk.Bases.EntityUpdateEnum.UPDATED) { Set_SchedulerShift(_SchedulerShiftCopy); if (HasChanges()) { ValidateControls(_SchedulerShiftCopy); if (dxErrorProvider1.HasErrors) return; if (!ValidateIntersection(_SchedulerShiftCopy)) { MessageBox.Show("Esta programacion de turnos se superpone con turnos existentes", "Programación de turnos del profesional"); return; } Set_SchedulerShift(_SchedulerShiftOriginal); } } } this.DialogResult = result; this.Close(); }
/// <summary> /// Valida la overlaping de horarios /// Si todo esta bien returna True /// </summary> /// <param name="pResourceSchedulingBE"></param> /// <returns></returns> Boolean ValidateIntersection(ResourceSchedulingBE pResourceSchedulingBE) { TimeInterval interva1 = null; TimeInterval interva2 = null; interva2 = new TimeInterval( Fwk.HelperFunctions.DateFunctions.BeginningOfTimes.AddHours(pResourceSchedulingBE.TimeStart_timesp.TotalHours), Fwk.HelperFunctions.DateFunctions.BeginningOfTimes.AddHours(pResourceSchedulingBE.TimeEnd_timesp.TotalHours)); foreach (ResourceSchedulingBE r in ResourceSchedulingList.Where(p=>!p.IdSheduler.Equals(pResourceSchedulingBE.IdSheduler))) { //Si no hay dias en comun no hay problema if (!r.HasDaysInCommon(pResourceSchedulingBE.WeekDays_BinArray)) { return true; } //Si tienen dias en comun hay que verificar que no se overlapen los horarios interva1 = new TimeInterval( Fwk.HelperFunctions.DateFunctions.BeginningOfTimes.AddHours(r.TimeStart_timesp.TotalHours), Fwk.HelperFunctions.DateFunctions.BeginningOfTimes.AddHours(r.TimeEnd_timesp.TotalHours)); if (interva1.IntersectsWithExcludingBounds(interva2)) return false; //bool val3 = interva1.IntersectsWith(interva2); } return true; }