Exemplo n.º 1
0
        public bool BookIn(int orderID, string bookedInBy, string bookedInWith, string bookedInReferences, string dateOption, string datefromDate, string dateFromTime, string dateFromByDate, string dateFromByTime)
        {
            Orchestrator.EF.DataContext context = new Orchestrator.EF.DataContext();
            Orchestrator.EF.Order       order   = context.OrderSet.FirstOrDefault(o => o.OrderId == orderID);
            order.BookedIn           = true;
            order.BookedInByUserName = bookedInBy;
            order.BookedInDateTime   = DateTime.Now;
            order.BookedInStateId    = (int)eBookedInState.BookedIn;
            order.BookedInWith       = bookedInWith;
            order.BookedInReferences = bookedInReferences;

            // Set the date and time for the Delivery based on the book in details
            if (int.Parse(dateOption) == 0) //window
            {
                order.DeliveryFromDateTime = DateTime.Parse(datefromDate).Add(TimeSpan.Parse(dateFromTime));
                order.DeliveryDateTime     = DateTime.Parse(dateFromByDate).Add(TimeSpan.Parse(dateFromByTime));
            }
            else
            {
                order.DeliveryFromDateTime = DateTime.Parse(datefromDate).Add(TimeSpan.Parse(dateFromTime));
                order.DeliveryDateTime     = DateTime.Parse(datefromDate).Add(TimeSpan.Parse(dateFromTime));
            }

            order.LastUpdateDate   = DateTime.Now;
            order.LastUpdateUserID = bookedInBy;
            context.SaveChanges(true);

            return(true);
        }
Exemplo n.º 2
0
        public static List <string> UpdateOrder(int orderID, DateTime collectFromDate, DateTime?collectFromTime, DateTime collectByDate, DateTime?collectByTime, int collectionTimeType,
                                                DateTime deliverFromDate, DateTime?deliverFromTime, DateTime deliverToDate, DateTime?deliverToTime, int deliveryTimeType,
                                                decimal rate, string deliveryNotes, string userID)
        {
            List <string> result = new List <string>();

            result.Add(true.ToString());

            Orchestrator.EF.DataContext data  = EF.DataContext.Current;
            Orchestrator.EF.Order       order = data.OrderSet.First(o => o.OrderId == orderID);

            //determine the date(s) to use

            order.CollectionDateTime = collectFromDate.Add(collectFromTime.HasValue ? new TimeSpan(collectFromTime.Value.Hour, collectFromTime.Value.Minute, 0) : new TimeSpan(23, 59, 0));
            if (collectionTimeType == 1)
            {
                order.CollectionByDateTime = order.CollectionDateTime;
            }
            else
            {
                order.CollectionByDateTime = collectByDate.Add(collectByTime.HasValue ? new TimeSpan(collectByTime.Value.Hour, collectByTime.Value.Minute, 0) : new TimeSpan(23, 59, 0));
            }

            order.DeliveryFromDateTime = deliverFromDate.Add(deliverFromTime.HasValue ? new TimeSpan(deliverFromTime.Value.Hour, deliverFromTime.Value.Minute, 0) : new TimeSpan(23, 59, 0));
            if (deliveryTimeType == 1)
            {
                order.DeliveryDateTime = order.DeliveryFromDateTime.Value;
            }
            else
            {
                order.DeliveryDateTime = deliverToDate.Add(deliverToTime.HasValue ? new TimeSpan(deliverToTime.Value.Hour, deliverToTime.Value.Minute, 0) : new TimeSpan(23, 59, 0));
            }

            order.LastUpdateDate   = DateTime.Now;
            order.LastUpdateUserID = userID;

            order.DeliveryNotes = deliveryNotes;
            order.ForeignRate   = rate;

            Facade.IExchangeRates facER         = new Facade.ExchangeRates();
            CultureInfo           nativeCulture = new CultureInfo(Orchestrator.Globals.Configuration.NativeCulture);

            if (order.LCID != nativeCulture.LCID)
            {
                order.ExchangeRateID = facER.GetCurrentExchangeRateID(Facade.Culture.GetCurrencySymbol(order.LCID.Value), order.CollectionDateTime);
                order.Rate           = facER.GetConvertedRate(order.ExchangeRateID.Value, order.ForeignRate.Value);
            }
            else
            {
                order.Rate = decimal.Round(order.ForeignRate.Value, 4, MidpointRounding.AwayFromZero);
            }

            data.SaveChanges();

            result.Add(orderID.ToString());


            return(result);
        }
Exemplo n.º 3
0
 public void SetBookedInState(int orderID, eBookedInState bookedInState, string userName)
 {
     Orchestrator.EF.DataContext context = new Orchestrator.EF.DataContext();
     Orchestrator.EF.Order       order   = context.OrderSet.FirstOrDefault(o => o.OrderId == orderID);
     order.BookedIn           = false;
     order.BookedInByUserName = string.Empty;
     order.BookedInDateTime   = null;;
     order.BookedInStateId    = (int)bookedInState;
     order.LastUpdateDate     = DateTime.Now;
     order.LastUpdateUserID   = userName;
     context.SaveChanges(true);
 }
