Esempio n. 1
0
        private bool CheckForSameItem()
        {
            var panelItems           = PanelProductRecord.Children.Cast <AddBoxUC>();
            var selectedProductNames = panelItems.Select(n => n.TxtTitle.SearchText).ToArray();

            foreach (var productName in selectedProductNames)
            {
                if (selectedProductNames.Where(n => n == productName).ToList().Count <= 1)
                {
                    continue;
                }
                {
                    var twoOperetionOnOnProduct = new RemoveWindow
                    {
                        WindowTitle = "مورد مشابه",
                        Caption     = $"شما کالای {productName} را دوبار انتخاب کرده اید.\nلطفا یکی را حذف کنید.",
                        OneBtn      = true,
                        Btn2        = "باشه"
                    };
                    twoOperetionOnOnProduct.ShowDialog();
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 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();
     }
 }
Esempio n. 3
0
        private void BtnPrintReceipt_Click(object sender, RoutedEventArgs e)
        {
            if (CheckForSameItem())
            {
                return;
            }
            var byPpl = false;

            foreach (var panelChild in PanelProductRecord.Children)
            {
                var addBoxItem = panelChild as AddBoxUC;
                if (addBoxItem.RadioButtonByPpl.IsChecked != true &&
                    addBoxItem.LblByPpl.Content.ToString() != "مردمی")
                {
                    continue;
                }
                byPpl = true;
                break;
            }
            if (!byPpl)
            {
                var windowRemove = new RemoveWindow
                {
                    WindowTitle     = "هیچ کالای مردمی نیست",
                    Caption         = "کالای اهدایی از طرف مردم در لیست نیست.",
                    OneBtn          = true,
                    InformationIcon = true,
                    Btn2            = "باشه"
                };
                windowRemove.ShowDialog();
                return;
            }
            foreach (var panelChild in PanelProductRecord.Children)
            {
                var addBoxItem = panelChild as AddBoxUC;
                if (string.IsNullOrWhiteSpace(addBoxItem.TxtTitle.SearchText) && addBoxItem.BtnNewRecord.Visibility == Visibility.Hidden)
                {
                    var windowRemove = new RemoveWindow
                    {
                        WindowTitle     = "عنوان نمیتواند خالی باشد",
                        Caption         = ".مقادیر عنوان را وارد کنید",
                        OneBtn          = true,
                        InformationIcon = true,
                        Btn2            = "باشه"
                    };
                    windowRemove.ShowDialog();
                    return;
                }
            }
            foreach (var panelChild in PanelProductRecord.Children)
            {
                var addBoxItem = panelChild as AddBoxUC;
                if (string.IsNullOrWhiteSpace(addBoxItem.TxtUserQty.Text) && addBoxItem.BtnNewRecord.Visibility == Visibility.Hidden)
                {
                    var windowRemove = new RemoveWindow
                    {
                        WindowTitle     = "مقدار نمیتواند خالی باشد",
                        Caption         = "مقدار را وارد کنید.",
                        InformationIcon = true,
                        OneBtn          = true,
                        Btn2            = "باشه"
                    };
                    windowRemove.ShowDialog();
                    return;
                }
            }
            foreach (var panelChild in PanelProductRecord.Children)
            {
                var addBoxItem = panelChild as AddBoxUC;
                if (string.IsNullOrWhiteSpace(addBoxItem.ComboBoxUnitQty.Text) & addBoxItem.BtnNewRecord.Visibility == Visibility.Hidden && string.IsNullOrWhiteSpace(addBoxItem.LblByPpl.Content.ToString()))
                {
                    var windowRemove = new RemoveWindow
                    {
                        WindowTitle     = "واحد مقدار نمیتواند خالی باشد",
                        Caption         = "واحد مقدار را انتخاب کنید.",
                        InformationIcon = true,
                        OneBtn          = true,
                        Btn2            = "باشه"
                    };
                    windowRemove.ShowDialog();
                    return;
                }
            }
            int dataIndex = 0;
            int gapItem   = 0;

            String[][] data = new string[PanelProductRecord.Children.Count][];
            foreach (var panelItem in PanelProductRecord.Children)
            {
                var addBoxItem = panelItem as AddBoxUC;
                if (addBoxItem.BtnNewRecord.Visibility == Visibility.Visible)
                {
                    gapItem++;
                    break;
                }
                if (addBoxItem.RadioButtonByPpl.IsChecked == true || addBoxItem.LblByPpl.Content.ToString() == "مردمی")
                {
                    // if (string.IsNullOrWhiteSpace(searchBoxItem.LblTotalPrice.Content.ToString()))
                    //     searchBoxItem.LblTotalPrice.Content = "1";
                    // searchBoxItem.LblQty.Content = searchBoxItem.TxtUserQty.Text.Replace(" ", String.Empty);
                    // var totalPrice = (Double.Parse(searchBoxItem.LblQty.Content.ToString()) *
                    //                   int.Parse(searchBoxItem.LblTotalPrice.Content.ToString()));
                    if (string.IsNullOrWhiteSpace(addBoxItem.ComboBoxUnitQty.Text))
                    {
                        addBoxItem.ComboBoxUnitQty.Text =
                            (addBoxItem.TxtTitle.SelectedItem as Product)?.Catalog.CatalogValue;
                    }
                    data[dataIndex] = new[] { "", "0", "0", addBoxItem.TxtUserQty.Text.Replace(" ", string.Empty), addBoxItem.ComboBoxUnitQty.Text, addBoxItem.TxtTitle.SearchText, (dataIndex + 1).ToString() };
                    dataIndex++;
                }
                else
                {
                    gapItem++;
                }
            }
            PrintDocuments.ReceiptDocument(data, gapItem);
        }
Esempio n. 4
0
        private void BtnAdd_Click(object sender, RoutedEventArgs e)
        {
            var done = true;

            if (CheckForSameItem())
            {
                return;
            }
            foreach (var panelChild in PanelProductRecord.Children)
            {
                var addBoxItem = panelChild as AddBoxUC;
                if (string.IsNullOrWhiteSpace(addBoxItem.TxtTitle.SearchText) && addBoxItem.BtnNewRecord.Visibility == Visibility.Hidden)
                {
                    var windowRemove = new RemoveWindow
                    {
                        WindowTitle     = "عنوان نمیتواند خالی باشد",
                        Caption         = "مقادیر عنوان را وارد کنید.",
                        InformationIcon = true,
                        OneBtn          = true,
                        Btn2            = "باشه"
                    };
                    windowRemove.ShowDialog();
                    return;
                }
            }
            foreach (var panelChild in PanelProductRecord.Children)
            {
                var addBoxItem = panelChild as AddBoxUC;
                if (string.IsNullOrWhiteSpace(addBoxItem.TxtUserQty.Text) && addBoxItem.BtnNewRecord.Visibility == Visibility.Hidden)
                {
                    var windowRemove = new RemoveWindow
                    {
                        WindowTitle     = "مقدار نمیتواند خالی باشد",
                        Caption         = "مقدار را وارد کنید.",
                        InformationIcon = true,
                        OneBtn          = true,
                        Btn2            = "باشه"
                    };
                    windowRemove.ShowDialog();
                    return;
                }
            }
            foreach (var panelChild in PanelProductRecord.Children)
            {
                var addBoxItem = panelChild as AddBoxUC;
                if (string.IsNullOrWhiteSpace(addBoxItem.ComboBoxUnitQty.Text) && addBoxItem.ComboBoxUnitQty.Visibility == Visibility.Visible)
                {
                    var windowRemove = new RemoveWindow
                    {
                        WindowTitle     = "واحد مقدار نمیتواند خالی باشد",
                        Caption         = "واحد مقدار را انتخاب کنید.",
                        InformationIcon = true,
                        OneBtn          = true,
                        Btn2            = "باشه"
                    };
                    windowRemove.ShowDialog();
                    return;
                }
            }
            foreach (var panelChild in PanelProductRecord.Children)
            {
                var addBoxItem = panelChild as AddBoxUC;
                if (string.IsNullOrWhiteSpace(addBoxItem.TxtPrice.Text) && addBoxItem.TxtPrice.IsEnabled == true && addBoxItem.TxtPrice.Visibility == Visibility.Visible)
                {
                    var windowRemove = new RemoveWindow
                    {
                        WindowTitle     = "قیمت نمیتواند خالی باشد",
                        Caption         = "مقادیر قیمت را وارد کنید.",
                        InformationIcon = true,
                        OneBtn          = true,
                        Btn2            = "باشه"
                    };
                    windowRemove.ShowDialog();
                    return;
                }
            }
            foreach (var panelChild in PanelProductRecord.Children)
            {
                var addBoxItem = panelChild as AddBoxUC;
                if (addBoxItem.TxtTitle.SelectedItem != null)
                {
                    var selectedWarningWindow = new RemoveWindow()
                    {
                        WindowTitle = "کالا موجود است",
                        Caption     = "نام کالا موجود است.\nمقدار مورد نظر به کالای موجود افزوده میشود.",
                        Btn1        = "ادامه",
                        Btn2        = "انصراف"
                    };
                    selectedWarningWindow.ShowDialog();
                    if (selectedWarningWindow.Accept)
                    {
                        break;
                    }
                    return;
                }
            }
            foreach (var panelChild in PanelProductRecord.Children)
            {
                var addBoxItem = panelChild as AddBoxUC;
                if (addBoxItem.BtnNewRecord.Visibility == Visibility.Visible)
                {
                    break;
                }
                var byPpl = false;
                if (addBoxItem.RadioButtonByPpl.IsChecked == true)
                {
                    addBoxItem.TxtPrice.Text = "0";
                    byPpl = true;
                }

                if (addBoxItem.TxtTitle.SelectedItem == null)
                {
                    var cata = _catalogItems.Single(c =>
                                                    c.CatalogId == Convert.ToInt32(addBoxItem.ComboBoxUnitQty.SelectedValue.ToString()));
                    if (!ProductTable.InsertIntoProductTable(new Product()
                    {
                        ProductName = addBoxItem.TxtTitle.SearchText,
                        ProductCount = double.Parse(addBoxItem.TxtUserQty.Text),
                        ProductUnitPrice = int.Parse(addBoxItem.TxtPrice.Text),
                        ProductPopularSupport = byPpl,
                        ProductDescription = addBoxItem.TxtDescription.Text,
                        Catalog = cata
                    }))
                    {
                        done = false;
                    }
                }
                else
                {
                    var newCount = double.Parse(addBoxItem.TxtUserQty.Text.Replace(" ", string.Empty)) + double.Parse(addBoxItem.LblQty.Content.ToString());
                    if (!ProductTable.UpdateQty(int.Parse(addBoxItem.LblId.ToString()), newCount))
                    {
                        done = false;
                    }
                }
            }
            if (!done)
            {
                return;
            }
            var windowWarning = new RemoveWindow()
            {
                WindowTitle     = "موفقیت آمیز",
                Caption         = "عملیات با موفقیت انجام شد.",
                InformationIcon = true,
                OneBtn          = true,
                Btn2            = "باشه"
            };

            windowWarning.ShowDialog();
            ResetNameTextBoxFocus();
        }
Esempio n. 5
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();
            }
        }
Esempio n. 6
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);
            }
        }