Example #1
0
        /// <summary>
        /// Item
        /// </summary>
        /// <returns></returns>

        async Task <IEnumerable <Item> > RefrishItems()
        {
            short defaultSale     = 0;
            short defaultPurchase = 0;
            int   branchId        = MainWindow.branchID.Value;

            selectedItems = new List <int>();
            if (CardType.Equals("sales"))
            {
                defaultSale     = 1;
                defaultPurchase = 0;
            }
            else if (CardType.Equals("purchase"))
            {
                defaultPurchase = 1;
                defaultSale     = 0;
            }
            else if (CardType.Equals("order"))
            {
                defaultPurchase = 0;
                defaultSale     = 0;
            }
            else if (CardType.Equals("movement"))
            {
                defaultPurchase = -1;
                defaultSale     = -1;
            }
            items = await itemModel.GetSaleOrPurItems(category.categoryId, defaultSale, defaultPurchase, branchId);

            MainWindow.InvoiceGlobalItemsList = items.ToList();
            if (CardType == "order" || CardType == "sales")
            {
                MainWindow.InvoiceGlobalSaleUnitsList = await itemUnitModel.GetForSale();
            }
            else
            {
                MainWindow.InvoiceGlobalItemUnitsList = await itemUnitModel.Getall();
            }
            return(items);
        }
        /// <summary>
        /// Selcted Items if selectedItems Have Items At the beginning
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {//load
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_offerList);
                }

                #region translate
                if (MainWindow.lang.Equals("en"))
                {
                    MainWindow.resourcemanager = new ResourceManager("POS.en_file", Assembly.GetExecutingAssembly()); grid_offerList.FlowDirection = FlowDirection.LeftToRight;
                }
                else
                {
                    MainWindow.resourcemanager = new ResourceManager("POS.ar_file", Assembly.GetExecutingAssembly()); grid_offerList.FlowDirection = FlowDirection.RightToLeft;
                }

                translat();
                #endregion

                offer = await offerModel.getOfferById(offerId);

                allItemsSource = await itemModel.Getall();

                selectedItemsSource = await itemUnitOffer.GetItemsByOfferId(offerId);

                allItems.AddRange(allItemsSource);

                foreach (var i in allItems)
                {
                    i.itemName = i.itemName + "-" + i.unitName;
                }

                selectedItems.AddRange(selectedItemsSource);
                foreach (var i in selectedItems)
                {
                    i.itemName = i.itemName + "-" + i.unitName;
                }
                //remove selected items from all items
                foreach (var i in selectedItems)
                {
                    itemUnit = allItemsSource.Where(s => s.itemUnitId == i.iuId).FirstOrDefault <ItemUnit>();
                    allItems.Remove(itemUnit);
                }

                dg_allItems.ItemsSource       = allItems;
                dg_allItems.SelectedValuePath = "itemUnitId";
                dg_allItems.DisplayMemberPath = "itemName";

                dg_selectedItems.ItemsSource       = selectedItems;
                dg_selectedItems.SelectedValuePath = "itemUnitId";
                dg_selectedItems.DisplayMemberPath = "itemName";

                if (sender != null)
                {
                    SectionData.EndAwait(grid_offerList);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_offerList);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Example #3
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {//load
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_offerList);
                }

                #region translate
                if (MainWindow.lang.Equals("en"))
                {
                    MainWindow.resourcemanager = new ResourceManager("POS.en_file", Assembly.GetExecutingAssembly()); grid_offerList.FlowDirection = FlowDirection.LeftToRight;
                }
                else
                {
                    MainWindow.resourcemanager = new ResourceManager("POS.ar_file", Assembly.GetExecutingAssembly()); grid_offerList.FlowDirection = FlowDirection.RightToLeft;
                }

                translat();
                #endregion

                allItemUnitsSource = await itemUnitModel.Getall();

                allItemUnits.AddRange(allItemUnitsSource);
                for (int i = 0; i < allItemUnits.Count; i++)
                {
                    //remove parent package itemunit
                    if (allItemUnits[i].itemUnitId == itemUnitId)
                    {
                        allItemUnits.Remove(allItemUnits[i]); break;
                    }
                }
                foreach (var iu in allItemUnits)
                {
                    iu.itemName = iu.itemName + "-" + iu.unitName;
                }

                if (CallerName.Equals("IUList"))
                {
                    dg_selectedItems.Columns[1].Visibility = Visibility.Collapsed;

                    selectedItemUnitsSource = await itemUnitUserModel.GetByUserId(MainWindow.userID.Value);

                    //remove selected itemunits from source itemunits
                    foreach (var p in selectedItemUnitsSource)
                    {
                        for (int i = 0; i < allItemUnits.Count; i++)
                        {
                            //remove saved itemunits
                            if (p.itemUnitId == allItemUnits[i].itemUnitId)
                            {
                                allItemUnits.Remove(allItemUnits[i]);
                            }
                        }
                    }
                    selectedItemUnits.AddRange(selectedItemUnitsSource);
                    foreach (var p in selectedItemUnits)
                    {
                        foreach (var iu in allItemUnits)
                        {
                            if (p.itemUnitId == iu.itemUnitId)
                            {
                                p.notes = iu.itemName + "-" + iu.unitName;
                            }
                        }
                    }

                    dg_selectedItems.ItemsSource  = selectedItemUnits;
                    dg_allItems.SelectedValuePath = "id";
                    dg_allItems.DisplayMemberPath = "notes";
                }
                else
                {
                    allIPackagesSource = await packageModel.GetChildsByParentId(itemUnitId);

                    //remove selected itemunits from source itemunits
                    foreach (var p in allIPackagesSource)
                    {
                        for (int i = 0; i < allItemUnits.Count; i++)
                        {
                            //remove saved itemunits
                            if (p.childIUId == allItemUnits[i].itemUnitId)
                            {
                                allItemUnits.Remove(allItemUnits[i]);
                            }
                        }
                    }
                    allPackages.AddRange(allIPackagesSource);
                    foreach (var p in allPackages)
                    {
                        foreach (var iu in allItemUnits)
                        {
                            if (p.parentIUId == iu.itemUnitId)
                            {
                                p.notes = iu.itemName + "-" + iu.unitName;
                            }
                        }
                    }

                    dg_selectedItems.ItemsSource  = allPackages;
                    dg_allItems.SelectedValuePath = "packageId";
                    dg_allItems.DisplayMemberPath = "notes";
                }
                dg_allItems.ItemsSource       = allItemUnits;
                dg_allItems.SelectedValuePath = "itemUnitId";
                dg_allItems.DisplayMemberPath = "itemName";

                if (sender != null)
                {
                    SectionData.EndAwait(grid_offerList);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_offerList);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }