Exemple #1
0
        private void LoadJob()
        {
            int jobID = int.Parse(Request.QueryString["jID"]);

            Orchestrator.Entities.Job job    = null;
            Orchestrator.Facade.IJob  facJob = new Orchestrator.Facade.Job();
            job = facJob.GetJob(jobID);

            Facade.IBusinessType  facBusinessType = new Facade.BusinessType();
            Entities.BusinessType businessType    = facBusinessType.GetForBusinessTypeID(job.BusinessTypeID);

            if (businessType != null)
            {
                lblBusinessType.Text = businessType.Description;
            }
            else
            {
                lblBusinessType.Text = "No Business Type Set";
            }

            DataSet dsTypes = facBusinessType.GetAll();

            cboBusinessType.DataSource     = dsTypes;
            cboBusinessType.DataTextField  = "Description";
            cboBusinessType.DataValueField = "BusinessTypeID";
            cboBusinessType.DataBind();

            if (businessType != null)
            {
                cboBusinessType.FindItemByValue(businessType.BusinessTypeID.ToString()).Selected = true;
                this.CurrentBusinessTypeID = businessType.BusinessTypeID;
            }
        }
Exemple #2
0
        public List <PalletForceOrder> GetOrdersForPalletNetworkExport(DateTime trunkDate)
        {
            // Search for orders based on Date Range Status and text
            // Determine the parameters
            List <int> orderStatusIDs = new List <int>();

            orderStatusIDs.Add((int)eOrderStatus.Approved);
            orderStatusIDs.Add((int)eOrderStatus.Delivered);
            orderStatusIDs.Add((int)eOrderStatus.Invoiced);

            // Set the Business Types
            List <int> BusinessTypes = new List <int>();

            Facade.IBusinessType facBusinessType = new Facade.BusinessType();
            DataSet dsBusinessTypes = facBusinessType.GetAll();

            foreach (DataRow row in dsBusinessTypes.Tables[0].Rows)
            {
                BusinessTypes.Add(int.Parse(row["BusinessTypeID"].ToString()));
            }
            // Retrieve the client id, resource id, and sub-contractor identity id.
            int clientID   = 0;
            int resourceID = 0;
            int subContractorIdentityID = Globals.Configuration.PalletNetworkID;

            int collectionPointId = 0;
            int deliveryPointId   = 0;

            int goodsType = 0;


            Facade.IOrder facOrder  = new Facade.Order();
            DataSet       orderData = null;

            orderData = facOrder.Search(orderStatusIDs, trunkDate, trunkDate, String.Empty, false, false, true, false, clientID, resourceID, subContractorIdentityID, BusinessTypes, collectionPointId, deliveryPointId, goodsType);
            List <PalletForceOrder> orders = new List <PalletForceOrder>();

            orders = (from row in orderData.Tables[0].AsEnumerable()
                      select new PalletForceOrder()
            {
                OrderID = row.Field <int>("OrderID"),
                JobID = row.Field <int>("JobID"),
                CustomerOrganisationName = row.Field <string>("CustomerOrganisationName"),
                DeliveryPointDescription = row.Field <string>("DeliveryPointDescription"),
                DeliveryOrderNumber = row.Field <string>("DeliveryOrderNumber"),
                CustomerOrderNumber = row.Field <string>("CustomerOrderNumber"),
                NoPallets = row.Field <int>("NoPallets"),
                PalletSpaces = row.Field <decimal>("PalletSpaces"),
                Weight = row.Field <decimal>("Weight"),
                HalfPallets = row.Field <int>("HalfPallets"),
                QtrPallets = row.Field <int>("QtrPallets"),
                FullPallets = row.Field <int>("FullPallets"),
                OverPallets = row.Field <int>("OverPallets"),
                MessageStateID = row.IsNull("MessageStateID") ? (int?)null : row.Field <int>("MessageStateID"),
                DeliveryDateTimeLabel = GetTime(row.Field <DateTime>("DeliveryFromDateTime"), row.Field <DateTime>("DeliveryDateTime")),
                Surcharges = GetSurcharges(row.Field <int>("OrderID"))
            }).ToList();

            return(orders);
        }
Exemple #3
0
        private void PopulateStaticControls()
        {
            cblOrderStatus.DataSource = Enum.GetNames(typeof(eOrderStatus));
            cblOrderStatus.DataBind();

            Facade.IBusinessType facBusinessType = new Facade.BusinessType();
            cboBusinessType.DataSource = facBusinessType.GetAll();
            cboBusinessType.DataBind();
        }
        private void BindRepeater()
        {
            Facade.IBusinessType facBusinessType = new Facade.BusinessType();
            DataSet dsBusinessType = null;

            dsBusinessType = facBusinessType.GetAll();

            repBusinessType.DataSource = dsBusinessType;
            repBusinessType.DataBind();
            grdNormal.Rebind();
            grdSummary.Rebind();
        }
        void grdBusinessTypes_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            Facade.IBusinessType facBusinessType = new Facade.BusinessType();
            DataSet ds = facBusinessType.GetAll();

            if (!e.IsFromDetailTable)
            {
                grdBusinessTypes.MasterTableView.DataSource = ds.Tables[0];
            }

            grdBusinessTypes.MasterTableView.DetailTables[0].DataSource = ds.Tables[1];
        }
