예제 #1
0
        void schedulerControl1_AppointmentDrop(object sender, AppointmentDragEventArgs e)
        {
            string createEventMsg = "Creating an event at {0} on {1}.";
            string moveEventMsg   = "Moving the event from {0} on {1} to {2} on {3}.";

            DateTime srcStart = e.SourceAppointment.Start;

            if (dragHandler.IsExternalDrag)
            {
                e.EditedAppointment.Start = dragHandler.newAppointmentDate;
            }
            DateTime newStart = e.EditedAppointment.Start;

            string msg = (srcStart == DateTime.MinValue) ? String.Format(createEventMsg, newStart.ToShortTimeString(), newStart.ToShortDateString()) :
                         String.Format(moveEventMsg, srcStart.ToShortTimeString(), srcStart.ToShortDateString(), newStart.ToShortTimeString(), newStart.ToShortDateString());

            MessageBoxResult mbResult = DXMessageBox.Show(msg + "\r\nProceed?", "Demo", MessageBoxButton.YesNo, MessageBoxImage.Question);

            schedulerControl1.Focus();

            if (mbResult == MessageBoxResult.Yes)
            {
                if (!this.dragFromGrid)
                {
                    return;
                }

                schedulerControl1.Storage.AppointmentStorage.Add(e.EditedAppointment.Copy());
                tableView1.DeleteRow(currentRowHandle);
            }

            e.Allow = false;
        }
