private void AddIncomeToBasket(SpareInSpareIncomeView income) { int SpareID = income.SpareID.Value; // если такой товар в корзине есть if (BasketItems.Where(x => x.SpareID == SpareID).Count() > 0) { if ((decimal)SpareContainer.Instance.Remains.FirstOrDefault(i => i.id == SpareID).QRest.Value > BasketItems.FirstOrDefault(x => x.SpareID == SpareID).Q) BasketItems.FirstOrDefault(x => x.SpareID == SpareID).Q++; } else { // если такого товара в корзине нет BasketView item = new BasketView(); item.ID = BasketItems.Count + 1; // [CreatedOn] item.CreatedOn = DateTime.Now; // [SpareID] item.SpareID = SpareID; // [Q] item.Q = 1; // [OfferingID] = income //item.OfferingInID = (dgIncomes.SelectedItem as SpareInSpareIncomeView).id; // [OfferingID] = outgo //TODO item.OfferingOutID decimal POutBasic = income.POutBasic.Value; DataAccess db = new DataAccess(); spare_outgo outgo = db.SpareOutgoOpened(); if (outgo == null) { MessageBox.Show("Сначала укажите текущую открытую накладную!"); return; } if (outgo.currency == null) outgo.currencyReference.Load(); if (outgo.currency.code == CurrencyHelper.BasicCurrencyCode) POutBasic = income.POut.Value; // [Pusd] item.Pusd = CurrencyHelper.GetPrice("USD", POutBasic); // [Peur] item.Peur = CurrencyHelper.GetPrice("EUR", POutBasic); // [Pbyr] item.Pbyr = CurrencyHelper.GetPrice("BYR", POutBasic); // [Prur] item.Prur = CurrencyHelper.GetPrice("RUR", POutBasic); // [SpareName] item.SpareName = income.SpareName; // [UnitID] item.UnitID = 1; // [SpareCode] item.SpareCode = income.SpareCode; // [SpareCodeShatem] item.SpareCodeShatem = income.SpareCodeShatem; BasketItems.Add(item); } // обновим грид LoadBasket(); }
private void OfferingAdd(int SpareID, decimal Q, decimal Pusd, string GroupName, string ParentGroupName) { SpareInSpareIncomeView sisi = new SpareInSpareIncomeView(); if (Income.currency == null) Income.currencyReference.Load(); sisi.num = offerings.Count + 1; sisi.CurrencyID = Income.currency.id; sisi.description = ""; sisi.Markup = 0; sisi.PIn = Pusd; sisi.PInBasic = Pusd; sisi.POut = Pusd; sisi.POutBasic = Pusd; sisi.QIn = Q; sisi.QRest = Q; sisi.S = Q * Pusd; sisi.SBasic = sisi.S; sisi.GroupName = GroupName; sisi.ParentGroupName = ParentGroupName; DataAccess db = new DataAccess(); sisi.SpareID = SpareID; SpareView sv = db.GetSpareView(SpareID); sisi.SpareName = sv.name; sisi.SpareCode = sv.code; sisi.SpareCodeShatem = sv.codeShatem; sisi.BrandName = sv.BrandName; sisi.SpareIncomeID = Income.id; sisi.VatRateName = "0%"; offerings.Add(sisi); }
/// <summary> /// Create a new SpareInSpareIncomeView object. /// </summary> /// <param name="qIn">Initial value of the QIn property.</param> /// <param name="markup">Initial value of the Markup property.</param> /// <param name="id">Initial value of the id property.</param> public static SpareInSpareIncomeView CreateSpareInSpareIncomeView(global::System.Decimal qIn, global::System.Decimal markup, global::System.Int32 id) { SpareInSpareIncomeView spareInSpareIncomeView = new SpareInSpareIncomeView(); spareInSpareIncomeView.QIn = qIn; spareInSpareIncomeView.Markup = markup; spareInSpareIncomeView.id = id; return spareInSpareIncomeView; }
private void OfferingAdd(int SpareID) { SpareInSpareIncomeView sisi = new SpareInSpareIncomeView(); if (Income.currency == null) Income.currencyReference.Load(); sisi.num = offerings.Count + 1; sisi.CurrencyID = Income.currency.id; sisi.description = ""; sisi.Markup = 0; sisi.PIn = 1; sisi.PInBasic = 1; sisi.POut = 1; sisi.POutBasic = 1; sisi.QIn = 1; sisi.QRest = 1; sisi.S = 1; sisi.SBasic = 1; DataAccess db = new DataAccess(); sisi.SpareID = SpareID; SpareView sv = db.GetSpareView(SpareID); sisi.SpareName = sv.name; sisi.SpareCode = sv.code; sisi.SpareCodeShatem = sv.codeShatem; sisi.BrandName = sv.BrandName; sisi.SpareIncomeID = Income.id; sisi.VatRateName = "0%"; sisi.GroupName = db.GetSpareGroup(sv.GroupID).name; sisi.ParentGroupName = db.GetSpareGroup(sv.spare_group1_id.Value).name; offerings.Add(sisi); }
/// <summary> /// Deprecated Method for adding a new object to the SpareInSpareIncomeViews EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToSpareInSpareIncomeViews(SpareInSpareIncomeView spareInSpareIncomeView) { base.AddObject("SpareInSpareIncomeViews", spareInSpareIncomeView); }