コード例 #1
0
 protected void dlProduct_ItemDataBound(object sender, DataListItemEventArgs e)
 {
     if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
     {
         Product product = e.Item.DataItem as Product;
         Literal ltImage = e.Item.FindControl("ltImage") as Literal;
         if (ltImage != null)
         {
             ltImage.Text = "<div class=\"productImage\" style=\"background-image:url(" + GlobalSettings.RelativeWebRoot + product.GetDefaultImageUrl(100, 100) + ")\"></div>";
         }
         Literal ltPrice = e.Item.FindControl("ltPrice") as Literal;
         if (ltPrice != null)
         {
             decimal?p1        = null;
             decimal?p2        = null;
             decimal?p         = null;
             string  priceText = string.Empty;
             if (!Context.User.Identity.IsAuthenticated)
             {
                 p1        = ProductPrices.GetPriceDefault(product.ProductID);
                 p2        = IsPromote(product.ProductID) ? ProductPrices.GetPricePromote(0, product.ProductID) : null;
                 priceText = GlobalSettings.GetPrice(p1, p2);
             }
             else
             {
                 p1        = ProductPrices.GetPriceMarket(Profile.AccountInfo.UserID, product.ProductID);
                 p2        = ProductPrices.GetPriceMember(Profile.AccountInfo.UserID, product.ProductID);
                 p         = IsPromote(product.ProductID) ?ProductPrices.GetPricePromote(Profile.AccountInfo.UserID, product.ProductID):null;
                 priceText = GlobalSettings.GetPrice(true, p, GlobalSettings.GetMinPrice(p1, p2));
             }
             ltPrice.Text = priceText;
         }
     }
 }
コード例 #2
0
 public ProductPrice GetProductPrice(DateTime date)
 {
     return(ProductPrices
            .Where(pp => pp.Date <= date)
            .OrderBy(pp => pp.Date)
            .LastOrDefault());
 }
コード例 #3
0
        public ActionResult Edit(int?id)
        {
            EditProduct editProduct;

            if (id.HasValue)
            {
                editProduct = Mapper.Map <EditProduct>(Products.GetByID(id.Value));

                editProduct.Text               = HttpUtility.HtmlDecode(editProduct.Text);
                editProduct.GroupUrlPerfix     = Groups.GetByID(editProduct.GroupID.Value).UrlPerfix;
                editProduct.Groups             = ProductGroups.GetByProductID(editProduct.ID).Select(item => item.GroupID).ToList();
                editProduct.Images             = ProductImages.GetByProductID(editProduct.ID);
                editProduct.Files              = ProductFiles.GetByProductID(editProduct.ID);
                editProduct.Marks              = ProductMarks.GetByProductID(editProduct.ID);
                editProduct.Points             = ProductPoints.GetByProductID(editProduct.ID);
                editProduct.Keywords           = ProductKeywords.GetByProductID(editProduct.ID);
                editProduct.Notes              = ProductNotes.GetByProductID(editProduct.ID);
                editProduct.ProductPricesLinks = ProductPricesLinks.GetByProductID(editProduct.ID);

                editProduct.Supplies = ProductSupplies.GetByProductID(editProduct.ID);
                editProduct.Prices   = ProductPrices.GetByProductID(editProduct.ID);
                editProduct.Varients = ProductVarients.GetByProductID(editProduct.ID);

                editProduct.Discounts = ProductDiscounts.GetAllByProductID(editProduct.ID);
            }
            else
            {
                editProduct        = new EditProduct();
                editProduct.userID = UserID;
            }

            return(View(editProduct));
        }
コード例 #4
0
    protected void Button41_Click(object sender, EventArgs e)
    {
        decimal?price = ProductPrices.GetPriceMarket(10, 23);

        lblCacheTip.Text = price.HasValue ? price.Value.ToString() : "询价";
        price            = ProductPrices.GetPriceMember(10, 23);
        Label5.Text      = price.HasValue ? price.Value.ToString() : "询价";
    }
