private void RemoveOrdersFromOriginalGroup()
        {
            IDictionary <int, List <int> > orderGroupIds = new Dictionary <int, List <int> >();

            Facade.IOrder      facOrder      = new Facade.Order();
            Facade.IOrderGroup facOrderGroup = new Facade.Order();

            if (Orders.Count > 0)
            {
                foreach (int OrderId in Orders)
                {
                    Entities.Order order = facOrder.GetForOrderID(OrderId);
                    KeyValuePair <int, List <int> > item = orderGroupIds.FirstOrDefault(kv => kv.Key == order.OrderGroupID);

                    if (item.Value != null && item.Value.Count > 0)
                    {
                        item.Value.Add(OrderId);
                    }
                    else
                    {
                        orderGroupIds.Add(order.OrderGroupID, new List <int>()
                        {
                            OrderId
                        });
                    }
                }
            }

            foreach (KeyValuePair <int, List <int> > pair in orderGroupIds)
            {
                facOrderGroup.RemoveOrdersFromGroup(pair.Key, pair.Value, ((CustomPrincipal)Page.User).UserName);
            }
        }
        //TODO: Change to work with Credit Notes.
        /// <summary>
        /// Prepares the page for viewing.
        /// </summary>
        private void ConfigureDisplay()
        {
            // Populate master page information
            //this.Master.WizardTitle = "Find Orders to Associate";

            // Bind the order states
            List <string> orderStateNames = new List <string>(Enum.GetNames(typeof(eOrderStatus)));

            orderStateNames.Remove(eOrderStatus.Invoiced.ToString());
            orderStateNames.Remove(eOrderStatus.Cancelled.ToString());
            cblOrderStatus.DataSource = orderStateNames;
            cblOrderStatus.DataBind();

            // Mark approved as being the only item checked.
            cblOrderStatus.Items.FindByValue(eOrderStatus.Approved.ToString()).Selected = true;

            // Default date range.
            dteStartDate.SelectedDate = DateTime.Today;
            dteEndDate.SelectedDate   = DateTime.Today.AddDays(2);

            // Set the client to match that of the orders in the group.
            Facade.IOrderGroup  facOrderGroup = new Facade.Order();
            Entities.OrderGroup orderGroup    = facOrderGroup.Get(_creditNoteID);
            if (orderGroup != null && orderGroup.Orders.Count > 0)
            {
                Facade.IOrganisation facOrganisation = new Facade.Organisation();
                int orderGroupCustomerIdentityID     = orderGroup.Orders[0].CustomerIdentityID;
                cboClient.Enabled       = false;
                cboClient.Text          = facOrganisation.GetNameForIdentityId(orderGroupCustomerIdentityID);
                cboClient.SelectedValue = orderGroupCustomerIdentityID.ToString();
            }
        }
Esempio n. 3
0
        void btnConfirmOrders_Click(object sender, EventArgs e)
        {
            // Check to see if there are any orders to save the changs for before approving
            if (!string.IsNullOrEmpty(hidOrderIDs.Value) && hidOrderIDs.Value.Length > 0)
            {
                SaveChanges();
            }

            var orderIDs = hidApproveOrderIDs.Value
                           .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                           .Select(s => int.Parse(s));

            //Attempt to find a customer specific implentation to approve the orders
            //if not use the default implementation
            Orchestrator.Application.IApproveOrder approveOrder = Orchestrator.Application.GetSpecificImplementation <Orchestrator.Application.IApproveOrder>();

            if (approveOrder != null)
            {
                approveOrder.ApproveOrders(orderIDs.ToList(), this.Page.User.Identity.Name);
            }
            else
            {
                Facade.IOrder facOrder = new Facade.Order();
                facOrder.Approve(orderIDs, this.Page.User.Identity.Name);
            }

            grdOrders.Rebind();
        }
Esempio n. 4
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);
        }
        /// <summary>
        /// Creates a job to manage the collection and delivery of the orders.
        /// </summary>
        private void CreateJob()
        {
            string userName = ((Entities.CustomPrincipal)Page.User).UserName;

            // Ensure the orders are all of the correct business type.
            Facade.IOrderGroup facOrderGroup = new Facade.Order();
            var businessTypeID = facOrderGroup.DetermineBusinessType(OrderGroup.OrderGroupID, false, userName);

            Facade.IJob           facJob = new Facade.Job();
            Entities.FacadeResult res    = facJob.CreateJobForOrderGroup(businessTypeID, this.OrderGroup, userName);

            if (res.Success)
            {
                int jobID = res.ObjectId;

                string jobDetailsRelativeURL = string.Format("~/Job/Job.aspx?wiz=true&jobID={0}", jobID);
                string jobDetailsURL         = Page.ResolveClientUrl(jobDetailsRelativeURL);
                string jobDetailsJS          = string.Format("openResizableDialogWithScrollbars('{0}' + getCSID(), 1220, 930);", jobDetailsURL);
                ScriptManager.RegisterStartupScript(this, this.GetType(), "viewJob", jobDetailsJS, true);
            }
            else
            {
                this.DisplayInfringments(res);
            }

            // Update the UI of the page.
            RebindPage();
        }