Exemple #6
0
        private void ConfigureDisplay()
        {
            string headerText = "Rate";

            if (this.PreInvoiceID > 0)
            {
                Facade.IPalletForceImportPreInvoice facPreInvoice = new Facade.PreInvoice();
                PFInvoice = facPreInvoice.GetImportedInvoiceForPreInvoiceID(PreInvoiceID, true);
                ItemIDs   = PFInvoice.GetOrdersOnInvoice();

                switch (PFInvoice.InvoiceType)
                {
                case eInvoiceType.PFDepotCharge:
                    headerText = "Sub Contract Rate";
                    break;

                case eInvoiceType.PFHubCharge:
                    headerText = "Hub Charge";
                    break;

                case eInvoiceType.PFSelfBillDeliveryPayment:
                    headerText = "Order Rate";
                    break;
                }

                if (consignmentNo != String.Empty)
                {
                    lblRefCaption.Text = "Consignment No";
                    lblRef.Text        = txtSearch.Text = consignmentNo;
                }
            }
            else
            if (LoadNo != String.Empty)
            {
                lblRefCaption.Text = "Load No";
                lblRef.Text        = txtSearch.Text = LoadNo;
            }

            grdOrders.Columns.FindByUniqueName("CurrentRate").HeaderText = headerText;

            dteStartDate.SelectedDate = new DateTime(DateTime.Today.Year, DateTime.Today.AddMonths(-1).Month, DateTime.Today.Day);
            dteEndDate.SelectedDate   = DateTime.Today;

            Facade.IBusinessType facBT = new Facade.BusinessType();
            cblBusinessType.DataSource = facBT.GetAll();
            cblBusinessType.DataBind();

            foreach (ListItem li in cblBusinessType.Items)
            {
                li.Selected = true;
            }
        }
Exemple #7
0
        //--------------------------------------------------------------------------------------------------------------------------

        private void LoadBusinessTypes()
        {
            Facade.IBusinessType facBusinessType = new Facade.BusinessType();
            DataSet dsBusinessTypes = facBusinessType.GetAll();

            foreach (DataRow row in dsBusinessTypes.Tables[0].Rows)
            {
                ListItem li = new ListItem(row["Description"].ToString(), row["BusinessTypeID"].ToString());
                // Select all the business types by default.
                li.Selected = true;
                cblBusinessType.Items.Add(li);
            }
        }
Exemple #8
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (Page.IsCallback)
            {
                return;
            }

            m_jobId   = Convert.ToInt32(Request.QueryString["jobId"]);
            m_isStock = Convert.ToBoolean(Request.QueryString["isStock"]);

            if (m_jobId > 0)
            {
                m_isUpdate              = true;
                cboClient.Enabled       = false;
                cboBusinessType.Enabled = false;
            }

            if (m_isUpdate)
            {
                GoToStep("JD");
            }

            if (!IsPostBack)
            {
                btnCancel.Attributes.Add("onClick", wizard.C_CONFIRM_MESSAGE);

                Facade.IBusinessType facBusinessType = new Facade.BusinessType();
                cboBusinessType.DataSource = facBusinessType.GetAll();
                cboBusinessType.DataBind();

                cboClient.Focus();
                if (Session[wizard.C_JOB] != null)
                {
                    m_job = (Entities.Job)Session[wizard.C_JOB];
                    PopulateClient();
                    cboBusinessType.ClearSelection();
                    cboBusinessType.Items.FindByValue(m_job.BusinessTypeID.ToString()).Selected = true;
                }
            }
            else
            {
                m_job = (Entities.Job)Session[wizard.C_JOB];
            }

//			infringementDisplay.Visible = false;
        }
        private void BindRepeater()
        {
            Facade.IBusinessType facBusinessType = new Facade.BusinessType();
            Facade.IOrganisation facOrganisation = new Facade.Organisation();
            DataSet dsBusinessType;

            int identityID;

            int.TryParse(cboClient.SelectedValue, out identityID);

            organisation = facOrganisation.GetForIdentityId(identityID);

            dsBusinessType = facBusinessType.GetAll();

            repBusinessType.DataSource = dsBusinessType;
            repBusinessType.DataBind();
            grdNormal.Rebind();
            grdSummary.Rebind();
        }
