コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
 }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #7
0
        private void grdPlanningCategories_InsertCommand(object sender, GridCommandEventArgs e)
        {
            var item = e.Item as GridEditableItem;

            var newValues = new Hashtable();

            e.Item.OwnerTableView.ExtractValuesFromItem(newValues, item);

            using (var ctx = new Orchestrator.EF.DataContext())
            {
                var planningCategory = new Orchestrator.EF.PlanningCategory();

                planningCategory.DisplayShort     = (string)newValues["DisplayShort"];
                planningCategory.DisplayLong      = (string)newValues["DisplayLong"];
                planningCategory.LastUpdateDate   = planningCategory.CreateDate = DateTime.Now;
                planningCategory.LastUpdateUserId = planningCategory.CreateUserId = User.Identity.Name;

                ctx.PlanningCategorySet.AddObject(planningCategory);

                ctx.SaveChanges();
            }
        }
コード例 #8
0
        private void grdPlanningCategories_UpdateCommand(object sender, GridCommandEventArgs e)
        {
            var item = e.Item as GridEditableItem;
            var id   = (int)item.GetDataKeyValue("ID");

            var newValues = new Hashtable();

            e.Item.OwnerTableView.ExtractValuesFromItem(newValues, item);

            using (var ctx = new Orchestrator.EF.DataContext())
            {
                var planningCategory = ctx.PlanningCategorySet.FirstOrDefault(pc => pc.ID == id);

                planningCategory.DisplayShort     = (string)newValues["DisplayShort"];
                planningCategory.DisplayLong      = (string)newValues["DisplayLong"];
                planningCategory.LastUpdateDate   = DateTime.Now;
                planningCategory.LastUpdateUserId = User.Identity.Name;

                ctx.SaveChanges();
            }

            item.Edit = false;
        }
コード例 #9
0
        //-----------------------------------------------------------------------------------------------------------



        //-----------------------------------------------------------------------------------------------------------

        protected void grdOrders_UpdateCommand(object source, GridCommandEventArgs e)
        {
            GridEditableItem editedItem = e.Item as GridEditableItem;
            int orderId = 0;

            if (!String.IsNullOrEmpty(editedItem.GetDataKeyValue("OrderId").ToString()))
            {
                orderId = Convert.ToInt32(editedItem.GetDataKeyValue("OrderId").ToString());
            }

            if (orderId > 0)
            {
                RadNumericTextBox txtNoPallets    = (RadNumericTextBox)e.Item.FindControl("txtNoPallets");
                RadNumericTextBox txtPalletSpaces = (RadNumericTextBox)e.Item.FindControl("txtPalletSpaces");
                RadNumericTextBox txtWeight       = (RadNumericTextBox)e.Item.FindControl("txtWeight");
                RadNumericTextBox txtQtrPallets   = (RadNumericTextBox)e.Item.FindControl("txtQtrPallets");
                RadNumericTextBox txtHalfPallets  = (RadNumericTextBox)e.Item.FindControl("txtHalfPallets");
                RadNumericTextBox txtFullPallets  = (RadNumericTextBox)e.Item.FindControl("txtFullPallets");
                RadNumericTextBox txtOverPallets  = (RadNumericTextBox)e.Item.FindControl("txtOverPallets");

                Orchestrator.EF.DataContext context   = new Orchestrator.EF.DataContext();
                Orchestrator.EF.VigoOrder   vigoOrder = context.VigoOrderSet.FirstOrDefault(vo => vo.OrderId == orderId);

                vigoOrder.QtrPallets  = Convert.ToInt32(txtQtrPallets.Value);
                vigoOrder.HalfPallets = Convert.ToInt32(txtHalfPallets.Value);
                vigoOrder.FullPallets = Convert.ToInt32(txtFullPallets.Value);
                vigoOrder.OverPallets = Convert.ToInt32(txtOverPallets.Value);

                vigoOrder.LastUpdateDate   = DateTime.Now;
                vigoOrder.LastUpdateUserId = Page.User.Identity.Name;

                context.SaveChanges(true);

                //Orchestrator.EF.RateInformation rateInformation = null;

                Facade.IOrder facOrder            = new Facade.Order();
                Orchestrator.Entities.Order order = facOrder.GetForOrderID(orderId);

                order.NoPallets    = Convert.ToInt32(txtNoPallets.Value);
                order.PalletSpaces = Convert.ToDecimal(txtPalletSpaces.Value);
                order.Weight       = Convert.ToDecimal(txtWeight.Value);

                order.LastUpdatedDateTime = DateTime.Now;
                order.LastUpdatedBy       = Page.User.Identity.Name;


                facOrder.Update(order, Page.User.Identity.Name);

                // We need to make sure the subcontractor (Palletforce) costs are re-rated
                Facade.IJobSubContractor jobSubContractor = new Facade.Job();
                if (order != null && order.JobSubContractID > 0)
                {
                    Entities.JobSubContractor js = jobSubContractor.GetSubContractorForJobSubContractId(order.JobSubContractID);
                    jobSubContractor.UpdateSubContractorCostsForOrders(new List <int>()
                    {
                        order.OrderID
                    }, js, this.Page.User.Identity.Name);
                }


                CheckBoxList        cblSurcharge = e.Item.FindControl("cblSurcharges") as CheckBoxList;
                List <EF.ExtraType> extraTypes   = context.ExtraTypeSet.Select(et => et).ToList();

                List <int> selectedExtraTypeIds = new List <int>();
                foreach (ListItem item in cblSurcharge.Items)
                {
                    if (item.Selected)
                    {
                        selectedExtraTypeIds.Add(int.Parse(item.Value));
                    }
                }

                //Remove the selected extras which are already present
                foreach (var extra in vigoOrder.VigoOrderExtras)
                {
                    selectedExtraTypeIds.Remove(extra.ExtraType.ExtraTypeId);
                }

                //Now add Extras for the selected extras remaining
                foreach (int extraTypeId in selectedExtraTypeIds)
                {
                    var vigoOrderExtra = new EF.VigoOrderExtra();
                    vigoOrderExtra.ExtraType = extraTypes.First(et => et.ExtraTypeId == extraTypeId); //new EntityKey("DataContext.ExtraTypeSet", "ExtraTypeId", extraTypeId);
                    vigoOrder.VigoOrderExtras.Add(vigoOrderExtra);
                }


                context.SaveChanges();

                //this.grdOrders.DataSource = null;
                //this.grdOrders.Rebind();
            }
        }