Esempio n. 6
0
        public string GetConsortiumMemberToAllocate(int?orderGroupID, int?orderID, int customerIdentityID, int collectionPointID, int deliveryPointID, DateTime collectionDateTime, DateTime deliveryDateTime)
        {
            Facade.IOrder facOrder         = new Facade.Order();
            var           consortiumMember = facOrder.GetConsortiumMemberToAllocate(orderGroupID, orderID, customerIdentityID, collectionPointID, deliveryPointID, collectionDateTime, deliveryDateTime);

            return(consortiumMember == null ? null : string.Format("{0},{1}", consortiumMember.IdentityId, consortiumMember.OrganisationName));
        }
Esempio n. 7
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            int orderID = Convert.ToInt32(Request.QueryString["orderID"]);

            Entities.Order order = null;

            if (orderID > 0)
            {
                string cacheName = "_orderNotes" + orderID.ToString();

                if (Cache[cacheName] == null)
                {
                    Facade.IOrder facOrder = new Facade.Order();
                    order = facOrder.GetForOrderID(orderID);
                    if (order != null)
                    {
                        Cache.Add(cacheName, order, null, System.Web.Caching.Cache.NoAbsoluteExpiration, new TimeSpan(0, 20, 0), System.Web.Caching.CacheItemPriority.Normal, null);
                    }
                }
                else
                {
                    order = (Entities.Order)Cache[cacheName];
                }
            }
            lblNotes.Text = order.Notes;
        }
Esempio n. 8
0
        private void btnConfirmOrders_Click(object sender, EventArgs e)
        {
            List <int> orderIDs = this.GetSelectedOrderIds();

            if (orderIDs.Count > 0)
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    Facade.IOrder facOrder = new Facade.Order();
                    facOrder.Update(orderIDs, eOrderStatus.Approved, ((Entities.CustomPrincipal)Page.User).UserName);

                    Facade.IOrderApproval facOrderApproval = new Facade.Order();

                    // Insert Order approval rows
                    facOrderApproval.Create(orderIDs, eOrderStatus.Approved, "", DateTime.Now, this.Page.User.Identity.Name);

                    // Send email to client user
                    try
                    {
                        facOrderApproval.SendClientOrderApprovalEmail(orderIDs, eOrderStatus.Approved, txtRejectionReasonTop.Text, this.Page.User.Identity.Name);
                    }
                    catch
                    { /* Swallow error: We dont care if the email approval/rejection email failed */ }

                    ts.Complete();
                }
            }

            this.ordersRadGrid.Rebind();
        }
Esempio n. 9
0
        private void btnRejectOrders_Click(object sender, EventArgs e)
        {
            List <int> orderIDs = this.GetSelectedOrderIds();

            if (orderIDs.Count > 0)
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    Facade.IOrder facOrder = new Facade.Order();
                    //Change status to rejected when the new type is added.
                    facOrder.Update(orderIDs, eOrderStatus.Rejected, ((Entities.CustomPrincipal)Page.User).UserName);

                    Facade.IOrderApproval facOrderApproval = new Facade.Order();

                    // Insert Order approval rows
                    facOrderApproval.Create(orderIDs, eOrderStatus.Rejected, txtRejectionReasonTop.Text, DateTime.Now, this.Page.User.Identity.Name);

                    // Send email to client user
                    facOrderApproval.SendClientOrderApprovalEmail(orderIDs, eOrderStatus.Rejected, txtRejectionReasonTop.Text, this.Page.User.Identity.Name);

                    ts.Complete();
                }
            }

            this.ordersRadGrid.Rebind();
        }
