void OnCustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e)
        {
            Model.Appointment obj = e.Value as Model.Appointment;

            if (obj == null)
            {
                return;
            }

            if (e.IsGetData)
            {
                e.Value = obj.CompletionStatus >= 0 ? false : true;
            }
            else if (e.IsSetData)
            {
                if (e.Value != null && e.Value is bool)
                {
                    if ((bool)e.Value)
                    {
                        obj.CompletionStatus = (int)Model.Appointment.CompletionCode.Completed;
                    }
                    else
                    {
                        obj.CompletionStatus = (int)Model.Appointment.CompletionCode.NotStarted;
                    }
                }
            }
        }
Exemple #2
0
        public string InsertAppointment(Model.Appointment appointment)
        {
            try
            {
                appointment.StartTime = this.ConvertTimeZone(appointment.StartTime);
                appointment.EndTime   = this.ConvertTimeZone(appointment.EndTime);
                using (BMAContext context = new BMAContext())
                {
                    var validAppointment = context.Appointments.Any(x => x.Employee_ID == appointment.Employee_ID && (x.StartTime >= appointment.StartTime && x.StartTime <= appointment.EndTime || x.EndTime >= appointment.StartTime && x.EndTime <= appointment.EndTime));

                    if (validAppointment)
                    {
                        return("Appointment already booked for these dates");
                    }

                    context.Appointments.Add(new Appointment
                    {
                        Employee_ID = appointment.Employee_ID,
                        Company_ID  = appointment.Company_ID,
                        StartTime   = appointment.StartTime,
                        EndTime     = appointment.EndTime,
                        Info        = appointment.Info
                    });
                    context.SaveChanges();
                }
                return(string.Empty);
            }
            catch (Exception ex)
            {
                return("error: " + ex.Message);
            }
        }
        private Model.Appointment ConvertAppointment(Appointment a)
        {
            if (a == null)
            {
                return(null);
            }
            var res = new Model.Appointment()
            {
                UniqueId          = a.Id.UniqueId,
                CanModify         = a.EffectiveRights.HasFlag(EffectiveRights.Modify) && (settings.ModifyEnabledCategories.Length == 0 || settings.ModifyEnabledCategories.Any(a.Categories.Contains)),
                CanDelete         = a.EffectiveRights.HasFlag(EffectiveRights.Delete) && (settings.DeleteEnabledCategories.Length == 0 || settings.DeleteEnabledCategories.Any(a.Categories.Contains)),
                Start             = a.Start,
                End               = a.End,
                IsAllDayEvent     = a.IsAllDayEvent,
                IsBusy            = a.LegacyFreeBusyStatus == LegacyFreeBusyStatus.Busy,
                Subject           = a.Subject,
                Body              = a.Body,
                Organizer         = ConvertEMailAddressToMailbox(a.Organizer, a.Service),
                RequiredAttendees = a.RequiredAttendees.Select(ra => ConvertEMailAddressToMailbox(ra, a.Service)).ToArray(), //ra => new Model.Mailbox() { EMail = ra.Address, Name = ra.Name }).ToArray(),
                OptionalAttendees = a.OptionalAttendees.Select(oa => ConvertEMailAddressToMailbox(oa, a.Service)).ToArray(), //ra => new Model.Mailbox() { EMail = ra.Address, Name = ra.Name }).ToArray(),
                Categories        = a.Categories.ToArray()
            };

            return(res);
        }
        private void OnAppointmentsChanged(object sender, PersistentObjectsEventArgs e)
        {
            using (new WaitCursor()) {
                bool bRefreshScheduler = false;

                Model.Service service = new Model.Service(Program.Service);

                foreach (Appointment apt in e.Objects)
                {
                    Model.Appointment obj = apt.GetSourceObject((SchedulerStorage)sender) as Model.Appointment;

                    if (obj != null)
                    {
                        Model.Appointment utc = obj.Clone(DateTimeKind.Utc);

                        service.AttachTo("Appointments", utc);
                        service.UpdateObject(utc);

                        if (!bRefreshScheduler)
                        {
                            if (Filter.Current.User != null && (!obj.AssignedTo.HasValue || obj.AssignedTo.Value != Filter.Current.User.ID))
                            {
                                bRefreshScheduler = true;
                            }
                        }
                    }
                }

                try {
                    service.SaveChanges(System.Data.Services.Client.SaveChangesOptions.Batch);
                } catch (DataServiceRequestException error) {
                    if (error.InnerException is DataServiceClientException &&
                        ((DataServiceClientException)error.InnerException).StatusCode == 404)
                    {
                        return;
                    }

                    if (error.Response.BatchStatusCode == 404)
                    {
                        return;
                    }

#if DEBUG
                    Debugger.Break();
#endif
                    throw;
                }

                gridControl.RefreshDataSource();

                if (bRefreshScheduler)
                {
                    isDirty = true;
                    schedulerControl.RefreshData();
                }
            }
        }
        void OnAppointmentsDeleting(object sender, PersistentObjectCancelEventArgs e)
        {
            using (new WaitCursor()) {
                Model.Appointment obj
                    = e.Object.GetSourceObject((SchedulerStorage)sender) as Model.Appointment;

                Delete(obj);
            }
        }
        void DeleteSelection()
        {
            bool bHasArchivShift = HasArchiveShift();
            bool bStop           = false;

            int[] rSelection = gridView.GetSelectedRows();

            foreach (int rowHandle in rSelection)
            {
                if (bStop)
                {
                    break;
                }

                Model.Appointment obj = gridView.GetRow(rowHandle) as Model.Appointment;

                if (obj == null)
                {
                    continue;
                }

                List <Model.Appointment> deleted = new List <Model.Appointment>();

                if (!bHasArchivShift)
                {
                    switch (MessageBox.Show(string.Format("Delete \"{0}\"?", obj.Subject), "Confirm",

                                            rSelection.Length > 1 ? MessageBoxButtons.YesNoCancel : MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                    {
                    case DialogResult.Yes:
                        Delete(obj);
                        break;

                    case DialogResult.No:
                        break;

                    default:
                        bStop = true;
                        break;
                    }
                }
                else
                {
                    deleted.Add(obj);
                }

                foreach (Model.Appointment mm in deleted)
                {
                    if (bHasArchivShift)
                    {
                        Delete(obj);
                    }
                }
            }

            schedulerStorage.RefreshData();
        }
Exemple #7
0
 private IEither <IEnumerable <ICommandError>, Agent> CreateOrUpdateAppointment(
     Guid customerId,
     Model.Appointment appointment)
 {
     return(this.CommandProcessor.Process(
                new Business.Agent.Commands.AppointmentUpdateCommand
     {
         CustomerId = customerId,
         Data = appointment
     }));
 }
 public ActionResult PutAppointment(string mailName, [FromBody] Model.Appointment appointment)
 {
     if (appointment == null)
     {
         return(BadRequest("No (valid) appointment was put"));
     }
     if (String.IsNullOrEmpty(appointment.UniqueId))
     {
         return(BadRequest("Existing appointment must have an id - use POST to add new appointments"));
     }
     return(StatusCode(501, "Appointment update with PUT yet not implemented"));
 }
        void Delete(Model.Appointment obj)
        {
            if (obj == null)
            {
                return;
            }

            BindingList <Model.Appointment> appointmentDataSource
                = schedulerStorage.Appointments.DataSource as BindingList <Model.Appointment>;

            if (appointmentDataSource != null)
            {
                appointmentDataSource.Remove(obj);
            }

            BindingList <Model.Appointment> taskDataSource
                = gridControl.DataSource as BindingList <Model.Appointment>;

            if (taskDataSource != null)
            {
                taskDataSource.Remove(obj);
            }


            Model.Service service = new Model.Service(Program.Service);

            try {
                Model.Appointment utc = obj.Clone(DateTimeKind.Utc);

                service.AttachTo("Appointments", utc);
                service.DeleteObject(utc);

                service.SaveChanges();
            } catch (DataServiceRequestException e) {
                if (e.InnerException is DataServiceClientException &&
                    ((DataServiceClientException)e.InnerException).StatusCode == 404)
                {
                    return;
                }

                if (e.Response.BatchStatusCode == 404)
                {
                    return;
                }

#if DEBUG
                Debugger.Break();
#endif
                throw;
            }
        }
        private Appointment ConvertAppointment(Model.Appointment appointment, ExchangeService service)
        {
            var a = new Appointment(service);

            a.Start                = appointment.Start;
            a.End                  = appointment.End;
            a.IsAllDayEvent        = appointment.IsAllDayEvent;
            a.LegacyFreeBusyStatus = appointment.IsBusy ? LegacyFreeBusyStatus.Busy : LegacyFreeBusyStatus.Free;
            a.Subject              = appointment.Subject;
            a.Body                 = appointment.Body;
            a.IsReminderSet        = false;
            a.Categories           = new StringList(appointment.Categories ?? new string[0]);
            return(a);
        }
Exemple #11
0
        public async Task <int> UpdateScript(Model.Appointment appointment, string Notes)
        {
            var reschDate    = appointment.ReScheduleDate.HasValue ? appointment.ReScheduleDate.Value.ToShortDateString() : string.Empty;
            var timeLimit    = appointment.ShippingTimeLimit.HasValue ? appointment.ShippingTimeLimit.Value.ToShortTimeString() : string.Empty;
            var shippingTime = appointment.ShippingTime.Value.ToString("yyyy-MM-dd HH:mm:ss.fff");
            var script       = @"UPDATE dbo.Appointments SET AppointmentNo = {0}, 
                        ShippTime = CAST({1} AS DATETIME), 
                        ShippingTimeLimit = {2}, 
                        DeliveryTypeId = {3}, 
                        Pallets = {6}, 
                        TruckNo = {7}, 
                        DriverNo = {8} 
                        WHERE CustomerId = {4} 
                            AND PickTicket = {5} 
                            AND Posted = 0";

            var scriptOrder = @"UPDATE dbo.OrderAppointment SET ShipFor = CAST({0} AS DATETIME), Notes = {3} WHERE CustomerId = {1} AND PickTicketId = {2} ";

            try
            {
                if (context.Database.Connection.ConnectionString.ToLower().Contains("diavolo"))
                {
                    script      = "SET LANGUAGE us_english; " + script;
                    scriptOrder = "SET LANGUAGE us_english; " + scriptOrder;
                }

                script = string.Format(script,
                                       $"'{appointment.AppointmentNumber}'",
                                       $"'{shippingTime}'",
                                       string.IsNullOrEmpty(timeLimit) ? "NULL" : $"'{timeLimit}'",
                                       $"{appointment.DeliveryTypeId}",
                                       $"'{appointment.CustomerId}'", $"'{appointment.PickTicket}'",
                                       appointment.Pallets.HasValue ? $"{appointment.Pallets.Value}" : "NULL",
                                       appointment.TruckId.HasValue ? $"{appointment.TruckId.Value}": "NULL",
                                       appointment.DriverId.HasValue ? $"{appointment.DriverId.Value}" : "NULL");

                scriptOrder = string.Format(scriptOrder, $"'{shippingTime}'", $"'{appointment.CustomerId}'", $"'{appointment.PickTicket}'", $"'{Notes}'");

                var result = await context.Database.ExecuteSqlCommandAsync(script);

                result = await context.Database.ExecuteSqlCommandAsync(scriptOrder);
            }
            catch (Exception exc)
            {
                throw exc;
            }
            return(0);
        }
        public async Task UpdateAppointment(Model.Appointment appointment)
        {
            try
            {
                var entity = context.Appointments.Where(x => x.AppointmentNumber == appointment.AppointmentNumber && x.CustomerId == appointment.CustomerId && x.PickTicketId == appointment.PickTicket).FirstOrDefault();

                if (entity != null)
                {
                    if (appointment.Posted.HasValue)
                    {
                        entity.Posted = appointment.Posted.Value;
                    }
                    if (!string.IsNullOrEmpty(appointment.Status))
                    {
                        entity.Status = appointment.Status;
                    }

                    //if (!string.IsNullOrEmpty(appointment.AppointmentNumber))
                    //{
                    //    entity.AppointmentNumber = appointment.AppointmentNumber;
                    //}
                    if (!string.IsNullOrEmpty(appointment.ScacCode))
                    {
                        entity.ScacCode = appointment.ScacCode;
                    }
                    if (appointment.ShippingDate.HasValue)
                    {
                        var order = context.OrderAppointments.Where(x => x.CustomerId == appointment.CustomerId && x.PickTicketId == appointment.PickTicket).FirstOrDefault();

                        order.ShipFor = appointment.ShippingDate.Value;
                    }
                    if (appointment.ShippingTime.HasValue)
                    {
                        entity.ShipTime = appointment.ShippingTime.Value;
                    }


                    await context.SaveChangesAsync();
                }
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }
        private void OnRowUpdated(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e)
        {
            using (new WaitCursor()) {
                Model.Service service = new Model.Service(Program.Service);

                Model.Appointment obj = e.Row as Model.Appointment;

                if (obj != null)
                {
                    if (obj.Resource != null)
                    {
                        obj.AssignedTo = obj.Resource.ID;
                        obj.Resource   = null;
                    }

                    if (obj.ID != Guid.Empty)
                    {
                        Model.Appointment utc = obj.Clone(DateTimeKind.Utc);

                        service.AttachTo("Appointments", utc);
                        service.UpdateObject(utc);
                    }
                    else
                    {
                        obj.ID = Guid.NewGuid();

                        if (!obj.AssignedTo.HasValue && Filter.Current.User != null)
                        {
                            obj.AssignedTo = Filter.Current.User.ID;
                        }

                        Model.Appointment utc = obj.Clone(DateTimeKind.Utc);

                        service.AddToAppointments(utc);
                    }
                }

                schedulerStorage.RefreshData();

                service.SaveChanges(System.Data.Services.Client.SaveChangesOptions.Batch);
            }
        }
        private void OnInitNewRow(object sender, DevExpress.XtraGrid.Views.Grid.InitNewRowEventArgs e)
        {
            /*
             * This event is called by the Grid when a new item is create using the new item row.
             * Here we want to assign default values to our items.
             */

            DevExpress.XtraGrid.Views.Grid.GridView view = sender as GridView;

            Model.Appointment appointment
                = view.GetRow(e.RowHandle) as Model.Appointment;

            if (appointment != null)
            {
                appointment.Start    = DateTime.Today;
                appointment.Finish   = DateTime.Today;
                appointment.IsAllDay = true;
                appointment.ItemType = (int)Model.Appointment.ItemCode.Task;
            }
        }
Exemple #15
0
        public void AddApointment(int PacienteID, string Name, string Description, DateTime startingD, DateTime endingD)
        {
            Model.Appointment newAppointment = new Model.Appointment();

            if (PacienteID == -1)
            {
                newAppointment.PatientID = null;
            }
            else
            {
                newAppointment.PatientID = PacienteID;
            }

            newAppointment.PersonName  = Name;
            newAppointment.Description = Description;
            newAppointment.TimeStart   = startingD;
            newAppointment.TimeEnd     = endingD;

            context.Appointment.Add(newAppointment);
            context.SaveChanges();
        }
Exemple #16
0
        public async Task <int> Create(Model.Appointment appointmentModel)
        {
            Entities.Appointment appointment = new Entities.Appointment();
            appointment.CustomerId   = appointmentModel.CustomerId;
            appointment.DateAdd      = DateTime.Now;
            appointment.PickTicketId = appointmentModel.PickTicket;
            appointment.DivisionId   = appointmentModel.DivisionId;

            appointment.ScacCode          = appointmentModel.ScacCode;
            appointment.ShipDate          = appointmentModel.ShippingDate.Value;
            appointment.ShipTime          = new DateTime(appointmentModel.ShippingDate.Value.Year, appointmentModel.ShippingDate.Value.Month, appointmentModel.ShippingDate.Value.Day, appointmentModel.ShippingTime.Value.Hour, appointmentModel.ShippingTime.Value.Minute, 0);
            appointment.AppointmentNumber = appointmentModel.AppointmentNumber;
            appointment.DeliveryTypeId    = appointmentModel.DeliveryTypeId.Value;
            appointment.UserName          = appointmentModel.UserName;

            if (appointmentModel.ShippingTimeLimit.HasValue)
            {
                appointment.ShippingTimeLimit = new DateTime(appointmentModel.ShippingDate.Value.Year, appointmentModel.ShippingDate.Value.Month, appointmentModel.ShippingDate.Value.Day, appointmentModel.ShippingTimeLimit.Value.Hour, appointmentModel.ShippingTimeLimit.Value.Minute, 0);
            }

            appointment.PtBulk = string.Empty;
            if (!string.IsNullOrEmpty(appointmentModel.PtBulk))
            {
                appointment.PtBulk       = appointmentModel.PtBulk;
                appointment.PickTicketId = appointmentModel.PtBulk;
            }

            context.Appointments.Add(appointment);

            try
            {
                return(await context.SaveChangesAsync());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #17
0
        public string UpdateAppointment(Model.Appointment appointment)
        {
            try
            {
                using (BMAContext context = new BMAContext())
                {
                    appointment.StartTime = this.ConvertTimeZone(appointment.StartTime);
                    appointment.EndTime   = this.ConvertTimeZone(appointment.EndTime);

                    var validAppointment = context.Appointments.Any(x => x.Employee_ID == appointment.Employee_ID && (x.StartTime >= appointment.StartTime && x.StartTime <= appointment.EndTime || x.EndTime >= appointment.StartTime && x.EndTime <= appointment.EndTime) && x.Appointment_ID != appointment.Appointment_ID);

                    if (validAppointment)
                    {
                        return("Appointment already booked for these times");
                    }

                    var updateAppointment = context.Appointments.Where(a => a.Appointment_ID == appointment.Appointment_ID).FirstOrDefault();

                    if (updateAppointment != null)
                    {
                        updateAppointment.Employee_ID = appointment.Employee_ID;
                        updateAppointment.Company_ID  = appointment.Company_ID;
                        updateAppointment.StartTime   = appointment.StartTime;
                        updateAppointment.EndTime     = appointment.EndTime;
                        updateAppointment.Info        = appointment.Info;
                    }

                    context.SaveChanges();
                }
                return(string.Empty);
            }
            catch (Exception ex)
            {
                return("error: " + ex.Message);
            }
        }
        public ActionResult PostAppointment(string mailName, [FromBody] Model.Appointment appointment)
        {
            if (appointment == null)
            {
                return(BadRequest("No (valid) appointment was posted"));
            }
            if (!String.IsNullOrEmpty(appointment.UniqueId))
            {
                return(BadRequest("New appointment cannot have an id - use PUT to update existing appointments"));
            }
            string       email;
            ActionResult errorResult;
            var          service = GetService(mailName, out email, out errorResult);

            if (service == null)
            {
                return(errorResult);
            }
            var folder = Folder.Bind(
                service,
                new FolderId(WellKnownFolderName.Calendar, new Mailbox(email)),
                new PropertySet(BasePropertySet.FirstClassProperties));

            if (!folder.EffectiveRights.HasFlag(EffectiveRights.CreateContents))
            {
                return(StatusCode(403, $"{System.Security.Principal.WindowsIdentity.GetCurrent().Name} has no create rights in the calendar of {email}"));
            }
            if (settings.CreateEnabledCategories.Any() && !settings.CreateEnabledCategories.Any(appointment.Categories.Contains))
            {
                return(StatusCode(403, "Create denied on category"));
            }
            var a = ConvertAppointment(appointment, service);

            a.Save(folder.Id, SendInvitationsMode.SendToNone);
            return(Ok(ConvertAppointment(service, a.Id.UniqueId)));
        }
Exemple #19
0
        public async Task <string> Update(Model.Appointment appointment)
        {
            try
            {
                var entity = context.Appointments.Where(x => x.CustomerId == appointment.CustomerId && x.PickTicketId == appointment.PickTicket).FirstOrDefault();

                if (entity != null)
                {
                    if (appointment.Posted.HasValue)
                    {
                        entity.Posted = appointment.Posted.Value;
                    }
                    if (!string.IsNullOrEmpty(appointment.Status))
                    {
                        entity.Status = appointment.Status;
                    }

                    if (!string.IsNullOrEmpty(appointment.AppointmentNumber))
                    {
                        entity.AppointmentNumber = appointment.AppointmentNumber;
                    }
                    if (!string.IsNullOrEmpty(appointment.ScacCode))
                    {
                        entity.ScacCode = appointment.ScacCode;
                    }
                    if (appointment.ShippingDate.HasValue)
                    {
                        entity.ShipDate = appointment.ShippingDate.Value;
                    }
                    if (appointment.ShippingTime.HasValue)
                    {
                        entity.ShipTime = appointment.ShippingTime.Value;
                    }
                    if (appointment.ShippingTimeLimit.HasValue)
                    {
                        entity.ShippingTimeLimit = appointment.ShippingTimeLimit;
                    }
                    if (appointment.DeliveryTypeId.HasValue)
                    {
                        entity.DeliveryTypeId = appointment.DeliveryTypeId;
                    }

                    if (appointment.ReScheduleDate.HasValue)
                    {
                        entity.ReScheduleDate = appointment.ReScheduleDate;
                    }
                    if (!string.IsNullOrEmpty(appointment.Status))
                    {
                        entity.Status = appointment.Status;
                    }

                    if (appointment.IsReSchedule.HasValue)
                    {
                        entity.IsReSchedule    = appointment.IsReSchedule.Value;
                        entity.RescheduleCount = entity.RescheduleCount.HasValue ? entity.RescheduleCount + 1 : 1;
                    }


                    var result = await context.SaveChangesAsync();
                }
            }
            catch (Exception exc)
            {
                return(exc.Message);
            }
            return(string.Empty);
        }
Exemple #20
0
 /// <summary>
 /// Create an Appointment
 /// </summary>
 /// <param name="appointment">appointment</param>
 /// <returns><see cref="Appointment"/></returns>
 public static InfusioOp <Appointment> CreateAppointment(Model.Appointment appointment) =>
 new InfusioOp <Appointment> .CreateAppointment(Return, appointment);
Exemple #21
0
        public async Task <string> SetAppointment(Model.Appointment appointmentModel, Model.OrderAppointment order)
        {
            using (System.Data.Entity.DbContextTransaction dbTran = context.Database.BeginTransaction())
            {
                try
                {
                    var existingAppt = context.Appointments.Where(x => x.CustomerId == appointmentModel.CustomerId && x.PickTicketId == appointmentModel.PickTicket).FirstOrDefault();

                    if (existingAppt != null)
                    {
                        if (existingAppt.Status == "D")
                        {
                            // update the existing one, could be a previous cancelation
                            context.Appointments.Remove(existingAppt);
                        }
                        else
                        {
                            throw new ArgumentException($"Order with picticket {appointmentModel.PickTicket} for client {appointmentModel.CustomerId} already have an appointment {existingAppt.AppointmentNumber}");
                        }
                    }

                    Entities.Appointment appointment = new Entities.Appointment();
                    appointment.CustomerId   = appointmentModel.CustomerId;
                    appointment.DateAdd      = DateTime.Now;
                    appointment.PickTicketId = appointmentModel.PickTicket;
                    appointment.DivisionId   = appointmentModel.DivisionId;

                    appointment.ScacCode = appointmentModel.ScacCode;
                    // appointment.ShipDate = appointmentModel.ShippingDate.Value;
                    appointment.ShipTime          = new DateTime(appointmentModel.ShippingDate.Value.Year, appointmentModel.ShippingDate.Value.Month, appointmentModel.ShippingDate.Value.Day, appointmentModel.ShippingTime.Value.Hour, appointmentModel.ShippingTime.Value.Minute, 0);
                    appointment.AppointmentNumber = appointmentModel.AppointmentNumber;
                    appointment.DeliveryTypeId    = appointmentModel.DeliveryTypeId.Value;
                    appointment.UserName          = appointmentModel.UserName;
                    appointment.Pallets           = appointmentModel.Pallets;
                    appointment.DriverId          = appointmentModel.DriverId;
                    appointment.TruckId           = appointmentModel.TruckId;

                    if (appointmentModel.ShippingTimeLimit.HasValue)
                    {
                        appointment.ShippingTimeLimit = new DateTime(appointmentModel.ShippingDate.Value.Year, appointmentModel.ShippingDate.Value.Month, appointmentModel.ShippingDate.Value.Day, appointmentModel.ShippingTimeLimit.Value.Hour, appointmentModel.ShippingTimeLimit.Value.Minute, 0);
                    }

                    appointment.PtBulk = string.Empty;
                    if (!string.IsNullOrEmpty(appointmentModel.PtBulk))
                    {
                        appointment.PtBulk       = appointmentModel.PtBulk;
                        appointment.PickTicketId = appointmentModel.PtBulk;
                    }

                    context.Appointments.Add(appointment);


                    var ptBulk = string.IsNullOrEmpty(appointment.PtBulk) ? "" : appointment.PtBulk;


                    var entity = await context.OrderAppointments.Where(x => x.PurchaseOrderId == order.PurchaseOrderId && x.PickTicketId == appointment.PickTicketId && x.CustomerId == appointment.CustomerId && x.PtBulk == ptBulk).FirstOrDefaultAsync();

                    if (entity != null)
                    {
                        entity.Status  = 1;
                        entity.ShipFor = appointmentModel.ShippingDate.Value;
                        entity.Notes   = !string.IsNullOrEmpty(entity.Notes) ? $"{entity.Notes} / {order.Notes}" : order.Notes;
                    }

                    await context.SaveChangesAsync();

                    dbTran.Commit();

                    return(null);
                }
                catch (Exception exc)
                {
                    dbTran.Rollback();

                    return($"{exc.Message} : { exc.InnerException?.Message} ");
                }
            }
        }
Exemple #22
0
 /// <summary>
 /// Replace an Appointment
 /// </summary>
 /// <param name="appointmentDTO">appointmentDTO</param>
 /// <param name="appointmentId">appointmentId</param>
 /// <returns><see cref="Appointment"/></returns>
 public static InfusioOp <Appointment> UpdateAppointment(Model.Appointment appointmentDTO, long appointmentId) =>
 new InfusioOp <Appointment> .UpdateAppointment(Return, appointmentDTO, appointmentId);
        void OnAppointmentsInserted(object sender, PersistentObjectsEventArgs e)
        {
            using (new WaitCursor()) {
                Model.Service service = new Model.Service(Program.Service);

                foreach (Appointment apt in e.Objects)
                {
                    Model.Appointment.ItemCode defaultValue = apt.AllDay ?
                                                              Model.Appointment.ItemCode.Task : Model.Appointment.ItemCode.Event;

                    if (apt.CustomFields["ItemType"] == null)
                    {
                        apt.CustomFields["ItemType"] = defaultValue;
                    }

                    if (apt.CustomFields["CompletionStatus"] == null)
                    {
                        apt.CustomFields["CompletionStatus"] = (int)Model.Appointment.CompletionCode.NotStarted;
                    }

                    if (Filter.Current.User != null)
                    {
                        if (apt.ResourceId == null || !(apt.ResourceId is Guid) ||
                            ((Guid)apt.ResourceId == Guid.Empty))
                        {
                            apt.ResourceId = Filter.Current.User.ID;
                        }
                    }

                    Model.Appointment obj
                        = apt.GetSourceObject((SchedulerStorage)sender) as Model.Appointment;

                    if (obj != null)
                    {
                        bool bIsNew = false;

                        if (obj.ID == Guid.Empty)
                        {
                            bIsNew = true;
                            obj.ID = Guid.NewGuid();
                        }

                        if (obj.AssignedTo == null &&
                            Filter.Current.User != null)
                        {
                            obj.AssignedTo = Filter.Current.User.ID;
                        }

                        obj.ItemType         = (int)apt.CustomFields["ItemType"];
                        obj.CompletionStatus = (int)apt.CustomFields["CompletionStatus"];

                        Model.Appointment utc = obj.Clone(DateTimeKind.Utc);

                        if (bIsNew)
                        {
                            service.AddToAppointments(utc);
                        }
                        else
                        {
                            service.AttachTo("Appointments", utc);
                            service.UpdateObject(utc);
                        }

                        BindingList <Model.Appointment> taskDataSource
                            = gridControl.DataSource as BindingList <Model.Appointment>;

                        if (taskDataSource != null)
                        {
                            if (obj != null &&
                                !taskDataSource.Any <Model.Appointment>(it => it.ID == obj.ID) &&
                                obj.AppointmentType == (int)AppointmentType.Normal)
                            {
                                taskDataSource.Add(obj);
                            }
                        }
                    }
                }

                service.SaveChanges(System.Data.Services.Client.SaveChangesOptions.Batch);
            }
        }
        private void OnCustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            if (e.Column == gridColumnIsCompleted)
            {
                return;
            }

            Model.Appointment obj = e.Column.View.GetRow(e.RowHandle) as Model.Appointment;

            if (e.Column == gridColumnAssignedTo)
            {
                string displayText = string.Empty;


                if (obj != null)
                {
                    Model.Resource resource = obj.AssignedTo.HasValue
                        ? FindResourceByID(obj.AssignedTo.Value) : null;

                    if (resource != null)
                    {
                        displayText = resource.DisplayText;
                    }
                }

                e.DisplayText = displayText;
            }

            Color     fontColor = e.Appearance.ForeColor;
            FontStyle fontStyle = e.Appearance.Font.Style;

            if (obj != null)
            {
                if (obj.CompletionStatus >= 0 && obj.Finish <= DateTime.Now

                    && !obj.IsAllDay)
                {
                    fontColor = Color.FromArgb(0xCF, 0x45, 0x55);
                    fontStyle = FontStyle.Bold;
                }
                else if (obj.CompletionStatus >= 0 && obj.IsAllDay

                         /* All day appointments today are not yet overdue */
                         && obj.Finish < DateTime.Now.Date)
                {
                    fontColor = Color.FromArgb(0xCF, 0x45, 0x55);
                    fontStyle = FontStyle.Bold;
                }
                else if (obj.CompletionStatus < 0)
                {
                    fontColor = Color.Silver;
                    fontStyle = FontStyle.Strikeout;
                }
            }

            e.Cache.FillRectangle(e.Appearance.GetBackBrush(e.Cache), e.Bounds);

            Rectangle rect = e.Bounds;

            if (e.Appearance.HAlignment == HorzAlignment.Near)
            {
                rect.Offset(2, 0);
            }

            e.Cache.DrawString(e.DisplayText, e.Cache.GetFont(e.Appearance.Font, fontStyle),
                               e.Cache.GetSolidBrush(fontColor),
                               rect, e.Appearance.GetStringFormat());

            e.Handled = true;
        }
 public string UpdateAppointment(Model.Appointment appointment)
 {
     return _appointmentDao.UpdateAppointment(appointment);
 }
 public async Task <int> Create(Model.Appointment orderAppointment)
 {
     return(await Repository.Create(orderAppointment));
 }
 public string InsertAppointment(Model.Appointment appointment)
 {
     return _appointmentDao.InsertAppointment(appointment);
 }