コード例 #5
0
        /// <summary>
        /// Readjust and Recalulate Prices.
        /// </summary>
        public void RecalculatePrices()
        {
            // TODO Allow for this to be modified by variations
            // TODO Create a way to allow for faster Price changes, when supply/demand differences are large.
            // for each product in the market.
            foreach (var pair in ProductPrices)
            {
                // Get the product
                var product = pair.Item1;

                double surplus;
                double shortfall;

                try
                {
                    // get surplus product not spent
                    surplus = Surplus.GetProductValue(product);

                    // get product that was desired to buy.
                    shortfall = Shortfall.GetProductValue(product);
                }
                catch (KeyNotFoundException)
                {
                    // if the item does not exist in surplus or shortfal, then it probably was not
                    // sold or desired in the market. Give it a boost to denote it's rarity, and try and encourage it.
                    ProductPrices.AddProducts(product, 0.01);
                    continue;
                }
                // the amount of change to make to the good's price.
                double priceChange = 0;

                // If any surplus and shortfall exists, price was too high
                if (surplus > 0 && shortfall > 0)
                {
                    priceChange += -0.01;
                }
                else if (surplus > 0)
                {
                    // If no shortfall but still surplus, try lowering price to sell it, oversupply is not good.
                    priceChange += -0.01;
                }
                else if (shortfall > 0)
                { // if shortfall but no surplus, price is too low.
                    priceChange += 0.01;
                }
                // In no surplus nor shortfall, then we have hit equilibrium.
                // No change in price.

                // add the change in price to the new price
                // TODO make this more flexible and reactive.
                // going in 0.01 ABS price unit sized steps is too small
                // and may make prices too stagnant
                var newPrice = ProductPrices.GetProductValue(product) + priceChange;

                // update to said price.
                ProductPrices.SetProductAmount(product, newPrice);
            }
        }
コード例 #6
0
        /// <summary>
        /// Gets a price for a good.
        /// </summary>
        /// <param name="product">The product we are pricing</param>
        /// <returns>The price in abstract currency.</returns>
        /// <exception cref="ArgumentNullException">
        /// If Product is null.
        /// </exception>
        public double GetPrice(IProduct product)
        {
            if (product is null)
            {
                throw new ArgumentNullException(nameof(product));
            }

            return(ProductPrices.GetProductValue(product));
        }
コード例 #7
0
        public decimal GetProductProfit(DateTime date)
        {
            var p = ProductPrices
                    .Where(pp => pp.Date <= date)
                    .OrderBy(pp => pp.Date)
                    .LastOrDefault();

            return(p.SellingPrice - p.PurchasePrice);
        }
コード例 #8
0
ファイル: MockClasses.cs プロジェクト: adamantzg/C2Portal
 public ApiClientMockData()
 {
     Orders         = new List <Order>();
     Invoices       = new List <Invoice>();
     CustomerTotals = new CustomerTotals();
     Order          = new Order();
     OrderTotals    = new OrderTotals();
     OrderDetails   = new List <OrderDetail>();
     StockData      = new StockData();
     ProductPrices  = new ProductPrices();
 }
コード例 #9
0
    void BindData()
    {
        ProductPrice price = ProductPrices.GetPrice(priceID);

        if (price == null)
        {
            price = new ProductPrice();
        }
        else
        {
            productID = price.ProductID;
        }

        Product product = Products.GetProduct(productID);

        if (product != null)
        {
            this.hyProductName.Text        = product.ProductName;
            this.hyProductName.NavigateUrl = GlobalSettings.RelativeWebRoot + "controlpanel/controlpanel.aspx?product-product&&id=" + productID;
        }
        else
        {
            throw new HHException(ExceptionType.ProductNotFound, "未找到商品信息!");
        }

        txtApplyTaxRate.Text   = price.ApplyTaxRate.ToString();
        txtPriceFloor.Text     = price.PriceFloor.HasValue ? price.PriceFloor.Value.ToString() : string.Empty;
        txtPriceGradeA.Text    = price.PriceGradeA.HasValue ? price.PriceGradeA.Value.ToString() : string.Empty;
        txtPriceGradeB.Text    = price.PriceGradeB.HasValue ? price.PriceGradeB.Value.ToString() : string.Empty;
        txtPriceGradeC.Text    = price.PriceGradeC.HasValue ? price.PriceGradeC.Value.ToString() : string.Empty;
        txtPriceGradeD.Text    = price.PriceGradeD.HasValue ? price.PriceGradeD.Value.ToString() : string.Empty;
        txtPriceGradeE.Text    = price.PriceGradeE.HasValue ? price.PriceGradeE.Value.ToString() : string.Empty;
        txtPriceMarket.Text    = price.PriceMarket.HasValue ? price.PriceMarket.Value.ToString() : string.Empty;
        txtPricePromotion.Text = price.PricePromotion.HasValue ? price.PricePromotion.Value.ToString() : string.Empty;
        txtPricePurchase.Text  = price.PricePurchase.HasValue ? price.PricePurchase.Value.ToString() : string.Empty;
        if (price.QuoteEnd != DateTime.MinValue)
        {
            txtQuoteEnd.Text = price.QuoteEnd.ToString("yyyy年MM月dd日");
        }
        if (price.QuoteFrom != DateTime.MinValue)
        {
            txtQuoteFrom.Text = price.QuoteFrom.ToString("yyyy年MM月dd日");
        }
        txtQuoteMOQ.Text              = price.QuoteMOQ.HasValue ? price.QuoteMOQ.Value.ToString() : string.Empty;
        txtQuoteRenewal.Text          = price.QuoteRenewal.ToString();
        ddlSupplyRegion.SelectedValue = price.SupplyRegion.ToString();
        piDeliverySpan.DateSpanValue  = price.DeliverySpan;
        piFreight.SelectedValue       = price.IncludeFreight;
        piTax.SelectedValue           = price.IncludeTax;
        piWarrantySpan.DateSpanValue  = price.WarrantySpan;
        csPrice.SelectedValue         = price.SupplyStatus;
    }
