Ejemplo n.º 1
0
        private void SelectProduct(object sender, EventArgs e)
        {
            if (dataGridView.SelectedRows.Count > 0)
            {
                try
                {
                    int index = dataGridView.SelectedRows[0].Index;
                    SelectedProduct = dataGridView.SelectedRows[0].DataBoundItem as SearchProductLD;

                    ListSelectedProduct.Add(SelectedProduct);

                    var orderForm = this.ParentForm as OrderForm;
                    if (orderForm != null)
                    {
                        orderForm.UpdateGridLD(SelectedProduct);
                    }

                    var list = dataGridView.DataSource as List <SearchProductLD>;
                    list.RemoveAt(index);

                    dataGridView.DataSource = null;
                    dataGridView.DataSource = list;
                    dataGridView.Refresh();
                }
                catch (Exception ex)
                {
                    logger.EnterMethod("Select Product LD");
                    logger.LogException(ex);
                }
            }
        }
Ejemplo n.º 2
0
        public void UpdateGridLD(SearchProductLD product)
        {
            if (product != null)
            {
                product.ActualPrice = product.Price;

                decimal discount = 0;
                if (product.Discount.HasValue)
                {
                    discount = product.Discount.Value;
                }

                if (product.Price.HasValue && product.Price.Value > 0)
                {
                    var rootPrice = product.Price.Value;
                    product.ActualPrice = rootPrice - (rootPrice * discount) / 100;
                }

                if (listProductLD == null)
                {
                    listProductLD = new List <SearchProductLD>();
                }

                if (!HasFooterLD)
                {
                    listProductLD.Add(product);
                    listProductLD.Add(new SearchProductLD());
                    HasFooterLD = true;
                }
                else
                {
                    listProductLD.Insert(listProductLD.Count - 1, product);
                }

                dataGridViewLD.DataSource = null;
                dataGridViewLD.DataSource = listProductLD;
                dataGridViewLD.Refresh();
            }
        }
Ejemplo n.º 3
0
        private void LoadProducts(Order order)
        {
            if (order.Details.Count == 0) return;

            listProduct = new List<SearchProduct>();
            listProductLD = new List<SearchProductLD>();

            foreach (var detail in order.Details)
            {
                if(detail.ProductId.HasValue)
                {
                    var searchProduct = new SearchProduct();
                    searchProduct.Price = detail.ProductPrice;
                    searchProduct.QuantityValue = detail.Quantity.ToString();
                    searchProduct.Total = detail.Total;
                    searchProduct.ActualPrice = detail.ProductActualPrice;
                    searchProduct.Discount = detail.Discount;
                    searchProduct.TotalValue = detail.Total.ToString(Constants.CurrencyFormat);
                    searchProduct.Id = detail.ProductId.Value;
                    searchProduct.Name = detail.Product.Name;
                    searchProduct.Code = detail.Product.Code;

                    listProduct.Add(searchProduct);
                }
                else if(detail.ProductLdId.HasValue)
                {
                    var searchProduct = new SearchProductLD();
                    searchProduct.Price = detail.ProductPrice;
                    searchProduct.QuantityValue = detail.Quantity.ToString();
                    searchProduct.Total = detail.Total;
                    searchProduct.ActualPrice = detail.ProductActualPrice;
                    searchProduct.Discount = detail.Discount;
                    searchProduct.TotalValue = detail.Total.ToString(Constants.CurrencyFormat);
                    searchProduct.Id = detail.ProductLdId.Value;
                    searchProduct.Name = detail.ProductLD.Name;
                    searchProduct.Code = detail.ProductLD.Code;

                    listProductLD.Add(searchProduct);
                }

            }
            if (listProduct.Count > 0)
            {
                listProduct.Add(new SearchProduct());
                HasFooter = true;

                dataGridView.DataSource = null;
                dataGridView.DataSource = listProduct;
                dataGridView.Refresh();
            }

            if (listProductLD.Count > 0)
            {
                listProductLD.Add(new SearchProductLD());
                HasFooterLD = true;

                dataGridViewLD.DataSource = null;
                dataGridViewLD.DataSource = listProductLD;
                dataGridViewLD.Refresh();
            }
        }
