/// <summary>
        /// The delete transaction click, from Transaction View will delete the row of transaction with a message box before it goes through
        /// </summary>
        /// <param name="sender">
        /// The sender is the parent object of the button, which is the Data Grid
        /// </param>
        /// <param name="e">
        /// The e is the event arguments if applicable
        /// </param>
        private void DeleteTransClick(object sender, RoutedEventArgs e)
        {
            var transView = ((FrameworkElement)sender).DataContext as TransactionView;

            if (MessageBox.Show("Are you want to Delete - " + transView.RefNo + "?", "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                foreach (var trans in transView.Transactions)
                {
                    var prod = Product.GetProduct(trans.Product.Id);
                    if (transView.TransactionType == "Purchased")
                    {
                        Product.BalanceCasePackPiece(trans, prod, "Sales");
                    }
                    else
                    {
                        Product.BalanceCasePackPiece(trans, prod, "Purchased");
                    }

                    Product.EditProduct(prod);
                }
                TransactionOrder.DeleteTransaction(transView.Id);
            }

            this.InitializeTransView();
            this.InitializeProductsFilter(this.locationFilterProduct, this.principalFilterProduct, this.categoryFilterProduct);
        }
        /// <summary>
        /// The export transaction click, from Transaction View will create a window to export the invoice of a transaction
        /// </summary>
        /// <param name="sender">
        /// The sender is the parent object of the button, which is the Data Grid
        /// </param>
        /// <param name="e">
        /// The e is the event arguments if applicable
        /// </param>
        private void ExportTransClick(object sender, RoutedEventArgs e)
        {
            var transView = ((FrameworkElement)sender).DataContext as TransactionView;
            var trans     = TransactionOrder.GetTransaction(transView.Id);

            ExcelExport.ExcelInvoice.ExportTransactionInvoice(trans);
        }
        /// <summary>
        /// The details transaction click, from Transaction View will check if a new value is selected and will initialize again
        /// </summary>
        /// <param name="sender">
        /// The sender is the parent object of the combo box, which is the Data Grid
        /// </param>
        /// <param name="e">
        /// The e is the event arguments if applicable
        /// </param>
        private void DetailsTransClick(object sender, RoutedEventArgs e)
        {
            var     transView = ((FrameworkElement)sender).DataContext as TransactionView;
            Details details   = new Details(TransactionOrder.GetTransaction(transView.Id));

            details.Show();
        }
Esempio n. 4
0
 public static string TrackAddTrans(TransactionOrder order)
 {
     try
     {
         return
             (Environment.NewLine + @"_itq.push([""_addTrans""," +
              @"""" + order.OrderNumber + @"""," + Environment.NewLine +
              @"""" + order.StoreName + @"""," + Environment.NewLine +
              @"""" + order.OrderTotal + @"""," + Environment.NewLine +
              @"""" + order.OrderTax + @"""," + Environment.NewLine +
              @"""" + order.ShippingFee + @"""," + Environment.NewLine +
              @"""" + order.ShippingCity + @"""," + Environment.NewLine +
              @"""" + order.ShippingState + @"""," + Environment.NewLine +
              @"""" + order.Country + @"""," + Environment.NewLine +
              "[" + Environment.NewLine +
              @"    {""name"": ""Transaction.Currency"", ""value"": """ + order.TransactionCurrency + @"""}," + Environment.NewLine +
              @"{""name"": ""Customer.Email"", ""value"": """ + order.Customer.Email + @"""}," + Environment.NewLine +
              @"{""name"": ""Customer.First Name"", ""value"": """ + order.Customer.FirstName + @"""}," + Environment.NewLine +
              @"{""name"": ""Customer.Last Name"", ""value"": """ + order.Customer.LastName + @"""}," + Environment.NewLine +
              @"{""name"": ""Customer.Current Language"", ""value"": """ + order.Customer.Language + @"""}," + Environment.NewLine +
              @"{""name"": ""Customer.Address 1"", ""value"": """ + order.Customer.Address1 + @"""}," + Environment.NewLine +
              @"{""name"": ""Customer.Address 2"", ""value"": """ + order.Customer.Address2 + @"""}," + Environment.NewLine +
              @"{""name"": ""Customer.Town"", ""value"": """ + order.Customer.Town + @"""}," + Environment.NewLine +
              @"{""name"": ""Customer.Postcode"", ""value"": """ + order.Customer.PostCode + @"""}," + Environment.NewLine +
              @"{""name"": ""Customer.Subscribed"", ""value"": ""false""}" + Environment.NewLine +
              "]" + Environment.NewLine +
              "]);" + Environment.NewLine);
     }
     catch (Exception ex)
     {
         return(string.Empty);
     }
 }
Esempio n. 5
0
        /// <summary>
        /// The initialize settings.
        /// </summary>
        public void InitializeSettings()
        {
            var config = StockbookWindows.OpenConfig();

            this.LastBackup.Text                = config.LastBackup.ToLongDateString();
            this.LocationTextBox.Text           = config.AutoBackupLocation;
            this.AutoBackupCheckBox.IsChecked   = config.IsAutoBackupOn;
            this.RetainBackupCheckBox.IsChecked = config.IsRetainHistoryOn;
            this.RetainCountTextBox.Text        = config.RetainHistoryCount.ToString();
            switch (config.TimeIntervalAutoBackup)
            {
            case "Weekly":
                this.WeeklyBackupRadioButton.IsChecked = true;
                break;

            case "Daily":
                this.DailyBackupRadioButton.IsChecked = true;
                break;

            case "Hourly":
                this.HourlyBackupRadioButton.IsChecked = true;
                break;
            }

            this.ProductCountTextBlock.Text     = Product.GetAllProducts().Count.ToString();
            this.TransactionCountTextBlock.Text = TransactionOrder.GetAllTransactions().Count.ToString();

            this.CompanyNameTextBox.Text = config.CompanyName;

            this.CurrencyComboBox.Items.Clear();
            this.CurrencyComboBox.Items.Add("PHP - ₱");
            this.CurrencyComboBox.Items.Add("USD - $");
            this.CurrencyComboBox.Items.Add("YEN - ¥");
            this.CurrencyComboBox.SelectedIndex = this.CurrencyComboBox.Items.IndexOf(config.Currency);
        }
        public void GetTransactionTest()
        {
            var actualResult = new TransactionOrder
            {
                TransactionType = "Sales",
                DateTransaction = DateTime.Now,
                RefNo           = "TestRef"
            };

            actualResult = TransactionOrder.CreateTransaction(actualResult);

            var expectedResult = TransactionOrder.GetTransaction(actualResult.Id);

            UnitTestingHelper.AssertPublicPropertiesEqual(actualResult, expectedResult);

            if (TransactionOrder.GetTransaction("DoesNotExist") != null)
            {
                Assert.Fail("Transaction Order should not exist and must return null");
            }

            if (TransactionOrder.GetTransaction(actualResult.Id + " ") != null)
            {
                Assert.Fail("Transaction Order must return null since the id is modified");
            }

            TransactionOrder.DeleteTransaction(actualResult.Id);
        }
Esempio n. 7
0
        public ActionResult InformationVietHan(VietHanForm form)
        {
            string         userId              = _userManager.GetUserId(HttpContext.User);
            string         senderAccountId     = form.SenderAccoutId;
            string         senderName          = form.SenderAccountName;
            string         receiverAccountId   = form.ReceiverAccoutId;
            string         receiverAccountName = form.ReceiverAccountName;
            KRW            value  = new KRW(form.MoneyValue);
            ActionTransfer action = form.action;

            var order = TransactionOrder.Create(userId, senderAccountId, senderName, receiverAccountId, receiverAccountName, value, action);


            service.SenderBank   = CreateBank.Create(form.senderbank);
            service.ReceiverBank = CreateBank.Create(form.receiverbank);

            service.Order = order;

            if (service.IsAvailable())
            {
                return(RedirectToAction("Confirm"));
            }

            return(View());
        }
Esempio n. 8
0
 /// <summary>
 /// The import transactions click.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="e">
 /// The e.
 /// </param>
 private void ImportTransactionsClick(object sender, RoutedEventArgs e)
 {
     var transactionOrder = new TransactionOrder
     {
         DateTransaction    = DateTime.Now,
         DiscountPercentage = 0,
         Particular         = "",
         ParticularAddress  = "",
         RefNo = "21"
     };
 }
Esempio n. 9
0
            public static int Cmp(TransactionOrder x, TransactionOrder y)
            {
                var a = x.block_timestamp - y.block_timestamp;

                if (x.block_timestamp < y.block_timestamp)
                {
                    return(-1);
                }
                if (x.block_timestamp > y.block_timestamp)
                {
                    return(1);
                }
                return(x.tx_index - y.tx_index);
            }
Esempio n. 10
0
 /// <summary>
 /// The delete transactions click.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="e">
 /// The e.
 /// </param>
 private void DeleteTransactionsClick(object sender, RoutedEventArgs e)
 {
     if (MessageBox.Show("Are you sure you want to delete all transaction order in database?", "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
     {
         var deleteCount = TransactionOrder.DeleteAllTransactions();
         MessageBox.Show(
             "Successfully Deleted Transaction Orders: " + deleteCount,
             string.Empty,
             MessageBoxButton.OK,
             MessageBoxImage.Asterisk);
     }
     StockbookWindows.RefreshMainWindow();
     InitializeSettings();
 }
        public void CreateTransactionTest()
        {
            var actualResult = new TransactionOrder
            {
                TransactionType = "Sales",
                DateTransaction = DateTime.Now,
                RefNo           = "TestRef"
            };

            actualResult = TransactionOrder.CreateTransaction(actualResult);
            var expectedResult = TransactionOrder.GetTransaction(actualResult.Id);

            UnitTestingHelper.AssertPublicPropertiesEqual(actualResult, expectedResult);
            TransactionOrder.DeleteTransaction(actualResult.Id);
        }
        public void DeleteTransactionTest()
        {
            var actualResult = new TransactionOrder
            {
                TransactionType = "Sales",
                DateTransaction = DateTime.Now,
                RefNo           = "TestRef"
            };

            actualResult = TransactionOrder.CreateTransaction(actualResult);

            TransactionOrder.DeleteTransaction(actualResult.Id);

            var expectedResult = TransactionOrder.GetTransaction(actualResult.Id);

            Assert.IsNull(expectedResult);
        }
        public void EditTransactionTest()
        {
            var actualResult = new TransactionOrder
            {
                TransactionType = "Sales",
                DateTransaction = DateTime.Now,
                RefNo           = "TestRef"
            };

            actualResult       = TransactionOrder.CreateTransaction(actualResult);
            actualResult.RefNo = "Change Ref No";
            TransactionOrder.EditTransaction(actualResult);
            var expectedResult = TransactionOrder.GetTransaction(actualResult.Id);

            Assert.AreEqual(actualResult.RefNo, expectedResult.RefNo);

            TransactionOrder.DeleteTransaction(actualResult.Id);
        }
        public void DeleteAllTransactionTest()
        {
            for (var i = 0; i < 5; i++)
            {
                var actualResult = new TransactionOrder
                {
                    TransactionType = "Sales",
                    DateTransaction = DateTime.Now,
                    RefNo           = "TestRef"
                };
                TransactionOrder.CreateTransaction(actualResult);
            }

            var trans          = TransactionOrder.GetAllTransactions();
            var expectedResult = TransactionOrder.DeleteAllTransactions();

            Assert.AreEqual(expectedResult, trans.Count);
        }
Esempio n. 15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Details"/> class.
        /// </summary>
        /// <param name="order">
        /// The transaction order that will be displayed in the window
        /// </param>
        public Details(TransactionOrder order)
        {
            this.InitializeComponent();

            var title = "Details - Ref. No: " + order.RefNo + " - " + order.TransactionType;

            this.Head.Title = title;

            foreach (var trans in order.Transactions.OrderBy(q => q.Product.Name))
            {
                this.dataGrid.Items.Add(trans);
            }

            foreach (var dc in dataGrid.Columns)
            {
                if (dc.Header.ToString() == "Case" || dc.Header.ToString() == "Pack" || dc.Header.ToString() == "Piece" || dc.Header.ToString() == "Product Name")
                {
                    dataGrid.Columns.FirstOrDefault(q => q.Header == dc.Header).IsReadOnly = true;
                }
            }

            this.TitleLabel.Content = title;
        }
        /// <summary>
        /// The submit create click event will finalize the transaction and store it in database
        /// </summary>
        /// <param name="sender">
        /// The sender is the parent object of the button, which is the Grid
        /// </param>
        /// <param name="e">
        /// The event argument which contains the product that has been updated or will be updated
        /// </param>
        private void SubmitClick(object sender, RoutedEventArgs e)
        {
            decimal discount, terms;
            string  discountTemp = this.DiscountInput.Text.Replace("%", string.Empty);

            if (!string.IsNullOrWhiteSpace(this.RefIdInput.Text) && !string.IsNullOrWhiteSpace(this.ParticularInput.Text) && !string.IsNullOrWhiteSpace(this.SalesmanInput.Text) && !string.IsNullOrWhiteSpace(this.AddressInput.Text) && decimal.TryParse(discountTemp.Trim(), out discount) && decimal.TryParse(this.TermsInput.Text.Trim(), out terms))
            {
                var order = new TransactionOrder
                {
                    TransactionType    = this.transType,
                    DateTransaction    = DateTime.Now,
                    RefNo              = this.RefIdInput.Text,
                    Particular         = this.ParticularInput.Text,
                    Transactions       = this.transList,
                    DiscountPercentage = discount,
                    ParticularAddress  = this.ParticularInput.Text,
                    SalesmanName       = this.SalesmanInput.Text,
                    Terms              = terms
                };
                TransactionOrder.CreateTransaction(order);
                foreach (var trans in this.transList)
                {
                    var prod = trans.Product;
                    prod = Product.BalanceCasePackPiece(trans, prod, this.transType);
                    Product.EditProduct(prod);
                }

                foreach (Window window in Application.Current.Windows)
                {
                    if (window.Title == "Main")
                    {
                        ((MainMetro)window).InitializeTransView();
                        ((MainMetro)window).InitializeProductsView();
                    }
                }

                this.Close();
            }
            else
            {
                string errorMessage = string.Empty;
                if (string.IsNullOrWhiteSpace(this.RefIdInput.Text))
                {
                    errorMessage = "No value was given in Ref No. Input";
                }
                else if (string.IsNullOrWhiteSpace(this.ParticularInput.Text))
                {
                    errorMessage = "No value was given in Particular Input";
                }
                else if (string.IsNullOrWhiteSpace(this.SalesmanInput.Text))
                {
                    errorMessage = "No value was given in Salesman Input";
                }
                else if (string.IsNullOrWhiteSpace(this.AddressInput.Text))
                {
                    errorMessage = "No value was given in Address Input";
                }
                else if (!decimal.TryParse(discountTemp.Trim(), out discount))
                {
                    errorMessage = "Discount Input has invalid characters or no value was given";
                }
                else if (!decimal.TryParse(this.TermsInput.Text.Trim(), out terms))
                {
                    errorMessage = "Terms Input has invalid characters or no value was given";
                }

                MessageBox.Show(
                    "Error: " + errorMessage,
                    "Error in Creating Transaction Order",
                    MessageBoxButton.OK,
                    MessageBoxImage.Error);
            }
        }
 public Expression<Func<Transaction, object>> GetOrderByExpression(TransactionOrder orderBy, out string orderByName)
 {
     switch (orderBy)
     {
         case TransactionOrder.Category:
             orderByName = "Categorias";
             return f => f.Category;
         case TransactionOrder.SubCategory:
             orderByName = "Sub-categorias";
             return f => f.SubCategory;
         case TransactionOrder.Date:
             orderByName = "Data";
             return f => f.Date;
         case TransactionOrder.Value:
             orderByName = "Valor";
             return f => f.Value;
         case TransactionOrder.Name:
             orderByName = "Nomes";
             return f => f.Name;
     }
     orderByName = "Nenhum";
     return null;
 }
        /// <summary>
        /// The initialize transaction filter determines the products that will be printed in View depending on the current filter parameters
        /// </summary>
        /// <param name="newValueTransaction">
        /// The parameter for a new transaction value or default empty if user did not put any
        /// </param>
        /// <param name="newValueParticular">
        /// The parameter for a new particular value or default empty if user did not put any
        /// </param>
        /// <param name="newValuePrincipal">
        /// The parameter for a new principal value or default empty if user did not put any
        /// </param>
        /// <param name="newValueSalesman">
        /// The parameter for a new salesman value or default empty if user did not put any
        /// </param>
        public void InitializeTransFilter(
            string newValueTransaction = "",
            string newValueParticular  = "",
            string newValuePrincipal   = "",
            string newValueSalesman    = "")
        {
            var listTrans = TransactionOrder.GetAllTransactions();

            this.ParticularFilterTrans.ItemsSource = null;
            this.ParticularFilterTrans.Items.Clear();
            this.ParticularFilterTrans.Items.Add("All Particular");
            this.PrincipalFilterTrans.ItemsSource = null;
            this.PrincipalFilterTrans.Items.Clear();
            this.PrincipalFilterTrans.Items.Add("All Principal");
            this.SalesmanFilterTrans.ItemsSource = null;
            this.SalesmanFilterTrans.Items.Clear();
            this.SalesmanFilterTrans.Items.Add("All Salesman");

            if (newValueTransaction != "All Transactions")
            {
                listTrans = listTrans.Where(q => q.TransactionType == newValueTransaction).ToList();
            }

            foreach (var prod in listTrans.Select(q => q.Particular).Distinct())
            {
                this.ParticularFilterTrans.Items.Add(prod);
            }

            if (newValueParticular != "All Particular")
            {
                listTrans = listTrans.Where(q => q.Particular == newValueParticular).ToList();
            }

            foreach (var prod in listTrans.SelectMany(q => q.Transactions).Select(s => s.Product.Principal).Distinct())
            {
                this.PrincipalFilterTrans.Items.Add(prod);
            }

            if (newValuePrincipal != "All Principal")
            {
                listTrans =
                    listTrans.Where(q => q.Transactions.Exists(s => s.Product.Principal == newValuePrincipal)).ToList();
            }

            foreach (var prod in listTrans.Select(q => q.SalesmanName).Distinct())
            {
                this.SalesmanFilterTrans.Items.Add(prod);
            }

            if (newValueSalesman != "All Salesman")
            {
                listTrans =
                    listTrans.Where(q => q.SalesmanName == newValueSalesman).ToList();
            }

            if (!string.IsNullOrWhiteSpace(this.startDate.Text))
            {
                listTrans = listTrans.Where(q => q.DateTransaction >= this.startDate.SelectedDate).ToList();
            }

            if (!string.IsNullOrWhiteSpace(this.endDate.Text))
            {
                listTrans = listTrans.Where(q => q.DateTransaction <= this.endDate.SelectedDate).ToList();
            }

            var transView = new List <TransactionView>();

            foreach (var tran in listTrans)
            {
                var temp = new TransactionView
                {
                    Id = tran.Id,
                    TransactionType = tran.TransactionType,
                    DateTransaction = tran.DateTransaction,
                    Particular      = tran.Particular,
                    PrincipalList   =
                        string.Join(
                            ",",
                            tran.Transactions.Select(q => q.Product)
                            .ToList()
                            .Select(q => q.Principal)
                            .Distinct()
                            .ToList()),
                    RefNo        = tran.RefNo,
                    ItemCount    = tran.Transactions.Count,
                    SalesmanName = tran.SalesmanName,
                    Transactions = tran.Transactions
                };
                transView.Add(temp);
            }

            this.TransactionDataGrid.ItemsSource      = transView;
            this.transactionFilterTrans               = newValueTransaction;
            this.particularFilterTrans                = newValueParticular;
            this.principalFilterTrans                 = newValuePrincipal;
            this.salesmanFilterTrans                  = newValueSalesman;
            this.TransactionFilterTrans.SelectedIndex = this.TransactionFilterTrans.Items.IndexOf(newValueTransaction);
            this.ParticularFilterTrans.SelectedIndex  = this.ParticularFilterTrans.Items.IndexOf(newValueParticular);
            this.PrincipalFilterTrans.SelectedIndex   = this.PrincipalFilterTrans.Items.IndexOf(newValuePrincipal);
            this.SalesmanFilterTrans.SelectedIndex    = this.SalesmanFilterTrans.Items.IndexOf(newValueSalesman);
        }
Esempio n. 19
0
        /// <summary>
        /// The method initialize the transactions and filter it with the input of the user
        /// </summary>
        /// <param name="newValueLocation">
        /// The new value location filter if user changed it.
        /// </param>
        /// <param name="newValuePrincipal">
        /// The new value principal filter if user changed it.
        /// </param>
        /// <param name="newValueCategory">
        /// The new value category filter if user changed it.
        /// </param>
        /// <param name="newValueName">
        /// The new value name filter if user changed it.
        /// </param>
        /// <param name="newValueType">
        /// The new value type filter if user changed it.
        /// </param>
        /// <param name="newValueParticular">
        /// The new value particular filter if user changed it.
        /// </param>
        /// <param name="newValueSalesman">
        /// The new value salesman filter if user changed it.
        /// </param>
        private void InitializeTransactions(string newValueLocation, string newValuePrincipal, string newValueCategory, string newValueName, string newValueType, string newValueParticular, string newValueSalesman)
        {
            var listTrans = TransactionOrder.GetAllTransactions();

            this.PrincipalInputTrans.Items.Clear();
            this.PrincipalInputTrans.Items.Add("All Principal");
            this.CategoryInputTrans.Items.Clear();
            this.CategoryInputTrans.Items.Add("All Category");
            this.LocationInputTrans.Items.Clear();
            this.LocationInputTrans.Items.Add("All Location");
            this.TypeInputTrans.Items.Clear();
            this.TypeInputTrans.Items.Add("All Transactions");
            this.TypeInputTrans.Items.Add("Sales");
            this.TypeInputTrans.Items.Add("Purchased");
            this.ParticularInputTrans.Items.Clear();
            this.ParticularInputTrans.Items.Add("All Particular");
            this.SalesmanInputTrans.Items.Clear();
            this.SalesmanInputTrans.Items.Add("All Salesman");
            this.NameInputTrans.Items.Clear();
            this.NameInputTrans.Items.Add("All Product");

            // Remove This
            foreach (var prod in listTrans.Select(q => q.TransactionType).Distinct())
            {
                this.TypeInputTrans.Items.Add(prod);
            }

            if (newValueType != "All Transactions")
            {
                listTrans = listTrans.Where(q => q.TransactionType == newValueType).ToList();
            }

            foreach (var prod in listTrans.Select(q => q.Particular).Distinct())
            {
                this.ParticularInputTrans.Items.Add(prod);
            }

            if (newValueParticular != "All Particular")
            {
                listTrans = listTrans.Where(q => q.Particular == newValueParticular).ToList();
            }

            foreach (var prod in listTrans.Select(q => q.SalesmanName).Distinct())
            {
                this.SalesmanInputTrans.Items.Add(prod);
            }

            if (newValueSalesman != "All Salesman")
            {
                listTrans = listTrans.Where(q => q.SalesmanName == newValueSalesman).ToList();
            }

            if (this.locationTransFilter != newValueLocation)
            {
                this.principalTransFilter = "All Principal";
                newValuePrincipal         = this.principalTransFilter;
                this.categoryTransFilter  = "All Category";
                newValueCategory          = this.categoryTransFilter;
                this.nameTransFilter      = "All Product";
                newValueName = this.nameTransFilter;
            }

            if (this.principalTransFilter != newValuePrincipal)
            {
                this.categoryTransFilter = "All Category";
                newValueCategory         = this.categoryTransFilter;
                this.nameTransFilter     = "All Product";
                newValueName             = this.nameTransFilter;
            }

            if (this.categoryTransFilter != newValueCategory)
            {
                this.nameTransFilter = "All Product";
                newValueName         = this.nameTransFilter;
            }

            foreach (var prod in listTrans.SelectMany(q => q.Transactions).Select(s => s.Product.Location).Distinct())
            {
                this.LocationInputTrans.Items.Add(prod);
            }

            if (newValueLocation != "All Location")
            {
                listTrans = listTrans.Where(q => q.Transactions.Exists(s => s.Product.Location == newValueLocation)).ToList();
            }

            foreach (var prod in listTrans.SelectMany(q => q.Transactions).Select(s => s.Product.Principal).Distinct())
            {
                this.PrincipalInputTrans.Items.Add(prod);
            }

            if (newValuePrincipal != "All Principal")
            {
                listTrans = listTrans.Where(q => q.Transactions.Exists(s => s.Product.Principal == newValuePrincipal)).ToList();
            }

            foreach (var prod in listTrans.SelectMany(q => q.Transactions).Select(s => s.Product.Category).Distinct())
            {
                this.CategoryInputTrans.Items.Add(prod);
            }

            if (newValueCategory != "All Category")
            {
                listTrans = listTrans.Where(q => q.Transactions.Exists(s => s.Product.Category == newValueCategory)).ToList();
            }

            foreach (var prod in listTrans.SelectMany(q => q.Transactions).Select(s => s.Product.Name).Distinct())
            {
                this.NameInputTrans.Items.Add(prod);
            }

            if (newValueName != "All Product")
            {
                listTrans = listTrans.Where(q => q.Transactions.Exists(s => s.Product.Name == newValueName)).ToList();
            }

            if (!string.IsNullOrWhiteSpace(this.DateFrom.Text))
            {
                listTrans = listTrans.Where(q => q.DateTransaction.Date >= this.DateFrom.SelectedDate).ToList();
            }

            if (!string.IsNullOrWhiteSpace(this.DateTo.Text))
            {
                listTrans = listTrans.Where(q => q.DateTransaction.Date <= this.DateTo.SelectedDate).ToList();
            }

            var transView = new List <TransactionView>();

            foreach (var tran in listTrans)
            {
                var temp = new TransactionView
                {
                    Id = tran.Id,
                    TransactionType = tran.TransactionType,
                    DateTransaction = tran.DateTransaction,
                    Particular      = tran.Particular,
                    PrincipalList   = string.Join(",", tran.Transactions.Select(q => q.Product).ToList().Select(q => q.Principal).Distinct().ToList()),
                    RefNo           = tran.RefNo,
                    ItemCount       = tran.Transactions.Count,
                    SalesmanName    = tran.SalesmanName,
                    Transactions    = tran.Transactions
                };
                transView.Add(temp);
            }

            this.typeTransFilter                    = newValueType;
            this.locationTransFilter                = newValueLocation;
            this.principalTransFilter               = newValuePrincipal;
            this.categoryTransFilter                = newValueCategory;
            this.particularTransFilter              = newValueParticular;
            this.salesmanTransFilter                = newValueSalesman;
            this.nameTransFilter                    = newValueName;
            this.TypeInputTrans.SelectedIndex       = this.TypeInputTrans.Items.IndexOf(newValueType);
            this.LocationInputTrans.SelectedIndex   = this.LocationInputTrans.Items.IndexOf(newValueLocation);
            this.PrincipalInputTrans.SelectedIndex  = this.PrincipalInputTrans.Items.IndexOf(newValuePrincipal);
            this.CategoryInputTrans.SelectedIndex   = this.CategoryInputTrans.Items.IndexOf(newValueCategory);
            this.ParticularInputTrans.SelectedIndex = this.ParticularInputTrans.Items.IndexOf(newValueParticular);
            this.SalesmanInputTrans.SelectedIndex   = this.SalesmanInputTrans.Items.IndexOf(newValueSalesman);
            this.NameInputTrans.SelectedIndex       = this.NameInputTrans.Items.IndexOf(newValueName);
            this.listTransactions                   = listTrans;
            this.TransactionDataGrid.ItemsSource    = transView;
        }