Пример #1
0
        private void BtnInventoryRequest_Click(object sender, RoutedEventArgs e)
        {
            var needRequestDocument = false;

            if (CheckForSameItem())
            {
                return;
            }
            foreach (var panelChild in PanelProductRecord.Children)
            {
                var searchItem = panelChild as SearchBoxUC;
                if (searchItem.LblStatus.Content.ToString() == "نیاز به خرید")
                {
                    needRequestDocument = true;
                    break;
                }
            }
            if (!needRequestDocument)
            {
                var windowRemove = new RemoveWindow
                {
                    WindowTitle     = "اقلام لیست در انبار موجود است",
                    Caption         = "کسری موجودی برای درخواست خرید نیست.",
                    InformationIcon = true,
                    OneBtn          = true,
                    Btn2            = "باشه"
                };
                windowRemove.ShowDialog();
                return;
            }
            foreach (var panelChild in PanelProductRecord.Children)
            {
                var searchItem = panelChild as SearchBoxUC;
                if (searchItem.BtnNewRecord.Visibility == Visibility.Visible)
                {
                    break;
                }
                if (string.IsNullOrWhiteSpace(searchItem.SearchBox.SearchText))
                {
                    var windowRemove = new RemoveWindow
                    {
                        WindowTitle     = "عنوان نمیتواند خالی باشد",
                        Caption         = "مقادیر عنوان را وارد کنید.",
                        InformationIcon = true,
                        OneBtn          = true,
                        Btn2            = "باشه"
                    };
                    windowRemove.ShowDialog();
                    return;
                }
            }
            foreach (var panelChild in PanelProductRecord.Children)
            {
                var searchItem = panelChild as SearchBoxUC;
                if (searchItem.BtnNewRecord.Visibility == Visibility.Visible)
                {
                    break;
                }
                if (string.IsNullOrWhiteSpace(searchItem.TxtUserQty.Text))
                {
                    var windowRemove = new RemoveWindow
                    {
                        WindowTitle     = "مقدار نمیتواند خالی باشد",
                        Caption         = "مقدار را وارد کنید.",
                        InformationIcon = true,
                        OneBtn          = true,
                        Btn2            = "باشه"
                    };
                    windowRemove.ShowDialog();
                    return;
                }
            }
            foreach (var panelChild in PanelProductRecord.Children)
            {
                var searchItem = panelChild as SearchBoxUC;
                if (searchItem.BtnNewRecord.Visibility == Visibility.Visible)
                {
                    break;
                }
                if (!string.IsNullOrWhiteSpace(searchItem.LblQtyWithUnit.Content.ToString()))
                {
                    continue;
                }
                if (searchItem.ComboBoxUnitQty.SelectedValue == null)
                {
                    var windowRemove = new RemoveWindow
                    {
                        WindowTitle     = "مقدار نمیتواند خالی باشد",
                        Caption         = "مقدار را وارد کنید.",
                        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;


                    if (searchBoxItem.LblStatus.Content.ToString() == "نیاز به خرید")
                    {
                        var qty    = searchBoxItem.TxtUserQty.Text.Replace("  ", String.Empty);
                        var produc = searchBoxItem.SearchBox.SelectedItem as Product;
                        if (searchBoxItem.SearchBox.SelectedItem != null)
                        {
                            qty = " " + produc.Catalog.CatalogValue + ((produc.ProductCount - double.Parse(searchBoxItem.TxtUserQty.Text.Replace(" ", String.Empty))) * -1);
                        }
                        else
                        {
                            qty = " " + searchBoxItem.ComboBoxUnitQty.Text + qty;
                        }
                        data[dataIndex] = new[] { "", searchBoxItem.SearchBox.SearchText, qty, (dataIndex + 1).ToString() };
                        dataIndex++;
                        if (searchBoxItem.SearchBox.SelectedItem != null)
                        {
                            ProductTable.UpdateProductTabel(new Product()
                            {
                                ProductId             = produc.ProductId,
                                ProductName           = produc.ProductName,
                                ProductUnitPrice      = produc.ProductUnitPrice,
                                ProductCount          = double.Parse(searchBoxItem.TxtUserQty.Text.Replace(" ", String.Empty)),
                                ProductPopularSupport = produc.ProductPopularSupport,
                                ProductDescription    = produc.ProductDescription
                            });
                        }
                        else
                        {
                            ProductTable.InsertIntoProductTable(new Product()
                            {
                                ProductName           = searchBoxItem.SearchBox.SearchText,
                                ProductCount          = double.Parse(searchBoxItem.TxtUserQty.Text.Replace(" ", string.Empty)),
                                Catalog               = CatalogTable.SelectFromCatalogTable().Single(c => c.CatalogId == int.Parse(searchBoxItem.ComboBoxUnitQty.SelectedValue.ToString())),
                                ProductUnitPrice      = 0,
                                ProductData           = persianDate,
                                ProductPopularSupport = false,
                                ProductDescription    = ""
                            });
                        }
                    }
                    else
                    {
                        gapItem++;
                    }
                }
                PrintDocuments.RequestDocument(data, gapItem);
                ConfirmInventory();
            }
        }
Пример #2
0
 private void BtnAccept_Click(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrWhiteSpace(TxtTitle.Text))
     {
         var windowRemove = new RemoveWindow
         {
             WindowTitle     = "عنوان را پر کنید",
             Caption         = "عنوان نمیتواند خالی باشد.",
             InformationIcon = true,
             OneBtn          = true,
             Btn2            = "باشه"
         };
         windowRemove.ShowDialog();
         return;
     }
     if (string.IsNullOrWhiteSpace(TxtQty.Text))
     {
         var windowRemove = new RemoveWindow
         {
             WindowTitle     = "مقدار را پر کنید",
             Caption         = "مقدار نمیتواند خالی باشد.",
             InformationIcon = true,
             OneBtn          = true,
             Btn2            = "باشه"
         };
         windowRemove.ShowDialog();
         return;
     }
     if (string.IsNullOrWhiteSpace(ComboBoxUnitQty.Text))
     {
         var windowRemove = new RemoveWindow
         {
             WindowTitle     = "واحد مقدار را انتخاب کنید",
             Caption         = "واحد مقدار نمیتواند خالی باشد.",
             InformationIcon = true,
             OneBtn          = true,
             Btn2            = "باشه"
         };
         windowRemove.ShowDialog();
         return;
     }
     if (string.IsNullOrWhiteSpace(TxtPrice.Text) || TxtPrice.IsEnabled == false)
     {
         TxtPrice.Text = "0";
     }
     TxtPrice.Text = TxtPrice.Text.Replace(" ", string.Empty);
     TxtQty.Text   = TxtQty.Text.Replace(" ", string.Empty);
     if (ProductTable.UpdateProductTabel(new Product()
     {
         ProductId = Pid,
         ProductName = TxtTitle.Text,
         ProductUnitPrice = int.Parse(TxtPrice.Text.Trim()),
         ProductCount = float.Parse(TxtQty.Text),
         Catalog = CatalogTable.SelectFromCatalogTable().Single(c => c.CatalogId == int.Parse(ComboBoxUnitQty.SelectedValue.ToString())),
         ProductPopularSupport = YesToPpl.IsChecked == true,
         ProductDescription = TxtDescription.Text
     }))
     {
         Close();
     }
 }
Пример #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);
            }
        }