public bool EditarUsuario(Negocio.Cliente clienteEditado) { try { using (Entidades contexto = new Entidades()) { DAL.CLIENTE clienteEditar = contexto.CLIENTEs.Where(p => p.CLIENTE_RUN == clienteEditado.Run).First(); clienteEditar.NOMBRE_COMPLETO = clienteEditado.NombreCompleto; clienteEditar.DIRECCION = clienteEditado.Direccion; clienteEditar.COMUNA = clienteEditado.Comuna; clienteEditar.PROVINCIA = clienteEditado.Provincia; clienteEditar.REGION = clienteEditado.Region; clienteEditar.FECHA_NACIMIENTO = clienteEditado.FechaNacimiento; clienteEditar.GENERO = clienteEditado.Genero; clienteEditar.CORREO_ELECTRONICO = clienteEditado.Email; clienteEditar.NUMERO_TELEFONICO = clienteEditado.NumeroTelefonico; clienteEditar.PASSWORD = clienteEditado.Password; contexto.SaveChanges(); contexto.Dispose(); return(true); } } catch (Exception) { return(false); } }
public bool RegistrarUsuario(Negocio.Cliente nuevoCliente) { try { using (Entidades contexto = new Entidades()) { DAL.CLIENTE clienteDal = new DAL.CLIENTE(); clienteDal.CLIENTE_RUN = nuevoCliente.Run; clienteDal.NOMBRE_COMPLETO = nuevoCliente.NombreCompleto; clienteDal.DIRECCION = nuevoCliente.Direccion; clienteDal.COMUNA = nuevoCliente.Comuna; clienteDal.PROVINCIA = nuevoCliente.Provincia; clienteDal.REGION = nuevoCliente.Region; clienteDal.FECHA_NACIMIENTO = nuevoCliente.FechaNacimiento; clienteDal.GENERO = nuevoCliente.Genero; clienteDal.CORREO_ELECTRONICO = nuevoCliente.Email; clienteDal.NUMERO_TELEFONICO = nuevoCliente.NumeroTelefonico; clienteDal.PASSWORD = nuevoCliente.Password; contexto.AddToCLIENTEs(clienteDal); contexto.SaveChanges(); contexto.Dispose(); } return(true); } catch (Exception) { return(false); } }
public Venta(int codv, Cliente cli, DateTime fec, List<Ejemplar> car) { codVenta = codv; cliente = cli; fecha = fec; carrito = car; }
protected void btn_Enviar_Click(object sender, EventArgs e) { if (Page.IsValid) { string username = txt_Username.Text; int t = cmb_TipoDoc.SelectedIndex; Negocio.TipoDNI tipoDni = Controlador.TipoDNIManager.obtenerTipoDNI(t + 1); int nrodoc = Convert.ToInt32(txt_Documento.Text); string contraseña = txt_Password.Text; string confirmacion = txt_Pass_Confirm.Text; if (contraseña != confirmacion) { lbl_ErrorContraseñas.Text = "Las contraseñas no coinciden"; txt_Pass_Confirm.Text = ""; txt_Password.Text = ""; txt_Password.Focus(); return; } string apellido = txt_Apellido.Text; string nombre = txt_Nombre.Text; DateTime fechaNac = new DateTime(Convert.ToInt32(txt_año.Text), Convert.ToInt32(txt_mes.Text), Convert.ToInt32(txt_dia.Text)); int pais = cmb_Pais.SelectedIndex; Negocio.Pais pai = Controlador.PaisManager.obtenerPais(pais); int provincia = cmb_Provincia.SelectedIndex; Negocio.Provincia prov = Controlador.ProvinciaManager.obtenerProvincia(provincia + 1); int localidad = cmb_Localidad.SelectedIndex; Negocio.Localidad loc = Controlador.LocalidadManager.obtenerLocalidad(localidad + 1); int barrio = cmb_Barrio.SelectedIndex; Negocio.Barrio barr = Controlador.BarrioManager.obtenerBarrio(barrio + 1); string domicilio = txt_Domicilio.Text; int sexo = cmb_Sexo.SelectedIndex; Negocio.Sexo sex = Controlador.SexoManager.obtenerSexo(sexo + 1); string email = txt_Email.Text; string telefono = txt_Telefono.Text; string celular = txt_Celular.Text; Negocio.Cliente cliente = new Cliente(username, contraseña, tipoDni, nrodoc, apellido, nombre, fechaNac, domicilio, barr, sex, email, telefono, celular); if (!Controlador.ClienteManager.guardarCliente(cliente)) { lbl_ErrorContraseñas.Text = "El nombre de usuario seleccionado ya existe, por favor seleccione otro"; txt_Username.Text = ""; txt_Username.Focus(); } else { Controlador.ClienteManager.agregarRol(cliente); panel_after_registro.Visible = true; limpiarControles(); } } }
private void btnBuscar_Click(object sender, EventArgs e) { try { string mensaje = string.Empty; if (cboTipoDoc.SelectedIndex == -1) { mensaje += "Debe seleccionar un tipo de documento." + Environment.NewLine; } if (nudDoc.Value == Decimal.Zero) { mensaje += "Debe ingresar su número de documento." + Environment.NewLine; } if (!string.IsNullOrEmpty(mensaje)) { throw new Exception(mensaje); } List<Cliente> clientes = new Cliente().obtenerListaPorDoc((int)cboTipoDoc.SelectedValue, nudDoc.Value); if (clientes == null || clientes.Count == 0) { throw new Exception("No se ha encontrado al cliente, ingrese de nuevo."); } if (clientes.Count > 1) { var frmFecha = new Devolucion.frmFechaNac(); frmFecha.ShowDialog(); if (clientes.Exists(c => c.nacimientoCliente.Date == frmFecha.fecha.Date)) { clienteActual = clientes.Find(c => c.nacimientoCliente.Date == frmFecha.fecha.Date); txtMillas.Text = Convert.ToString(clienteActual.millasCliente); cargarDGVs(); } else { throw new Exception("No se ha encontrado al cliente, ingrese de nuevo."); } } else { clienteActual = clientes[0]; txtMillas.Text = Convert.ToString(clienteActual.millasCliente); cargarDGVs(); } } catch (Exception exc) { MessageBox.Show(exc.Message, "Error"); } }
private void btnSiguiente_Click(object sender, EventArgs e) { try { string mensaje = string.Empty; if (cboTipoDoc.SelectedIndex == -1) { mensaje += "Debe seleccionar un tipo de documento." + Environment.NewLine; } if (nudDoc.Value == Decimal.Zero) { mensaje += "Debe ingresar su numero de documento." + Environment.NewLine; } if (txtNombre.Text.Trim() == string.Empty) { mensaje += "Debe ingresar su nombre." + Environment.NewLine; } if (txtApellido.Text.Trim() == string.Empty) { mensaje += "Debe ingresar su apellido." + Environment.NewLine; } if (nudTel.Value == Decimal.Zero) { mensaje += "Debe ingresar su numero de telefono." + Environment.NewLine; } if (txtCalle.Text.Trim() == string.Empty) { mensaje += "Debe ingresar su direccion." + Environment.NewLine; } if (!string.IsNullOrEmpty(mensaje)) { throw new Exception(mensaje); } c.idTipoDoc = (int)cboTipoDoc.SelectedValue; c.docCliente = nudDoc.Value; c.nombreCliente = txtNombre.Text.Trim(); c.apellidoCliente = txtApellido.Text.Trim(); c.telefonoCliente = nudTel.Value; c.direccionCliente = txtCalle.Text.Trim(); c.mailCliente = txtMail.Text.Trim(); c.nacimientoCliente = dtpNacimiento.Value.Date; if (clientesDoc.Count > 1) { if(clientesDoc.Exists(cl => cl.nacimientoCliente.Date == dtpNacimiento.Value.Date)) { Cliente cliPosta = clientesDoc.Find(cl => cl.nacimientoCliente.Date == dtpNacimiento.Value.Date); c.idCliente = cliPosta.idCliente; } } if (c.clienteYaEstaEnEstaCompra(c)) { c = new Cliente(); cboTipoDoc.SelectedIndex = -1; nudDoc.Value = Decimal.Zero; txtNombre.Enabled = false; txtNombre.Text = string.Empty; txtApellido.Enabled = false; txtApellido.Text = string.Empty; txtMail.Enabled = false; txtMail.Text = string.Empty; txtCalle.Enabled = false; txtCalle.Text = string.Empty; nudTel.Enabled = false; nudTel.Value = Decimal.Zero; dtpNacimiento.Enabled = false; dtpNacimiento.Value = ConfiguracionGlobal.FechaSistema.Date; lblContinuar.Visible = true; btnSiguiente.Enabled = false; this.Width = 450; throw new Exception("El cliente ingresado ya cuenta con un pasaje en este viaje."); } if(c.clienteViajaEnFechaViaje(viajeActual.idViaje,c.idCliente)) { c = new Cliente(); cboTipoDoc.SelectedIndex = -1; nudDoc.Value = Decimal.Zero; txtNombre.Enabled = false; txtNombre.Text = string.Empty; txtApellido.Enabled = false; txtApellido.Text = string.Empty; txtMail.Enabled = false; txtMail.Text = string.Empty; txtCalle.Enabled = false; txtCalle.Text = string.Empty; nudTel.Enabled = false; nudTel.Value = Decimal.Zero; dtpNacimiento.Enabled = false; dtpNacimiento.Value = ConfiguracionGlobal.FechaSistema.Date; lblContinuar.Visible = true; btnSiguiente.Enabled = false; this.Width = 450; throw new Exception("El cliente ingresado no esta disponible en la fecha del viaje."); } this.Width = 892; dgvButacas.DataSource = new Butaca().obtenerButacasLibresPorViaje(viajeActual.idViaje); dgvButacas.Columns[0].Visible = false; var seleccion = new DataGridViewButtonColumn { Text = "Seleccionar", UseColumnTextForButtonValue = true, AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill, }; dgvButacas.Columns.Add(seleccion); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); } }
private void nudDoc_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Enter && nudDoc.Value <= nudDoc.Maximum) { if (txtNombre.Enabled == false) { try { if (cboTipoDoc.SelectedIndex == -1) { throw new Exception("Debe seleccionar el tipo de documento."); } if (nudDoc.Value == Decimal.Zero) { throw new Exception("Debe ingresar su numero de documento."); } clientesDoc = new Cliente().obtenerListaPorDoc((int)cboTipoDoc.SelectedValue, nudDoc.Value); txtNombre.Enabled = true; txtApellido.Enabled = true; txtMail.Enabled = true; txtCalle.Enabled = true; nudTel.Enabled = true; dtpNacimiento.Enabled = true; btnSiguiente.Enabled = true; lblContinuar.Visible = false; if (clientesDoc.Count == 1) { c = clientesDoc[0]; txtNombre.Text = c.nombreCliente; txtApellido.Text = c.apellidoCliente; txtMail.Text = c.mailCliente; txtCalle.Text = c.direccionCliente; nudTel.Value = c.telefonoCliente; dtpNacimiento.Value = c.nacimientoCliente.Date; } else { c = new Cliente(); c.idCliente = null; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); } } } }
private void nudDoc_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Enter) { if (txtNombre.Enabled == false) { try { if (cboTipoDoc.SelectedIndex == -1) { throw new Exception("Debe seleccionar el tipo de documento."); } if (nudDoc.Value == Decimal.Zero) { throw new Exception("Debe ingresar su numero de documento."); } if (cantPasajes > 0) { ClienteAux ca = new ClienteAux().obtenerPorDoc((int)cboTipoDoc.SelectedValue, nudDoc.Value); if (ca != null) { var msg = MessageBox.Show("Ya hay un cliente ingresado en los datos de pasajes con el mismo documento, ¿Desea utilizarlo?", "Atención", MessageBoxButtons.YesNo); if (msg == DialogResult.Yes) { clienteCompraAnterior = ca; cboTipoDoc.SelectedValue = clienteCompraAnterior.idTipoDoc; nudDoc.Value = clienteCompraAnterior.doc; txtNombre.Text = clienteCompraAnterior.nombre; txtApellido.Text = clienteCompraAnterior.apellido; txtCalle.Text = clienteCompraAnterior.direccion; txtMail.Text = clienteCompraAnterior.mail; nudTel.Value = clienteCompraAnterior.telefono; dtpNacimiento.Value = clienteCompraAnterior.fechaNac; lblContinuar.Visible = false; btnEfectivo.Enabled = true; btnTarjeta.Enabled = true; } else { clienteCompraAnterior = null; } } } clientesDoc = new Cliente().obtenerListaPorDoc((int)cboTipoDoc.SelectedValue, nudDoc.Value); txtNombre.Enabled = true; txtApellido.Enabled = true; txtMail.Enabled = true; txtCalle.Enabled = true; nudTel.Enabled = true; dtpNacimiento.Enabled = true; lblContinuar.Visible = false; btnEfectivo.Enabled = true; btnTarjeta.Enabled = true; if (clientesDoc.Count == 1) { clienteCompra = clientesDoc[0]; txtNombre.Text = clienteCompra.nombreCliente; txtApellido.Text = clienteCompra.apellidoCliente; txtMail.Text = clienteCompra.mailCliente; txtCalle.Text = clienteCompra.direccionCliente; nudTel.Value = clienteCompra.telefonoCliente; dtpNacimiento.Value = clienteCompra.nacimientoCliente.Date; } else { clienteCompra = new Cliente(); clienteCompra.idCliente = null; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); } } } }
private void btnLimpiar_Click(object sender, EventArgs e) { nudDoc.Value = Decimal.Zero; nudDoc.Enabled = false; btnBuscar.Enabled = false; cboTipoDoc.SelectedIndex = -1; dgvEncomiendas.DataSource = null; dgvEncomiendas.Columns.Clear(); dgvPasajes.DataSource = null; dgvPasajes.Columns.Clear(); btnDevolverTodos.Enabled = false; clienteActual = null; }