Exemplo n.º 1
0
        // GET: Comanda/Edit/5
        public ActionResult Edit(int id)
        {
            if (!base.VerifyIsAuthenticated())
            {
                return(base.RedirectHome());
            }
            Comanda comanda = comandaService.Show(id);

            if (comanda == null)
            {
                return(HttpNotFound());
            }
            ViewBag.clientes = new SelectList(clienteService.List(), "ClienteID", "Cpf", comanda.ClienteID);
            ViewBag.servicos = new SelectList(servicoService.List(), "ServicoID", "Nome", comanda.ServicoID);
            ViewBag.vagas    = new SelectList(vagaService.List(), "VagaID", "Codigo", comanda.VagaID);
            ViewBag.veiculos = new SelectList(veiculoService.List(), "VeiculoID", "Placa", comanda.VeiculoID);
            return(PartialView("ModalCadastroComandaView", comanda));
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Cliente cliente            = cbCliente.SelectedItem as Cliente;
            Servico servico            = cbServico.SelectedItem as Servico;
            Veiculo veiculoSelecionado = cbVeiculos.SelectedItem as Veiculo;
            bool    reserved           = chkReserved.IsChecked.Value;

            try
            {
                if (cliente == null)
                {
                    throw new Exception("Por favor, selecione um Cliente");
                }
                if (servico == null)
                {
                    throw new Exception("Por favor, selecione um Serviço");
                }
                if (veiculoSelecionado == null)
                {
                    throw new Exception("Por favor, selecione um Veículo");
                }

                Comanda comanda = new Comanda();
                comanda.ClienteID       = cliente.ClienteID;
                comanda.ServicoID       = servico.ServicoID;
                comanda.VagaID          = vaga.VagaID;
                comanda.VeiculoID       = veiculoSelecionado.VeiculoID;
                comanda.FuncionarioID   = App.FuncionarioLogado.FuncionarioID;
                comanda.ComandaStatusID = reserved ? ComandaStatusEnum.Reservada : ComandaStatusEnum.Ativa;
                comanda.Total           = servico.Valor;
                comandaController.Store(comanda);

                Vaga vagaOcupada = vagaController.FindById(vaga.VagaID);
                vagaOcupada.Ocupada = true;
                vagaController.Edit(vagaOcupada);

                MessageBox.Show("Comanda criada com sucesso!");
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 3
0
        public List <Mecanic> ObtineMecaniciPentruComanda(Comanda comanda)
        {
            if (comanda == null)
            {
                return(null);
            }
            var query = from detalii in Context.DetaliiComandas
                        where detalii.ComandaId == comanda.ComandaId
                        select detalii;

            List <Mecanic> mecaniciPentruComanda = new List <Mecanic>();

            foreach (var i in query.ToList())
            {
                mecaniciPentruComanda.Add(i.Mecanic);
            }

            return(mecaniciPentruComanda == null ? null : mecaniciPentruComanda);
        }
Exemplo n.º 4
0
        public List <Operatie> ObtineOperatiiPentruComanda(Comanda comanda)
        {
            if (comanda == null)
            {
                return(null);
            }
            var query = from detalii in Context.DetaliiComandas
                        where detalii.ComandaId == comanda.ComandaId
                        select detalii;

            var operatiiPentruComanda = new List <Operatie>();

            foreach (var i in query.ToList())
            {
                operatiiPentruComanda.Add(i.Operatie);
            }

            return(operatiiPentruComanda == null ? null : operatiiPentruComanda);
        }
Exemplo n.º 5
0
        public static string Detalhes(string id)
        {
            RepComanda   repComanda   = new RepComanda();
            Comandas_Emp comandas_Emp = new Comandas_Emp();
            Comanda      comanda      = new Comanda();

            comanda.id_Comanda = Convert.ToInt32(id);
            var result = repComanda.Select_Comanda(comanda);

            if (result.Rows.Count > 0)
            {
                HttpContext.Current.Session["Objhistoricocomandaempresa"] = result;
                return("");
            }
            else
            {
                return("Comanda vazia");
            }
        }
Exemplo n.º 6
0
        public void RepetirNaoVezesTest()
        {
            var produto = new Produto()
            {
                Descricao = "Prod Test",
                Id        = 1,
                Valor     = 50
            };

            var promocao = new Promocao
            {
                Id              = 1,
                Desconto        = 0,
                DescontoMaximo  = true,
                ItemDesconto    = produto,
                ItensAtivadores = new PromocaoItem[]
                {
                    new PromocaoItem {
                        Id         = 1,
                        Item       = produto,
                        Quantidade = 2
                    }
                },
                RepetirPromocao = false
            };

            var comanda = new Comanda()
            {
                Id = 1
            };

            comanda.AddItem(produto);
            comanda.AddItem(produto);
            comanda.AddItem(produto);
            comanda.AddItem(produto);

            var promValid = promocao.PromocaoValida(comanda);
            var repetir   = promocao.RepetirXVezes(comanda);

            Assert.True(promocao.Invalid, "Promoção valida");
            Assert.True(promValid, "Promoção pode ser aplicada");
            Assert.Equal(0, repetir);
        }
Exemplo n.º 7
0
        public static string Detalhes(string id, string nome)
        {
            Comanda    comanda    = new Comanda();
            RepComanda repComanda = new RepComanda();

            comanda.id_Comanda = Convert.ToInt32(id);
            comanda.nm_Comanda = nome;
            var detalhecomanda = repComanda.Select_Comanda_Cliente(comanda);

            if (detalhecomanda.Rows.Count > 0)
            {
                HttpContext.Current.Session["Objhistoricocomanda"] = detalhecomanda;
                return("");
            }
            else
            {
                return("Comanda vazia");
            }
        }
Exemplo n.º 8
0
        public List <Imagine> ObtineImaginiPentruComanda(Comanda comanda)
        {
            if (comanda == null)
            {
                return(null);
            }
            var query = from detalii in Context.DetaliiComandas
                        where detalii.ComandaId == comanda.ComandaId
                        select detalii;

            List <Imagine> imaginiPentruComanda = new List <Imagine>();

            foreach (var i in query.ToList())
            {
                imaginiPentruComanda.Add(i.Imagine);
            }

            return(imaginiPentruComanda == null ? null : imaginiPentruComanda);
        }
Exemplo n.º 9
0
        public List<Comanda> Listar_Comanda()
        {
            List<COMANDA> usa = new List<COMANDA>();
            Orden dto = null;
            try
            {
                using (OracleConnection con = new OracleConnection())
                {

                    con.Open();
                    using (OracleCommand comando = new OracleCommand("SP_SELECT_COMANDA", con))
                    {
                        comando.CommandType = System.Data.CommandType.StoredProcedure;
                        comando.Parameters.Add(new OracleParameter("P_CURSOR", OracleType.Cursor)).Direction = System.Data.ParameterDirection.Output;

                        using (OracleDataReader dr = comando.ExecuteReader(System.Data.CommandBehavior.CloseConnection))
                        {

                            while (dr.Read())
                            {

                                dto = new Comanda();
                                dto.Id_orden = dr["ID_COMANDA"].ToString();
                                dto.Mesa_id_mesa = dr["MESA_ID_MESA"].ToString();
                                dto.Fecha_orden = dr["FECHA_ORDEN"].ToString();
                                dto.Hora_entrada = dr["HORA_ENTRADA"].ToString();
                                dto.Hora_salida = dr["HORA_SALIDA"].ToString();
                                usa.Add(dto);

                            }
                        }
                    }

                }

            }
            catch (Exception ex)
            {
                new Exception("Error en el metodo Listar" + ex.Message);
            }
            return usa;
        }
Exemplo n.º 10
0
        public List<DetaComan> Listar_DetaComan()
        {
            List<DetaComan> usa = new List<DetaComan>();
            DetaComan dto = null;
            try
            {
                using (OracleConnection con = new OracleConnection())
                {

                    con.Open();
                    using (OracleCommand comando = new OracleCommand("SP_SELECT_DETACOMAN", con))
                    {
                        comando.CommandType = System.Data.CommandType.StoredProcedure;
                        comando.Parameters.Add(new OracleParameter("P_CURSOR", OracleType.Cursor)).Direction = System.Data.ParameterDirection.Output;

                        using (OracleDataReader dr = comando.ExecuteReader(System.Data.CommandBehavior.CloseConnection))
                        {

                            while (dr.Read())
                            {

                                dto = new Comanda();
                                dto.Id_detalle = dr["ID_DETALLE"].ToString();
                                dto.Cantidad = dr["CANTIDAD"].ToString();
                                dto.Producto_id_producto = dr["PRODUCTO_ID_PRODUCTO"].ToString();
                                dto.Comanda_id_comanda = dr["COMANDA_ID_COMANDA"].ToString();
                               
                                usa.Add(dto);

                            }
                        }
                    }

                }

            }
            catch (Exception ex)
            {
                new Exception("Error en el metodo Listar" + ex.Message);
            }
            return usa;
        }
Exemplo n.º 11
0
        private bool esFacturable(string idMesa)
        {
            Comanda comanda = new Comanda();

            comanda = ComandaLN.SeleccionarComandaSegunMesaAsignada(idMesa);

            if (comanda != null)
            {
                comanda.estadoComanda = EstadoComandaLN.SeleccionarEstadoComanda(comanda.estadoComanda.estadoComanda_id);
                comanda.mesa          = MesaLN.SeleccionarMesa(comanda.mesa.mesa_id);
                comanda.estadoCuenta  = EstadoCuentaLN.SeleccionarEstadoCuenta(comanda.estadoCuenta.estadoCuenta_id);
            }

            if (comanda.estadoComanda.estadoComanda_id.Equals("DE"))
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 12
0
        public async Task <ComandaDto> EditarAsync(ComandaDto comandaDto)
        {
            using var dbTransaction = _repository.BeginTransaction(_validador);
            if (!await _validador.ValidarAsync(comandaDto))
            {
                return(null);
            }

            Comanda comanda = comandaDto.ToEntity();

            comanda.Prepare();
            await _repository.EditarAsync(comanda);

            ComandaDto dto = comanda.ToDto();
            await _serviceCache.SalvarAsync(dto.Id, dto);

            await _mensageriaService.EnviarAsync(new ComandaEditarCommand(dto));

            return(dto);
        }
Exemplo n.º 13
0
    private void showTotal()
    {
        Comanda comanda = Session["comanda"] as Comanda;

        if (comanda == null)
        {
            return;
        }
        Total.InnerHtml = "<span class='pull-right' > Total " + comanda.Pret + " RON</span>";
        if (ComandaListView.Items.Any())
        {
            Total.Visible            = true;
            TrimitereComanda.Visible = true;
        }
        else
        {
            Total.Visible            = false;
            TrimitereComanda.Visible = false;
        }
    }
Exemplo n.º 14
0
        public void Update(Comanda comanda)
        {
            if (comanda != null)
            {
                throw new System.ArgumentNullException();
            }

            var comandaU = comandaRepository.Where(c => c.Id == comanda.Id).FirstOrDefault();

            comanda.Auto            = comanda.Auto == null ? comanda.Auto : comanda.Auto;
            comanda.DataFinalizare  = comanda.DataFinalizare == default(DateTime) ? comanda.DataFinalizare : comanda.DataFinalizare;
            comanda.DataProgramare  = comanda.DataProgramare == default(DateTime) ? comanda.DataProgramare : comanda.DataProgramare;
            comanda.DataSystem      = comanda.DataSystem == null ? comanda.DataSystem : comanda.DataSystem;
            comanda.Descriere       = comanda.Descriere == null ? comanda.Descriere : comanda.Descriere;
            comanda.DetaliuComandas = comanda.DetaliuComandas == null ? comanda.DetaliuComandas : comanda.DetaliuComandas;
            comanda.KmBord          = comanda.KmBord == default(int) ? comanda.KmBord : comanda.KmBord;
            comanda.StareComanda    = comanda.StareComanda == default(int) ? comanda.StareComanda : comanda.StareComanda;
            comanda.ValoarePise     = comanda.ValoarePise == default(int) ? comanda.ValoarePise : comanda.ValoarePise;
            comandaRepository.Save();
        }
Exemplo n.º 15
0
        public static List <Comanda> ObtenerTodos(string estadoComanda)
        {
            List <Comanda> lista = new List <Comanda>();
            DataSet        ds    = ComandaDato.SeleccionarTodos(estadoComanda);

            foreach (DataRow fila in ds.Tables[0].Rows)
            {
                Comanda registro = new Comanda();

                registro.comanda_id     = fila["comanda_id"].ToString();
                registro.estadoComanda  = EstadoComandaLN.SeleccionarEstadoComanda(fila["estadoComanda_id"].ToString());
                registro.mesa           = MesaLN.SeleccionarMesa(fila["mesa_id"].ToString());
                registro.estadoCuenta   = EstadoCuentaLN.SeleccionarEstadoCuenta(fila["estadoCuenta_id"].ToString());
                registro.nombreCliente  = fila["nombreCliente"].ToString();
                registro.usuarioComanda = UsuarioLN.SeleccionarUsuarioPorId(fila["usuario_id"].ToString());

                lista.Add(registro);
            }
            return(lista);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Actualiza el estado de la comanda para comenzar el ciclo de vida.
        /// A este estado, no hay cambios permitidos en la orden.
        /// </summary>
        /// <param name="comanda"></param>
        private void modificarVidaComanda(Comanda comanda, string estado)
        {
            try
            {
                comanda.estadoComanda = EstadoComandaLN.SeleccionarEstadoComanda(estado);

                ComandaLN.Modificar(comanda);

                lblErrorMessage.Text     = "Se ha actualizado el estado de la comanda con éxito. Espere un unos segundos mientras se refleja el cambio en pantalla.";
                lblErrorMessage.CssClass = "alert alert-success";
            }
            catch (Exception ex)
            {
                lblErrorMessage.Text = "Ha ocurrido un error al formalizar la orden.\n" +

                                       "Código de error: " + ex.Message;

                lblErrorMessage.CssClass = "alert alert-danger";
            }
        }
Exemplo n.º 17
0
        public ActionResult Adaugare()
        {
            String  userId  = User.Identity.GetUserId();
            Comanda comanda = new Comanda();

            comanda.idUtilizator = userId;
            comanda.Adrese       = GetAllAdresses();

            var cartItems = (from cp in db.CartItems
                             where cp.idUtilizator == userId
                             select cp).ToList <CartItem>();

            if (cartItems.Count() == 0)
            {
                TempData["mesaj"] = "Nu aveți nici un produs în coș!";
                return(RedirectToAction("Index", "CartItem"));
            }

            return(View("FormAdaugare", comanda));
        }
Exemplo n.º 18
0
        public List<Tipo_pago> Listar_Tipo_pago()
        {
            List<Tipo_pago> usa = new List<Tipo_pago>();
            Tipo_pago dto = null;
            try
            {
                using (OracleConnection con = new OracleConnection())
                {

                    con.Open();
                    using (OracleCommand comando = new OracleCommand("SP_SELECT_TIPO_PAGO", con))
                    {
                        comando.CommandType = System.Data.CommandType.StoredProcedure;
                        comando.Parameters.Add(new OracleParameter("P_CURSOR", OracleType.Cursor)).Direction = System.Data.ParameterDirection.Output;

                        using (OracleDataReader dr = comando.ExecuteReader(System.Data.CommandBehavior.CloseConnection))
                        {

                            while (dr.Read())
                            {

                                dto = new Comanda();
                                dto.Id_tipo = dr["ID_TIPO"].ToString();
                                dto.Nombre = dr["NOMBRE"].ToString();
                              
                                
                                usa.Add(dto);

                            }
                        }
                    }

                }

            }
            catch (Exception ex)
            {
                new Exception("Error en el metodo Listar" + ex.Message);
            }
            return usa;
        }
        public bool AdaugaComanda(Adresa adresa, int idClient, IEnumerable <Cos> listaProduse)
        {
            var client = _context.Client.FirstOrDefault(c => c.IdClient == idClient);

            var statusComanda = new StatusComanda();

            statusComanda.DescriereStatusComanda = Constante.InAsteptare;

            var comanda = new Comanda();

            comanda.Adresa        = adresa;
            comanda.Email         = client.Email;
            comanda.Data          = DateTime.Now;
            comanda.Adresa        = adresa;
            comanda.Client        = client;
            comanda.StatusComanda = statusComanda;

            _context.Adresa.Add(adresa);
            _context.Comanda.Add(comanda);

            var comandaProdus = new List <ComandaProdus>();

            foreach (var produs in listaProduse)
            {
                _context.ComandaProdus.Add(new ComandaProdus()
                {
                    Cantitate       = produs.Cantitate,
                    Comanda         = comanda,
                    DescriereProdus = produs.Produs.DescriereProdus,
                    NumeProdus      = produs.Produs.NumeProdus,
                    PretProdus      = produs.Produs.PretProdus,
                    Produs          = produs.Produs,
                });

                _context.Cos.Remove(produs);
            }

            _context.SaveChanges();

            return(true);
        }
Exemplo n.º 20
0
        private void buttonUpdateOrders_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in dataGridViewDisplayOrders.SelectedRows)
            {
                int          state      = Convert.ToInt32(row.Cells[7].Value);
                StareComanda orderState = getOrderState(state);
                int          id         = Convert.ToInt32(row.Cells[0].Value);

                Comanda order = _carService.FindOrderById(id);
                order.DataProgramare = Convert.ToDateTime(row.Cells[2].Value);
                order.DataFinalizare = Convert.ToDateTime(row.Cells[3].Value);
                order.KmBord         = Convert.ToInt32(row.Cells[4].Value);
                order.Descriere      = row.Cells[5].Value.ToString();
                order.ValoarePiese   = Convert.ToDecimal(row.Cells[6].Value);
                order.StareComanda   = orderState;

                _carService.UpdateOrder(order);
            }

            FormDisplayOrders_Load(sender, e);
        }
Exemplo n.º 21
0
        public void AddItemTest()
        {
            var produto = new Produto()
            {
                CompraMaxima = 3,
                Descricao    = "Prod Test",
                Id           = 1,
                Valor        = 50
            };

            var comanda = new Comanda()
            {
                Id = 1
            };

            comanda.AddItem(produto);

            Assert.True(comanda.Valid, "Comanda segue valida");
            Assert.True(comanda.Itens.Count == 1, "Adicionado o item na lista");
            Assert.True(comanda.Itens.First().Quantidade == 1, "Adicionado a quantidade");
        }
 private void DataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == dataGridView2.Columns["alege"].Index)
     {
         var comanda = new Comanda {
             id_comanda = (DateTime.Now.ToBinary().ToString()), id_client = clientLogat.id_client, data_comanda = DateTime.Now
         };
         RepositoryController.ComandaRepository.Insert(comanda);
         RepositoryController.SubcomandaRepository.Insert(new Subcomanda {
             id_comanda = comanda.id_comanda, id_produs = felmenu1.id_produs, cantitate = 1
         });
         RepositoryController.SubcomandaRepository.Insert(new Subcomanda {
             id_comanda = comanda.id_comanda, id_produs = felmenu2.id_produs, cantitate = 1
         });
         RepositoryController.SubcomandaRepository.Insert(new Subcomanda {
             id_comanda = comanda.id_comanda, id_produs = felmnu3.id_produs, cantitate = 1
         });
     }
     MessageBox.Show("Comanda trimisa!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
     this.Close();
 }
Exemplo n.º 23
0
        public ActionResult ExcluiComanda(int comandaId, int mesaId)
        {
            ComandaDAO dao       = new ComandaDAO();
            PedidoDAO  pedidoDao = new PedidoDAO();
            Pedido     pedido    = pedidoDao.BuscaPorComanda(comandaId);

            pedidoDao.Excluir(pedido);
            Comanda comanda = dao.BuscaPorId(comandaId);

            comanda.MesaId = null;
            dao.Atualizar(comanda);
            if (dao.ListarPorMesa(mesaId).Count == 0)
            {
                MesasDAO mesaDao = new MesasDAO();
                Mesa     mesa    = mesaDao.BuscaPorId(mesaId);
                mesa.Ocupada = false;
                mesaDao.Atualizar(mesa);
            }

            return(Json(new { success = true, resposta = "comanda removida com sucesso" }));
        }
        public void TestUpdate()
        {
            Comanda comanda = new Comanda(0, "MESA 1", DateTime.Now);

            comandaRepository.Add(comanda);
            Assert.NotEqual(0, comanda.Id);

            Pedido pedido = new Pedido(0, comanda.Id, "Pedido 1");

            pedidoRepository.Add(pedido);
            Assert.NotEqual(0, pedido.Id);
            var nome = pedido.Descricao;

            Assert.NotEqual(0, pedido.Id);

            pedido.Descricao = "Pedido 1 (ALTERAÇÃO)";
            pedidoRepository.Update(pedido);
            Assert.NotEqual(nome, pedido.Descricao);

            pedidoRepository.Remove(pedido.Id);
        }
Exemplo n.º 25
0
 public ActionResult Editar(Comanda comanda)
 {
     if (!User.IsInRole(RolesMontin.Administrador) && (comanda.EstadoDeVenta == EstadoDeVenta.Facturada || comanda.EstadoDeVenta == EstadoDeVenta.PagadaEnEfectivo || comanda.EstadoDeVenta == EstadoDeVenta.PagadaPorTarjeta))
     {
         TempData["error"] = "Usted no puede editar una venta impresa o pagada";
         return(RedirectToAction("Index"));
     }
     if (ModelState.IsValid)
     {
         var result = true;
         comanda.Comensales       = null;
         comanda.Detalles         = null;
         _db.Entry(comanda).State = EntityState.Modified;
         _db.SaveChanges();
         TempData["exito"] = "Comanda editada correctamente";
         return(RedirectToAction("Index"));
     }
     ViewBag.PuntoDeVentaId = new SelectList(_ventasService.PuntosDeVentas(), "Id", "Nombre", comanda.PuntoDeVentaId);
     ViewBag.VendedorId     = new SelectList(_ventasService.Vendedores(), "Id", "NombreCompleto", comanda.VendedorId);
     return(View(comanda));
 }
Exemplo n.º 26
0
 public int Salvar(Comanda comanda)
 {
     try
     {
         int retorno = Insucesso;
         if (_comandaBO.VerificaSeExisteComanda(comanda) == NaoExiste)
         {
             _banco.Entry(comanda).State = EntityState.Added;
             retorno = _banco.SaveChanges() == Sucesso ? Sucesso : Insucesso.ErroCustomForTernary("Não foi possível cadastrar a comanda, verifique os dados.");
         }
         return(retorno);
     }
     catch (CustomException erro)
     {
         throw new CustomException(erro.Message);
     }
     catch (Exception erro)
     {
         throw new Exception(erro.Message);
     }
 }
Exemplo n.º 27
0
 public int Alterar(Comanda comanda)
 {
     try
     {
         int retorno = Insucesso;
         if (_comandaBO.VerificarSeExisteComandaNaAlteracao(comanda) == NaoExiste)
         {
             _banco.Entry(comanda).State = EntityState.Modified;
             retorno = _banco.SaveChanges() == Sucesso ? Sucesso : Insucesso;
         }
         return(retorno);
     }
     catch (CustomException erro)
     {
         throw new CustomException(erro.Message);
     }
     catch (Exception erro)
     {
         throw new Exception(erro.Message);
     }
 }
Exemplo n.º 28
0
 // Recomandari calculate prin Collective Filtering.
 private static List<Preparat> Gaseste_recomandari_Collective(int id_user, Comanda comanda, int k)
 {
     // Gasim cei mai similari k vecini pentru userul cu id-ul user_id.
     int[] lista_vecini ;
     if (DatabaseFunctions.numarUtilizatori() < 1000)
     {
         lista_vecini = Calculeaza_vecini(3, id_user);
     }
     else
     {
         lista_vecini = Calculeaza_vecini_LSH(3, id_user);
     }
     List<IstoricComenzi> lista_istorice = DatabaseFunctions.istoricUtilizatori(lista_vecini);
     IstoricComenzi istoric_user = DatabaseFunctions.getIstoric(id_user);
     // Eliminare preparate comandate.
     // Eliminare cele a caror ora nu apartine intervalului curent.
     comanda = (comanda == null)? new Comanda(): comanda;
     List<Preparat> preparate = eliminaComandate(lista_istorice, istoric_user, comanda);
     List<Preparat> recomandari = preparate.GetRange(0,k) as List<Preparat>;
     return recomandari;
 }
        private void buttonAddNewOrder_Click(object sender, EventArgs e)
        {
            int             index       = dataGridViewAddOrderSelectCar.CurrentCell.RowIndex;
            DataGridViewRow selectedRow = dataGridViewAddOrderSelectCar.Rows[index];
            string          autoIdText  = selectedRow.Cells[0].Value.ToString();
            int             autoId      = Convert.ToInt32(autoIdText);

            string startDate   = dateTimePickerStartDate.Text;
            string endDate     = dateTimePickerEndDate.Text;
            string description = textBoxAddOrderDescription.Text;
            object state       = comboBoxAddOrderState.SelectedItem;

            if (string.IsNullOrEmpty(description) || state == null)
            {
                labelAddOrder.Text = @"Must complete all mandatory fields.";
            }
            else
            {
                buttonAddNewOrder.Enabled = true;
                Comanda order = new Comanda()
                {
                    AutoId         = autoId,
                    DataFinalizare = Convert.ToDateTime(endDate),
                    DataProgramare = Convert.ToDateTime(startDate),
                    DataSystem     = DateTime.Now,
                    Descriere      = description,
                    KmBord         = Convert.ToInt32(textBoxAddOrderKm.Text),
                    StareComanda   = getOrderState(Convert.ToString(state)),
                    ValoarePiese   = TotalCost
                };

                _carService.AddOrder(order);

                labelAddOrder.Text    = @"Order added.";
                labelAddOrder.Visible = true;

                string getOrdersQuery = $"SELECT Id, Descriere, StareComanda FROM Comenzi WHERE AutoId = {autoId}";
                ExecuteQuery(getOrdersQuery, dataGridViewAddDetailByOrder);
            }
        }
Exemplo n.º 30
0
        public void PromocaoValidaExedTest()
        {
            var produto = new Produto()
            {
                CompraMaxima = 3,
                Descricao    = "Prod Test",
                Id           = 1,
                Valor        = 50
            };

            var promocao = new Promocao
            {
                Id              = 1,
                Desconto        = 0,
                DescontoMaximo  = true,
                ItemDesconto    = produto,
                ItensAtivadores = new PromocaoItem[]
                {
                    new PromocaoItem {
                        Id         = 1,
                        Item       = produto,
                        Quantidade = 2
                    }
                },
                RepetirPromocao = false
            };

            var comanda = new Comanda()
            {
                Id = 1
            };

            comanda.AddItem(produto);
            comanda.AddItem(produto);
            comanda.AddItem(produto);

            var promValid = promocao.PromocaoValida(comanda);

            Assert.True(promValid, "Promoção valida com mais itens que o necessário");
        }