Esempio n. 10
0
        private void PrintOutloadingAdvice()
        {
            // Detrmine the Outloading Advice Sheets to Print
            List <int> collectionPoints = Points;

            Facade.IOrder facOrder = new Facade.Order();
            DataSet       ds       = facOrder.GetOrdersForOutloadingAdviceSheet(collectionPoints, dteCollectionDate.SelectedDate.Value);



            NameValueCollection reportParams = new NameValueCollection();

            //-------------------------------------------------------------------------------------
            //									Load Report Section
            //-------------------------------------------------------------------------------------
            Session[Orchestrator.Globals.Constants.ReportTypeSessionVariable]       = eReportType.OutloadingAdviceSheet;
            Session[Orchestrator.Globals.Constants.ReportParamsSessionVariable]     = reportParams;
            Session[Orchestrator.Globals.Constants.ReportDataSessionTableVariable]  = ds;
            Session[Orchestrator.Globals.Constants.ReportDataSessionSortVariable]   = String.Empty;
            Session[Orchestrator.Globals.Constants.ReportDataMemberSessionVariable] = "Table";

            // Show the user control
            Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", "<script language=\"javascript\">window.open('" + Page.ResolveClientUrl("../reports/reportviewer.aspx?wiz=true") + "');</script>");
            //Response.Redirect("../reports/reportviewer.aspx");
        }
Esempio n. 11
0
        private void BindData()
        {
            this.ordersRadGrid.DataSource = null;
            Facade.IOrder facOrder = new Facade.Order();

            int clientIdentityId = 0;

            try
            {
                clientIdentityId = Convert.ToInt32(Request.QueryString["iId"]);
            }
            catch
            {
                clientIdentityId = -1;
            }

            DataSet orderData = null;

            if (clientIdentityId > 0)
            {
                orderData = facOrder.GetOrdersForClientAndStatus(clientIdentityId, eOrderStatus.Awaiting_Approval);
            }
            else
            {
                orderData = facOrder.GetOrders(eOrderStatus.Awaiting_Approval);
            }

            this.ordersRadGrid.DataSource    = orderData;
            this.btnConfirmOrdersTop.Visible = orderData.Tables[0].Rows.Count > 0;
            this.btnRejectOrdersTop.Visible  = orderData.Tables[0].Rows.Count > 0;
        }
Esempio n. 12
0
        private void ProduceReport(int jobID)
        {
            Facade.IOrder facOrder  = new Facade.Order();
            DataSet       sheetData = facOrder.GetTransShippedOrdersOnJob(jobID);

            if (sheetData != null && sheetData.Tables.Count == 1)
            {
                DataTable instructionData = new DataTable();
                instructionData.Columns.Add(new DataColumn("Instruction"));
                DataRow row = instructionData.NewRow();
                row["Instruction"] = txtInstruction.Text;
                instructionData.Rows.Add(row);
                sheetData.Tables.Add(instructionData);

                sheetData.AcceptChanges();

                NameValueCollection reportParams = new NameValueCollection();
                reportParams.Add("JobID", jobID.ToString());

                //-------------------------------------------------------------------------------------
                //									Load Report Section
                //-------------------------------------------------------------------------------------
                Session[Orchestrator.Globals.Constants.ReportTypeSessionVariable]       = eReportType.TransshippingSheet;
                Session[Orchestrator.Globals.Constants.ReportParamsSessionVariable]     = reportParams;
                Session[Orchestrator.Globals.Constants.ReportDataSessionTableVariable]  = sheetData;
                Session[Orchestrator.Globals.Constants.ReportDataSessionSortVariable]   = String.Empty;
                Session[Orchestrator.Globals.Constants.ReportDataMemberSessionVariable] = "Table";

                reportViewer.Visible = true;
            }
        }
Esempio n. 13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (LoadOrderGroup())
            {
                //ConfigureDisplay();

                if (!IsPostBack)
                {
                    ConfigureDisplay();

                    // Detect presence of auto-add order and add the javascript to pop the add order window up (if presence detected).
                    if ((!string.IsNullOrEmpty(Request.QueryString[_addorder_QS]) && Request.QueryString[_addorder_QS].ToLower() == "true"))
                    {
                        LaunchAddOrderWindow();
                    }
                }
                else
                {
                    Facade.IOrder facOrder = new Facade.Order();
                    this.IsBeingInvoiced = facOrder.IsOrderBeingInvoiced(OrderGroup.OrderIDs());
                }
            }
            else
            {
                // Invalid order group specified.
            }
        }