Ejemplo n.º 4
0
        public void UpdateGridLD(SearchProductLD product)
        {
            if (product != null)
            {
                product.ActualPrice = product.Price;

                decimal discount = 0;
                if (product.Discount.HasValue)
                    discount = product.Discount.Value;

                if (product.Price.HasValue && product.Price.Value > 0)
                {
                    var rootPrice = product.Price.Value;
                    product.ActualPrice = rootPrice - (rootPrice * discount) / 100;
                }

                if (listProductLD == null)
                {
                    listProductLD = new List<SearchProductLD>();
                }

                if (!HasFooterLD)
                {
                    listProductLD.Add(product);
                    listProductLD.Add(new SearchProductLD());
                    HasFooterLD = true;
                }
                else
                {
                    listProductLD.Insert(listProductLD.Count - 1, product);
                }

                dataGridViewLD.DataSource = null;
                dataGridViewLD.DataSource = listProductLD;
                dataGridViewLD.Refresh();
            }
        }
Ejemplo n.º 5
0
        private void LoadProducts(Order order)
        {
            if (order.Details.Count == 0)
            {
                return;
            }

            listProduct   = new List <SearchProduct>();
            listProductLD = new List <SearchProductLD>();

            foreach (var detail in order.Details)
            {
                if (detail.ProductId.HasValue)
                {
                    var searchProduct = new SearchProduct();
                    searchProduct.Price         = detail.ProductPrice;
                    searchProduct.QuantityValue = detail.Quantity.ToString();
                    searchProduct.Total         = detail.Total;
                    searchProduct.ActualPrice   = detail.ProductActualPrice;
                    searchProduct.Discount      = detail.Discount;
                    searchProduct.TotalValue    = detail.Total.ToString(Constants.CurrencyFormat);
                    searchProduct.Id            = detail.ProductId.Value;
                    searchProduct.Name          = detail.Product.Name;
                    searchProduct.Code          = detail.Product.Code;

                    listProduct.Add(searchProduct);
                }
                else if (detail.ProductLdId.HasValue)
                {
                    var searchProduct = new SearchProductLD();
                    searchProduct.Price         = detail.ProductPrice;
                    searchProduct.QuantityValue = detail.Quantity.ToString();
                    searchProduct.Total         = detail.Total;
                    searchProduct.ActualPrice   = detail.ProductActualPrice;
                    searchProduct.Discount      = detail.Discount;
                    searchProduct.TotalValue    = detail.Total.ToString(Constants.CurrencyFormat);
                    searchProduct.Id            = detail.ProductLdId.Value;
                    searchProduct.Name          = detail.ProductLD.Name;
                    searchProduct.Code          = detail.ProductLD.Code;

                    listProductLD.Add(searchProduct);
                }
            }
            if (listProduct.Count > 0)
            {
                listProduct.Add(new SearchProduct());
                HasFooter = true;

                dataGridView.DataSource = null;
                dataGridView.DataSource = listProduct;
                dataGridView.Refresh();
            }

            if (listProductLD.Count > 0)
            {
                listProductLD.Add(new SearchProductLD());
                HasFooterLD = true;

                dataGridViewLD.DataSource = null;
                dataGridViewLD.DataSource = listProductLD;
                dataGridViewLD.Refresh();
            }
        }
Ejemplo n.º 6
0
        private void SelectProduct(object sender, EventArgs e)
        {
            if (dataGridView.SelectedRows.Count > 0)
            {
                try
                {
                    int index = dataGridView.SelectedRows[0].Index;
                    SelectedProduct = dataGridView.SelectedRows[0].DataBoundItem as SearchProductLD;

                    ListSelectedProduct.Add(SelectedProduct);

                    var orderForm = this.ParentForm as OrderForm;
                    if (orderForm != null)
                    {
                        orderForm.UpdateGridLD(SelectedProduct);
                    }

                    var list = dataGridView.DataSource as List<SearchProductLD>;
                    list.RemoveAt(index);

                    dataGridView.DataSource = null;
                    dataGridView.DataSource = list;
                    dataGridView.Refresh();
                }
                catch(Exception ex)
                {
                    logger.EnterMethod("Select Product LD");
                    logger.LogException(ex);
                }
            }
        }