示例#1
0
        private void SetPrice(Nomenclature nomenclature, string price)
        {
            bool    havePrice  = false;
            decimal priceValue = 0;

            if (!string.IsNullOrWhiteSpace(price))
            {
                price = price.Replace(",", ".");
                var culture = CultureInfo.CreateSpecificCulture("ru-RU");
                culture.NumberFormat.NumberDecimalSeparator = ".";
                havePrice = decimal.TryParse(price, NumberStyles.AllowDecimalPoint, culture, out priceValue);
            }

            NomenclaturePrice nomenclaturePrice = nomenclature.NomenclaturePrice.FirstOrDefault();

            if (nomenclaturePrice == null)
            {
                if (!havePrice)
                {
                    return;
                }
                nomenclaturePrice = new NomenclaturePrice();
                nomenclaturePrice.Nomenclature = nomenclature;
                nomenclaturePrice.Price        = priceValue;
                nomenclaturePrice.MinCount     = 1;
                nomenclature.NomenclaturePrice.Add(nomenclaturePrice);
            }
            else
            {
                nomenclaturePrice.Price    = havePrice ? priceValue : 0;
                nomenclaturePrice.MinCount = 1;
            }
        }
示例#2
0
        private void AddPriceRow(NomenclaturePrice newPrice)
        {
            datatablePrices.NRows = RowNum + 1;

            Gtk.Label textFromLabel = new Gtk.Label("от (шт.)");
            datatablePrices.Attach(textFromLabel, (uint)0, (uint)1, RowNum, RowNum + 1, (AttachOptions)0, (AttachOptions)0, (uint)0, (uint)0);

            var countDataEntry = new ySpinButton(0, 9999, 1);

            countDataEntry.Binding.AddBinding(newPrice, e => e.MinCount, w => w.ValueAsInt).InitializeFromSource();
            datatablePrices.Attach(countDataEntry, (uint)1, (uint)2, RowNum, RowNum + 1, AttachOptions.Expand | AttachOptions.Fill, (AttachOptions)0, (uint)0, (uint)0);

            Gtk.Label textCplLabel = new Gtk.Label(" - ");
            datatablePrices.Attach(textCplLabel, (uint)2, (uint)3, RowNum, RowNum + 1, (AttachOptions)0, (AttachOptions)0, (uint)0, (uint)0);

            var priceDataEntry = new ySpinButton(0, 999999, 1);

            priceDataEntry.Digits = 2;
            priceDataEntry.Binding.AddBinding(newPrice, e => e.Price, w => w.ValueAsDecimal).InitializeFromSource();
            datatablePrices.Attach(priceDataEntry, (uint)3, (uint)4, RowNum, RowNum + 1, AttachOptions.Expand | AttachOptions.Fill, (AttachOptions)0, (uint)0, (uint)0);

            Gtk.Label textCurrencyLabel = new Gtk.Label("руб.");
            datatablePrices.Attach(textCurrencyLabel, (uint)4, (uint)5, RowNum, RowNum + 1, (AttachOptions)0, (AttachOptions)0, (uint)0, (uint)0);

            Gtk.Button deleteButton = new Gtk.Button();
            Gtk.Image  image        = new Gtk.Image();
            image.Pixbuf          = Stetic.IconLoader.LoadIcon(this, "gtk-delete", global::Gtk.IconSize.Menu);
            deleteButton.Image    = image;
            deleteButton.Clicked += OnButtonDeleteClicked;
            datatablePrices.Attach(deleteButton, (uint)5, (uint)6, RowNum, RowNum + 1, (AttachOptions)0, (AttachOptions)0, (uint)0, (uint)0);

            datatablePrices.ShowAll();

            RowNum++;
        }
示例#3
0
 public NomenclaturePriceDTO(NomenclaturePrice price)
 {
     MinCount = price.MinCount;
     Price    = price.Price;
 }