コード例 #10
0
 public async static Task DeleteProductPrice(ProductPrice itemPara)
 {
     using (var db = new SalesContext())
     {
         //if (itemPara.Store != null)                                   //NOT DELETE - IMPORTANT
         //    db.Stores.Attach(itemPara.Store);
         //if (itemPara.Product != null)                                   //NOT DELETE - IMPORTANT
         //    db.Products.Attach(itemPara.Product);
         db.Entry(itemPara).State = EntityState.Unchanged;                       //NOT DELETE - IMPORTANT
         ProductPrices.Remove(itemPara);
         db.Entry(itemPara).State = EntityState.Deleted;
         await UpdateDatabase(db);
     }
 }
コード例 #11
0
        private static void SavePrices(EditProduct editProduct, int productID)
        {
            if (editProduct.Price.Price != 0)
            {
                var productPrice = new ProductPrice();

                productPrice.ProductID   = productID;
                productPrice.PriceType   = editProduct.Price.PriceType;
                productPrice.Price       = editProduct.Price.Price * (ExtensionMethods.IsRial ? 1 : 10);
                productPrice.Description = editProduct.Price.Description;

                ProductPrices.Insert(productPrice);
            }
        }
コード例 #12
0
        public ActionResult ExportToExcel(string jsonGroups)
        {
            var pricesdt = new System.Data.DataTable("Prices");

            var groups = Newtonsoft.Json.JsonConvert.DeserializeObject <List <int?> >(jsonGroups);

            var productprices = ProductPrices.GetByGroupIDs(groups);
            var varientPrices = ProductVarientPrices.GetByGroupIDs(groups);

            var prices = productprices.Union(varientPrices).Where(item => item.PriceID.HasValue || item.VarientID.HasValue);

            pricesdt.Columns.Add("ProductID", typeof(string));
            pricesdt.Columns.Add("PriceID", typeof(string));
            pricesdt.Columns.Add("VarientID", typeof(string));
            pricesdt.Columns.Add("PriceCode", typeof(string));
            pricesdt.Columns.Add("Title", typeof(string));
            pricesdt.Columns.Add("PriceType", typeof(string));
            pricesdt.Columns.Add("Price", typeof(string));
            pricesdt.Columns.Add("NewPrice", typeof(string));

            foreach (var item in prices)
            {
                pricesdt.Rows.Add(item.ProductID, item.PriceID, item.VarientID, item.PriceCode, item.Title, item.PriceType, item.Price, "");
            }

            var grid = new GridView();

            grid.Font.Name  = "tahoma";
            grid.Font.Size  = new FontUnit(11, UnitType.Pixel);
            grid.DataSource = pricesdt;
            grid.DataBind();

            Response.ClearContent();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment; filename=Prices.xls");
            Response.ContentType = "application/ms-excel";

            Response.Charset = "";
            StringWriter   sw  = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);

            grid.RenderControl(htw);

            Response.Output.Write(sw.ToString());
            Response.Flush();
            Response.End();

            return(View("MyView"));
        }
コード例 #13
0
    protected void egvProductPrices_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int priceID             = (int)egvProductPrices.DataKeys[e.RowIndex].Value;
        DataActionStatus status = ProductPrices.Delete(priceID);

        switch (status)
        {
        case DataActionStatus.Success:
            BindData();
            break;

        default:
        case DataActionStatus.UnknownFailure:
            throw new HHException(ExceptionType.Failed, "删除报价信息失败,请确认此报价信息存在,并状态正常!");
        }
    }
