private void metroButton3_Click(object sender, EventArgs e)
        {
            if (txtClientName.Text == "")
            {
                MessageBox.Show("Se necesita un cliente para ordenrar");
                return;
            }



            var example = metroGrid1.Rows
                          .OfType <DataGridViewRow>()
                          .Where(x => x.Cells[2].Value != null)
                          .Select(x => x.Cells[2].Value)
                          .ToList();

            if (example.Count() == 0)
            {
                MessageBox.Show("Se necesita un articulo en la orden");
                return;
            }

            foreach (decimal price in example)
            {
                Total += price;
            }
            ITBIS            = Total * 0.18M;
            txtSubTotal.Text = string.Format("{0:0.00}", Total);
            Total            = Total + ITBIS;
            txtTotal.Text    = string.Format("{0:0.00}", Total);

            Orden.Cliente = _dbContext.Clients.FirstOrDefault(c => c.Cedula == SelectedClient.Cedula);
            if (Orden.TipoOrden == "Aqui")
            {
                int standId = Int32.Parse(metroComboBox1.SelectedItem.ToString());
                Orden.Stand = _dbContext.Stands.First(s => s.Id == standId);
            }
            var CombosList = metroGrid1.Rows
                             .OfType <DataGridViewRow>()
                             .Where(x => x.Cells[1].Value != null)
                             .Select(x => x.Cells[1].Value.ToString())
                             .ToList();


            for (int i = 0; i < metroGrid1.RowCount; i++)
            {
                OrdenDetail ordenDetail = new OrdenDetail
                {
                    Item      = metroGrid1.Rows[i].Cells[1].Value.ToString(),
                    ItemPrice = decimal.Parse(metroGrid1.Rows[i].Cells[2].Value.ToString()),
                };
                DetalleOrden.Add(ordenDetail);
            }
            Orden.OrderDetails = DetalleOrden;
            Orden.CreatedAt    = DateTime.Now;
            Orden.Status       = "Proceso";

            BtnProcesarFactura.Enabled = true;
        }
示例#2
0
        public IActionResult AddItem(int?id)
        {
            var producto = _context.Producto.Find(id);

            var orderDetail = new OrdenDetail();

            orderDetail.producID = producto.ID;
            orderDetail.Price    = producto.Price;
            orderDetail.Quantity = 1;
            var name = _userManager.GetUserName(User);

            //if is null please login
            orderDetail.Email = name;

            _context.Add(orderDetail);
            _context.SaveChanges();
            return(RedirectToAction("Index", "Producto"));
        }
        public IActionResult AddItem(int?id)
        {
            var producto = _context.Productos.Find(id);

            var orderDetail = new OrdenDetail();

            orderDetail.productoID = producto.ID;
            orderDetail.Nombre     = producto.nombre;
            orderDetail.Precio     = producto.precio;
            orderDetail.Cantidad   = 1;
            var name = _userManager.GetUserName(User);

            orderDetail.Email = name;

            _context.Add(orderDetail);
            _context.SaveChanges();
            return(RedirectToAction("Index", "Catalogo"));
        }
示例#4
0
        private List <OrdenDetail> GetOrderById(int id)
        {
            var OrderDetail1 = new OrdenDetail
            {
                Id            = 1,
                Product       = productRepository.GetById(1),
                PurchasePrice = 23.2m,
                Quantity      = 2,
            };

            var OrderDetail2 = new OrdenDetail
            {
                Id            = 2,
                Product       = productRepository.GetById(2),
                PurchasePrice = 105.2m,
                Quantity      = 1,
            };
            var OrdenDetailList = new List <OrdenDetail>();

            OrdenDetailList.Add(OrderDetail1);
            OrdenDetailList.Add(OrderDetail2);
            return(OrdenDetailList);
        }