예제 #2
0
 /// <summary>
 /// 일정의 duration은 그대로 둔 채 시간을 변경하였을 경우
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void schedulerControl_AppointmentDrop(object sender, AppointmentDragEventArgs e)
 {
     if (e.EditedAppointment.Start.Date.CompareTo(DateTime.Now) > 0 || e.EditedAppointment.End.Date.CompareTo(DateTime.Now) > 0)
     {
         if (e.EditedAppointment.Start.Day.Equals(e.SourceAppointment.Start.Day))//일자가 변경되지 않았다면
         {
             //if (CheckDuplicateSchedule(_assetNumber, e.EditedAppointment.Start.ToString("yyyyMMdd"), e.EditedAppointment.Start.ToString("HHmm"), e.EditedAppointment.End.ToString("HHmm"), e.EditedAppointment.LabelId.ToString()))
             string start = e.EditedAppointment.Start.ToString("yyyy-MM-dd HH:mm:ss");
             string end   = e.EditedAppointment.End.ToString("yyyy-MM-dd HH:mm:ss");
             if (CheckDuplicateSchedule(e.EditedAppointment.Description.Split(' ')[0], e.EditedAppointment.Start.ToString("yyyy-MM-dd HH:mm:ss"), start, end, e.EditedAppointment.LabelId.ToString()))
             {//중복검사
                 EditScheduleTime(e.EditedAppointment.LabelId.ToString(), start, end);
             }
             else//스케쥴이 겹칠 경우
             {
                 XtraMessageBox.Show("해당 자산번호는 입력된 일시에 사용중입니다.", "안내", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             }
         }
         else//스케쥴을 하루가 넘길 경우
         {
             XtraMessageBox.Show("일자를 수정할 수 없습니다", "안내", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
     }
     else
     {
         XtraMessageBox.Show("현시간 이전의 일정을 수정할 수 없습니다", "안내", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
 private void schedulerControl1_AppointmentDrop(object sender, AppointmentDragEventArgs e)
 {
     BeginInvoke(new MethodInvoker(delegate {
         TimeInterval dragAppointmentInterval = new TimeInterval(e.SourceAppointment.Start, e.SourceAppointment.End);
         ReOrderOtherAppointments(e.SourceAppointment.ResourceId, dragAppointmentInterval, e.SourceAppointment);
     }));
 }
예제 #4
0
 private void scheduler_AppointmentDrag(object sender, AppointmentDragEventArgs e)
 {
     if (scheduler.SelectedAppointments.Any(sa => sa.Start < DateTime.Now))
     {
         e.Allow = false;
     }
 }
        private void schedulerControl1_AppointmentDrop(object sender, AppointmentDragEventArgs e)
        {
            TimeSpan     ts                = schedulerControl1.DayView.TimeScale;
            DateTime     currentday        = schedulerControl1.SelectedInterval.Start.Date;
            TimeInterval ti                = new TimeInterval(currentday, currentday.AddHours(24));
            AppointmentBaseCollection apts = schedulerStorage1.GetAppointments(ti);

            for (int i = 0; i < apts.Count; i++)
            {
                if (object.Equals(apts[i], e.SourceAppointment))
                {
                    apts.Remove(apts[i]);
                    break;
                }
            }
            TimeInterval interval = new TimeInterval(e.EditedAppointment.Start, e.EditedAppointment.End);

            schedulerStorage1.BeginUpdate();
            bool snapFlag = false;

            for (int i = 0; i < apts.Count; i++)
            {
                TimeInterval currentInterval = new TimeInterval(apts[i].Start, apts[i].End);
                if (currentInterval.IntersectsWith(interval))
                {
                    SnapAppointments(e.EditedAppointment, apts[i]);
                    snapFlag = true;
                }
            }
            schedulerStorage1.EndUpdate();
            if (snapFlag)
            {
                BeginInvoke(new MethodInvoker(RemoveSelectedAppointment));
            }
        }
예제 #6
0
        private void PostDragDropActions(AppointmentDragEventArgs e)
        {
            if (_draggedTask == null)
            {
                return;
            }

            try
            {
                if (Properties.Settings.Default.Main_MarkActivityCompletedafterDragDrop)
                {
                    //completo l'attività che è stata draggata
                    StartCompleteActivityActions(_draggedTask);
                }



                if (Properties.Settings.Default.Main_RenewActivityAfterDragDrop)
                {
                    //ne creo una nuova a partire da quella
                    StartRenewActivityActions(CreateTask());
                }

                e.Allow = true;
            }
            catch (Exception ex)
            {
                ErrorHandler.Show(ex);
                e.Allow = false;
            }
            finally
            {
                _draggedTask = null;
            }
        }
        private void SchedulerControl_AppointmentDrag(object sender, AppointmentDragEventArgs e)
        {
            // Find a special appointment among visible appointments.
            AppointmentBaseCollection visbileApts = schedulerControl1.ActiveView.GetAppointments();
            Appointment apt = visbileApts.Find(item => (item.Subject == "Finalize" && item.ResourceId.Equals(e.HitResource.Id)));

            if (apt == null)
            {
                e.AdditionalAppointments.Clear();
            }
            else
            {
                if (e.SourceAppointment != apt)
                {
                    // If the dragged appointment overlaps with the special appointment,
                    // add the special appointment to the AdditionalAppointments collection
                    // to drag along with the initial appointment.
                    // The AdditionalAppointmentsDrag event will occur.
                    if (e.EditedAppointment.End > apt.Start)
                    {
                        e.AdditionalAppointments.Add(apt);
                    }
                    else
                    {
                        e.AdditionalAppointments.Clear();
                    }
                }
            }
        }
예제 #8
0
        private void schedulerControl1_AppointmentDrop(object sender, AppointmentDragEventArgs e)
        {
            Result res = new Result();

            object[] OldObj = new object[8];
            OldObj[0] = ProdType;
            OldObj[1] = ProdNo;
            OldObj[2] = Static.ToStr(e.SourceAppointment.ResourceId);
            OldObj[3] = e.SourceAppointment.Description;
            OldObj[4] = e.SourceAppointment.Subject;
            OldObj[5] = e.SourceAppointment.Start;
            OldObj[6] = e.SourceAppointment.End;
            OldObj[7] = e.SourceAppointment.LabelId;

            object[] obj = new object[8];
            obj[0] = ProdType;
            obj[1] = ProdNo;
            obj[2] = Static.ToStr(e.EditedAppointment.ResourceId);
            obj[3] = e.SourceAppointment.Description;
            obj[4] = e.SourceAppointment.Subject;
            obj[5] = e.EditedAppointment.Start;
            obj[6] = e.EditedAppointment.End;
            obj[7] = e.SourceAppointment.LabelId;

            res = _core.RemoteObject.Connection.Call(_core.RemoteObject.User.UserNo, 210, 130124, 130124, new object[] { OldObj, obj });
            if (res.ResultNo != 0)
            {
                MessageBox.Show(res.ResultNo + " : " + res.ResultDesc);
            }
        }
 void AdjustSourceAptStart(AppointmentDragEventArgs e)
 {
     if (e.SourceAppointment.Start.Day != CurrentDate.Day)
     {
         e.SourceAppointment.Start = e.SourceAppointment.End < e.EditedAppointment.End ?
                                     e.SourceAppointment.Start.AddDays(1) : e.SourceAppointment.Start.AddDays(-1);
     }
 }
예제 #10
0
 private void schedulerControlPrenotazioni_AppointmentDrag(object sender, AppointmentDragEventArgs e)
 {
     if (e.SourceAppointment.LabelId == Prenotazione.LabelDisabled)
     {
         e.Handled = true;
         e.Allow   = false;
     }
 }
        void OnSchedulerControlAppointmentDrag(object sender, AppointmentDragEventArgs e)
        {
            Appointment apt = e.EditedAppointment;

            if (apt.Start == DateTime.MinValue)
            {
                apt.Start = e.HitInterval.Start;
            }
        }
        private void SchedulerControl1_AppointmentDrop(object sender, AppointmentDragEventArgs e)
        {
            var app = e.EditedAppointment.Id as MyAppointment;

            if (app != null)
            {
                app.Dropped(e);
            }
        }
 internal void Dropped(AppointmentDragEventArgs e)
 {
     if (Changed != null)
     {
         var app = new AppTimeInformation(e.EditedAppointment);
         app.Allow = e.Allow;
         Changed(app);
         e.Allow = app.Allow;
     }
 }
        void schedulerControl1_AppointmentDrag(object sender, AppointmentDragEventArgs e)
        {
            SchedulerControl scheduler         = (SchedulerControl)sender;
            Appointment      apt               = e.SourceAppointment;
            DateTime         safeIntervalStart = (DateTime)apt.CustomFields["SafeIntervalStartCF"];
            DateTime         safeIntervalEnd   = (DateTime)apt.CustomFields["SafeIntervalEndCF"];

            e.Allow = e.EditedAppointment.Start >= safeIntervalStart && e.EditedAppointment.End <= safeIntervalEnd;
            drag    = true;
        }
예제 #15
0
 private void schedulerControl1_AppointmentDrop(object sender, AppointmentDragEventArgs e)
 {
     if (e.EditedAppointment.IsRecurring)
     {
         e.Allow = DropRecurringAppointment(e.SourceAppointment.RecurrencePattern, e.EditedAppointment.Start);
     }
     else
     {
         e.Allow = DropNormalAppointment(e.EditedAppointment, e.EditedAppointment.Start, e.SourceAppointment.Start);
     }
 }
예제 #16
0
        private void schedulerControl1_AppointmentDrop(object sender, AppointmentDragEventArgs e)
        {
            if (_draggedTask == null)
            {
                e.Handled = true;
                return;
            }



            PostDragDropActions(e);

            e.Handled = true;
        }
        void OnSchedulerControlAppointmentDrop(object sender, AppointmentDragEventArgs e)
        {
            string createEventMsg = "Creating an event at {0} on {1}.";
            string moveEventMsg   = "Moving the event from {0} on {1} to {2} on {3}.";

            DateTime srcStart = e.SourceAppointment.Start;
            DateTime newStart = e.EditedAppointment.Start;

            string msg = (srcStart == DateTime.MinValue) ? String.Format(createEventMsg, newStart.ToShortTimeString(), newStart.ToShortDateString()) :
                         String.Format(moveEventMsg, srcStart.ToShortTimeString(), srcStart.ToShortDateString(), newStart.ToShortTimeString(), newStart.ToShortDateString());

            if (XtraMessageBox.Show(msg + "\r\nProceed?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                e.Allow = false;
            }
        }
예제 #18
0
    void OnDragDrop(AppointmentDragEventArgs e)
    {
        if (dragInfo == null)
        {
            return;
        }
        if (dragInfo.Appointment == null)
        {
            e.EditedAppointment.Start = GetCurrentDateTime() + dragInfo.InitialInterval.Start.TimeOfDay - dragInfo.TimeAtCursor;
        }
        else
        {
            e.EditedAppointment.Start = GetCurrentDateTime() + e.SourceAppointment.Start.TimeOfDay - dragInfo.TimeAtCursor;
        }

        newAppointmentDate = e.EditedAppointment.Start;
    }
예제 #19
0
        void scheduler_AppointmentDrop(object sender, AppointmentDragEventArgs e)
        {
            string createEventMsg = "Creating an event at {0} on {1}.";
            string moveEventMsg   = "Moving the event from {0} on {1} to {2} on {3}.";

            DateTime srcStart = e.SourceAppointment.Start;
            DateTime newStart = e.EditedAppointment.Start;

            string msg = (srcStart == DateTime.MinValue) ? String.Format(createEventMsg, newStart.ToShortTimeString(), newStart.ToShortDateString()) :
                         String.Format(moveEventMsg, srcStart.ToShortTimeString(), srcStart.ToShortDateString(), newStart.ToShortTimeString(), newStart.ToShortDateString());

            if (DXMessageBox.Show(msg + "\r\nProceed?", "Demo", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
            {
                e.Allow = false;
            }

            scheduler.Focus();
        }
예제 #20
0
        void CorrectAppointmentParameters(AppointmentDragEventArgs e)
        {
            TimeSpan customScaleDuration = (maxTime - minTime).Add(TimeSpan.FromHours(2));
            DateTime initialStart        = e.EditedAppointment.Start;

            if (e.EditedAppointment.Start.TimeOfDay < minTime || e.EditedAppointment.Start.TimeOfDay >= maxTime)
            {
                bool durationMustBeIncreased = e.EditedAppointment.Duration > customScaleDuration;
                e.EditedAppointment.Start = durationMustBeIncreased ? e.EditedAppointment.Start + customScaleDuration : e.EditedAppointment.Start - customScaleDuration;

                TimeInterval appInterval = new TimeInterval(e.EditedAppointment.Start, e.EditedAppointment.Start + e.EditedAppointment.Duration + customScaleDuration);
                if (!appInterval.Contains(e.HitInterval))
                {
                    durationMustBeIncreased   = !durationMustBeIncreased;
                    e.EditedAppointment.Start = durationMustBeIncreased ? initialStart + customScaleDuration : initialStart - customScaleDuration;
                }
            }

            if (e.EditedAppointment.End.TimeOfDay >= maxTime || e.EditedAppointment.End.TimeOfDay < minTime)
            {
                e.EditedAppointment.End = e.EditedAppointment.Duration > customScaleDuration ? e.EditedAppointment.End - customScaleDuration : e.EditedAppointment.End + customScaleDuration;
            }
        }
예제 #21
0
 //public async Task OnAppointmentDropAsync(AppointmentDragEventArgs e)
 public void OnAppointmentDrop(object sender, AppointmentDragEventArgs e)
 {
     SaveAppointmentEntity(e.EditedAppointment);
 }
예제 #22
0
        private void schedulerControl1_AppointmentDrop(object sender, AppointmentDragEventArgs e)
        {
            string createEventMsg = "Crear el evento a las {0} el dia {1}.";
            string moveEventMsg   = "Mover el evento desde {0} el dia {1} a las {2} el dia {3}.";

            bool Crear = false;
            bool Mover = false;


            DateTime srcStart = e.SourceAppointment.Start;
            DateTime newStart = e.EditedAppointment.Start;

            string msg = (srcStart == DateTime.MinValue) ? String.Format(createEventMsg, newStart.ToShortTimeString(), newStart.ToShortDateString()) :
                         String.Format(moveEventMsg, srcStart.ToShortTimeString(), srcStart.ToShortDateString(), newStart.ToShortTimeString(), newStart.ToShortDateString());


            if (msg.Contains("Crear"))
            {
                Crear = true;
            }

            if (msg.Contains("Mover"))
            {
                Mover = true;
            }

            clsVisita visita = new clsVisita();

            if (Mover)
            {
                if (!PermitirModificarVisita(e.SourceAppointment))
                {
                    e.Allow   = false;
                    e.Handled = true;
                    return;
                }
            }


            if (XtraMessageBox.Show(msg + "\r\nProceder?", "Mi Calendario", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                e.Allow   = false;
                e.Handled = true;
                return;
            }



            if (Convert.ToInt64(e.SourceAppointment.CustomFields["IdVisita"]) > 0)
            {
                if (Mover)
                {
                    visita =
                        LogicaNegocios.Calendarios.clsCalendarios.ObtenerVisitaPorId(
                            Convert.ToInt64(e.SourceAppointment.CustomFields["IdVisita"]));
                }

                //visita.Id = Convert.ToInt64(e.SourceAppointment.CustomFields["IdVisita"]);
                //visita.Asunto = e.SourceAppointment.Subject;
                //visita.Descripcion = e.SourceAppointment.Description;
                //visita.Ubicacion = e.SourceAppointment.Location;
                visita.FechaHoraComienzo = e.EditedAppointment.Start;
                visita.FechaHoraTermino  = e.EditedAppointment.End;
            }
            else
            {
                visita.Id                = Convert.ToInt64(e.SourceAppointment.CustomFields["IdVisita"]);
                visita.Asunto            = e.SourceAppointment.Subject;
                visita.Descripcion       = e.SourceAppointment.Description;
                visita.Ubicacion         = e.SourceAppointment.Location;
                visita.FechaHoraComienzo = e.EditedAppointment.Start;
                visita.FechaHoraTermino  = e.EditedAppointment.End;
            }

            if (Crear)
            {
                visita.Cliente  = LogicaNegocios.Clientes.clsClientesMaster.ObtenerClienteMasterPorId(IdClienteDraw);
                visita.EstadoBD = Entidades.Enums.Enums.VisitaEstado.Incompleta;

                if (visita.Cliente.Tipo == Enums.TipoPersona.Cuenta)
                {
                    ResultadoTransaccion resCuenta = LogicaNegocios.Clientes.clsCuentas.ObtenerCuentaPorIdMaster(visita.Cliente.Id);
                    clsCuenta            cuenta    = new clsCuenta();
                    if (resCuenta.Estado == Enums.EstadoTransaccion.Aceptada)
                    {
                        cuenta = (clsCuenta)resCuenta.ObjetoTransaccion;
                    }

                    if (cuenta != null)
                    {
                        visita.Vendedor = cuenta.VendedorAsignado;
                    }
                }
                else if (visita.Cliente.Tipo == Enums.TipoPersona.Target)
                {
                    ResultadoTransaccion resCuenta =
                        LogicaNegocios.Clientes.clsTarget.ObtenerTargetPorIdMaster(visita.Cliente.Id);

                    clsTarget target = new clsTarget();
                    if (resCuenta.Estado == Enums.EstadoTransaccion.Aceptada)
                    {
                        target = (clsTarget)resCuenta.ObjetoTransaccion;
                    }

                    if (target != null)
                    {
                        visita.Vendedor = target.VendedorAsignado;
                    }
                }


                clsVisitaAsistente asistente = new clsVisitaAsistente();
                asistente.Usuario       = Base.Usuario.UsuarioConectado.Usuario;
                asistente.TipoAsistente = Entidades.Enums.Enums.VisitaTipoAsistente.Usuario;
                visita.Asistentes.Add(asistente);

                clsParametrosInfo paraminfo = LogicaNegocios.Parametros.clsParametros.ListarParametrosPorTipo(Entidades.Enums.Enums.TipoParametro.ImportanciaVisita);
                visita.NivelImportancia = paraminfo.Items[0];  // Entidades.Enums.Enums.VisitaNivelImportancia.Baja;
            }


            //visita.Vendedor = Base.Usuario.UsuarioConectado.Usuario;

            visita.UsuarioOrganizador = Base.Usuario.UsuarioConectado.Usuario;
            Entidades.GlobalObject.ResultadoTransaccion res = LogicaNegocios.Calendarios.clsCalendarios.GuardarVisita(visita);

            if (res.Estado == Entidades.Enums.Enums.EstadoTransaccion.Aceptada)
            {
            }
            else
            {
                MessageBox.Show(res.Descripcion, "Calendario", MessageBoxButtons.OK, MessageBoxIcon.Error);
                e.Allow   = false;
                e.Handled = true;
                return;
            }

            PopupClientes.Visible = false;

            //if(schedulerStorage1.Appointments.IsNewAppointment(e.EditedAppointment))
            //{
            //    schedulerStorage1.Appointments.Add(e.EditedAppointment);
            //}

            //SincronizarOutlook();
        }
예제 #23
0
 void AppointmentDropHandler(object sender, AppointmentDragEventArgs e)
 {
     OnDragDrop(e);
     dragInfo = null;
 }
예제 #24
0
 void AppointmentDragHandler(object sender, AppointmentDragEventArgs e)
 {
     CreateAppoointmentDragInfo();
     OnDragDrop(e);
 }
 void OnDragDrop(AppointmentDragEventArgs e)
 {
     e.EditedAppointment.Start = e.SourceAppointment.Start + CurrentTimeStamp - dragInfo.TimeAtCursor;
 }
 private void schedulerControl1_AppointmentDrag(object sender, AppointmentDragEventArgs e)
 {
 }
 protected virtual void AppointmentDragHandler(object sender, AppointmentDragEventArgs e)
 {
     AdjustSourceAptStart(e);
     OnDragDrop(e);
 }
 protected virtual void AppointmentDropHandler(object sender, AppointmentDragEventArgs e)
 {
     OnDragDrop(e);
 }
예제 #29
0
파일: fLichSX.cs 프로젝트: trancongvy/CBAPV
 private void Schedu_AppointmentDrag(object sender, AppointmentDragEventArgs e)
 {
     Changed = true;
     // throw new NotImplementedException();
 }
예제 #30
0
        private void schedulerControl1_AppointmentDrop(object sender, AppointmentDragEventArgs e)
        {
            string createEventMsg = "Crear el evento a las {0} el dia {1}.";
            string moveEventMsg = "Mover el evento desde {0} el dia {1} a las {2} el dia {3}.";

            bool Crear = false;
            bool Mover = false;

            DateTime srcStart = e.SourceAppointment.Start;
            DateTime newStart = e.EditedAppointment.Start;

            string msg = (srcStart == DateTime.MinValue) ? String.Format(createEventMsg, newStart.ToShortTimeString(), newStart.ToShortDateString()) :
                String.Format(moveEventMsg, srcStart.ToShortTimeString(), srcStart.ToShortDateString(), newStart.ToShortTimeString(), newStart.ToShortDateString());

            if (msg.Contains("Crear"))
                Crear = true;

            if (msg.Contains("Mover"))
                Mover = true;

            clsVisita visita = new clsVisita();

            if (Mover) {
                if (!PermitirModificarVisita(e.SourceAppointment)) {
                    e.Allow = false;
                    e.Handled = true;
                    return;
                }
            }

            if (XtraMessageBox.Show(msg + "\r\nProceder?", "Mi Calendario", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) {
                e.Allow = false;
                e.Handled = true;
                return;
            }

            if (Convert.ToInt64(e.SourceAppointment.CustomFields["IdVisita"]) > 0) {
                if (Mover) {
                    visita =
                        LogicaNegocios.Calendarios.clsCalendarios.ObtenerVisitaPorId(
                            Convert.ToInt64(e.SourceAppointment.CustomFields["IdVisita"]));

                }

                //visita.Id = Convert.ToInt64(e.SourceAppointment.CustomFields["IdVisita"]);
                //visita.Asunto = e.SourceAppointment.Subject;
                //visita.Descripcion = e.SourceAppointment.Description;
                //visita.Ubicacion = e.SourceAppointment.Location;
                visita.FechaHoraComienzo = e.EditedAppointment.Start;
                visita.FechaHoraTermino = e.EditedAppointment.End;
            } else {
                visita.Id = Convert.ToInt64(e.SourceAppointment.CustomFields["IdVisita"]);
                visita.Asunto = e.SourceAppointment.Subject;
                visita.Descripcion = e.SourceAppointment.Description;
                visita.Ubicacion = e.SourceAppointment.Location;
                visita.FechaHoraComienzo = e.EditedAppointment.Start;
                visita.FechaHoraTermino = e.EditedAppointment.End;
            }

            if (Crear) {
                visita.Cliente = LogicaNegocios.Clientes.clsClientesMaster.ObtenerClienteMasterPorId(IdClienteDraw);
                visita.EstadoBD = Entidades.Enums.Enums.VisitaEstado.Incompleta;

                if (visita.Cliente.Tipo == Enums.TipoPersona.Cuenta) {
                    ResultadoTransaccion resCuenta = LogicaNegocios.Clientes.clsCuentas.ObtenerCuentaPorIdMaster(visita.Cliente.Id);
                    clsCuenta cuenta = new clsCuenta();
                    if (resCuenta.Estado == Enums.EstadoTransaccion.Aceptada)
                        cuenta = (clsCuenta)resCuenta.ObjetoTransaccion;

                    if (cuenta != null)
                        visita.Vendedor = cuenta.VendedorAsignado;
                } else if (visita.Cliente.Tipo == Enums.TipoPersona.Target) {
                    ResultadoTransaccion resCuenta =
                        LogicaNegocios.Clientes.clsTarget.ObtenerTargetPorIdMaster(visita.Cliente.Id);

                    clsTarget target = new clsTarget();
                    if (resCuenta.Estado == Enums.EstadoTransaccion.Aceptada)
                        target = (clsTarget)resCuenta.ObjetoTransaccion;

                    if (target != null)
                        visita.Vendedor = target.VendedorAsignado;
                }

                clsVisitaAsistente asistente = new clsVisitaAsistente();
                asistente.Usuario = Base.Usuario.UsuarioConectado.Usuario;
                asistente.TipoAsistente = Entidades.Enums.Enums.VisitaTipoAsistente.Usuario;
                visita.Asistentes.Add(asistente);

                clsParametrosInfo paraminfo = LogicaNegocios.Parametros.clsParametros.ListarParametrosPorTipo(Entidades.Enums.Enums.TipoParametro.ImportanciaVisita);
                visita.NivelImportancia = paraminfo.Items[0];  // Entidades.Enums.Enums.VisitaNivelImportancia.Baja;
            }

            //visita.Vendedor = Base.Usuario.UsuarioConectado.Usuario;

            visita.UsuarioOrganizador = Base.Usuario.UsuarioConectado.Usuario;
            Entidades.GlobalObject.ResultadoTransaccion res = LogicaNegocios.Calendarios.clsCalendarios.GuardarVisita(visita);

            if (res.Estado == Entidades.Enums.Enums.EstadoTransaccion.Aceptada) {

            } else {

                MessageBox.Show(res.Descripcion, "Calendario", MessageBoxButtons.OK, MessageBoxIcon.Error);
                e.Allow = false;
                e.Handled = true;
                return;
            }

            PopupClientes.Visible = false;

            //if(schedulerStorage1.Appointments.IsNewAppointment(e.EditedAppointment))
            //{
            //    schedulerStorage1.Appointments.Add(e.EditedAppointment);
            //}

            //SincronizarOutlook();
        }
예제 #31
0
 private void SchedulerMain_AppointmentDrop(object sender, AppointmentDragEventArgs e)
 {
     try
     {
         if (e.EditedAppointment.ResourceId is EmptyResource || Convert.ToInt32(e.EditedAppointment.ResourceId) <= 0)
         {
             TwinkleMessageBox.ShowError("Заяка не будет назначена: выбран пустой ресурс(ТС)");
             e.Allow = false;
             return;
         }
         var start = e.SourceAppointment.Start;
         if (start <= DateTime.Now)
         {
             TwinkleMessageBox.ShowError("Заяка не будет назначена: невозможно назначить заяку на прошедшее время");
             e.Allow = false;
             return;
         }
         var end       = e.SourceAppointment.End;
         var vehicleId = Convert.ToInt32(e.EditedAppointment.ResourceId);
         if (CheckIfResourceIsBusy(vehicleId, start, end))
         {
             TwinkleMessageBox.ShowError("Заяка не будет назначена: выбранный ресурс(ТС) занят");
             e.Allow = false;
             return;
         }
         var sourceDealId = e.SourceAppointment.Id;
         if (sourceDealId == null)
         {
             var dealId = e.SourceAppointment.CustomFields["Id"];
             _model.AssignAppointment((int)dealId, vehicleId);
             //-->
             //using (var db = new TwinkleDbContext())
             //{
             //    deal = await db.Deals.FindAsync(dealId);
             //    deal.VehicleId = vehicleId;
             //    await db.SaveChangesAsync();
             //}
             //<--
         }
         else
         {
             var dealId = sourceDealId;
             _model.AssignAppointment((int)dealId, vehicleId);
             //-->
             //using (var db = new TwinkleDbContext())
             //{
             //    deal = await db.Deals.FindAsync(dealId);
             //    deal.VehicleId = vehicleId;
             //    await db.SaveChangesAsync();
             //}
             //<--
         }
         e.Allow = true;
         schedulerMain.BeginUpdate();
         schedulerMain.GoToDate(start.Date.AddHours(schedulerMain.Start.Hour));
         //RefreshAppointments();
         schedulerMain.EndUpdate();
     }
     catch (Exception ex)
     {
         TwinkleMessageBox.ShowError($"Заявка не назначена: {ex.Message}");
         e.Allow = false;
     }
 }
예제 #32
0
 private void schRezervasyon_AppointmentDrop(object sender, AppointmentDragEventArgs e)
 {
 }