コード例 #1
0
        public void PrintAllDocuments()
        {
            var empty     = true;
            int dataIndex = 0;

            String[][] data = new string[_allProducts.Count][];
            foreach (var product in _allProducts)
            {
                if (product.Catalog == null)
                {
                    product.Catalog = new Catalog {
                        CatalogValue = string.Empty
                    }
                }
                ;
                data[dataIndex] = new[] { $"{product.TotalPrice:#,0}", $"{product.ProductUnitPrice:#,0}", " " + product.Catalog.CatalogValue + product.ProductCount, product.ProductName, product.ProductId.ToString() };
                dataIndex++;
                empty = false;
            }

            if (empty)
            {
                var windowRemove = new RemoveWindow
                {
                    WindowTitle     = "لیست خالی است",
                    Caption         = "هیچ محصولی وجود ندارد.",
                    OneBtn          = true,
                    InformationIcon = true,
                    Btn2            = "باشه"
                };
                windowRemove.ShowDialog();
                return;
            }
            PrintDocuments.AssignmentDocument(data, 0, 2);
        }
コード例 #2
0
ファイル: Print.cs プロジェクト: lulzzz/allors2
        public int OnExecute(CommandLineApplication app)
        {
            var exitCode = ExitCode.Success;

            using (var session = this.databaseService.Database.CreateSession())
            {
                this.logger.LogInformation("Begin");

                var administrator = new Users(session).GetUser("administrator");
                session.SetUser(administrator);

                var printDocuments = new PrintDocuments(session).Extent();
                printDocuments.Filter.AddNot().AddExists(M.PrintDocument.Media);

                foreach (PrintDocument printDocument in printDocuments)
                {
                    var printable = printDocument.PrintableWherePrintDocument;
                    if (printable == null)
                    {
                        this.logger.LogWarning($"PrintDocument with id {printDocument.Id} has no Printable object");
                        continue;
                    }

                    try
                    {
                        printable.Print();

                        if (printable.ExistPrintDocument)
                        {
                            this.logger.LogInformation($"Printed {printable.PrintDocument.Media.FileName}");
                        }

                        session.Derive();
                        session.Commit();
                    }
                    catch (Exception e)
                    {
                        session.Rollback();
                        exitCode = ExitCode.Error;

                        this.logger.LogError(e, $"Could not print {printable.ToString()}");
                    }
                }

                this.logger.LogInformation("End");
            }

            return(exitCode);
        }
コード例 #3
0
        public void PrintByPplDocuments()
        {
            var empty     = true;
            int dataIndex = 0;
            int gapItems  = 0;

            String[][] data = new string[_allProducts.Count][];
            foreach (var product in _allProducts)
            {
                if (product.Catalog == null)
                {
                    product.Catalog = new Catalog {
                        CatalogValue = string.Empty
                    }
                }
                ;
                if (product.ProductPopularSupport)
                {
                    data[dataIndex] = new[] { " " + product.Catalog.CatalogValue + product.ProductCount, product.ProductName, product.ProductId.ToString() };
                    dataIndex++;
                    empty = false;
                }
                else
                {
                    gapItems++;
                }
            }

            if (empty)
            {
                var windowRemove = new RemoveWindow
                {
                    WindowTitle     = "لیست خالی است",
                    Caption         = "محصول کمک مردمی در لیست نیست.",
                    OneBtn          = true,
                    InformationIcon = true,
                    Btn2            = "باشه"
                };
                windowRemove.ShowDialog();
                return;
            }
            PrintDocuments.AssignmentDocument(data, gapItems, 3);
        }
コード例 #4
0
        public void PrintSelectedItems()
        {
            int dataIndex = 0;

            String[][] data = new string[GridViewMain.SelectedItems.Count][];
            foreach (var gridItem in GridViewMain.SelectedItems)
            {
                var product = gridItem as Product;
                if (product.Catalog == null)
                {
                    product.Catalog = new Catalog {
                        CatalogValue = String.Empty
                    }
                }
                ;
                data[dataIndex] = new[] { $"{product.TotalPrice:#,0}", $"{product.ProductUnitPrice:#,0}", " " + product.Catalog.CatalogValue + product.ProductCount, product.ProductName, product.ProductId.ToString() };
                dataIndex++;
            }
            PrintDocuments.AssignmentDocument(data, 0, 5);
        }
コード例 #5
0
ファイル: AddNewProducts.xaml.cs プロジェクト: DiniMad/Nasibe
        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);
        }
コード例 #6
0
ファイル: DocumentWindow.xaml.cs プロジェクト: DiniMad/Nasibe
        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();
            }
        }
コード例 #7
0
ファイル: DocumentWindow.xaml.cs プロジェクト: DiniMad/Nasibe
        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);
            }
        }