private bool IsWarehouseExists()
 {
     using (var uow = new UnitOfWork())
     {
         return uow.Warehouses.GetWarehouses().Any(whs => whs.Name.Equals(txtName.Text, StringComparison.OrdinalIgnoreCase) && whs.Id != _warehouse.Id);
     }
 }
Beispiel #2
0
        private void BtnDelete_OnClick(object sender, RoutedEventArgs e)
        {
            var lvGoodItem = lvGoods.SelectedItem as LVGoodItem;
            if (lvGoodItem == null)
            {
                return;
            }

            var result = MessageBox.Show("Are you sure?", "Warning!", MessageBoxButton.OKCancel);
            if (result == MessageBoxResult.Cancel)
            {
                return;
            }

            using (var uow = new UnitOfWork())
            {
                var good = uow.Goods.GetAllGoods().SingleOrDefault(gd => gd.Id == lvGoodItem.Id);
                uow.GoodsInCells.DeleteGoodInCells(good);
                uow.Goods.DeleteGood(good);

                uow.Commit();
            }

            lvGoods.Items.Remove(lvGoodItem);
        }
Beispiel #3
0
        private void BasketWindow_OnLoaded(object sender, RoutedEventArgs e)
        {
            using (var uow = new UnitOfWork())
            {
                var userCarts = uow.UserCartsRepository.GetLVUserCarts(CurrentUser.Id);

                AddUserCarts(userCarts);
            }
        }
        private void SetWarehouses()
        {
            lvWarehouses.Items.Clear();
            using (var uow = new UnitOfWork())
            {
                var whs = uow.Warehouses.GetWarehouses();

                foreach (var warehouse in whs)
                {
                    lvWarehouses.Items.Add(warehouse);
                }
            }
        }
Beispiel #5
0
        private void SetCellsValues()
        {
            using (var uow = new UnitOfWork())
            {
                lvCells.Items.Clear();
                var cells = uow.Cells.GetLVCells();

                foreach (var cell in cells)
                {
                    lvCells.Items.Add(cell);
                }
            }
        }
Beispiel #6
0
 private void BtnAdd_OnClick(object sender, RoutedEventArgs e)
 {
     var window = new GoodWindow(null);
     window.Owner = this;
     window.ShowDialog();
     lvGoods.Items.Clear();
     using (var uow = new UnitOfWork())
     {
         var goods = uow.Goods.GetLVGoods();
         foreach (var good in goods)
         {
             AddGoodToListView(good);
         }
     }
 }
        private void UIElement_OnKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key != Key.Return)
            {
                return;
            }

            lvWarehouses.Items.Clear();
            using (var uow = new UnitOfWork())
            {
                var whs = uow.Warehouses.GetWarehouses().Where(wh => wh.Name.Contains(SearchTextBox.Text));

                foreach (var warehouse in whs)
                {
                    lvWarehouses.Items.Add(warehouse);
                }
            }
        }
 private void BtnDelete_OnClick(object sender, RoutedEventArgs e)
 {
     var user = lvUsers.SelectedItem as User;
     if (user == null)
     {
         return;
     }
     var result = MessageBox.Show("Are you sure?", "Warning!", MessageBoxButton.OKCancel);
     if (result == MessageBoxResult.Cancel)
     {
         return;
     }
     using (var uow = new UnitOfWork())
     {
         uow.Users.DeleteUser(user);
         uow.Commit();
     }
     lvUsers.Items.Remove(user);
 }
Beispiel #9
0
        private void LvCells_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var currentCell = lvCells.SelectedItem as LVCellsItems;
            if (currentCell == null)
            {
                return;
            }

            Cell cell;
            using (var uow = new UnitOfWork())
            {
                cell = uow.Cells.GetCell(currentCell.Id);
            }

            var window = new CellWindow(cell);
            window.Owner = this;
            window.ShowDialog();
            SetCellsValues();
        }
Beispiel #10
0
        private bool IsUserValues()
        {
            using (var uow = new UnitOfWork())
            {
                var users = uow.Users.GetListOfUsers();

                CurrentUser = users.FirstOrDefault(usr => usr.Login.Equals(txtLogin.Text) && usr.Password.Equals(txtPassword.Text));

                if (CurrentUser == null)
                {
                    return false;
                }

                CurrentUser.LastLoginedDate = DateTime.Now.Date;
                uow.Users.UpdateUser(CurrentUser);
                uow.Commit();
            }
            return true;
        }
Beispiel #11
0
        private void BtnDelete_OnClick(object sender, RoutedEventArgs e)
        {
            var currentCell = lvCells.SelectedItem as LVCellsItems;
            if (currentCell == null)
            {
                return;
            }
            var result = MessageBox.Show("Are you sure?", "Warning!", MessageBoxButton.OKCancel);
            if (result == MessageBoxResult.Cancel)
            {
                return;
            }

            using (var uow = new UnitOfWork())
            {
                var cell = uow.Cells.GetCell(currentCell.Id);
                uow.Cells.DeleteCell(cell);
                uow.Commit();
            }

            SetCellsValues();
        }
Beispiel #12
0
        private void SaveAndCloseButtonClick(object sender, RoutedEventArgs routedEventArgs)
        {
            if (!IsWarehouseValid())
            {
                return;
            }

            _warehouse.Name = txtName.Text;
            if (chkIsDefault.IsChecked != null)
            {
                _warehouse.IsDefault = (bool) chkIsDefault.IsChecked;
            }

            using (var uow = new UnitOfWork())
            {
                var whs = uow.Warehouses.GetWarehouses();

                foreach (var warehouse in whs)
                {
                    warehouse.IsDefault = false;
                    uow.Warehouses.UpdateWarehouse(warehouse);
                }

                if (_warehouse.Id == 0)
                {
                    uow.Warehouses.AddWarehouse(_warehouse);
                }
                else
                {
                    uow.Warehouses.UpdateWarehouse(_warehouse);
                }

                uow.Commit();
            }

            Close();
        }