示例#4
0
        public List <WaterPriceNode> GetWaterPrices(IUnitOfWork uow)
        {
            List <WaterPriceNode> result = new List <WaterPriceNode>();

            var waterPrintNom = GetPrintableWaterNomenclatures(uow);

            if (!waterPrintNom.Any())
            {
                return(result);
            }

            //Цены
            WaterPriceNode    nodeAlias = null;
            NomenclaturePrice nomenclaturePriceAlias = null;
            Nomenclature      nomenclatureAlias      = null;
            var resultPrices =
                uow.Session.QueryOver <NomenclaturePrice>(() => nomenclaturePriceAlias)
                .Left.JoinAlias(() => nomenclaturePriceAlias.Nomenclature, () => nomenclatureAlias)
                .WhereRestrictionOn(() => nomenclatureAlias.Id).IsIn(waterPrintNom.Select(x => x.Id).ToArray())
                .SelectList(list => list
                            .SelectGroup(() => nomenclaturePriceAlias.MinCount)
                            //Количество
                            .Select(
                                Projections.Cast(
                                    NHibernateUtil.AnsiString,
                                    Projections.Property(() => nomenclaturePriceAlias.MinCount))
                                ).WithAlias(() => nodeAlias.Count)

                            //Цена номенклатуры 1
                            .Select(Projections.Max(
                                        Projections.Conditional(
                                            Restrictions.Eq(Projections.Property(() => nomenclatureAlias.Id), waterPrintNom[0].Id),
                                            Projections.Cast(
                                                NHibernateUtil.AnsiString,
                                                Projections.Property(() => nomenclaturePriceAlias.Price)),
                                            Projections.Constant("", NHibernateUtil.AnsiString)))
                                    ).WithAlias(() => nodeAlias.Water1)
                            //Id номенклатуры 1
                            .Select(() => waterPrintNom[0].Id).WithAlias(() => nodeAlias.Id1)

                            //Цена номенклатуры 2
                            .Select(Projections.Max(
                                        waterPrintNom.Count() > 1
                                                           ? Projections.Conditional(
                                            Restrictions.Eq(Projections.Property(() => nomenclatureAlias.Id), waterPrintNom[1].Id),
                                            Projections.Cast(
                                                NHibernateUtil.AnsiString,
                                                Projections.Property(() => nomenclaturePriceAlias.Price)),
                                            Projections.Constant("", NHibernateUtil.AnsiString))
                                                           : Projections.Constant("", NHibernateUtil.AnsiString))
                                    ).WithAlias(() => nodeAlias.Water2)
                            //Id номенклатуры 2
                            .Select(() => waterPrintNom.Count() > 1 ? waterPrintNom[1].Id : 0).WithAlias(() => nodeAlias.Id2)

                            //Цена номенклатуры 3
                            .Select(Projections.Max(
                                        waterPrintNom.Count() > 2
                                                           ? Projections.Conditional(
                                            Restrictions.Eq(Projections.Property(() => nomenclatureAlias.Id), waterPrintNom[2].Id),
                                            Projections.Cast(
                                                NHibernateUtil.AnsiString,
                                                Projections.Property(() => nomenclaturePriceAlias.Price)),
                                            Projections.Constant("", NHibernateUtil.AnsiString))
                                                           : Projections.Constant("", NHibernateUtil.AnsiString))
                                    ).WithAlias(() => nodeAlias.Water3)
                            //Id номенклатуры 3
                            .Select(() => waterPrintNom.Count() > 2 ? waterPrintNom[2].Id : 0).WithAlias(() => nodeAlias.Id3)

                            //Цена номенклатуры 4
                            .Select(Projections.Max(
                                        waterPrintNom.Count() > 3
                                                           ? Projections.Conditional(
                                            Restrictions.Eq(Projections.Property(() => nomenclatureAlias.Id), waterPrintNom[3].Id),
                                            Projections.Cast(
                                                NHibernateUtil.AnsiString,
                                                Projections.Property(() => nomenclaturePriceAlias.Price)),
                                            Projections.Constant("", NHibernateUtil.AnsiString))
                                                           : Projections.Constant("", NHibernateUtil.AnsiString))
                                    ).WithAlias(() => nodeAlias.Water4)
                            //Id номенклатуры 4
                            .Select(() => waterPrintNom.Count() > 3 ? waterPrintNom[3].Id : 0).WithAlias(() => nodeAlias.Id4)

                            //Цена номенклатуры 5
                            .Select(Projections.Max(
                                        waterPrintNom.Count() > 4
                                                           ? Projections.Conditional(
                                            Restrictions.Eq(Projections.Property(() => nomenclatureAlias.Id), waterPrintNom[4].Id),
                                            Projections.Cast(
                                                NHibernateUtil.AnsiString,
                                                Projections.Property(() => nomenclaturePriceAlias.Price)),
                                            Projections.Constant("", NHibernateUtil.AnsiString))
                                                           : Projections.Constant("", NHibernateUtil.AnsiString))
                                    ).WithAlias(() => nodeAlias.Water5)
                            //Id номенклатуры 5
                            .Select(() => waterPrintNom.Count() > 4 ? waterPrintNom[4].Id : 0).WithAlias(() => nodeAlias.Id5)
                            ).TransformUsing(Transformers.AliasToBean <WaterPriceNode>())
                .List <WaterPriceNode>();

            foreach (var item in resultPrices)
            {
                result.Add(item);
            }

            return(result);
        }