コード例 #10
0
        //-----------------------------------------------------------------------------------------------------------

        protected void grdOrders_UpdateCommand(object source, GridCommandEventArgs e)
        {
            GridEditableItem editedItem = e.Item as GridEditableItem;
            int orderId = 0;

            if (!String.IsNullOrEmpty(editedItem.GetDataKeyValue("OrderId").ToString()))
            {
                orderId = Convert.ToInt32(editedItem.GetDataKeyValue("OrderId").ToString());
            }

            if (orderId > 0)
            {
                RadNumericTextBox txtNoPallets    = (RadNumericTextBox)e.Item.FindControl("txtNoPallets");
                RadNumericTextBox txtPalletSpaces = (RadNumericTextBox)e.Item.FindControl("txtPalletSpaces");
                RadNumericTextBox txtWeight       = (RadNumericTextBox)e.Item.FindControl("txtWeight");
                RadNumericTextBox txtQtrPallets   = (RadNumericTextBox)e.Item.FindControl("txtQtrPallets");
                RadNumericTextBox txtHalfPallets  = (RadNumericTextBox)e.Item.FindControl("txtHalfPallets");
                RadNumericTextBox txtFullPallets  = (RadNumericTextBox)e.Item.FindControl("txtFullPallets");
                RadNumericTextBox txtOverPallets  = (RadNumericTextBox)e.Item.FindControl("txtOverPallets");

                Orchestrator.EF.DataContext context   = new Orchestrator.EF.DataContext();
                Orchestrator.EF.VigoOrder   vigoOrder = context.VigoOrderSet.FirstOrDefault(vo => vo.OrderId == orderId);

                vigoOrder.QtrPallets  = Convert.ToInt32(txtQtrPallets.Value);
                vigoOrder.HalfPallets = Convert.ToInt32(txtHalfPallets.Value);
                vigoOrder.FullPallets = Convert.ToInt32(txtFullPallets.Value);
                vigoOrder.OverPallets = Convert.ToInt32(txtOverPallets.Value);

                vigoOrder.LastUpdateDate   = DateTime.Now;
                vigoOrder.LastUpdateUserId = Page.User.Identity.Name;

                context.SaveChanges(true);

                //Orchestrator.EF.RateInformation rateInformation = null;

                Facade.IOrder facOrder            = new Facade.Order();
                Orchestrator.Entities.Order order = facOrder.GetForOrderID(orderId);

                order.NoPallets    = Convert.ToInt32(txtNoPallets.Value);
                order.PalletSpaces = Convert.ToDecimal(txtPalletSpaces.Value);
                order.Weight       = Convert.ToDecimal(txtWeight.Value);

                order.LastUpdatedDateTime = DateTime.Now;
                order.LastUpdatedBy       = Page.User.Identity.Name;

                //// Rate has not changed so auto rate it
                //if (order.ForeignRate == Convert.ToDecimal(txtRate.Value.Value))
                //{
                //    IEnumerable<Orchestrator.EF.RateSurcharge> rateSurcharge = new List<Orchestrator.EF.RateSurcharge>();
                //    rateInformation = facOrder.GetRate(order, true, out rateSurcharge);

                //    if (rateInformation != null)
                //    {
                //        order.TariffRateID = rateInformation.TariffRateId;
                //        order.ForeignRate = rateInformation.ForeignRate;
                //        order.Rate = rateInformation.Rate;
                //    }
                //    else
                //    {
                //        Facade.IExchangeRates facER = new Facade.ExchangeRates();
                //        CultureInfo nativeCulture = new CultureInfo(Orchestrator.Globals.Configuration.NativeCulture);

                //        order.ForeignRate = Convert.ToDecimal(txtRate.Value);

                //        if (order.LCID != nativeCulture.LCID)
                //        {
                //            order.ExchangeRateID = facER.GetCurrentExchangeRateID(Facade.Culture.GetCurrencySymbol(order.LCID), order.CollectionDateTime);
                //            order.Rate = facER.GetConvertedRate((int)order.ExchangeRateID, order.ForeignRate);
                //        }
                //        else
                //            order.Rate = order.ForeignRate;

                //        order.IsTariffOverride = true;
                //        order.TariffRateID = null;
                //        order.TariffOverrideUserID = Page.User.Identity.Name;
                //        order.TariffOverrideDate = DateTime.Now;
                //    }
                //}
                //else
                //{
                //    Facade.IExchangeRates facER = new Facade.ExchangeRates();
                //    CultureInfo nativeCulture = new CultureInfo(Orchestrator.Globals.Configuration.NativeCulture);

                //    order.ForeignRate = Convert.ToDecimal(txtRate.Value);

                //    if (order.LCID != nativeCulture.LCID)
                //    {
                //        order.ExchangeRateID = facER.GetCurrentExchangeRateID(Facade.Culture.GetCurrencySymbol(order.LCID), order.CollectionDateTime);
                //        order.Rate = facER.GetConvertedRate((int)order.ExchangeRateID, order.ForeignRate);
                //    }
                //    else
                //        order.Rate = order.ForeignRate;

                //    order.IsTariffOverride = true;
                //    order.TariffRateID = null;
                //    order.TariffOverrideUserID = Page.User.Identity.Name;
                //    order.TariffOverrideDate = DateTime.Now;
                //}

                facOrder.Update(order, Page.User.Identity.Name);

                // We need to make sure the subcontractor (Palletforce) costs are re-rated
                Facade.IJobSubContractor jobSubContractor = new Facade.Job();
                if (order != null && order.JobSubContractID > 0)
                {
                    Entities.JobSubContractor js = jobSubContractor.GetSubContractorForJobSubContractId(order.JobSubContractID);
                    jobSubContractor.UpdateSubContractorCostsForOrders(new List <int>()
                    {
                        order.OrderID
                    }, js, this.Page.User.Identity.Name);
                }

                this.grdOrders.DataSource = null;
                this.grdOrders.Rebind();
            }
        }