Esempio n. 14
0
        void btnRemoveAll_Click(object sender, EventArgs e)
        {
            if (OrderGroup != null && OrderGroup.Orders.Count > 0)
            {
                List <int> orderIDs = new List <int>();
                foreach (Entities.Order order in OrderGroup.Orders)
                {
                    if (!orderIDs.Contains(order.OrderID))
                    {
                        orderIDs.Add(order.OrderID);
                    }
                }

                Facade.IOrderGroup facOrderGroup = new Facade.Order();
                FacadeResult       result        =
                    facOrderGroup.RemoveOrdersFromGroup(OrderGroup.OrderGroupID, orderIDs,
                                                        ((CustomPrincipal)User).UserName);
                if (result.Success)
                {
                    RebindPage();
                }
                else
                {
                    DisplayInfringments(result);
                }
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Checks the querystring for a valid order group id and, if one
        /// is found, attempts to load the relevant order group.
        /// </summary>
        /// <returns>True if the order group was loaded, False otherwise.</returns>
        private bool LoadOrderGroup()
        {
            int orderGroupID;

            if (int.TryParse(Request.QueryString[_orderGroupID_QS], out orderGroupID))
            {
                // Set the viewstate element.
                this.OrderGroupID = orderGroupID;
            }
            else
            {
                // Attempt to read from the viewstate element.
                orderGroupID = OrderGroupID;
            }

            if (orderGroupID > 0)
            {
                Facade.IOrderGroup facOrderGroup = new Facade.Order();
                OrderGroup = facOrderGroup.Get(orderGroupID);

                _decimalPlaces = GetDecimalPlaces(OrderGroup);
            }

            return(OrderGroup != null);
        }
Esempio n. 16
0
        //-----------------------------------------------------------------------------------------------------------

        public DataSet GetData()
        {
            DataSet dsOrders      = null;
            int     orderId       = -1;
            int     instructionId = -1;

            Facade.IOrder facOrder = new Facade.Order();

            if (Request.QueryString["OrderId"] != null)
            {
                int.TryParse(Request.QueryString["OrderId"].ToString(), out orderId);
                dsOrders = facOrder.GetOrdersOnSameDropInstruction(orderId);
            }
            else
            {
                int.TryParse(Request.QueryString["InstructionId"].ToString(), out instructionId);
                dsOrders = facOrder.GetOrdersForInstructionID(instructionId);
            }

            if (dsOrders != null && dsOrders.Tables[0].Rows.Count > 0)
            {
                lblTitleDelivery.Text = dsOrders.Tables[0].Rows[0]["DeliveryPointDescription"].ToString();
            }
            else
            {
                lblTitleDelivery.Text = String.Empty;
            }

            return(dsOrders);
        }
Esempio n. 17
0
        void cboExtraType_SelectedIndexChanged(object sender, EventArgs e)
        {
            eExtraType extraType = (eExtraType)Enum.Parse(typeof(eExtraType), cboExtraType.SelectedValue.Replace(" ", ""));

            if (this.OrderID > 0)
            {
                Facade.IOrder  facOrder = new Facade.Order();
                Entities.Order order    = facOrder.GetForOrderID(this.OrderID);
                IEnumerable <Repositories.DTOs.RateSurcharge> surcharges = null;

                try
                {
                    Repositories.DTOs.RateInformation rateInfo = facOrder.GetRate(order, true, out surcharges);
                }
                catch (ApplicationException)
                {
                    // Swallow application exceptions as get rate can fall over if a rate cannot be
                    // found for a given postcode. If this happens then we don't really care.
                }

                if (surcharges != null)
                {
                    var rs = (from s in surcharges
                              where s.ExtraTypeID == (int)extraType
                              select s).FirstOrDefault();

                    if (rs != null)
                    {
                        rntAmount.Value = (double?)rs.ForeignRate;
                    }
                }
            }
        }
Esempio n. 18
0
        private void PrepareOrders()
        {
            if (!IsPostBack)
            {
                OrdersCSV = PreviousPage.Orders;
            }

            Facade.IOrder facOrder = new Facade.Order();
            DataSet       dsOrders = facOrder.GetOrdersForList(OrdersCSV, true, false);

            Facade.IOrganisation  facOrg   = new Facade.Organisation();
            Entities.Organisation org      = facOrg.GetForIdentityId(Globals.Configuration.IdentityId);
            Facade.IPoint         facPoint = new Facade.Point();
            Entities.Point        deliveryRunCollectionPoint = null;
            if (org.Defaults[0].GroupageDeliveryRunCollectionPoint > 0)
            {
                deliveryRunCollectionPoint = facPoint.GetPointForPointId(org.Defaults[0].GroupageDeliveryRunCollectionPoint);
            }

            dsOrders.Tables[0].Columns.Add("CollectFromPointID", typeof(int));
            dsOrders.Tables[0].Columns.Add("CollectFromPoint", typeof(string));
            dsOrders.Tables[0].Columns.Add("CollectAtDateTime", typeof(DateTime));
            dsOrders.Tables[0].Columns.Add("CollectAtAnyTime", typeof(bool));
            dsOrders.Tables[0].Columns.Add("LoadOrder", typeof(string));
            dsOrders.Tables[0].Columns.Add("DeliveryOrder", typeof(int));

            int loadOrder = 1;

            foreach (DataRow row in dsOrders.Tables[0].Rows)
            {
                row["CollectFromPointID"] = (int)row["DeliveryRunCollectionPointID"];
                row["CollectFromPoint"]   = row["DeliveryRunCollectionPointDescription"].ToString();
                row["CollectAtDateTime"]  = (DateTime)row["DeliveryRunCollectionDateTime"];
                row["CollectAtAnyTime"]   = (bool)row["DeliveryRunCollectionIsAnyTime"];
                if (loadOrder == dsOrders.Tables[0].Rows.Count)
                {
                    row["LoadOrder"] = "L";
                }
                else
                {
                    row["LoadOrder"] = loadOrder.ToString();
                }
                loadOrder++;

                // Set the default collection point to that specified by the organisation settings
                if (row["LastPlannedOrderActionID"] == DBNull.Value)
                {
                    if (deliveryRunCollectionPoint != null)
                    {
                        row["CollectFromPointID"] = deliveryRunCollectionPoint.PointId;
                        row["CollectFromPoint"]   = deliveryRunCollectionPoint.Description;
                    }
                }
            }

            dsOrders.AcceptChanges();
            OrderData = dsOrders;
            grdOrders.Rebind();
        }
Esempio n. 19
0
        private void BindCollectDrops()
        {
            Facade.IOrder facOrder = new Facade.Order();
            DataSet       dsOrders = facOrder.GetForJob(this.JobID);

            gvDockets.DataSource = dsOrders;
            gvDockets.DataBind();
        }
Esempio n. 20
0
        private void PopulateStaticControls()
        {
            if (m_instructionId > 0)
            {
                Facade.IOrder facOrder  = new Facade.Order();
                DataSet       dsclients = facOrder.GetOrdersForInstructionID(this.InstructionID);
                cboClient.DataSource = dsclients;
                cboClient.DataBind();

                List <String> Clients = new List <string>();

                foreach (DataRow row in dsclients.Tables[0].Rows)
                {
                    if (!Clients.Contains(row["CustomerOrganisationName"].ToString()))
                    {
                        Clients.Add(row["CustomerOrganisationName"].ToString());
                    }
                }

                if (Clients.Count == 1)
                {
                    cboClient.Enabled           = false;
                    cboClient.Items[0].Selected = true;
                }
            }
            else
            {
                trClient.Visible = false;
            }


            Facade.ExtraType facExtraType        = new Orchestrator.Facade.ExtraType();
            bool?            getActiveExtraTypes = true;

            cboExtraType.DataSource     = facExtraType.GetForIsEnabled(getActiveExtraTypes);
            cboExtraType.DataValueField = "ExtraTypeId";
            cboExtraType.DataTextField  = "Description";

            cboExtraState.DataSource = Utilities.UnCamelCase(Enum.GetNames(typeof(eExtraState)));

            // If culture set, set culture of amount textbox, otherwise, set to system default.
            if (m_lcid > 0)
            {
                rntAmount.Culture = new CultureInfo(m_lcid);
            }
            else
            {
                rntAmount.Culture = new CultureInfo(Orchestrator.Globals.Configuration.NativeCulture);
            }

            Page.DataBind();

            //If its for Demurrage then pre-select the demurrage extra
            if (m_demurrage)
            {
                cboExtraType.SelectedValue = ((int)eExtraType.Demurrage).ToString();
            }
        }
Esempio n. 21
0
        private void exportButton_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }

            var customerIdentityID      = Utilities.ParseNullable <int>(clientCombo.SelectedValue);
            var fromDate                = this.startDate.SelectedDate.Value.Date;
            var toDate                  = this.endDate.SelectedDate.Value.Date;
            var businessTypeIDs         = this.businessTypeCheckList.AllBusinessTypesSelected ? null : this.businessTypeCheckList.SelectedBusinessTypeIDs;
            var subcontractorIdentityID = Utilities.ParseNullable <int>(this.cboSubcontractor.SelectedValue);
            var isInvoiced              = this.rblInvoiced.SelectedIndex == 1 ? false : this.rblInvoiced.SelectedIndex == 2 ? true : (bool?)null;
            var hasSubcontractorInvoice = this.rblSubcontractorInvoiced.SelectedIndex == 1 ? false : this.rblInvoiced.SelectedIndex == 2 ? true : (bool?)null;

            Facade.IOrder facOrder = new Facade.Order();
            var           dtSource = facOrder.GetOrderListForExport(customerIdentityID, fromDate, toDate, businessTypeIDs, subcontractorIdentityID, isInvoiced, hasSubcontractorInvoice).Tables[0];

            if (dtSource.Rows.Count == 0)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "NoData", "$(function() { alert('No matching orders were found'); });", true);
                return;
            }

            Func <DataRow, string, string> dateFormatter             = (dr, col) => dr.Field <DateTime>(col).ToShortDateString();
            Func <DataRow, string, string> nullableCurrencyFormatter = (dr, col) => string.Format("{0:n2}", dr.Field <decimal?>(col));
            Func <DataRow, string, string> nullableIntFormatter      = (dr, col) => string.Format("{0}", dr.Field <int?>(col));

            CsvExport.Export(
                dtSource,
                "Orders.csv",
                new CsvExport.ColumnMappings
            {
                { "OrderID", "Order ID" },
                { "CustomerName", "Customer" },
                { "DeliveryOrderNumber", "Docket number" },
                { "CustomerOrderNumber", "Load number" },
                { "JobID", "Run ID", nullableIntFormatter },
                { "BusinessType", "Business Type" },
                { "CollectionPoint", "Collection point" },
                { "CollectionPostcode", "Collection postcode" },
                { "DeliveryPoint", "Delivery point" },
                { "DeliveryPostcode", "Delivery postcode" },
                { "PalletSpaces", "Pallet spaces" },
                { "Weight", "Weight" },
                { "SubcontractorRate", "Subcontractor cost", nullableCurrencyFormatter },
                { "ForeignRateIncludingFuelSurcharge", "Total revenue" },
                { "ExtrasForeignTotal", "Extras" },
                { "FuelSurchargeForeignAmount", "Fuel surcharge" },
                { "ForeignRate", "Revenue" },
                { "CollectionDateTime", "Collection date", dateFormatter },
                { "DeliveryDateTime", "Delivery date", dateFormatter },
                { "SubcontractorName", "Subcontractor" },
                { "OrderStatus", "Order status" },
                { "HasSubcontractorInvoice", "Has subcontractor invoice?", (dr, col) => dr.Field <bool>(col) ? "Yes" : "No" },
            });
        }