コード例 #14
0
        public void OnGet(string id)
        {
            ProductId   = id;
            ShowProduct = _context.PriceDetails.Any(e => e.CatalogEntryCode == id);

            if (ShowProduct)
            {
                // get price details for the product and sort by market->currency->date
                ProductPrices = _context.PriceDetails.AsNoTracking()
                                .Where(p => p.CatalogEntryCode == ProductId)
                                .OrderBy(p => p.MarketId)
                                .ThenBy(p => p.CurrencyCode)
                                .ThenBy(p => p.ValidUntil);

                OptimisedPrices = OptimisedPriceCalculator.Calculate(ProductPrices.ToList());
            }
        }
コード例 #15
0
        private async Task CheckProductsAndPricesOf(IEnumerable <RentedProduct> rentedProductList)
        {
            Products = await Tenant.Products
                       .WhereIdIn(rentedProductList.Select(p => p.ProductId))
                       .WhereMarketed(true)
                       .IncludePrices()
                       .ToListAsync();

            ProductPrices = Products.SelectMany(product => product.ProductPrices);

            HasOneOrMoreProductsNotFound    = rentedProductList.Count() != Products.Count();
            HasOneOrMoreProductsNotMarketed = Products.Any(product => !product.Marketed);
            HasOneOrMorePricesNotDefined    = !ProductPrices.Any() ||
                                              ProductPrices.Any(productPrice =>
                                                                productPrice == null ||
                                                                productPrice.UnitRentPrice == null);
        }
コード例 #16
0
        public async static Task AddProductPrice(ProductPrice itemPara)
        {
            using (var db = new SalesContext())
            {
                if (itemPara.Store != null)
                {
                    itemPara.StoreID         = itemPara.Store.Id;
                    itemPara.ProductID       = itemPara.Product.Id;
                    db.Entry(itemPara).State = EntityState.Unchanged;
                }
                db.ProductPrices.Add(itemPara);
                await UpdateDatabase(db);

                CodeGenerate(itemPara);
                await UpdateDatabase(db);

                ProductPrices.Add(itemPara);
            }
        }
コード例 #17
0
 public async static Task GetAllProducts()
 {
     Products.Clear();
     Categories.Clear();
     ProductPrices.Clear();
     Stores.Clear();
     GoodsReceipts.Clear();
     using (var db = new SalesContext())
     {
         try
         {
             var result  = await(from c in db.Products select c).Include("ProductPrices").ToListAsync();
             var result1 = await(from c in db.Categories.Include("Products") select c).ToListAsync();
             var result2 = await(from c in db.ProductPrices select c).Include("Product").Include("Store").ToListAsync();
             var result3 = await(from c in db.Stores select c).Include("ProductPrices").ToListAsync();
             var result4 = await(from c in db.GoodsReceipts select c).Include("ReceiptDetails").Include("Store").ToListAsync();
             foreach (Product item in result)
             {
                 Products.Add(item);
             }
             foreach (Category item in result1)
             {
                 Categories.Add(item);
             }
             foreach (ProductPrice item in result2)
             {
                 ProductPrices.Add(item);
             }
             foreach (Store item in result3)
             {
                 Stores.Add(item);
             }
             foreach (GoodsReceipt item in result4)
             {
                 GoodsReceipts.Add(item);
             }
         }
         catch (Exception e)
         {
             var x = e.Message;
         }
     }
 }
コード例 #18
0
        private List <ProductPrices> GetProductPrices(Product product)
        {
            List <ProductPrices> lstProductPrices = new List <ProductPrices>();

            ProductPrices objProductPrice = null;

            foreach (var price in product.ProductPrices)
            {
                objProductPrice = new ProductPrices()
                {
                    CurrencyID = price.CurrencyID.Value, Price = price.Price.Value, PriceID = price.PriceID, SizeID = price.SizeID.Value
                };

                lstProductPrices.Add(objProductPrice);

                objProductPrice = null;
            }

            return(lstProductPrices);
        }
コード例 #19
0
 public async static Task DeleteAllProductPrices(ICollectionView itemParas)
 {
     using (var db = new SalesContext())
     {
         List <ProductPrice> list = new List <ProductPrice>();
         foreach (object item in itemParas)
         {
             list.Add((ProductPrice)item);
         }
         foreach (ProductPrice item in list)
         {
             db.Entry(item).State = EntityState.Unchanged;
             ProductPrices.Remove(item);
             db.Entry(item).State = EntityState.Deleted;
             //Categories.Remove(item);
             //var query = db.Categories.Find(item.Id);
             //db.Entry(query).State = EntityState.Deleted;
         }
         await UpdateDatabase(db);
     }
 }
