示例#1
0
        private void btnGravar_Click(object sender, EventArgs e)
        {
            if ((txtNome.Text == "") || (txtTel.Text == ""))
            {
                MessageBox.Show("Os campos em negrito são obrigatórios!", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                try
                {
                    var cliente = new Cliente();
                    cliente.Nome     = txtNome.Text;
                    cliente.Endereco = txtEnd.Text;
                    cliente.Bairro   = txtBairro.Text;
                    cliente.Estado   = cbbEstado.Text;
                    cliente.Telefone = txtTel.Text;
                    cliente.Celular  = txtCel.Text;
                    cliente.Email    = txtEmail.Text;

                    var logica = new ClienteLogica();
                    logica.Salvar(cliente);

                    MessageBox.Show("Salvo com sucesso!", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (ArgumentOutOfRangeException)
                {
                    MessageBox.Show("O telefone deve ter 8 ou 9 dígitos.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private void Refrescar()
        {
            ClienteLogica  logica = new ClienteLogica();
            List <Cliente> lista  = new List <Cliente>();

            lista = logica.obtenerClientes();
            dataGrid.ItemsSource = lista;
        }
示例#3
0
        //Construtor 1
        public CadastroClientes(Menu menu) : base(menu)
        {
            //Inicializa o Form (vem por padrão Não Alterar/Remover)
            InitializeComponent();

            //Instancia um objeto da camada de lógica
            _logica = new ClienteLogica();
        }
 private void Lista_Load(object sender, EventArgs e)
 {
     try
     {
         var logica = new ClienteLogica();
         dgvClientes.DataSource = logica.Listar();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 public IActionResult Venta(string ID)
 {
     try
     {
         clienteVenta = new ClienteLogica();
         Cliente clienteBuscado = clienteVenta.BuscarCliente(_con, ID);
         return(View(clienteBuscado));
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
示例#6
0
 private void Refrescar()
 {
     try
     {
         ClienteLogica  logica = new ClienteLogica();
         List <Cliente> lista  = new List <Cliente>();
         lista = logica.obtenerClientes();
         dataGrid.ItemsSource = lista;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#7
0
        // GET: ClienteController/Details/5
        public ActionResult DetailsCliente(int id)
        {
            SucursalProductoVM model = new SucursalProductoVM();

            var resultado = new ClienteLogica().ObtenerClientePorCodigo(id);

            if (resultado.GetType() == typeof(ErrorDTO))
            {
                model.Error = (ErrorDTO)resultado;
            }
            else
            {
                model.Cliente = (ClienteDTO)resultado;
            }
            return(View(model));
        }
示例#8
0
 private void btnGuardar_Click(object sender, RoutedEventArgs e)
 {
     if (Validaciones() == true)
     {
         txtTextBlockDialogo.Text = error;
         dialogoMENS.IsOpen       = true;
         return;
     }
     else
     {
         frmVentasCliente    frm    = new frmVentasCliente();
         FacturaVentasLogica log    = new FacturaVentasLogica();
         ClienteLogica       pl     = new ClienteLogica();
         Cliente             c      = pl.obtenerCliente(txtId.Text);
         DateTime            inicio = fechaInicio.SelectedDate.Value;
         DateTime            fin    = fechaFin.SelectedDate.Value;
         frm.GenerarReporte(c.Nombre, log.ReporteTotalVentasCl(inicio, fin, c.Id), inicio, fin);
         frm.Show();
     }
 }
 public IActionResult Venta(string docIdentidad, string fecha)
 {
     try
     {
         clienteVenta = new ClienteLogica();
         Cliente IDCliente = clienteVenta.BuscarCliente(_con, docIdentidad);
         ventaOperacion = new VentaLogica();
         Venta ve = new Venta
         {
             IdCliente  = IDCliente.Id,
             Fecha      = Convert.ToDateTime(fecha),
             MontoTotal = 0.00f
         };
         ventaOperacion.RegistrarVenta(_con, ve);
         return(RedirectToAction("DetalleVenta", "Transaccion", new { ID = ve.Id }));
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
示例#10
0
 public IActionResult Cliente(string nombre, string apellido, string telefono, string dni, string edad)
 {
     try
     {
         cli = new ClienteLogica();
         Cliente cl = new Cliente
         {
             Nombre    = nombre,
             Apellidos = apellido,
             Telefono  = telefono,
             Dni       = dni,
             Edad      = Convert.ToInt32(edad)
         };
         cli.RegistrarCliente(_con, cl);
         return(RedirectToAction("Venta", "Transaccion", new { ID = cl.Dni }));
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
示例#11
0
        private void btnGuardar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Cliente       cliente = new Cliente();
                ClienteLogica logica  = new ClienteLogica();

                cliente.Id = txtid.Text;
                if (cliente.Id == "")
                {
                    cliente.Id = Guid.NewGuid().ToString();
                }


                if (validaciones() == true)
                {
                    txtTextBlockDialogo.Text = "Debe ingresar todos los datos solicitados.";
                    dialogo.IsOpen           = true;
                    return;
                }
                else
                {
                    cliente.Indentificacion = txtIndentificacion.Text;
                    cliente.Nombre          = txtNombre.Text;
                    cliente.Direccion       = txtDireccion.Text;
                    cliente.Correo          = txtCorreo.Text;
                    cliente.Telefono        = int.Parse(txtTelefono.Text);

                    logica.InsertarActialiarCliente(cliente);
                    Refrescar();
                    txtTextBlockDialogo.Text = "Registro procesado";
                    dialogo.IsOpen           = true;
                    btnVolver_Click(sender, e);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ClienteLogica log     = new ClienteLogica();
            Usuario       usuario = new Usuario();

            usuario = (Usuario)App.Current.Properties["usuarioSesion"];
            DataTable dt = log.ReporteClientes();

            ReportClientes.Reset();
            ReportDataSource rd = new ReportDataSource("DataSet1", dt);

            ReportClientes.LocalReport.DataSources.Add(rd);

            ReportParameter ReportParameter1 = new ReportParameter();

            ReportParameter1.Name = "paramUsuario";
            ReportParameter1.Values.Add(usuario.Nombre);

            ReportClientes.LocalReport.ReportEmbeddedResource = "PracticaProfesionalVivarsan.Reportes.ReporteClientes.rdlc";
            ReportClientes.LocalReport.SetParameters(ReportParameter1);
            ReportClientes.RefreshReport();
        }
示例#13
0
        public ActionResult CreateCliente(ClienteDTO model)
        {
            try
            {
                var resultado = new ClienteLogica().AgregarCliente(model);


                if (resultado.GetType() == typeof(ErrorDTO))
                {
                    throw new Exception("Error");
                }
                else
                {
                    return(RedirectToAction("DetailsCliente", new { id = resultado.IdEntidad }));
                    // return RedirectToAction(nameof(Index));
                }
            }
            catch
            {
                return(View());
            }
        }
        private void btnGuardar_Click(object sender, RoutedEventArgs e)
        {
            Cliente       cliente = new Cliente();
            ClienteLogica logica  = new ClienteLogica();

            cliente.Id = txtid.Text;
            if (cliente.Id == "")
            {
                cliente.Id = Guid.NewGuid().ToString();
            }


            //  cliente.Id = Guid.NewGuid().ToString();
            cliente.Indentificacion = txtIndentificacion.Text;
            cliente.Nombre          = txtNombre.Text;
            cliente.Direccion       = txtDireccion.Text;
            cliente.Correo          = txtCorreo.Text;
            cliente.Telefono        = int.Parse(txtTelefono.Text);

            logica.InsertarActialiarCliente(cliente);
            MessageBox.Show("Correcto.", "Advertencia");
            Refrescar();
        }
示例#15
0
        static void Main(string[] args)
        {
            List <Cliente>     clientes     = new List <Cliente>();
            List <Animal>      animales     = new List <Animal>();
            List <Diagnostico> diagnosticos = new List <Diagnostico>();
            List <Factura>     facturas     = new List <Factura>();

            FacturaLogica     oFacturaLogica     = new FacturaLogica();
            AnimalLogica      oAnimalLogica      = new AnimalLogica();
            DiagnosticoLogica oDiagnosticoLogica = new DiagnosticoLogica();
            ClienteLogica     oClienteLogica     = new ClienteLogica();

            Cliente     oCliente;
            Animal      oAnimal;
            Diagnostico oDiagnostico;
            Factura     oFactura;

            Random oRandom = new Random(23231);

            for (int i = 0; i < 100; i++)
            {
                diagnosticos.Add(
                    oDiagnosticoLogica.AgregarDiagnostico(diagnosticos, "Dianostico " + i, float.Parse((oRandom.NextDouble() * 100.0 - (100.0 / 2.0)).ToString())));
            }


            for (int i = 0; i < 100; i++)
            {
                try
                {
                    animales.Add(oAnimalLogica.AgregarAnimal(animales, "Animal" + i, float.Parse((oRandom.NextDouble() * 100.0 - (100.0 / 2.0)).ToString()), diagnosticos.GetRange(oRandom.Next(1, 100), oRandom.Next(1, 100))));
                }
                catch (Exception)
                {
                    i--;
                }
            }

            for (int i = 0; i < 100; i++)
            {
                try
                {
                    clientes.Add(oClienteLogica.AgregarCliente(clientes, "Factura" + i, animales.GetRange(oRandom.Next(1, 100), oRandom.Next(1, 100))));
                }
                catch (Exception)
                {
                    i--;
                }
            }

            for (int i = 0; i < oRandom.Next(1, 100); i++)
            {
                try
                {
                    facturas.Add(oFacturaLogica.AgregarFactura(facturas, clientes.ElementAt(oRandom.Next(1, 100)), diagnosticos.GetRange(oRandom.Next(1, 100), oRandom.Next(1, 100)), "Descripcion" + i));
                }
                catch (Exception)
                {
                    i--;
                }
            }

            foreach (var item in clientes)
            {
                Console.WriteLine(item.id + " - " + item.nombre);
                foreach (var item2 in item.animales)
                {
                    Console.WriteLine(item2.id + " - " + item2.nombre + " - " + item2.peso);
                }
            }
            Console.ReadLine();
        }