Пример #1
0
        private async void Cb_item_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }


                if (cb_item.SelectedValue != null && cb_item.SelectedIndex != -1)
                {
                    if (int.Parse(cb_item.SelectedValue.ToString()) != -1)
                    {
                        var list = await itemUnit.GetItemUnits(int.Parse(cb_item.SelectedValue.ToString()));

                        cb_unit.ItemsSource       = list;
                        cb_unit.SelectedValuePath = "itemUnitId";
                        cb_unit.DisplayMemberPath = "mainUnit";
                        cb_unit.SelectedIndex     = 0;
                        int  itemId = (int)cb_item.SelectedValue;
                        Item item   = items.ToList().Find(x => x.itemId == itemId);
                        _ItemType = item.type;
                        if (item.type == "sn")
                        {
                            grid_serial.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            grid_serial.Visibility = Visibility.Collapsed;
                        }
                    }
                }
                Btn_clearSerial_Click(null, null);
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
        private async Task <bool> checkAmount()
        {
            bool valid    = true;
            int  quantity = 0;

            if (!tb_quantity.Text.Equals(""))
            {
                quantity = int.Parse(tb_quantity.Text);
            }
            if (cb_item.SelectedIndex != -1 && quantity > 0)
            {
                ItemUnit        itemUnit  = new ItemUnit();
                List <ItemUnit> itemUnits = new List <ItemUnit>();
                itemUnits = await itemUnit.GetItemUnits((int)cb_item.SelectedValue);

                _PackageParentId = itemUnits[0].itemUnitId;
                int itemUnitId = 0;
                packages = await package.GetChildsByParentId(_PackageParentId);

                foreach (Package p in packages)
                {
                    int branchQuantity = 0;
                    int itemQuanP      = p.quantity;
                    itemUnitId = (int)p.childIUId;
                    int requireQuan = itemQuanP * quantity;

                    //branchQuantity = await itemLocation.getUnitAmount(itemUnitId, MainWindow.branchID.Value);
                    branchQuantity = await itemLocation.getAmountInBranch(itemUnitId, MainWindow.branchID.Value);

                    if (requireQuan > branchQuantity)
                    {
                        valid            = false;
                        tb_quantity.Text = "0";
                        Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trErrorItemAmntNotAvailableToolTip") + " " + p.citemName, animation: ToasterAnimation.FadeIn);
                        return(valid);
                    }
                }
            }
            return(valid);
        }
        private async void Cb_item_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                if (cb_item.SelectedIndex != -1)
                {
                    units = await itemUnit.GetItemUnits(int.Parse(cb_item.SelectedValue.ToString()));

                    cb_fromUnit.ItemsSource       = units;
                    cb_fromUnit.SelectedValuePath = "itemUnitId";
                    cb_fromUnit.DisplayMemberPath = "mainUnit";
                    cb_fromUnit.SelectedIndex     = 0;

                    cb_toUnit.ItemsSource       = units;
                    cb_toUnit.SelectedValuePath = "itemUnitId";
                    cb_toUnit.DisplayMemberPath = "mainUnit";
                }
            }
            catch (Exception ex)
            {
                SectionData.ExceptionMessage(ex, this);
            }
        }