コード例 #20
0
        public ProductPrices GetPrice(string customer, string product)
        {
            var objCust = conn.QueryFirstOrDefault("SELECT special_price, cust_disc_code FROM scheme.slcustm WITH (NOLOCK) WHERE customer = @customer", new { customer });
            var result  = new ProductPrices();
            var objProd = conn.QueryFirstOrDefault <Product>("SELECT product, discount, exvat_price FROM dbo.[mpcportalprodlist] WITH (NOLOCK) WHERE product = @product",
                                                             new { product });

            result.basePrice = objProd?.exvat_price;
            if (objCust != null)
            {
                if (!string.IsNullOrWhiteSpace(objCust.special_price))
                {
                    result.customerPrice = conn.ExecuteScalar <double?>("SELECT price FROM scheme.oplistm WITH (NOLOCK) WHERE price_list = @special_price AND product_code = @product",
                                                                        new { objCust.special_price, product });
                    if (result.customerPrice != null)
                    {
                        return(result);
                    }
                }

                if (objProd != null)
                {
                    if (!string.IsNullOrWhiteSpace(objProd.discount))
                    {
                        var discount = conn.ExecuteScalar <double?>("SELECT discount1 FROM scheme.opdscntm WITH (NOLOCK) WHERE cust_disc_code = @cust_disc_code AND prod_disc_code = @prod_disc_code",
                                                                    new { objCust.cust_disc_code, prod_disc_code = objProd.discount });
                        if (discount != null)
                        {
                            result.customerPrice = objProd.exvat_price * (100 + discount) / 100.0;
                            return(result);
                        }
                    }

                    return(result);
                }
            }

            return(null);
        }
コード例 #21
0
    protected void egvShoppings_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Literal ltPN = e.Row.FindControl("ltProductName") as Literal;
            Literal ltMN = e.Row.FindControl("ltModelName") as Literal;
            Literal ltPC = e.Row.FindControl("ltPrice") as Literal;

            Shopping shop = (Shopping)e.Row.DataItem;
            Product  p    = Products.GetProduct(shop.ProductID);
            ltPN.Text = string.Format(productFormat,
                                      GlobalSettings.Encrypt(p.ProductID.ToString()),
                                      p.ProductName,
                                      p.ProductAbstract,
                                      p.GetDefaultImageUrl(50, 50));
            decimal?price1 = null;
            decimal?price2 = null;
            if (Profile.IsAnonymous)
            {
                price1 = ProductPrices.GetPriceDefault(p.ProductID);
            }
            else
            {
                price1 = ProductPrices.GetPriceMarket(Profile.AccountInfo.UserID, p.ProductID);
                price2 = ProductPrices.GetPriceMember(Profile.AccountInfo.UserID, p.ProductID);
            }
            ltPC.Text = GlobalSettings.GetPrice(price1, price2);
            if (shop.ModelID != 0)
            {
                ProductModel pm = ProductModels.GetModel(shop.ModelID);
                ltMN.Text = pm.ModelName;
            }
            else
            {
                ltMN.Text = "——";
            }
        }
    }
コード例 #22
0
        public void loadProductsList()
        {
            using (var db = new POSApplication.Model.posdbEntities())
            {
                //var catID = (from c in db.categories
                //             where c.CategoryName == categoryname
                //             select new { CategoryID = c.CategoryID }).SingleOrDefault();

                var query = (from c in db.products
                             join p in db.inventories on c.ProductID equals p.ProductID
                             where p.UpdateDt == null
                             //&& c.CategoryID == catID.CategoryID
                             select new
                {
                    c.ProductName,
                    p.PurchasePrice,
                    c.ProductID,
                    p.SalePrice,
                    //p.TaxPaid,
                    c.Barcode,
                    c.ProductCode
                }).ToList();

                var query2 = query.GroupBy(p => p.ProductID).Select(a => a.First()).ToList();

                productPrices = new List <ProductPrices>();
                foreach (var d in query)
                {
                    var item = new ProductPrices(d.ProductName, d.PurchasePrice, d.SalePrice,
                                                 d.ProductID,
                                                 //d.TaxPaid,
                                                 d.Barcode,
                                                 d.ProductCode);
                    productPrices.Add(item);
                }
                LoadProductComboBox();
            }
        }
コード例 #23
0
        string GetPrice(int pId)
        {
            decimal?price1 = null;
            decimal?price2 = null;
            decimal?price3 = null;
            decimal?p      = null;

            if (Context.User.Identity.IsAuthenticated)
            {
                SettingsPropertyValueCollection spvc = this.Context.Profile.PropertyValues;
                User u = spvc["AccountInfo"].PropertyValue as User;
                price1 = ProductPrices.GetPriceMarket(u.UserID, pId);
                price2 = ProductPrices.GetPriceMember(u.UserID, pId);
                price3 = ProductPrices.GetPricePromote(u.UserID, pId);
                p      = GlobalSettings.GetMinPrice(price1, price2);
                return(GlobalSettings.GetPrice(p, price3));
            }
            else
            {
                price1 = ProductPrices.GetPriceDefault(pId);
                price3 = ProductPrices.GetPricePromote(0, pId);
                return(GlobalSettings.GetPrice(price1, price3));
            }
        }