Esempio n. 22
0
        private void LoadOrder()
        {
            int orderID = Utilities.ParseNullable <int>(Request.QueryString["orderID"]) ?? 0;

            Facade.IOrder facOrder = new Facade.Order();
            var           order    = facOrder.GetForOrderID(orderID);

            string msg       = null;
            bool   canCancel = false;

            if (order == null)
            {
                msg = "Error: order cannot be found";
            }
            else
            {
                eCannotCancelOrderReason?reason;
                IEnumerable <int>        ordersToCancel;
                canCancel = facOrder.CanRejectOrCancel(order, out ordersToCancel, out reason);

                if (canCancel)
                {
                    this.OrdersToCancel = ordersToCancel.ToArray();
                    var otherOrders = ordersToCancel.Where(oid => oid != orderID);

                    if (otherOrders.Any())
                    {
                        // Display a warning message... note that canCancel is true so this will be displayed but still allow the user to proceed with cancelling the orders.
                        msg = string.Format(
                            "This order is part of a group which may only be cancelled as a whole.  As a result, if you continue, order{0} {1} will also be cancelled.",
                            otherOrders.Count() == 1 ? string.Empty : "s",
                            Entities.Utilities.SentenceMerge(otherOrders.Select(oid => oid.ToString())));
                    }
                }
                else
                {
                    var messages = new Dictionary <eCannotCancelOrderReason, string>
                    {
                        { eCannotCancelOrderReason.Already_Rejected, "Cannot cancel: the order has already been rejected." },
                        { eCannotCancelOrderReason.Already_Cancelled, "Cannot cancel: the order has already been cancelled." },
                        { eCannotCancelOrderReason.Invoiced, "Cannot cancel: this order has been invoiced." },
                        { eCannotCancelOrderReason.Grouped_With_Delivered, "This order cannot be cancelled because it is part of a group which may only be cancelled as a whole and which contains one or more orders which have already been delivered." },
                        { eCannotCancelOrderReason.Grouped_With_On_Run, "This order cannot be cancelled because it is part of a group which may only be cancelled as a whole and which contains one or more orders which are on a run.  All orders in the group must first be removed from any run they are on." },
                    };

                    msg = messages[reason.Value];
                }
            }

            lblCancellationMessage.Text    = msg;
            pnlCancellationMessage.Visible = !string.IsNullOrEmpty(msg);

            txtCancellationReason.Text    = order.CancellationReason;
            pnlCancellationReason.Visible = canCancel || txtCancellationReason.Text.Length > 0;

            btnConfirm.Visible = canCancel;
        }