Exemple #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Security.Authorise.EnforceAuthorisation(eSystemPortion.AddEditOrder);

            if (!IsPostBack)
            {
                btnCreateCollection.PostBackUrl = "collectionjob.aspx";
                //TODO: Replace this on Collection and Deliveries
                //dteStartDate.MinValue = DateTime.Today;
                Facade.ITrafficArea facTrafficArea = new Facade.Traffic();
                cblTrafficAreas.DataSource = facTrafficArea.GetAll();
                cblTrafficAreas.DataBind();

                Facade.IBusinessType facBusinessType = new Facade.BusinessType();
                DataSet dsBusinessTypes = facBusinessType.GetAll();

                cblBusinessTypes.DataSource = dsBusinessTypes;
                cblBusinessTypes.DataBind();

                foreach (DataRow row in dsBusinessTypes.Tables[0].Rows)
                {
                    RadMenuItem rmi = new RadMenuItem();
                    rmi.Text  = row["Description"].ToString();
                    rmi.Value = row["BusinessTypeID"].ToString();
                    RadMenu1.Items.Add(rmi);
                }

                if (Session[C_ONLYSHOWNONCOLLECTED] != null && Session[C_ONLYSHOWNONCOLLECTED] is bool)
                {
                    chkShowUnPlannedOnly.Checked = (bool)Session[C_ONLYSHOWNONCOLLECTED];
                }

                // Get the Dates from the filter if one exists
                GetDates();
            }
        }
Exemple #11
0
        private void ConfigureContextMenu()
        {
            Facade.IBusinessType facBusinessType = new Facade.BusinessType();
            DataSet dsBusinessTypes = facBusinessType.GetAll();

            //Top level context menu items.
            RadMenuItem cbt = new RadMenuItem("Change Business Type To");
            RadMenuItem cdn = new RadMenuItem("Create Delivery Note");

            cdn.Value = "-1";

            //Create business type menu items.
            foreach (DataRow row in dsBusinessTypes.Tables[0].Rows)
            {
                RadMenuItem rmi = new RadMenuItem();
                rmi.Text  = row["Description"].ToString();
                rmi.Value = row["BusinessTypeID"].ToString();
                cbt.Items.Add(rmi);
            }

            //Add items to context menu.
            RadMenu1.Items.Add(cbt);
            RadMenu1.Items.Add(cdn);
        }
        private void ConfigureDisplay()
        {
            System.Globalization.GregorianCalendar cal = new System.Globalization.GregorianCalendar();

            Facade.BusinessType       facBusinessType      = new Facade.BusinessType();
            Facade.IOrderServiceLevel facOrderServiceLevel = new Facade.Order();

            cblBusinessType.DataSource = facBusinessType.GetAll();
            cblBusinessType.DataBind();

            foreach (ListItem li in cblBusinessType.Items)
            {
                li.Selected = true;
            }

            cblServiceLevel.DataSource = facOrderServiceLevel.GetAll();
            cblServiceLevel.DataBind();

            foreach (ListItem li in cblServiceLevel.Items)
            {
                li.Selected = true;
            }

            string referencesSortExpression = Globals.Configuration.FlagForInvoicingReferencesSortExpression;

            if (!string.IsNullOrEmpty(referencesSortExpression))
            {
                grdOrders.Columns.FindByUniqueName("References").SortExpression = referencesSortExpression;
            }

            int IdentityID = 0;

            if (!string.IsNullOrEmpty(Request.QueryString["identityid"]))
            {
                int.TryParse(Request.QueryString["identityid"].ToString(), out IdentityID);
            }

            string MinDate = string.Empty;

            if (!string.IsNullOrEmpty(Request.QueryString["MinDate"]))
            {
                MinDate = Request.QueryString["MinDate"];
            }

            if (IdentityID > 0 && MinDate.Length > 0)
            {
                m_isFromDash = true;
                Facade.IOrganisation facOrg = new Facade.Organisation();
                string name = facOrg.GetNameForIdentityId(IdentityID);

                cboClient.SelectedValue = IdentityID.ToString();
                cboClient.Text          = name;

                DateTime startDate = new DateTime();
                DateTime.TryParse(MinDate, out startDate);

                rdiStartDate.SelectedDate = startDate;
                rdiEndDate.SelectedDate   = System.DateTime.Today;

                if (startDate >= System.DateTime.Today)
                {
                    rdiEndDate.SelectedDate = startDate.AddDays(1);
                }

                rdoListInvoiceType.Items[0].Selected = false;
                rdoListInvoiceType.Items[2].Selected = true;

                grdOrders.Rebind();
            }
        }
        private void PopulateStaticControls()
        {
            #region // Populate Control Areas
            Facade.IControlArea facControlArea = new Facade.Traffic();
            cboControlArea.DataSource = facControlArea.GetAll();
            cboControlArea.DataBind();
            cboControlArea.Items[0].Selected = true;
            #endregion

            #region // Populate Traffic Areas
            Facade.ITrafficArea facTrafficArea = (Facade.ITrafficArea)facControlArea;
            cboTrafficAreas.DataSource = facTrafficArea.GetAll();
            cboTrafficAreas.DataBind();
            #endregion

            #region // Populate Depots
            Facade.IOrganisationLocation facOrganisationLocation = new Facade.Organisation();
            cboDepot.DataSource = facOrganisationLocation.GetAllDepots(Orchestrator.Globals.Configuration.IdentityId);
            cboDepot.DataBind();
            cboDepot.Items.Insert(0, new ListItem("Use Control Area and Traffic Areas to determine resource pool", "0"));
            #endregion

            #region // Populate Filters for this user
            PopulateFilterList();
            #endregion

            #region // Configure the default dates.
            // Default dates are from the start of today until:
            //   1) On a Saturday, until the end of Monday.
            //   2) On any other day, until the end of tomorrow.
            DateTime startOfToday = DateTime.Now;
            startOfToday = startOfToday.Subtract(startOfToday.TimeOfDay);
            DateTime endOfTomorrow = startOfToday.Add(new TimeSpan(1, 23, 59, 59));

            DateTime startDate = startOfToday;
            DateTime endDate   = endOfTomorrow;
            if (startOfToday.DayOfWeek == DayOfWeek.Saturday)
            {
                DateTime endOfMonday = startOfToday.Add(new TimeSpan(2, 23, 59, 59));
                endDate = endOfMonday;
            }
            #endregion

            #region // Cause the job states to be displayed
            chkJobStates.DataSource = Utilities.UnCamelCase(Enum.GetNames(typeof(eJobState)));
            chkJobStates.DataBind();
            #endregion

            #region // Load the Job Types
            Facade.IBusinessType facBusinessType = new Facade.BusinessType();

            cblBusinessType.DataSource     = facBusinessType.GetAll();
            cblBusinessType.DataTextField  = "Description";
            cblBusinessType.DataValueField = "BusinessTypeID";
            cblBusinessType.DataBind();
            #endregion

            #region React to supplied values

            bool haveReacted = false;

            try
            {
                Entities.TrafficSheetFilter m_trafficSheetFilter = Utilities.GetFilterFromCookie(this.CookieSessionID, Request);

                if (m_trafficSheetFilter == null)
                {
                    m_trafficSheetFilter = GetDefaultFilter();
                    m_trafficSheetFilter.FilterStartDate = startDate;
                    m_trafficSheetFilter.FilterEnddate   = endDate;
                }

                cboControlArea.ClearSelection();
                SelectItem(cboControlArea.Items, m_trafficSheetFilter.ControlAreaId);
                haveReacted = true;

                foreach (var taid in m_trafficSheetFilter.TrafficAreaIDs)
                {
                    SelectItem(cboTrafficAreas.Items, taid);
                }

                for (int i = 0; i < m_trafficSheetFilter.JobStates.Count; i++)
                {
                    chkJobStates.Items.FindByValue(Utilities.UnCamelCase(Enum.Parse(typeof(eJobState), m_trafficSheetFilter.JobStates[i].ToString()).ToString())).Selected = true;
                }

                cboDepot.ClearSelection();
                cboDepot.Items.FindByValue(m_trafficSheetFilter.DepotId.ToString()).Selected = true;
                dteStartDate.SelectedDate = m_trafficSheetFilter.FilterStartDate;
                dteEndDate.SelectedDate   = m_trafficSheetFilter.FilterEnddate;



                cblBusinessType.ClearSelection();
                foreach (int i in m_trafficSheetFilter.BusinessTypes)
                {
                    cblBusinessType.Items.FindByValue(i.ToString()).Selected = true;
                }
            }
            catch (Exception eX)
            {
                Entities.TrafficSheetFilter ts = GetDefaultFilter();
                ts.FilterStartDate        = startDate;
                dteStartDate.SelectedDate = startDate;
                ts.FilterEnddate          = endDate;
                dteEndDate.SelectedDate   = endDate;
                if (Request.Cookies[this.CookieSessionID] == null)
                {
                    SetCookie(ts);
                }

                BindDefaultFilter();
            }
            finally
            {
                // Apply the dates.
            }
            #endregion
        }
