예제 #1
0
        private async Task CalculateOutputValue()
        {
            OutputProductsSearchRequest request = new OutputProductsSearchRequest
            {
                OutputId = _outputs.Id
            };
            List <Model.OutputProducts> list = await _outputProductsService.Get <List <Model.OutputProducts> >(request);

            decimal amount = 0;

            foreach (var item in list)
            {
                amount += item.Price - ((item.Price * item.Discount) / 100);
            }

            _outputs.ValueWithoutPdv = amount;
            _outputs.ValueWithPdv    = amount - ((amount * 17) / 100);
            try
            {
                await _outputsService.Update <Model.Inputs>(_outputs.Id, _outputs);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
        private async Task LoadProductsFromOrder(int productTypesId = 0)
        {
            try
            {
                OutputsSearchRequest orequest = new OutputsSearchRequest
                {
                    OrderId = _orders.Id
                };
                var output = await _outputsService.Get <List <Model.Outputs> >(orequest);

                OutputProductsSearchRequest oprequest = new OutputProductsSearchRequest
                {
                    OutputId = output.FirstOrDefault().Id,
                };
                var result = await _outputProductsService.Get <List <Model.OutputProducts> >(oprequest);

                List <Model.Products> list = new List <Model.Products>();
                foreach (var item in result)
                {
                    Model.Products tmp = await _products.GetById <Model.Products>(item.ProductId);

                    list.Add(tmp);
                }

                var query = list.AsQueryable();
                if (!string.IsNullOrWhiteSpace(txtSearchName?.Text))
                {
                    query = query.Where(x => x.Name.StartsWith(txtSearchName.Text));
                }

                query = query.OrderBy(x => x.Name);
                var finalResults = query.ToList();

                dgvProducts.AutoGenerateColumns = false;
                var productTypesProducts = new List <Model.Products>();
                if (productTypesId != 0)
                {
                    foreach (var item in finalResults)
                    {
                        if (item.ProductTypeId == productTypesId)
                        {
                            productTypesProducts.Add(item);
                        }
                    }

                    dgvProducts.DataSource = productTypesProducts;
                }
                else
                {
                    dgvProducts.DataSource = finalResults;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("This order has no products in list", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }