Пример #1
0
//-------------------------------------------------------------------------------------------
        public decimal CalculateMonthlyTotal()
        {
            decimal cost = 0;

            foreach (Control ctrl in UpdatePanel1.ContentTemplateContainer.FindControl("OrderFormControls").Controls)
            {
                if (ctrl.GetType() == typeof(DropDownList))
                {
                    DropDownList ddl = (DropDownList)ctrl;
                    //DropDownList ddl = (DropDownList) UpdatePanel1.ContentTemplateContainer.FindControl("OrderForm").FindControl("feature-" + i.ToString());
                    if (ddl != null)
                    {
                        Guid featureOptionId;
                        Guid.TryParse(ddl.SelectedValue, out featureOptionId);
                        using (WeavverEntityContainer data = new WeavverEntityContainer())
                        {
                            Logistics_FeatureOptions option = (from x in data.Logistics_FeatureOptions
                                                               where x.Id == featureOptionId
                                                               select x).First();
                            if (option != null && option.BillingType == FeatureBillingType.Monthly.ToString())
                            {
                                cost += option.Cost;
                            }
                        }
                    }
                }
            }
            return(cost + item.UnitMonthly);
        }
Пример #2
0
//-------------------------------------------------------------------------------------------
        public decimal CalculateOneTimeCosts()
        {
            using (WeavverEntityContainer data = new WeavverEntityContainer())
            {
                decimal total = 0;
                for (int i = 0; i < 5; i++)
                {
                    DropDownList ddl = (DropDownList)UpdatePanel1.ContentTemplateContainer.FindControl("OrderFormControls").FindControl("feature-" + i.ToString());
                    if (ddl != null)
                    {
                        Guid featureOptionId;
                        Weavver.Utilities.Common.GuidTryParse(ddl.SelectedValue, out featureOptionId);
                        Logistics_FeatureOptions option = (from x in data.Logistics_FeatureOptions
                                                           where x.Id == featureOptionId
                                                           select x).First();
                        if (option != null && option.BillingType == FeatureBillingType.OneTime.ToString())
                        {
                            total += option.Cost;
                        }
                    }
                }
                return(total + item.UnitRetailPrice);
            }
        }
Пример #3
0
//-------------------------------------------------------------------------------------------
        protected void Next_Click(object sender, EventArgs e)
        {
            string notes = item.BillingNotes;

            if (!String.IsNullOrEmpty(notes))
            {
                notes += "\r\n";
            }
            using (WeavverEntityContainer data = new WeavverEntityContainer())
            {
                var features = from x in data.Logistics_Features
                               where x.OrganizationId == SelectedOrganization.Id &&
                               x.ParentId == item.Id
                               orderby x.Name
                               select x;

                int idPos = 0;
                Sales_ShoppingCartItems shoppingCartItem = Sales_ShoppingCartItems.GetInstance(Server.MapPath("~/bin"), item.PluginURL);
                int i = 0;
                foreach (Logistics_Features feature in features)
                {
                    DropDownList ddl             = (DropDownList)UpdatePanel1.ContentTemplateContainer.FindControl("OrderFormControls").FindControl("feature-" + i.ToString());
                    Guid         featureOptionId = new Guid(ddl.SelectedValue);

                    Logistics_FeatureOptions option = (from x in data.Logistics_FeatureOptions
                                                       where x.Id == featureOptionId
                                                       select x).First();
                    notes += "- " + data.GetName(option.ParentId) + ": " + option.Name;
                    if (i < features.Count() - 1)
                    {
                        notes += "\r\n";
                    }
                    i++;
                }

                shoppingCartItem.SessionId      = Session.SessionID;
                shoppingCartItem.OrganizationId = SelectedOrganization.Id;
                shoppingCartItem.ProductId      = item.Id;
                if (LoggedInUser != null)
                {
                    shoppingCartItem.UserId = LoggedInUser.Id;
                }
                shoppingCartItem.Name     = item.Name;
                shoppingCartItem.Notes    = notes;
                shoppingCartItem.Deposit  = item.Deposit;
                shoppingCartItem.SetUp    = item.SetUp;  // TODO: add set-up summing for sub features - add provisioning time tracking to sub-features
                shoppingCartItem.UnitCost = CalculateOneTimeCosts();
                shoppingCartItem.Monthly  = CalculateMonthlyTotal();
                shoppingCartItem.Quantity = Int32.Parse(Quantity.Text);
                shoppingCartItem.RequiresOrganizationId = true;
                shoppingCartItem.BackLink = Request.Url.ToString();

                var customForm = (ISales_OrderForm)OrderFormCell.FindControlR <Control>("CustomOrderForm");
                if (customForm != null)
                {
                    customForm.BeforeAddingToCart(shoppingCartItem);
                }
                data.Sales_ShoppingCartItems.AddObject(shoppingCartItem);
                data.SaveChanges();

                string reviewurl = "~/workflows/sales_orderreview";
                if (Request["IFrame"] == "true")
                {
                    reviewurl += "?IFrame=true";
                }
                Response.Redirect(reviewurl);
            }
        }