Esempio n. 23
0
        private void FindOrder()
        {
            // 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);
            bool searchCustomFields = true;

            if (PFInvoice != null && PFInvoice.InvoiceType == eInvoiceType.PFDepotCharge)
            {
                orderStatusIDs.Add((int)eOrderStatus.Invoiced);
            }

            List <int> businessTypeIDs = new List <int>();

            foreach (ListItem li in cblBusinessType.Items)
            {
                if (li.Selected)
                {
                    businessTypeIDs.Add(int.Parse(li.Value));
                }
            }

            // Retrieve the client id, resource id, and sub-contractor identity id.
            int clientID = 0, resourceID = 0, subContractorIdentityID = 0;

            int.TryParse(cboClient.SelectedValue, out clientID);
            int.TryParse(cboResource.SelectedValue, out resourceID);
            int.TryParse(cboSubContractor.SelectedValue, out subContractorIdentityID);

            // Find the orders.
            if (dteStartDate.SelectedDate == null)
            {
                dteStartDate.SelectedDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 01);
            }
            if (dteEndDate.SelectedDate == null || dteEndDate.SelectedDate < dteStartDate.SelectedDate)
            {
                dteEndDate.SelectedDate = DateTime.Today;
            }

            if (chkSearchByOrderID.Checked)
            {
                searchCustomFields = false;
            }

            Facade.IOrder            facOrder = new Facade.Order();
            Facade.IJobSubContractor facJSC   = new Facade.Job();
            DataSet orderData = facOrder.Search(orderStatusIDs, (DateTime)dteStartDate.SelectedDate, (DateTime)dteEndDate.SelectedDate, txtSearch.Text, true, true, true, true, clientID, resourceID, subContractorIdentityID, businessTypeIDs, 0, 0, 0, searchCustomFields);

            var queryResultsSet = orderData.Tables[0].AsEnumerable();

            grdOrders.DataSource = queryResultsSet;
            grdOrders.DataBind();
        }
