示例#1
0
        void Dlg_PriceLoadCompleted(object sender, PriceLoadCompletedEventArgs e)
        {
            var fittings = UoW.GetById <Fitting> (e.Rows.Select(x => x.Fitting.Id).ToArray());

            foreach (var item in e.Rows)
            {
                var exist = Entity.Prices.FirstOrDefault(x => x.Fitting.Id == item.Fitting.Id);
                if (exist != null)
                {
                    logger.Debug("Арматура Id:{0} уже существует в прайсе, просто обновляем цену.", exist.Fitting.Id);
                    exist.Currency = e.Currency;
                    exist.Cost     = item.Price.Value;
                }
                else
                {
                    Entity.AddItem(fittings.First(x => x.Id == item.Fitting.Id), e.Currency, item.Price.Value);
                }
            }
        }
示例#2
0
 protected void OnButtonFinishClicked(object sender, EventArgs e)
 {
     progressFinal.Adjustment.Upper = 3;
     logger.Info("Создаем новую арматуру...");
     foreach (var row in xlsRows.Where(x => x.Status == ReadingXLSRow.RowStatus.WillCreated))
     {
         row.Fitting = new Fitting {
             Code           = row.Code,
             BodyMaterial   = row.BodyMaterial,
             ConnectionType = row.ConnectionType,
             Diameter       = row.Diameter,
             DiameterUnits  = row.DiameterUnits,
             Name           = row.Name,
             Note           = row.Note,
             Pressure       = row.Pressure,
             PressureUnits  = row.PressureUnits,
         };
         UoW.Save(row.Fitting);
     }
     progressFinal.Adjustment.Value++;
     logger.Info("Записываем в базу...");
     UoW.Commit();
     progressFinal.Adjustment.Value++;
     logger.Info("Передаем в диалог прайса...");
     if (PriceLoadCompleted != null)
     {
         var arg = new PriceLoadCompletedEventArgs {
             Rows     = xlsRows.Where(x => x.Fitting != null && x.Price != null).ToArray(),
             Currency = (PriceСurrency)comboCurrency.SelectedItem
         };
         PriceLoadCompleted(this, arg);
     }
     progressFinal.Adjustment.Value++;
     logger.Info("Ок");
     OnCloseTab(false);
 }