コード例 #24
0
    void BindPrice(int pId)
    {
        decimal?p = null, p1 = null, p2 = null;
        string  priceText = string.Empty;

        if (!Context.User.Identity.IsAuthenticated)
        {
            p1 = ProductPrices.GetPriceDefault(pId);
            p2 = IsPromote(pId) ? ProductPrices.GetPricePromote(0, pId) : null;
            if (p2 != null)
            {
                lblPrice.Text = "促销价";
                ltPrice1.Text = p2.Value.ToString("c");
            }
            else
            {
                ltPrice1.Text = (p1 == null ? "需询价" : p1.Value.ToString("c"));
            }
        }
        else
        {
            p1 = ProductPrices.GetPriceMarket(Profile.AccountInfo.UserID, pId);
            p2 = ProductPrices.GetPriceMember(Profile.AccountInfo.UserID, pId);
            p  = IsPromote(pId) ? ProductPrices.GetPricePromote(Profile.AccountInfo.UserID, pId) : null;
            if (p != null)
            {
                lblPrice.Text = "促销价";
                ltPrice1.Text = p.Value.ToString("c");
            }
            else
            {
                ltPrice1.Text = (p1 == null ? "需询价" : p1.Value.ToString("c"));
            }
            ltPrice2.Text = (p2 == null ? "需询价" : p2.Value.ToString("c"));
        }
    }
コード例 #25
0
 void BindData()
 {
     this.egvProductPrices.DataSource = ProductPrices.GetPrices(productID);
     this.egvProductPrices.DataBind();
 }
コード例 #26
0
    public void btnPost_Click(object sender, EventArgs e)
    {
        ProductPrice price = null;

        if (action == OperateType.Add)
        {
            price           = new ProductPrice();
            price.ProductID = productID;
        }
        else
        {
            price = ProductPrices.GetPrice(priceID);
        }
        price.ApplyTaxRate = Convert.ToDecimal(txtApplyTaxRate.Text);
        if (!string.IsNullOrEmpty(txtPriceFloor.Text))
        {
            price.PriceFloor = Convert.ToDecimal(txtPriceFloor.Text);
        }
        else
        {
            price.PriceFloor = null;
        }

        if (!string.IsNullOrEmpty(txtPriceFloor.Text))
        {
            price.PriceFloor = Convert.ToDecimal(txtPriceFloor.Text);
        }
        else
        {
            price.PriceFloor = null;
        }

        if (!string.IsNullOrEmpty(txtPriceGradeA.Text))
        {
            price.PriceGradeA = Convert.ToDecimal(txtPriceGradeA.Text);
        }
        else
        {
            price.PriceGradeA = null;
        }

        if (!string.IsNullOrEmpty(txtPriceGradeB.Text))
        {
            price.PriceGradeB = Convert.ToDecimal(txtPriceGradeB.Text);
        }
        else
        {
            price.PriceGradeB = null;
        }

        if (!string.IsNullOrEmpty(txtPriceGradeC.Text))
        {
            price.PriceGradeC = Convert.ToDecimal(txtPriceGradeC.Text);
        }
        else
        {
            price.PriceGradeC = null;
        }

        if (!string.IsNullOrEmpty(txtPriceGradeD.Text))
        {
            price.PriceGradeD = Convert.ToDecimal(txtPriceGradeD.Text);
        }
        else
        {
            price.PriceGradeD = null;
        }

        if (!string.IsNullOrEmpty(txtPriceGradeE.Text))
        {
            price.PriceGradeE = Convert.ToDecimal(txtPriceGradeE.Text);
        }
        else
        {
            price.PriceGradeE = null;
        }

        if (!string.IsNullOrEmpty(txtPriceMarket.Text))
        {
            price.PriceMarket = Convert.ToDecimal(txtPriceMarket.Text);
        }
        else
        {
            price.PriceMarket = null;
        }

        if (!string.IsNullOrEmpty(txtPricePromotion.Text))
        {
            price.PricePromotion = Convert.ToDecimal(txtPricePromotion.Text);
        }
        else
        {
            price.PricePromotion = null;
        }

        if (!string.IsNullOrEmpty(txtPricePurchase.Text))
        {
            price.PricePurchase = Convert.ToDecimal(txtPricePurchase.Text);
        }
        else
        {
            price.PricePurchase = null;
        }

        price.QuoteEnd  = Convert.ToDateTime(txtQuoteEnd.Text);
        price.QuoteFrom = Convert.ToDateTime(txtQuoteFrom.Text);

        if (!string.IsNullOrEmpty(txtQuoteMOQ.Text))
        {
            price.QuoteMOQ = Convert.ToInt32(txtQuoteMOQ.Text);
        }
        else
        {
            price.QuoteMOQ = null;
        }

        price.QuoteRenewal   = Convert.ToInt32(txtQuoteRenewal.Text);
        price.DeliverySpan   = piDeliverySpan.DateSpanValue;
        price.IncludeFreight = piFreight.SelectedValue;
        price.IncludeTax     = piTax.SelectedValue;
        price.WarrantySpan   = piWarrantySpan.DateSpanValue;
        price.SupplyStatus   = csPrice.SelectedValue;
        price.SupplyRegion   = Convert.ToInt32(ddlSupplyRegion.SelectedValue);
        DataActionStatus status;

        if (action == OperateType.Add)
        {
            status = ProductPrices.Create(price);
            switch (status)
            {
            case DataActionStatus.UnknownFailure:
                mbMessage.ShowMsg("产品报价失败,请联系管理员!", Color.Red);
                break;

            case DataActionStatus.Success:
            default:
                mbMessage.ShowMsg("产品报价成功,可继续进行产品报价,若完成请返回!", Color.Navy);
                break;
            }
        }
        else
        {
            status = ProductPrices.Update(price);
            switch (status)
            {
            case DataActionStatus.UnknownFailure:
                mbMessage.ShowMsg("修改产品报价失败,请联系管理员!", Color.Red);
                break;

            case DataActionStatus.Success:
            default:
                mbMessage.ShowMsg("修改产品报价成功,可继续修改产品报价,若完成请返回!", Color.Navy);
                break;
            }
        }
        if (status == DataActionStatus.Success)
        {
            BindData();
        }
    }