Esempio n. 24
0
        void grdOrders_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            List <int> businessTypeIDs = new List <int>();

            foreach (ListItem li in cblBusinessTypes.Items)
            {
                if (li.Selected)
                {
                    businessTypeIDs.Add(int.Parse(li.Value));
                }
            }

            List <int> trafficAreaIDs = new List <int>();

            foreach (ListItem li in cblTrafficAreas.Items)
            {
                if (li.Selected)
                {
                    trafficAreaIDs.Add(int.Parse(li.Value));
                }
            }

            Facade.IOrder facOrder = new Facade.Order();
            DateTime      endDate  = dteEndDate.SelectedDate.Value.Add(new TimeSpan(23, 59, 59));

            DataSet orderData = facOrder.GetOrdersForDelivery(dteStartDate.SelectedDate.Value, endDate, trafficAreaIDs, businessTypeIDs, this.SurchargeIDs, this.ServiceLevelIDs, rblDateFiltering.SelectedItem == null ? C_DEFAULT_DATE_FILTERING : (eDateFilterType)Enum.Parse(typeof(eDateFilterType), rblDateFiltering.SelectedItem.Value), chkBookedInYes.Checked, chkBookedInNo.Checked, null, null, chkNoTrunkDate.Checked);

            // Build the surcharge lookup data.
            this.SurchargeLookupData.Clear();
            if (orderData.Tables.Count > 1)
            {
                foreach (DataRow row in orderData.Tables[1].Rows)
                {
                    int    orderID     = (int)row["OrderID"];
                    string description = (string)row["Description"];

                    if (this.SurchargeLookupData.ContainsKey(orderID))
                    {
                        this.SurchargeLookupData[orderID] = string.Format("{0}, {1}", this.SurchargeLookupData[orderID], description);
                    }
                    else
                    {
                        this.SurchargeLookupData[orderID] = description;
                    }
                }
            }

            DataView dv = orderData.Tables[0].DefaultView;

            if (!string.IsNullOrEmpty(RowFilter))
            {
                dv.RowFilter = this.RowFilter;
            }

            grdDeliveries.DataSource = dv;
        }
Esempio n. 25
0
        private void LoadServiceLevels()
        {
            Facade.IOrderServiceLevel facServiceLevel = new Facade.Order();

            cboServiceLevel.DataValueField = "OrderServiceLevelID";
            cboServiceLevel.DataTextField  = "Description";
            cboServiceLevel.DataSource     = facServiceLevel.GetAll();
            cboServiceLevel.DataBind();
            cboServiceLevel.Items.Insert(0, new RadComboBoxItem("Any"));
        }
Esempio n. 26
0
 private void cboAllocatedTo_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
 {
     if (OrderGroup != null)
     {
         int?allocatedToIdentityID        = Utilities.ParseNullable <int>(e.Value);
         Facade.IOrderGroup facOrderGroup = new Facade.Order();
         facOrderGroup.UpdateAllocation(OrderGroupID, allocatedToIdentityID, true, Page.User.Identity.Name);
         RebindPage();
     }
 }