Exemple #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Security.Authorise.EnforceAuthorisation(eSystemPortion.AddEditOrder);
            _exportOrderEnabled = bool.Parse(ConfigurationManager.AppSettings["ExportOrderEnabled"].ToLower());

            if (!IsPostBack)
            {
                // Show/hide the "Export to Palletforce" button depending on whether a module id is present in the config.
                btnExportOrder.Visible = _exportOrderEnabled;

                btnCreateDelivery.PostBackUrl = "DeliveryJob.aspx?" + this.CookieSessionID;

                rblDateFiltering.Items.Clear();

                // amended to remove the var so that I can deploy a hot fix
                foreach (eDateFilterType item in Enum.GetValues(typeof(eDateFilterType)))
                {
                    rblDateFiltering.Items.Add(new ListItem(Enum.GetName(typeof(eDateFilterType), item).Replace("_", " "), ((int)item).ToString()));
                }

                rblDateFiltering.Items.Add(new ListItem("Trunk Date", "3"));

                ListItem defaultDateFiltering = rblDateFiltering.Items.FindByValue(((int)C_DEFAULT_DATE_FILTERING).ToString());
                if (defaultDateFiltering != null)
                {
                    defaultDateFiltering.Selected = true;
                }
                if (rblDateFiltering.Items.Count > 0 && rblDateFiltering.SelectedItem == null)
                {
                    rblDateFiltering.Items[0].Selected = true;
                }

                Facade.ITrafficArea facTrafficArea = new Facade.Traffic();
                cblTrafficAreas.DataSource = facTrafficArea.GetAll();
                cblTrafficAreas.DataBind();

                Facade.IBusinessType facBusinessType = new Facade.BusinessType();
                DataSet dsBusinessTypes = facBusinessType.GetAll();

                cblBusinessTypes.DataSource = dsBusinessTypes;
                cblBusinessTypes.DataBind();

                foreach (DataRow row in dsBusinessTypes.Tables[0].Rows)
                {
                    RadMenuItem rmi = new RadMenuItem();
                    rmi.Text  = row["Description"].ToString();
                    rmi.Value = row["BusinessTypeID"].ToString();
                    RadMenu1.Items.Add(rmi);
                }

                Facade.IOrderServiceLevel facOrderServiceLevel = new Facade.Order();
                cblServiceLevel.DataSource = facOrderServiceLevel.GetAll();
                cblServiceLevel.DataBind();

                Facade.ExtraType facExtraType = new Facade.ExtraType();
                cblSurcharges.DataSource = facExtraType.GetAllForFiltering();
                cblSurcharges.DataBind();

                PreSelectItems(cblServiceLevel, C_SELECTED_SERVICE_LEVELS);
                PreSelectItems(cblSurcharges, C_SELECTED_SURCHARGES);

                GetDates();
            }
        }