コード例 #27
0
 private decimal PriceOf(RentedProduct rentedProduct)
 {
     return(ProductPrices.Where(price => price.ProductId == rentedProduct.ProductId)
            .Single().UnitRentPrice.Value);
 }
コード例 #28
0
        /// <summary>
        /// Given a set of cash and a desired price, get the amount of the cash
        /// to meet the price (rounded up for safety)
        /// </summary>
        /// <param name="AvailableCash">The amount of cash avaliable.</param>
        /// <param name="price">The price to meet (roughly)</param>
        /// <returns>The appropriate cash for the price.</returns>
        /// <exception cref="ArgumentNullException">If <paramref name="AvailableCash"/> is null.</exception>
        /// <exception cref="ArgumentOutOfRangeException">If <paramref name="price"/> is less than or equal to 0.</exception>
        public IProductAmountCollection ChangeForPrice(IProductAmountCollection AvailableCash, double price)
        {
            // ensure cash is not null.
            if (AvailableCash is null)
            {
                throw new ArgumentNullException(nameof(AvailableCash));
            }
            // ensure that the price is greater than 0
            if (price <= 0) // TODO, allow this to savely give change for 0. It's not that hard.
            {
                throw new ArgumentOutOfRangeException("Price must be greater than 0.");
            }

            // first, check that all available cash can meet the price.
            var totalCash = AvailableCash.Sum(x => x.Item2 * ProductPrices.GetProductValue(x.Item1));

            // If the total cash available is less than the price sought, return a copy of the available cash.
            if (totalCash < price)
            {
                return(AvailableCash.Copy());
            }

            // since we have more than we need,
            var result = new ProductAmountCollection();

            // start from the best and start making change, highest to lowest value.
            foreach (var coin in AvailableCash.OrderByDescending(x => ProductPrices.GetProductValue(x.Item1)))
            {
                // if none of that coin exist
                if (coin.Item2 == 0)
                {
                    // add it as zero
                    result.AddProducts(coin.Item1, 0);
                    // and skip to the next loop
                    continue;
                }

                // coin type
                var curr = coin.Item1;
                // coin value
                var val = ProductPrices.GetProductValue(curr);
                // if value is higher then remaining price.
                if (val > price)
                {
                    // add it as zero
                    result.AddProducts(curr, 0);
                    // and skip
                    continue;
                }

                // coin amount
                var amt = coin.Item2;

                // how many whole coins can fit into the price.
                var count = Math.Floor(price / val);

                // select cap coins at the available level.
                count = Math.Min(count, amt);

                // add to our change
                result.AddProducts(curr, count);

                // subtract the value we took out
                price -= val * count;
                // then go to the next coin.
            }

            // if there is a remainder
            if (price > 0)
            {
                // find the smallest coin available
                foreach (var coin in AvailableCash.OrderBy(x => ProductPrices.GetProductValue(x.Item1)))
                {
                    // if we have any available
                    if (result.GetProductValue(coin.Item1) < AvailableCash.GetProductValue(coin.Item1))
                    {
                        // add one
                        result.AddProducts(coin.Item1, 1);

                        // and move on.
                        break;

                        // by logic, only one should be needed as we guaranteed have
                        // more value in coins then the requested price and the
                        // remainder should be smaller than the smallest coin.
                    }
                }
            }

            // return the change.
            return(result);
        }