Esempio n. 27
0
        void grdOrders_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
        {
            if (!IsCallback && (IsPostBack || m_isFromDash))
            {
                int           clientID;
                bool          getUnflaggedOrders;
                StringBuilder bts = new StringBuilder();
                StringBuilder sls = new StringBuilder();

                int.TryParse(cboClient.SelectedValue, out clientID);
                getUnflaggedOrders = rdoListOrderTypes.SelectedItem.Value == "Unflagged";

                foreach (ListItem li in cblBusinessType.Items)
                {
                    if (li.Selected)
                    {
                        bts.Append(bts.Length > 0 ? "," + li.Value : li.Value);
                    }
                }

                foreach (ListItem li in cblServiceLevel.Items)
                {
                    if (li.Selected)
                    {
                        sls.Append(sls.Length > 0 ? "," + li.Value : li.Value);
                    }
                }



                Facade.IOrder facOrder = new Facade.Order();
                DataSet       ds       = facOrder.GetOrdersThatCanBeFlaggedForInvoicing(
                    rdiStartDate.SelectedDate.Value,
                    rdiEndDate.SelectedDate.Value,
                    rdoListInvoiceType.Items[0].Selected || rdoListInvoiceType.Items[2].Selected,
                    rdoListInvoiceType.Items[1].Selected || rdoListInvoiceType.Items[2].Selected,
                    rblJobs.Items[0].Selected || rblJobs.Items[1].Selected,
                    rblJobs.Items[0].Selected || rblJobs.Items[2].Selected,
                    rblPricing.Items[0].Selected || rblPricing.Items[1].Selected,
                    rblPricing.Items[0].Selected || rblPricing.Items[2].Selected,
                    rblPricing.Items[0].Selected || rblPricing.Items[3].Selected,
                    bts.ToString(),
                    sls.ToString(),
                    getUnflaggedOrders,
                    clientID,
                    chkShowExcluded.Checked);

                grdOrders.DataSource = ds;
            }
            else
            {
                // No need to show on first load.
                grdOrders.DataSource = null;
            }
        }
Esempio n. 28
0
        void gvOrders2_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            // Determine the parameters
            bool       plannedForCollection = chkPlannedForCollection.Checked;
            bool       plannedForDelivery   = chkPlannedForDelivery.Checked;
            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)));
                }
            }

            List <int> lastPlannedActions = new List <int>();

            if (chkCrossDock.Checked)
            {
                lastPlannedActions.Add((int)eOrderAction.Cross_Dock);
            }
            if (chkTransShipped.Checked)
            {
                lastPlannedActions.Add((int)eOrderAction.Trans_Ship);
            }
            if (chkLeaveOnTrailer.Checked)
            {
                lastPlannedActions.Add((int)eOrderAction.Leave_On_Trailer);
            }

            List <int> businessTypeIDs = new List <int>();

            foreach (ListItem businessType in cboBusinessType.Items)
            {
                if (businessType.Selected)
                {
                    businessTypeIDs.Add(int.Parse(businessType.Value));
                }
            }

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

            if (tdDateOptions.Visible)
            {
                orderData = facOrder.GetOrdersForStatusAndDateRange(orderStatusIDs, plannedForCollection, plannedForDelivery, dteStartDate.SelectedDate.Value, dteEndDate.SelectedDate.Value, lastPlannedActions, businessTypeIDs);
            }
            else
            {
                orderData = facOrder.GetOrdersForStatus(orderStatusIDs, plannedForCollection, plannedForDelivery, lastPlannedActions, businessTypeIDs);
            }
            gvOrders2.DataSource = orderData;

            lblOrderCount.Text = orderData.Tables[0].Rows.Count.ToString();
        }
Esempio n. 29
0
        void grdJobs_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
        {
            Telerik.Web.UI.GridDataItem dataItem = e.DetailTableView.ParentItem as Telerik.Web.UI.GridDataItem;

            if (e.DetailTableView.Name == "Orders")
            {
                int           jobID    = int.Parse(((HyperLink)dataItem["JobId"].Controls[0]).Text);
                Facade.IOrder facOrder = new Facade.Order();

                e.DetailTableView.DataSource = facOrder.GetOrdersForJob(jobID);
            }
        }
Esempio n. 30
0
 void grdOrders_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
 {
     if (OrderGroup != null)
     {
         Facade.IOrder facOrder = new Facade.Order();
         grdOrders.DataSource = facOrder.GetOrdersForList(OrderGroup.OrderIDs(), true, false);
     }
     else
     {
         grdOrders.DataSource = null;
     }
 }