Exemplo n.º 4
0
        public static bool BookIn(int orderID, string bookedInBy, string bookedInWith, string bookedInReferences, string dateOption, string datefromDate, string dateFromTime, string dateFromByDate, string dateFromByTime)
        {
            Orchestrator.EF.DataContext context = EF.DataContext.Current;
            Orchestrator.EF.Order       order   = context.OrderSet.FirstOrDefault(o => o.OrderId == orderID);

            Facade.IOrder  facOrder      = new Facade.Order();
            Entities.Order orderOriginal = facOrder.GetForOrderID(orderID);

            order.BookedIn           = true;
            order.BookedInByUserName = bookedInBy;
            order.BookedInDateTime   = DateTime.Now;
            order.BookedInStateId    = (int)eBookedInState.BookedIn;
            order.BookedInWith       = bookedInWith;
            order.BookedInReferences = bookedInReferences;

            // Set the date and time for the Delivery based on the book in etails
            if (int.Parse(dateOption) == 0) //window
            {
                order.DeliveryFromDateTime = DateTime.Parse(datefromDate).Add(TimeSpan.Parse(dateFromTime));
                order.DeliveryDateTime     = DateTime.Parse(dateFromByDate).Add(TimeSpan.Parse(dateFromByTime));
            }
            else
            {
                order.DeliveryFromDateTime = DateTime.Parse(datefromDate).Add(TimeSpan.Parse(dateFromTime));
                order.DeliveryDateTime     = DateTime.Parse(datefromDate).Add(TimeSpan.Parse(dateFromTime));
            }

            order.LastUpdateDate   = DateTime.Now;
            order.LastUpdateUserID = bookedInBy;
            context.SaveChanges(true);

            Entities.Order orderNew = facOrder.GetForOrderID(orderID);

            var exports = Orchestrator.Application.GetSpecificImplementations <Application.IExportOrder>();

            if (exports.Any())
            {
                foreach (var export in exports)
                {
                    export.Update(orderNew, orderOriginal, bookedInBy);
                }
            }

            return(true);
        }
Exemplo n.º 5
0
        public static List <string> RemoveRequiresBookingIn(int orderID, string linkClientID, string userName)
        {
            Orchestrator.EF.DataContext context = EF.DataContext.Current;
            Orchestrator.EF.Order       order   = context.OrderSet.FirstOrDefault(o => o.OrderId == orderID);
            order.BookedIn           = false;
            order.BookedInByUserName = string.Empty;
            order.BookedInDateTime   = null;;
            order.BookedInStateId    = (int)eBookedInState.NotRequired;
            order.LastUpdateDate     = DateTime.Now;
            order.LastUpdateUserID   = userName;
            context.SaveChanges(true);

            List <string> result = new List <string>();

            result.Add(true.ToString().ToLower());
            result.Add(linkClientID);
            result.Add(string.Format("SetBookInRequired(this,{0}); return false;", orderID));
            return(result);
        }
Exemplo n.º 6
0
        public bool UpdateOrder(int orderID, DateTime collectFromDate, DateTime?collectFromTime, DateTime collectByDate, DateTime?collectByTime, int collectionTimeType,
                                DateTime deliverFromDate, DateTime?deliverFromTime, DateTime deliverToDate, DateTime?deliverToTime, int deliveryTimeType,
                                decimal rate, string deliveryNotes, string userID)
        {
            bool result = true;

            Orchestrator.EF.DataContext data  = new Orchestrator.EF.DataContext();
            Orchestrator.EF.Order       order = data.OrderSet.First(o => o.OrderId == orderID);

            //determine the date(s) to use

            order.CollectionDateTime = collectFromDate.Add(collectFromTime.HasValue ? new TimeSpan(collectFromTime.Value.Hour, collectFromTime.Value.Minute, 0) : new TimeSpan(23, 59, 0));
            if (collectionTimeType == 1 || collectionTimeType == 2)
            {
                order.CollectionByDateTime = order.CollectionDateTime;
            }
            else
            {
                order.CollectionByDateTime = collectByDate.Add(collectByTime.HasValue ? new TimeSpan(collectByTime.Value.Hour, collectByTime.Value.Minute, 0) : new TimeSpan(23, 59, 0));
            }

            order.DeliveryFromDateTime = deliverFromDate.Add(deliverFromTime.HasValue ? new TimeSpan(deliverFromTime.Value.Hour, deliverFromTime.Value.Minute, 0) : new TimeSpan(23, 59, 0));
            if (deliveryTimeType == 1 || deliveryTimeType == 2)
            {
                order.DeliveryDateTime = order.DeliveryFromDateTime.Value;
            }
            else
            {
                order.DeliveryDateTime = deliverToDate.Add(deliverToTime.HasValue ? new TimeSpan(deliverToTime.Value.Hour, deliverToTime.Value.Minute, 0) : new TimeSpan(23, 59, 0));
            }

            order.LastUpdateDate   = DateTime.Now;
            order.LastUpdateUserID = userID;

            order.DeliveryNotes = deliveryNotes;
            order.ForeignRate   = rate;

            data.SaveChanges();

            return(result);
        }