private void Dg_itemShortage_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }

                if (dg_itemShortage.SelectedItem != null)
                {
                    invItemLoc             = dg_itemShortage.SelectedItem as InventoryItemLocation;
                    tb_itemUnit.Visibility = Visibility.Visible;
                    if (invItemLoc.itemType == "sn")
                    {
                        grid_serial.Visibility = Visibility.Visible;
                    }
                    tb_amount.IsEnabled = false;
                    this.DataContext    = invItemLoc;
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Example #2
0
        private async Task fillItemLocations()
        {
            int sequence = 0;

            _DestroyAmount  = 0;
            _ShortageAmount = 0;
            invItemsLocations.Clear();
            inventory = new Inventory();
            inventory = await inventory.getByBranch("d", MainWindow.branchID.Value);

            if (inventory.inventoryId == 0)// there is no draft in branch
            {
                itemsLocations = await itemLocationModel.getAll(MainWindow.branchID.Value);

                foreach (ItemLocation il in itemsLocations)
                {
                    sequence++;
                    InventoryItemLocation iil = new InventoryItemLocation();
                    iil.sequence        = sequence;
                    iil.itemName        = il.itemName;
                    iil.section         = il.section;
                    iil.location        = il.location;
                    iil.unitName        = il.unitName;
                    iil.quantity        = (int)il.quantity;
                    iil.itemLocationId  = il.itemsLocId;
                    iil.isDestroyed     = false;
                    iil.isFalls         = false;
                    iil.amountDestroyed = 0;
                    iil.amount          = 0;
                    iil.createUserId    = MainWindow.userLogin.userId;

                    invItemsLocations.Add(iil);

                    //calculate _ShortageCount
                    _ShortageAmount += (int)il.quantity;
                }
                tb_shortage.Text = _ShortageAmount.ToString();
                await inputEditable();

                dg_items.ItemsSource = invItemsLocations.ToList();
                if (firstTimeForDatagrid)
                {
                    await Task.Delay(1000);

                    dg_items.Items.Refresh();
                    firstTimeForDatagrid = false;
                }
            }
            else
            {
                Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trDraftExist"), animation: ToasterAnimation.FadeIn);
            }
        }
Example #3
0
 private void Btn_clear_Click(object sender, RoutedEventArgs e)
 {
     if (invItemLoc != null)
     {
         invItemLoc.id = 0;
     }
     _ItemType                 = "";
     DataContext               = new InventoryItemLocation();
     cb_item.SelectedIndex     =
         cb_unit.SelectedIndex = -1;
     grid_serial.Visibility    = Visibility.Collapsed;
     tb_notes.Clear();
     tb_reasonOfDestroy.Clear();
     tb_notes.Clear();
     invoiceModel = new Invoice();
 }
 private void Btn_clear_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (invItemLoc != null)
         {
             invItemLoc.id = 0;
         }
         _ItemType              = "";
         cb_user.SelectedIndex  = -1;
         DataContext            = new InventoryItemLocation();
         grid_serial.Visibility = Visibility.Collapsed;
         tb_notes.Clear();
         tb_reasonOfShortage.Clear();
         tb_notes.Clear();
         invoiceModel = new Invoice();
     }
     catch (Exception ex)
     {
         SectionData.ExceptionMessage(ex, this);
     }
 }
Example #5
0
        private void Dg_items_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }

                TextBox t = new TextBox();
                InventoryItemLocation row = e.Row.Item as InventoryItemLocation;
                var index = e.Row.GetIndex();
                if (dg_items.SelectedIndex != -1 && index < invItemsLocations.Count)
                {
                    var columnName = e.Column.Header.ToString();
                    t = e.EditingElement as TextBox;
                    int oldCount;
                    int newCount;
                    if (t != null && columnName == MainWindow.resourcemanager.GetString("trDestoryCount"))
                    {
                        oldCount = (int)row.amountDestroyed;
                        newCount = int.Parse(t.Text);
                        if (newCount > invItemsLocations[index].quantity)
                        {
                            t.Text   = "0";
                            newCount = 0;
                            Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trErrorDistroyMoreQuanToolTip"), animation: ToasterAnimation.FadeIn);
                        }
                        _DestroyAmount -= oldCount;
                        _DestroyAmount += newCount;
                        tb_destroy.Text = _DestroyAmount.ToString();
                    }
                    if (t != null && columnName == MainWindow.resourcemanager.GetString("trInventoryAmount"))
                    {
                        oldCount = (int)row.amount;
                        newCount = int.Parse(t.Text);
                        if (newCount > invItemsLocations[index].quantity)
                        {
                            t.Text   = "0";
                            newCount = 0;
                            Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trErrorShortMoreQuanToolTip"), animation: ToasterAnimation.FadeIn);
                        }

                        _ShortageAmount -= (int)(invItemsLocations[index].quantity - oldCount);
                        _ShortageAmount += (int)invItemsLocations[index].quantity - newCount;
                        tb_shortage.Text = _ShortageAmount.ToString();
                    }
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Example #6
0
        private async Task fillInventoryDetails()
        {
            int sequence = 0;

            _ShortageAmount = 0;
            _DestroyAmount  = 0;
            invItemsLocations.Clear();

            if (_InventoryType == "d")
            {
                inventory = await inventory.getByBranch("d", MainWindow.branchID.Value);
            }
            if (inventory.inventoryId == 0)// there is no draft in branch
            {
                itemsLocations = await itemLocationModel.getAll(MainWindow.branchID.Value);

                foreach (ItemLocation il in itemsLocations)
                {
                    sequence++;
                    InventoryItemLocation iil = new InventoryItemLocation();
                    iil.sequence        = sequence;
                    iil.itemName        = il.itemName;
                    iil.section         = il.section;
                    iil.location        = il.location;
                    iil.unitName        = il.unitName;
                    iil.quantity        = (int)il.quantity;
                    iil.itemLocationId  = il.itemsLocId;
                    iil.isDestroyed     = false;
                    iil.isFalls         = false;
                    iil.amountDestroyed = 0;
                    iil.amount          = 0;
                    iil.createUserId    = MainWindow.userLogin.userId;

                    invItemsLocations.Add(iil);

                    //calculate _ShortageCount
                    _ShortageAmount += (int)il.quantity;
                }
            }
            else
            {
                txt_inventoryNum.Text  = inventory.num;
                txt_inventoryDate.Text = inventory.createDate.ToString();
                invItemsLocations      = await invItemModel.GetAll(inventory.inventoryId);

                foreach (InventoryItemLocation il in invItemsLocations)
                {
                    _ShortageAmount += (int)(il.quantity - il.amount);
                    _DestroyAmount  += (int)il.amountDestroyed;
                }
            }

            tb_shortage.Text = _ShortageAmount.ToString();
            tb_destroy.Text  = _DestroyAmount.ToString();
            await inputEditable();

            dg_items.ItemsSource = invItemsLocations.ToList();
            if (firstTimeForDatagrid)
            {
                await Task.Delay(1000);

                dg_items.Items.Refresh();
                firstTimeForDatagrid = false;
            }
        }