private void BackgroundShowDetails_DoWork(object sender, DoWorkEventArgs e) { // DETAILED INFO IList selectedItems = e.Argument as IList; if (selectedItems.Count == 0) { DetailSpareInfo_Brand = ""; DetailSpareInfo_Group = ""; DetailSpareInfo_Name = ""; Detail_Incomes = null; Detail_Analogues = null; } else { SpareView selected = selectedItems[0] as SpareView; DetailSpareInfo_Brand = selected.BrandName; DetailSpareInfo_Name = selected.name; // построим путь по группам к запчасти // текущая группа DataAccess db = new DataAccess(); spare s = db.GetSpare(selected.id); string gp = s.spare_group.name; // родительская if (s.spare_group1 != null) gp = s.spare_group1.name + "/" + gp; // дедушка if (s.spare_group2 != null) gp = s.spare_group2.name + "/" + gp; // прадедушка if (s.spare_group3 != null) gp = s.spare_group3.name + "/" + gp; DetailSpareInfo_Group = gp; // INCOMES & ANALOGS WINDOWS // anlogues Detail_Analogues = db.GetAnalogues(selected.id); // incomes Detail_Incomes = db.GetIncomes(selected.id); foreach (SpareInSpareIncomeView i in Detail_Incomes) { decimal POutBasic = 0; decimal PInBasic = 0; if (!i.POutBasic.HasValue) { string IncomeCurrencyCode = i.CurrencyCode; decimal PIn = i.PIn.Value; POutBasic = CurrencyHelper.GetBasicPrice(IncomeCurrencyCode, PIn); } else { POutBasic = i.POutBasic.Value; } if (i.PInBasic.HasValue) { PInBasic = i.PInBasic.Value; } else { string IncomeCurrencyCode = i.CurrencyCode; decimal PIn = i.PIn.Value; PInBasic = CurrencyHelper.GetBasicPrice(IncomeCurrencyCode, PIn); } i.DF_PriceInCurrency = CurrencyHelper.GetPrice(currentCurrencyName, POutBasic); i.DF_PriceInCurrencyIn = CurrencyHelper.GetPrice(currentCurrencyName, PInBasic); string strDate = ""; if (i.SpareIncomeDate.Value.Day < 10) strDate += "0"; strDate += i.SpareIncomeDate.Value.Day + "."; if (i.SpareIncomeDate.Value.Month < 10) strDate += "0"; strDate += i.SpareIncomeDate.Value.Month + "."; strDate += i.SpareIncomeDate.Value.Year; i.DF_Date = strDate; } } }
private void loadAnalogues(int spareId) { DataAccess da = new DataAccess(); List<SpareView> items = da.GetAnalogues(spareId); dgAnalogues.DataContext = items; dgAnalogues.SelectedIndex = 0; }