//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();
            }
        }
예제 #2
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);
        }
예제 #3
0
        private void btnEditRates_Click(object sender, EventArgs e)
        {
            if (this.grdOrders.Items.Count > 0)
            {
                Button editRates = (Button)sender;
                if (editRates.Text == "Edit Rates")
                {
                    foreach (GridItem item in grdOrders.MasterTableView.Items)
                    {
                        if (item is GridEditableItem)
                        {
                            GridEditableItem editableItem = item as GridDataItem;
                            editableItem.Edit = true;
                        }
                    }
                    this.btnEditRates.Text = "Update Rates";
                }
                else
                {
                    foreach (GridEditableItem editedItem in grdOrders.EditItems)
                    {
                        bool orderInGroupOverridden = false;
                        bool updateOrder            = false;
                        // UpdateRate if it has changed

                        HtmlInputText txtRate = editedItem.FindControl("txtOrderRate") as HtmlInputText;
                        int           orderId = int.Parse(editedItem.GetDataKeyValue("OrderID").ToString());

                        Facade.IOrder facOrder = new Facade.Order();
                        // get the data item so we can compare the rate before it was changed
                        Entities.Order order = facOrder.GetForOrderID(orderId);

                        CheckRateInformation(order, ref orderInGroupOverridden, ref updateOrder);

                        CultureInfo culture = new CultureInfo(order.LCID);
                        decimal     newRate = Decimal.Parse(txtRate.Value, NumberStyles.Any, culture);

                        if (newRate != order.ForeignRate)
                        {
                            // Mark as overridden... update the rate on the order.
                            order.ForeignRate = newRate;
                            if (!order.IsTariffOverride)
                            {
                                order.IsTariffOverride     = true;
                                order.TariffOverrideDate   = DateTime.Now;
                                order.TariffOverrideUserID = User.Identity.Name;
                            }

                            // Recalculate the GBP amounts
                            BusinessLogicLayer.IExchangeRates    blER = new BusinessLogicLayer.ExchangeRates();
                            BusinessLogicLayer.CurrencyConverter currencyConverter = blER.CreateCurrencyConverter(order.LCID, order.CollectionDateTime);
                            order.Rate = currencyConverter.ConvertToLocal(order.ForeignRate);

                            updateOrder = true;
                        }

                        // Update the order as the CheckRateInformation method may have amended the order
                        if (updateOrder)
                        {
                            facOrder.Update(order, User.Identity.Name);
                        }

                        if (orderInGroupOverridden && order.OrderGroupID > 0)
                        {
                            Facade.IOrderGroup  facOrderGroup = new Facade.Order();
                            Entities.OrderGroup orderGroup    = facOrderGroup.Get(order.OrderGroupID);
                            orderGroup.TariffRateDescription = "Overridden";
                            facOrderGroup.Update(orderGroup, this.Page.User.Identity.Name);
                        }

                        editedItem.Edit = false;
                    }
                    this.btnEditRates.Text = "Edit Rates";
                }

                this.grdOrders.Rebind();
            }
        }