Exemple #15
0
        private void PopulateStaticControls()
        {
            #region // Configure the min and max dates.
            dteStartDate.MinDate = new DateTime(2000, 1, 1);
            dteEndDate.MaxDate   = new DateTime(2036, 12, 31);
            #endregion

            #region // Populate Control Areas
            Facade.IControlArea facControlArea = new Facade.Traffic();
            cboControlArea.DataSource = facControlArea.GetAll();
            cboControlArea.DataBind();
            cboControlArea.Items[0].Selected = true;
            #endregion

            #region // Populate Traffic Areas
            Facade.ITrafficArea facTrafficArea = (Facade.ITrafficArea)facControlArea;
            cboTrafficAreas.DataSource = facTrafficArea.GetAll();
            cboTrafficAreas.DataBind();

            if (cboTrafficAreas.Items.Count > 8)
            {
                divTrafficAreas.Attributes.Add("class", "overflowHandler");
                divTrafficAreas.Attributes.Add("style", "height:100px;");
            }
            #endregion

            #region // Populate Depots
            Facade.IOrganisationLocation facOrganisationLocation = new Facade.Organisation();
            cboDepot.DataSource = facOrganisationLocation.GetAllDepots(Orchestrator.Globals.Configuration.IdentityId);
            cboDepot.DataBind();
            cboDepot.Items.Insert(0, new ListItem("Use Control Area and Traffic Areas to determine resource pool", "0"));
            #endregion

            #region // Populate Filters for this user
            PopulateFilterList();
            #endregion

            #region // Configure the default dates.
            // Default dates are from the start of today until:
            //   1) On a Saturday, until the end of Monday.
            //   2) On any other day, until the end of tomorrow.
            DateTime startOfToday = DateTime.Now;
            startOfToday = startOfToday.Subtract(startOfToday.TimeOfDay);
            DateTime endOfTomorrow = startOfToday.Add(new TimeSpan(1, 23, 59, 59));

            DateTime startDate = startOfToday;
            DateTime endDate   = endOfTomorrow;
            if (startOfToday.DayOfWeek == DayOfWeek.Saturday)
            {
                DateTime endOfMonday = startOfToday.Add(new TimeSpan(2, 23, 59, 59));
                endDate = endOfMonday;
            }
            #endregion

            #region // Populate the Business Types
            Facade.IBusinessType facBusinessType = new Facade.BusinessType();
            cblBusinessType.DataSource     = facBusinessType.GetAll();
            cblBusinessType.DataTextField  = "Description";
            cblBusinessType.DataValueField = "BusinessTypeID";
            cblBusinessType.DataBind();
            #endregion

            #region // Populate the Instruction States

            cblInstructionStates.DataSource = Enum.GetNames(typeof(eInstructionState));
            cblInstructionStates.DataBind();

            #endregion

            #region // Populate the In Progress Sub-States

            cblInProgressSubStates.DataSource = this.InProgressSubStateDescriptions.ToDictionary(kvp => (int)kvp.Key, kvp => kvp.Value);
            cblInProgressSubStates.DataBind();

            #endregion

            #region // Populate the Planning Categories Types

            cblPlanningCategory.DataSource = DataContext.PlanningCategorySet.OrderBy(pc => pc.DisplayShort);
            cblPlanningCategory.DataBind();
            var liAll = new ListItem("All", "-1")
            {
                Selected = true
            };

            cblPlanningCategory.Items.Add(liAll);

            #endregion

            #region // Populate the Instruction Types

            cblInstructionType.Items.Clear();

            var liMWF = new ListItem("MWF", "1");
            liMWF.Attributes.Add("onclick", "onInstructionTypeChecked();");
            var liNonMWF = new ListItem("Non-MWF", "2");
            liNonMWF.Attributes.Add("onclick", "onInstructionTypeChecked();");

            cblInstructionType.Items.Add(liMWF);
            cblInstructionType.Items.Add(liNonMWF);

            #endregion

            #region // Populate the MWF Comms Status

            var list = Enum.GetValues(typeof(MWFCommunicationStatusForTrafficSheetEnum)).Cast <object>().ToDictionary(v => (int)v, v => MWF_Instruction.GetCommunicationStatusForTrafficSheetDescription((int)v));

            cblMWFCommsStates.DataSource = list;
            cblMWFCommsStates.DataBind();

            #endregion

            #region // Populate the MWF Instruction States

            // Only adding the states that we use for now
            var list2 = new Dictionary <int, string>
            {
                { (int)MWFStatusEnum.Drive, "Drive" },
                { (int)MWFStatusEnum.OnSite, "On Site" },
                { (int)MWFStatusEnum.Suspend, "Suspend" },
                { (int)MWFStatusEnum.Resume, "Resume" },
                { (int)MWFStatusEnum.Complete, "Complete" }
            };

            cblMWFInstructionStates.DataSource = list2;
            cblMWFInstructionStates.DataBind();

            #endregion

            if (Filter == null)
            {
                Filter = Utilities.GetFilterFromCookie(this.CookieSessionID, Request);
            }



            if (Filter == null)
            {
                Filter = GetDefaultFilter();

                // Configure the default dates.
                // Default dates are from the start of today until:
                //   1) On a Saturday, until the end of Monday.
                //   2) On any other day, until the end of tomorrow.
                Filter.FilterStartDate = startOfToday;
                if (startOfToday.DayOfWeek == DayOfWeek.Saturday)
                {
                    DateTime endOfMonday = startOfToday.Add(new TimeSpan(2, 23, 59, 59));
                    Filter.FilterEnddate = endOfMonday;
                }
                else
                {
                    Filter.FilterEnddate = endOfTomorrow;
                }
            }


            cboControlArea.ClearSelection();
            SelectItem(cboControlArea.Items, Filter.ControlAreaId);

            foreach (var taid in Filter.TrafficAreaIDs)
            {
                SelectItem(cboTrafficAreas.Items, taid);
            }

            startDate = Filter.FilterStartDate;
            endDate   = Filter.FilterEnddate;
            chkShowPlanned.Checked           = Filter.ShowPlannedLegs;
            chkShowStockMovementJobs.Checked = Filter.ShowStockMovementJobs;

            cboDepot.ClearSelection();
            cboDepot.Items.FindByValue(Filter.DepotId.ToString()).Selected = true;

            foreach (var i in Filter.BusinessTypes)
            {
                try
                {
                    // P1 use if we try to work on different client's version of Orchestrator
                    // the same cookie is used (domain).
                    cblBusinessType.Items.FindByValue(i.ToString()).Selected = true;
                }
                catch { }
            }

            foreach (int i in this.Filter.InstructionStates)
            {
                cblInstructionStates.Items.FindByValue(((eInstructionState)i).ToString()).Selected = true;
            }

            foreach (var ipss in this.Filter.InProgressSubStates)
            {
                cblInProgressSubStates.Items.FindByValue(((int)ipss).ToString()).Selected = true;
            }

            if (this.Filter.PlanningCategories.Count > 0)
            {
                foreach (ListItem li in cblPlanningCategory.Items)
                {
                    li.Selected = this.Filter.PlanningCategories.Contains(int.Parse(li.Value));
                }
            }

            this.chkSortbyEvent.Checked  = Filter.SortbyEvent;
            this.chkCollapseRuns.Checked = this.Filter.CollapseRuns;

            liMWF.Selected    = Filter.IncludeMWFInstructions;
            liNonMWF.Selected = Filter.IncludeNonMWFInstructions;

            chkSelectAllInstructionTypes.Checked = (liMWF.Selected && liNonMWF.Selected);

            bool allSelected = false;
            if (Filter.MWFCommsStates.Count > 0)
            {
                allSelected = true;
                foreach (ListItem li in cblMWFCommsStates.Items)
                {
                    li.Selected = Filter.MWFCommsStates.Contains(int.Parse(li.Value));
                    if (!li.Selected)
                    {
                        allSelected = false;
                    }
                }
            }

            chkSelectAllMWFCommsStates.Checked = allSelected;


            var selected = false;
            if (Filter.MWFInstructionStates.Count > 0)
            {
                selected = true;
                foreach (ListItem li in cblMWFInstructionStates.Items)
                {
                    li.Selected = Filter.MWFInstructionStates.Contains(int.Parse(li.Value));
                    if (!li.Selected)
                    {
                        selected = false;
                    }
                }
            }

            chkSelectAllMWFInstructionStates.Checked = selected;


            #region     // Apply the dates.
            dteStartDate.SelectedDate = startDate;
            dteEndDate.SelectedDate   = endDate;
            #endregion
        }
        void grdOrders_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            if (IsPostBack && string.IsNullOrEmpty(Request.QueryString["rcbID"]))
            {
                // Search for orders based on Date Range Status and text
                // Determine the parameters
                List <int> orderStatusIDs = new List <int>();
                foreach (ListItem li in cblOrderStatus.Items)
                {
                    if (li.Selected)
                    {
                        orderStatusIDs.Add((int)((eOrderStatus)Enum.Parse(typeof(eOrderStatus), li.Value)));
                    }
                }

                // Retrieve the client id, resource id, and sub-contractor identity id.
                int clientID;
                int.TryParse(cboClient.SelectedValue, out clientID);
                int resourceID;
                int.TryParse(cboResource.SelectedValue, out resourceID);
                int subContractorIdentityID;
                int.TryParse(cboSubContractor.SelectedValue, out subContractorIdentityID);

                // Find the orders.
                Facade.IOrder facOrder = new Facade.Order();
                DataSet       orderData;
                try
                {
                    List <int> businessTypes = new List <int>();

                    Facade.IBusinessType facBusinessType = new Facade.BusinessType();
                    DataSet dsBusinessTypes = facBusinessType.GetAll();

                    foreach (DataRow row in dsBusinessTypes.Tables[0].Rows)
                    {
                        businessTypes.Add(Convert.ToInt32(row["BusinessTypeID"]));
                    }

                    orderData =
                        facOrder.Search(orderStatusIDs, dteStartDate.SelectedDate.Value, dteEndDate.SelectedDate.Value, txtSearch.Text,
                                        cboSearchAgainstDate.Items[0].Selected || cboSearchAgainstDate.Items[2].Selected,
                                        cboSearchAgainstDate.Items[1].Selected || cboSearchAgainstDate.Items[2].Selected,
                                        false, false, clientID, resourceID, subContractorIdentityID, businessTypes, 0, 0, 0);
                }
                catch (SqlException exc)
                {
                    if (exc.Message.StartsWith("Timeout expired."))
                    {
                        // A timeout exception has been encountered, instead of throwing the error page, instruct the user to refine their search.
                        DisplayMessage(
                            "Your query is not precise enough, please provide additional information or narrow the date/order state range.");

                        // Communicate the details of the exception to support.
                        string methodCall = "Facade.IOrder.Search('{0}', {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}); encountered by {9}";
                        Utilities.SendSupportEmailHelper(
                            string.Format(methodCall,
                                          Entities.Utilities.GetCSV(orderStatusIDs),
                                          dteStartDate.SelectedDate.Value,
                                          dteEndDate.SelectedDate.Value,
                                          txtSearch.Text,
                                          cboSearchAgainstDate.Items[0].Selected ||
                                          cboSearchAgainstDate.Items[2].Selected,
                                          cboSearchAgainstDate.Items[1].Selected ||
                                          cboSearchAgainstDate.Items[2].Selected,
                                          clientID,
                                          resourceID,
                                          subContractorIdentityID,
                                          ((Entities.CustomPrincipal)Page.User).UserName), exc);

                        orderData = null;
                    }
                    else
                    {
                        throw;
                    }
                }

                grdOrders.DataSource = orderData;
            }
        }
