Example #1
0
        public void LoadEditContent()
        {
            ComboBoxUnitQty.ItemsSource       = CatalogTable.SelectFromCatalogTable();
            ComboBoxUnitQty.DisplayMemberPath = "CatalogValue";
            ComboBoxUnitQty.SelectedValuePath = "CatalogId";
            var product = ProductTable.SelectSingleProduct(Pid);

            TxtTitle.Text       = product.ProductName;
            TxtPrice.Text       = product.ProductUnitPrice.ToString();
            TxtQty.Text         = product.ProductCount.ToString();
            TxtDescription.Text = string.Empty;
            TxtDescription.AppendText(product.ProductDescription);
            var ppl = product.ProductPopularSupport;

            if (ppl)
            {
                YesToPpl.IsChecked = true;
            }
            else
            {
                NoToPpl.IsChecked = true;
            }
            if (product.Catalog != null)
            {
                ComboBoxUnitQty.SelectedValue = product.Catalog.CatalogId;
            }
        }
Example #2
0
        private void RadButton_Click(object sender, RoutedEventArgs e)
        {
            var catalogItemsWindow = new UnitQtyItmesWindow {
                Changed = false
            };

            catalogItemsWindow.ShowDialog();
            if (catalogItemsWindow.Changed)
            {
                ComboBoxUnitQty.ItemsSource       = CatalogTable.SelectFromCatalogTable();
                ComboBoxUnitQty.DisplayMemberPath = "CatalogValue";
                ComboBoxUnitQty.SelectedValuePath = "CatalogId";
                ComboBoxUnitQty.SelectedIndex     = ComboBoxUnitQty.Items.Count - 1;
            }
            else
            {
                var product = ProductTable.SelectSingleProduct(Pid);
                if (product.Catalog == null)
                {
                    return;
                }
                ComboBoxUnitQty.SelectedValue = product.Catalog.CatalogValue;
            }
        }
Example #3
0
        private void BtnInventoryDocument_Click(object sender, RoutedEventArgs e)
        {
            bool emptyList = true;

            if (CheckForSameItem())
            {
                return;
            }
            foreach (var panelChild in PanelProductRecord.Children)
            {
                var searchItem = panelChild as SearchBoxUC;
                if (!string.IsNullOrWhiteSpace(searchItem.LblStatus.Content.ToString()))
                {
                    if (searchItem.LblStatus.Content.ToString() == "نیاز به خرید")
                    {
                        var windowRemove = new RemoveWindow
                        {
                            WindowTitle     = "موجودی انبار را تکمیل کنید",
                            Caption         = $"موجودی \"{searchItem.SearchBox.SearchText}\" کافی نیست.",
                            InformationIcon = true,
                            OneBtn          = true,
                            Btn2            = "باشه"
                        };
                        windowRemove.ShowDialog();
                        return;
                    }
                }
            }
            foreach (var panelChild in PanelProductRecord.Children)
            {
                var product = panelChild as SearchBoxUC;
                if (!string.IsNullOrWhiteSpace(product.LblStatus.Content.ToString()))
                {
                    emptyList = false;
                    break;
                }
            }
            if (emptyList)
            {
                var windowRemove = new RemoveWindow
                {
                    WindowTitle     = "لیست خالی است",
                    Caption         = "لیست خالی است.\nبرای افزودن به لیست روی جدید کلیک کنید.",
                    InformationIcon = true,
                    OneBtn          = true,
                    Btn2            = "باشه"
                };
                windowRemove.ShowDialog();
                return;
            }
            var windowWarning = new RemoveWindow
            {
                WindowTitle = "ایجاد حواله",
                Caption     = "با ایجاد حواله مقادیر از موجودی کم میشوند.\nادامه میدهید؟",
                Btn1        = "ادامه",
                Btn2        = "انصراف"
            };

            windowWarning.ShowDialog();
            if (windowWarning.Accept)
            {
                int        dataIndex = 0;
                int        gapItem   = 0;
                String[][] data      = new string[PanelProductRecord.Children.Count][];
                foreach (var panelChild in PanelProductRecord.Children)
                {
                    var searchBoxItem = panelChild as SearchBoxUC;
                    var produc        = new Product();
                    if (!string.IsNullOrWhiteSpace(searchBoxItem.LblStatus.Content.ToString()))
                    {
                        if (searchBoxItem.SearchBox.SelectedItem == null)
                        {
                            produc = ProductTable.SelectSingleProduct(searchBoxItem.SearchBox.SearchText);
                            searchBoxItem.LblId = produc.ProductId;
                        }
                        else
                        {
                            produc = ProductTable.SelectSingleProduct((searchBoxItem.SearchBox.SelectedItem as Product).ProductId);
                        }
                        if (string.IsNullOrWhiteSpace(searchBoxItem.LblTotalPrice.Content.ToString()))
                        {
                            searchBoxItem.LblTotalPrice.Content = "0";
                        }
                        searchBoxItem.LblQty = searchBoxItem.TxtUserQty.Text.Replace(" ", String.Empty);
                        var totalPrice = (Double.Parse(searchBoxItem.LblQty.ToString()) *
                                          int.Parse(searchBoxItem.LblTotalPrice.Content.ToString()));
                        data[dataIndex] = new[]
                        {
                            $"{totalPrice:#,0}", $"{searchBoxItem.LblTotalPrice.Content:#,0}",
                            " " + produc.Catalog.CatalogValue + searchBoxItem.TxtUserQty.Text,
                            searchBoxItem.SearchBox.SearchText, searchBoxItem.LblId.ToString()
                        };
                        dataIndex++;
                        var newQty = (produc.ProductCount -
                                      double.Parse(searchBoxItem.TxtUserQty.Text.Replace(" ", String.Empty)));
                        if (newQty == 0)
                        {
                            ProductTable.DeleteFromProductTable(produc.ProductId);
                        }
                        else
                        {
                            ProductTable.UpdateProductTabel(new Product()
                            {
                                ProductId             = produc.ProductId,
                                ProductName           = produc.ProductName,
                                ProductUnitPrice      = produc.ProductUnitPrice,
                                ProductCount          = newQty,
                                Catalog               = CatalogTable.SelectFromCatalogTable().SingleOrDefault(c => c.CatalogId == produc.Catalog.CatalogId),
                                ProductPopularSupport = produc.ProductPopularSupport,
                                ProductDescription    = produc.ProductDescription
                            });
                        }
                    }
                    else
                    {
                        gapItem++;
                    }
                }

                PrintDocuments.AssignmentDocument(data, gapItem, 1);
                PanelProductRecord.Children.Clear();
                Window_Loaded(null, null);
            }
        }