Пример #1
0
        public item_price New_ItemPrice(item item)
        {
            item_price item_price = new item_price();

            Brillo.General general = new Brillo.General();
            item_price.id_currency   = general.Get_Currency(CurrentSession.Id_Company);
            item_price.id_price_list = general.get_price_list(CurrentSession.Id_Company);
            return(item_price);
        }
Пример #2
0
 private void item_priceDataGrid_InitializingNewItem(object sender, InitializingNewItemEventArgs e)
 {
     entity.item       item       = itemViewSource.View.CurrentItem as entity.item;
     entity.item_price item_price = e.NewItem as entity.item_price;
     if (item != null)
     {
         item_price.id_item = item.id_item;
         item_price.item    = item;
     }
 }
Пример #3
0
        public decimal get_SalesPrice(int id_item, contact Contact, int CurrencyFX_ID)
        {
            int PriceList_ID = 0;

            if (id_item > 0)
            {
                if (Contact != null)
                {
                    if (Contact.id_price_list != null)
                    {
                        PriceList_ID = (int)Contact.id_price_list;
                    }
                    else
                    {
                        PriceList_ID = 0;
                    }
                }

                //Step 1. If 'PriceList_ID' is 0, Get Default PriceList.
                if (PriceList_ID == 0 && PriceList_ID != null)
                {
                    using (db db = new db())
                    {
                        if (db.item_price_list.Where(x => x.is_active == true && x.id_company == Properties.Settings.Default.company_ID) != null)
                        {
                            PriceList_ID = db.item_price_list.Where(x => x.is_active == true && x.is_default == true && x.id_company == CurrentSession.Id_Company).FirstOrDefault().id_price_list;
                        }
                    }
                }

                //Step 1 1/2. Check if Quantity gets us a better Price List.


                //Step 2. Get Price in Currency.
                using (db db = new db())
                {
                    app_currencyfx app_currencyfx = null;
                    if (db.app_currencyfx.Where(x => x.id_currencyfx == CurrencyFX_ID).FirstOrDefault() != null)
                    {
                        app_currencyfx = db.app_currencyfx.Where(x => x.id_currencyfx == CurrencyFX_ID).FirstOrDefault();

                        //Check if we have available Price for this Product, Currency, and List.
                        item_price item_price = db.item_price.Where(x => x.id_item == id_item &&
                                                                    x.id_currency == app_currencyfx.id_currency &&
                                                                    x.id_price_list == PriceList_ID)
                                                .FirstOrDefault();

                        if (item_price != null)
                        {   //Return Perfect Value
                            return(item_price.value);
                        }
                        else
                        {
                            //If Perfect Value not found, get one pased on Product and List. (Ignore Currency and Convert Later basd on Current Rate.)
                            if (db.item_price.Where(x => x.id_item == id_item && x.id_price_list == PriceList_ID).FirstOrDefault() != null)
                            {
                                item_price     = db.item_price.Where(x => x.id_item == id_item && x.id_price_list == PriceList_ID).FirstOrDefault();
                                app_currencyfx = db.app_currencyfx.Where(x => x.id_currency == item_price.id_currency && x.is_active == true).FirstOrDefault();
                                return(Currency.convert_BackValue(item_price.value, app_currencyfx.id_currencyfx, App.Modules.Sales));
                            }
                        }
                    }
                }
            }

            return(0);
        }