예제 #1
0
        private void btn_remove_Click(object sender, RoutedEventArgs e)
        {
            RepackStockModel productContent = (RepackStockModel)lvProductDetails.SelectedItem;

            OpeningStocks.Remove(productContent);
            lvProductDetails.ItemsSource = OpeningStocks;
            btn_remove.IsEnabled         = false;
            btn_remove.Background        = System.Windows.Media.Brushes.Gray;
            CalculateStock(null);
        }
예제 #2
0
        private void TextBox_KeyUp(object sender, KeyEventArgs e)
        {
            RepackStockModel product = null;
            string           value   = ((System.Windows.Controls.TextBox)e.Source).Text;

            if (string.IsNullOrWhiteSpace(value))
            {
                product = (RepackStockModel)((FrameworkElement)e.Source).DataContext;
            }
            CalculateStock(product);
        }
예제 #3
0
        private void AddItemSource(ProductModel openingModel)
        {
            CurrentRepackStockVm pack = null;

            currentStockofBulk  = OpeningStockController.GetCurrentStockByProductCode(openingModel.BulkCode.Value);
            selectedBulkProduct = controller.GetProductsById(UserModelVm.CompanyId, UserModelVm.BranchId, openingModel.BulkCode.Value);
            var SavedBulkData = controller.GetRepackByBulkId(0, null, openingModel.BulkCode.Value);

            if (SavedBulkData.Any())
            {
                pack = GetCurrentStock(_products, SavedBulkData);
            }
            if (currentStockofBulk > 0)
            {
                RepackStockModel _openingStock = new RepackStockModel();
                _openingStock.ProductName = openingModel.ItemName;
                _openingStock.productCode = Convert.ToInt64(openingModel.Id);
                //_openingStock.CurrentStock = OpeningStockController.GetCurrentStockByProductCode(Convert.ToInt64(openingModel.Id));
                _openingStock.RetailPrice    = openingModel.RetailPrice;
                _openingStock.Weight         = openingModel.Weight;
                OpeningStocks[rowIndex]      = _openingStock;
                lvProductDetails.ItemsSource = OpeningStocks;
                if (pack == null)
                {
                    CalculateStock(null);
                }
                else
                {
                    AddIntoBulk(selectedBulkProduct, pack);
                }
                txt_BulkName.Text     = selectedBulkProduct.ItemName;
                txt_Weight.Text       = Convert.ToString(selectedBulkProduct.Weight);
                txt_Cost.Text         = Convert.ToString(selectedBulkProduct.TradePrice);
                txt_LatestSale.Text   = Convert.ToString(selectedBulkProduct.RetailPrice);
                txt_CurrentStock.Text = pack != null?Convert.ToString(pack.CurrentStock) : Convert.ToString(currentStockofBulk);
            }
            else
            {
                //  AddIntoBulk(selectedBulkProduct, pack);
                ErroMessage((string)Application.Current.Resources["repack_NoStockRemain_Error"], header);
                selectedBulkProduct = null;
                ClearFields();
                // ConfirmationPopup form = new ConfirmationPopup("There is no stock for this", "Repack", false);
                // form.ShowDialog();
            }
        }
예제 #4
0
 private void txtProduct_PreviewMouseDown(object sender, MouseButtonEventArgs e)
 {
     productPopUp.IsOpen   = true;
     this.IsEnabled        = false;
     btn_remove.IsEnabled  = false;
     btn_remove.Background = System.Windows.Media.Brushes.Gray;
     //  this.ApplicationBar.IsVisible = false;
     //ProductListPopUp productList = new ProductListPopUp();
     //productList.ShowDialog();
     System.Windows.Controls.ListViewItem lvi = GetAncestorByType(
         e.OriginalSource as DependencyObject, typeof(System.Windows.Controls.ListViewItem)) as System.Windows.Controls.ListViewItem;
     if (lvi != null)
     {
         lvProductDetails.SelectedIndex =
             lvProductDetails.ItemContainerGenerator.IndexFromContainer(lvi);
         rowIndex       = lvProductDetails.SelectedIndex;
         _selectedStock = (RepackStockModel)lvProductDetails.SelectedItem;
     }
 }
예제 #5
0
        private void CalculateStock(RepackStockModel product)
        {
            var Stocks = lvProductDetails.Items.Cast <RepackStockModel>().Select(x => x).ToList();

            if (Stocks.Where(x => x.ProductCode > 0 && x.Quantity > 0).Any())
            {
                Stocks.ToList().ForEach(x =>
                {
                    x.ProductCode        = x.productCode;
                    x.Id                 = x.Id;
                    x.ProductName        = x.ProductName;
                    x.Quantity           = x.Quantity;
                    x.Weight             = x.Weight;
                    x.RetailPrice        = x.RetailPrice;
                    x.BatchNo            = x.BatchNo;
                    x.CompanyCode        = x.CompanyCode;
                    x.TotalQuantityStock = x.Quantity * x.Weight;
                });
                decimal?TotalStockInUse = Stocks.Sum(x => x.TotalQuantityStock).Value;
                if (TotalStockInUse > selectedBulkProduct.Weight * currentStockofBulk)
                {
                    ErroMessage((string)Application.Current.Resources["repack_bulkweight_Error"], header);
                    txt_Packed.Text    = Convert.ToString(0);
                    txt_AvailPack.Text = Convert.ToString(currentStockofBulk);
                }
                else
                {
                    if (product != null)
                    {
                        TotalStockInUse = TotalStockInUse - product.Quantity * product.Weight;
                    }
                    decimal?totalPacked = GetTotalPackedItems(TotalStockInUse);
                    txt_Packed.Text    = Convert.ToString(totalPacked);
                    txt_AvailPack.Text = Convert.ToString(currentStockofBulk - totalPacked);
                }
            }
            if (Stocks.Count == 0)
            {
                selectedBulkProduct = null;
                ClearFields();
            }
        }