Beispiel #13
0
        private void SaveAndCloseButtonClick(object sender, RoutedEventArgs routedEventArgs)
        {
            if (!IsGoodValuesValidated())
            {
                return;
            }

            GetGoodValues();

            using (var uow = new UnitOfWork())
            {
                if (_good.Id == 0)
                {
                    uow.Goods.AddGood(_good);
                }
                else
                {
                    uow.Goods.UpdateGood(_good);
                }

                uow.Commit();
            }

            Close();
        }
Beispiel #14
0
        private void SetConsignmentValues()
        {
            using (var uow = new UnitOfWork())
            {
                var consignments = uow.Consignments.GetListOfConsignments();

                foreach (var consignment in consignments)
                {
                    cbConsignment.Items.Add(consignment);

                }
                if (cbConsignment.Items.Count > 0)
                {
                    cbConsignment.SelectedIndex = 0;
                }
            }
        }
Beispiel #15
0
        private void UIElement_OnKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Return)
            {
                lvCells.Items.Clear();
                using (var uow = new UnitOfWork())
                {
                    var users = uow.Cells.GetLVCells().Where(cell => cell.Number.ToString().Contains(SearchTextBox.Text));

                    foreach (var user in users)
                    {
                        lvCells.Items.Add(user);
                    }
                }
            }
        }
Beispiel #16
0
        private void SaveCell()
        {
            using (var uow = new UnitOfWork())
            {
                if (_cell.Id == 0)
                {
                    uow.Cells.AddCell(_cell);
                }
                else
                {
                    uow.Cells.UpdateCell(_cell);
                }

                uow.Commit();
            }
        }
Beispiel #17
0
        private void SetWarehousesValues()
        {
            using (var uow = new UnitOfWork())
            {
                var whs = uow.Warehouses.GetWarehouses();
                foreach (var warehouse in whs)
                {
                    cbWarehouses.Items.Add(warehouse);
                }

                if (cbWarehouses.Items.Count > 0)
                {
                    cbWarehouses.SelectedIndex = 0;
                }
            }
        }
Beispiel #18
0
        private bool IsNumberExistsInWarehouse()
        {
            var warehouse = cbWarehouses.SelectedItem as Warehouse;
            var number = int.Parse(txtNumber.Text);

            IEnumerable<Cell> cells;

            using (var uow = new UnitOfWork())
            {
                cells = uow.Cells.GetCells();
            }

            return cells.Any(cell => cell.WarehouseId == warehouse.Id && cell.Number == number && cell.Id != _cell.Id);
        }
 private void SetUsersInListView()
 {
     lvUsers.Items.Clear();
     using (var uow = new UnitOfWork())
     {
         var users = uow.Users.GetListOfUsers();
         foreach (var user in users)
         {
             lvUsers.Items.Add(user);
         }
     }
 }
Beispiel #20
0
        private void BtnPick_OnClick(object sender, RoutedEventArgs e)
        {
            if (lvGoods.SelectedItems.Count <= 0)
            {
                return;
            }

            var result = MessageBox.Show("Are you sure?", "Warning!", MessageBoxButton.OKCancel);
            if (result == MessageBoxResult.Cancel)
            {
                return;
            }

            var goodsItems = lvGoods.SelectedItems.Cast<LVGoodItem>().Select(gi => new PickAndStoreObject(gi.Id, null, CurrentUser.Id, gi.Count)).ToList();

            using (var uow = new UnitOfWork())
            {
                foreach (var lvGoodItem in goodsItems)
                {
                    if (!uow.PickAndStoreValidationService.IsPickValid(lvGoodItem))
                    {
                        return;
                    }
                }

                foreach (var lvGoodItem in goodsItems)
                {
                    uow.PickAndStoreService.PickGood(lvGoodItem);
                }

                uow.Commit();
            }
        }
        private void UIElement_OnKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Return)
            {
                lvUsers.Items.Clear();
                using (var uow = new UnitOfWork())
                {
                    var users = uow.Users.GetListOfUsers().Where(usr => usr.Login.Contains(SearchTextBox.Text));

                    foreach (var user in users)
                    {
                        lvUsers.Items.Add(user);
                    }
                }
            }
        }
Beispiel #22
0
        private void UIElement_OnKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Return)
            {
                lvGoods.Items.Clear();
                using (var uow = new UnitOfWork())
                {
                    var goods = uow.Goods.GetLVGoods().Where(gd => gd.Name.Contains(SearchTextBox.Text));

                    foreach (var good in goods)
                    {
                        AddGoodToListView(good);
                    }
                }
            }
        }
Beispiel #23
0
        private void GetAllGoods()
        {
            using (var uow = new UnitOfWork())
            {
                var goods = uow.Goods.GetLVGoods();

                foreach (var good in goods)
                {
                    AddGoodToListView(good);
                }
            }
        }
Beispiel #24
0
        private void SaveUserValues()
        {
            using (var uow = new UnitOfWork())
            {
                if (_user.Id == 0)
                {
                    uow.Users.AddUser(_user);
                }
                else
                {
                    uow.Users.UpdateUser(_user);
                }

                uow.Commit();
            }
        }
Beispiel #25
0
 private bool IsUserExists()
 {
     using (var uow = new UnitOfWork())
     {
         return uow.Users.GetListOfUsers().Any(usr => usr.Login.Equals(txtLogin.Text));
     }
 }