Exemple #17
0
        //-----------------------------------------------------------------------------------------------------------

        protected void grdOrders_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            // Search for orders based on Date Range Status and text
            // Determine the parameters
            List <int> orderStatusIDs = new List <int>();

            orderStatusIDs.Add((int)eOrderStatus.Approved);
            orderStatusIDs.Add((int)eOrderStatus.Delivered);
            orderStatusIDs.Add((int)eOrderStatus.Invoiced);

            // Set the Business Types
            List <int> BusinessTypes = new List <int>();

            Facade.IBusinessType facBusinessType = new Facade.BusinessType();
            DataSet dsBusinessTypes = facBusinessType.GetAll();

            foreach (DataRow row in dsBusinessTypes.Tables[0].Rows)
            {
                BusinessTypes.Add(int.Parse(row["BusinessTypeID"].ToString()));
            }
            // Retrieve the client id, resource id, and sub-contractor identity id.
            int clientID   = 0;
            int resourceID = 0;
            int subContractorIdentityID = Globals.Configuration.PalletNetworkID;

            int collectionPointId = 0;
            int deliveryPointId   = 0;

            int goodsType = 0;

            // Find the orders.
            Facade.IOrder facOrder  = new Facade.Order();
            DataSet       orderData = null;

            try
            {
                orderData =
                    facOrder.Search(orderStatusIDs, this.dteTrunkDate.SelectedDate, this.dteTrunkDate.SelectedDate.Value.AddDays(1), String.Empty, false, false, true, false,
                                    clientID, resourceID, subContractorIdentityID, BusinessTypes, collectionPointId, deliveryPointId, goodsType);
            }
            catch (SqlException exc)
            {
                throw;
            }

            orderCount           = 0;
            totalPalletCount     = 0;
            totalPalletSpaces    = 0;
            totalWeight          = 0;
            QtrPalletsTotal      = 0;
            HalfPalletsTotal     = 0;
            FullPalletsTotal     = 0;
            OverPalletsTotal     = 0;
            OrderRateTotal       = 0;
            SubContractCostTotal = 0;
            HubChargeTotal       = 0;

            if (rboFilterOption.SelectedValue == "1")
            {
                grdOrders.DataSource = orderData;
            }
            else if (rboFilterOption.SelectedValue == "2")
            {
                DataView dv = orderData.Tables[0].DefaultView;
                dv.RowFilter         = "MessageStateId IS NOT NULL";
                grdOrders.DataSource = dv;
            }
            else
            {
                DataView dv = orderData.Tables[0].DefaultView;
                dv.RowFilter         = "MessageStateId IS NULL";
                grdOrders.DataSource = dv;
            }
        }
        //-----------------------------------------------------------------------------------------------------------

        protected void grdOrders_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            // Search for orders based on Date Range Status and text
            // Determine the parameters
            List <int> orderStatusIDs = new List <int>();

            orderStatusIDs.Add((int)eOrderStatus.Approved);
            orderStatusIDs.Add((int)eOrderStatus.Delivered);
            orderStatusIDs.Add((int)eOrderStatus.Invoiced);

            // Set the Business Types
            List <int> BusinessTypes = new List <int>();

            Facade.IBusinessType facBusinessType = new Facade.BusinessType();
            DataSet dsBusinessTypes = facBusinessType.GetAll();

            foreach (DataRow row in dsBusinessTypes.Tables[0].Rows)
            {
                BusinessTypes.Add(int.Parse(row["BusinessTypeID"].ToString()));
            }
            // Retrieve the client id, resource id, and sub-contractor identity id.
            int clientID   = 0;
            int resourceID = 0;
            int subContractorIdentityID = Globals.Configuration.PalletNetworkID;

            int collectionPointId = 0;
            int deliveryPointId   = 0;

            int goodsType = 0;

            // Find the orders.
            Facade.IOrder facOrder  = new Facade.Order();
            DataSet       orderData = null;

            try
            {
                orderData =
                    facOrder.Search(orderStatusIDs, this.dteTrunkDate.SelectedDate, this.dteTrunkDate.SelectedDate.Value.AddDays(1), String.Empty, false, false, true, false,
                                    clientID, resourceID, subContractorIdentityID, BusinessTypes, collectionPointId, deliveryPointId, goodsType);
            }
            catch (SqlException exc)
            {
                throw;
            }

            // sort out the rate to display, when none of the orders have a rate and only the order group has a rate.
            // we only want to display the rate for one order in the group.
            List <int> orderGroupIds = new List <int>();

            if (orderData != null)
            {
                orderCount           = 0;
                totalPalletCount     = 0;
                totalPalletSpaces    = 0;
                totalWeight          = 0;
                QtrPalletsTotal      = 0;
                HalfPalletsTotal     = 0;
                FullPalletsTotal     = 0;
                OverPalletsTotal     = 0;
                OrderRateTotal       = 0;
                SubContractCostTotal = 0;
                HubChargeTotal       = 0;

                foreach (DataRow row in orderData.Tables[0].Rows)
                {
                    if (row["OrderGroupId"] != System.DBNull.Value && Convert.ToDouble(row["ForeignRate"].ToString()) > 0.00)
                    {
                        if (orderGroupIds.Contains(int.Parse(row["OrderGroupId"].ToString())))
                        {
                            row["ForeignRate"] = 0.00;
                        }
                        else
                        {
                            row["ForeignRate"] = row["GroupRate"];
                            orderGroupIds.Add(int.Parse(row["OrderGroupId"].ToString()));
                        }
                    }

                    orderCount++;
                    totalPalletCount     += (int)row["NoPallets"];
                    totalPalletSpaces    += Convert.ToDouble(row["PalletSpaces"]);
                    totalWeight          += Convert.ToDouble(row["Weight"]);
                    QtrPalletsTotal      += Convert.ToDouble(row["QtrPallets"]);
                    HalfPalletsTotal     += Convert.ToDouble(row["HalfPallets"]);
                    FullPalletsTotal     += Convert.ToDouble(row["FullPallets"]);
                    OverPalletsTotal     += Convert.ToDouble(row["OverPallets"]);
                    OrderRateTotal       += (row["ForeignRate"] != DBNull.Value) ? Convert.ToDouble(row["ForeignRate"]) : 0.00;
                    SubContractCostTotal += (row["SubContractRate"] != DBNull.Value) ? Convert.ToDouble(row["SubContractRate"]) : 0.00;
                    HubChargeTotal       += (row["SubContractRate"] != DBNull.Value) ? Convert.ToDouble(row["HubCharge"]) : 0.00;
                }
            }

            grdOrders.DataSource = orderData;
        }