//价格区间显示
        private void gridView3_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
        {
            if (e.ListSourceRowIndex < 0)
            {
                return;
            }
            IList <PriceRange> details = this.bindingSourcePriceRang.DataSource as IList <PriceRange>;

            if (details == null || details.Count < 1)
            {
                return;
            }
            PriceRange prcur = details[e.ListSourceRowIndex] as PriceRange;

            if (prcur != null)
            {
                switch (e.Column.Name)
                {
                case "gridColumn7":
                case "gridColumn11":
                    e.DisplayText = prcur.endRange == 999999999999 ? "Infinity" : prcur.endRange.ToString();
                    break;
                }
            }
        }
        //增加删除价格区间
        private void gridView3_KeyDown(object sender, KeyEventArgs e)
        {
            if (this.action != "view")
            {
                switch (e.KeyData)
                {
                case Keys.Enter:
                    PriceRange pr1 = this._priceRangeList.Last();
                    if (pr1.endRange != 999999999999)
                    {
                        this._priceRangeList.Add(new PriceRange {
                            startRange = pr1.endRange + 1, endRange = 999999999999, RangePrice = 0
                        });
                    }
                    break;

                case Keys.Delete:
                    PriceRange pr2 = this.bindingSourcePriceRang.Current as PriceRange;
                    if (pr2.endRange != 999999999999)
                    {
                        this._priceRangeList.Remove(pr2);
                        if (this._priceRangeList.Count == 0)
                        {
                            this._priceRangeList.Add(new PriceRange {
                                startRange = 1, endRange = 999999999999, RangePrice = 0
                            });
                        }
                    }
                    break;
                }
            }
            this.gridControl3.RefreshDataSource();
        }
        //解析价格区间
        //DEMO: 0/0/0,0/0/0,0/0/0,0/0/0,0/0/0,0/0/0,0/999999999999/0
        //Means: {起始数量/终止数量/价格}
        private void AnalyzePriceRange(string priceR)
        {
            this._priceRangeList.Clear();
            if (string.IsNullOrEmpty(priceR))
            {
                priceR = "1/999999999999/0/0";
            }
            string[] inPriceR;
            if (priceR.Contains(","))
            {
                inPriceR = priceR.Split(',');
            }
            else
            {
                inPriceR = new string[] { priceR }
            };
            PriceRange pr = null;

            foreach (string s in inPriceR)
            {
                string[] prs = s.Split('/');
                pr              = new PriceRange();
                pr.startRange   = Convert.ToDouble(prs[0]);
                pr.endRange     = Convert.ToDouble(prs[1]);
                pr.RangePrice   = Convert.ToDouble(prs[2]);
                pr.GiveQuantity = Convert.ToDouble(prs[3]);
                this._priceRangeList.Add(pr);
            }
        }
Example #4
0
        //检验价格区间是否正确
        private void VerificationPriceRange()
        {
            IList <PriceRange> priceRList = this.bindingSourcePriceRang.DataSource as IList <PriceRange>;

            if (priceRList != null && priceRList.Count > 0)
            {
                try
                {
                    if (priceRList.Last().endRange != 999999999999)
                    {
                        throw new Exception();
                    }

                    double     ComSR, ComER, ComPrice, InSr, InEr, InPrice;
                    bool       isContinue = true;
                    PriceRange prFirst    = priceRList.First();

                    ComSR = prFirst.startRange; ComER = prFirst.endRange; ComPrice = prFirst.RangePrice;

                    foreach (PriceRange pr in priceRList)
                    {
                        InSr = pr.startRange; InEr = pr.endRange; InPrice = pr.RangePrice;
                        if (priceRList.IndexOf(pr) == 0)
                        {
                            if (InSr != 1 || InPrice <= 0 || InSr > InEr)
                            {
                                throw new Exception();
                            }
                        }
                        else
                        {
                            if (InSr != ComER + 1 || InPrice <= 0 || InSr > InEr)
                            {
                                throw new Exception();
                            }
                        }
                        ComSR = pr.startRange; ComER = pr.endRange; InPrice = pr.RangePrice;
                    }
                }
                catch
                {
                    throw new Helper.InvalidValueException("PriceRange.Error");
                    return;
                }
            }
        }