Exemple #1
0
        private void addProduct()
        {
            if (orderState.Equals((int)OrderState.Done))
            {
                MessageBox.Show("Hàng đã bán, bạn không thể chỉnh sửa danh sách hàng.");
                return;
            }

            ProductSearchDialog dialog = new ProductSearchDialog();
            dialog.ShowDialog();
            if (dialog.DialogResult == DialogResult.OK)
            {
                Product prod = dialog.ReturnProduct();
                if (prodsList.Any(p => p.prod_id.Equals(prod.prod_id)))
                {
                    MessageBox.Show("Sản phảm đã có trong danh sách.");
                }
                else
                {
                    // Add product to product list
                    prod = db.Products.Where(p => p.prod_id.Equals(prod.prod_id))
                        .Include(p => p.Stocks)
                        .First();
                    // Get all non-empty stock
                    //prod.Stocks = db.Stocks
                    //    .Where(s => s.prod_id.Equals(prod.prod_id) & (s.quantity_by_stock > 0 || s.quantity_by_unit > 0))
                    //    .ToList();
                    prodsList.Add(prod);

                    // Create new Item
                    SaleOrderItem item = db.SaleOrderItems.Create();
                    item.prod_id = prod.prod_id;
                    item.sale_price_by_stock = prod.sale_price_by_stock;
                    item.sale_price_by_unit = prod.sale_price_by_unit;
                    item.quantity_by_stock = 0;
                    item.quantity_by_unit = 0;
                    item.quantity_control = prod.quantity_control;
                    item.TotalItemPrice = 0;
                    item.ProductName = prod.prod_name;

                    saleOrder.SaleOrderItems.Add(item);
                    dataGridView.DataSource = saleOrder.SaleOrderItems.ToList();
                }
            }
        }
Exemple #2
0
        private void addProduct()
        {
            ProductSearchDialog dialog = new ProductSearchDialog();
            dialog.ShowDialog();
            if (dialog.DialogResult == DialogResult.OK)
            {
                Product p = dialog.ReturnProduct();

                // Add new Item
                ImportOrderItem item = db.ImportOrderItems.Create();
                item.prod_id = p.prod_id;
                item.ProductName = p.prod_name;

                item.quantity_control = p.quantity_control;
                item.quantity_by_stock = 0;
                item.quantity_by_unit = 0;

                item.base_price_by_stock = 0;
                item.base_price_by_unit = 0;

                item.date_expired = DateTime.Now;

                importOrder.ImportOrderItems.Add(item);
                dataGridView.DataSource = importOrder.ImportOrderItems.ToList();
            }
        }