コード例 #29
0
        public ActionResult Edit(EditProduct editProduct, string score, string chkSendSms)
        {
            try
            {
                float scoreValue = score != "" ? float.Parse(score) : 0;

                var product = Mapper.Map <Product>(editProduct);

                product.LastUpdate   = DateTime.Now;
                product.ProductScore = scoreValue;
                ViewBag.Success      = true;

                int productID = product.ID;
                if (productID == -1)
                {
                    if (base.IsAdmin)
                    {
                        product.ProductStatus = editProduct.ProductStatus;
                    }
                    else
                    {
                        product.ProductStatus = ProductStatus.NotChecked;
                    }

                    product.UserID      = base.UserID;
                    product.CreatedDate = DateTime.Now;

                    Products.Insert(product);
                    productID = product.ID;

                    string[] dKeys = GetDefaultKeys(editProduct);

                    SaveGroups(editProduct, productID);
                    SaveImages(editProduct, productID);
                    SaveFiles(editProduct, productID);
                    SaveMarks(editProduct, productID);
                    SavePoints(editProduct, productID);
                    SaveKeywords(editProduct, productID);
                    SaveDefaultKeywords(dKeys, productID);
                    SaveNotes(editProduct, productID, UserID);
                    SaveProductLinks(editProduct, productID);

                    SaveSupplies(editProduct, productID);
                    SavePrices(editProduct, productID);
                    SaveAttributes(Request, productID);
                    SaveVarients(editProduct, productID);

                    UserNotifications.Send(UserID, String.Format("جدید - محصول '{0}'", editProduct.Title), "/Admin/Products/Edit/" + editProduct.ID, NotificationType.Success);
                    editProduct        = new EditProduct();
                    editProduct.userID = product.UserID;
                }
                else
                {
                    Products.Update(product);

                    SaveGroups(editProduct, productID);
                    SaveImages(editProduct, productID);
                    SaveFiles(editProduct, productID);
                    SaveMarks(editProduct, productID);
                    SavePoints(editProduct, productID);
                    SaveKeywords(editProduct, productID);
                    SaveNotes(editProduct, productID, UserID);
                    SaveProductLinks(editProduct, productID);

                    SaveSupplies(editProduct, productID);
                    SavePrices(editProduct, productID);
                    SaveAttributes(Request, productID);
                    SaveVarients(editProduct, productID);

                    editProduct.Text = HttpUtility.HtmlDecode(editProduct.Text);

                    editProduct.Groups   = ProductGroups.GetByProductID(editProduct.ID).Select(item => item.GroupID).ToList();
                    editProduct.Supplies = ProductSupplies.GetByProductID(editProduct.ID);
                    editProduct.Prices   = ProductPrices.GetByProductID(editProduct.ID);
                    editProduct.Varients = ProductVarients.GetByProductID(editProduct.ID);
                    editProduct.Keywords = ProductKeywords.GetByProductID(editProduct.ID);
                    editProduct.Notes    = ProductNotes.GetByProductID(editProduct.ID);

                    editProduct.userID         = product.UserID;
                    editProduct.GroupUrlPerfix = Groups.GetByID(editProduct.GroupID.Value).UrlPerfix;
                    editProduct.ProductScore   = scoreValue;

                    if (chkSendSms == "on")
                    {
                        SendMessageToRequests(editProduct, productID);
                    }
                }

                Products.UpdateIsUnavailable(product.ID);
            }
            catch (Exception ex)
            {
                SetErrors(ex);
            }

            return(ClearView(editProduct));
        }
コード例 #30
0
ファイル: RawProduct.cs プロジェクト: p1zza/VaporStoreClub
 public void AddPrice(int id, int?price)
 {
     ProductPrices.Add(id, price);
 }