//BOTON SELECCIONAR CLIENTE-MASCOTA private void BotonSeleccionarCliente_Click(object sender, EventArgs e) { ConsultasSecretaria conse = new ConsultasSecretaria(); if (CajaIdCliente.Text == "" || CajaIdMascota.Text == "") { MessageBox.Show("Rellene casillas para seleccionar mascota-cliente."); } else { //Compruebo que la id del cliente y la mascota existen if (conse.VerificarClienteMascota(Convert.ToInt32(CajaIdMascota.Text), Convert.ToInt32(CajaIdCliente.Text))) { //cierra el formulario IdCliente = Convert.ToInt32(CajaIdCliente.Text); IdMascota = Convert.ToInt32(CajaIdMascota.Text); DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show("No existe registro del cliente o mascota."); } } }
//BOTON CREAR CITA private void BotonRegistrar_Click(object sender, EventArgs e) { if (CajaNombreCliente.Text == "" || CajaDescripcion.Text == "") { MessageBox.Show("Busque o cree un usuario en primera instancia."); } else { //Creo la cita ya con el nombre del cliente String fech = CajaFecha.Value.ToString("d-MMM-yyyy hh:mm:ss"); ConsultasSecretaria conse = new ConsultasSecretaria(); if (conse.RegistrarNuevaCita(fech, CajaDescripcion.Text, IdCliente)) { MessageBox.Show("Se ha agendado una nueva cita."); } else { MessageBox.Show("Ha ocurrido un error. Intente nuevamente."); } CajaDescripcion.Text = ""; CajaNombreCliente.Text = ""; CajaFecha.ResetText(); } }
//LOAD private void VerCitas_Load(object sender, EventArgs e) { CajaVerCitas.Items.Add("EN ESPERA"); CajaVerCitas.Items.Add("REALIZADAS"); ConsultasSecretaria conse = new ConsultasSecretaria(); conse.MostrarCitasEnEsperaSecretaria(MostrarDatos); }
//BOTON CREAR NUEVO CLIENTE private void BotonNuevoCliente_Click(object sender, EventArgs e) { NuevoCliente nv = new NuevoCliente(); nv.ShowDialog(); ConsultasSecretaria conse = new ConsultasSecretaria(); conse.MostraDatosClientesSecretaria(MostrarDatos); }
//BOTON PARA AÑADIR OTRA MASCOTA A UN CLIENTE private void BotonAñadirMascota_Click(object sender, EventArgs e) { AñadirMascota an = new AñadirMascota(); an.ShowDialog(); ConsultasSecretaria conse = new ConsultasSecretaria(); conse.MostraDatosClientesSecretaria(MostrarDatos); }
//CAMBIAR VISUALIZACION DE CITAS private void CajaVerCitas_SelectedIndexChanged(object sender, EventArgs e) { ConsultasSecretaria conse = new ConsultasSecretaria(); switch (CajaVerCitas.Text) { case "EN ESPERA": conse.MostrarCitasEnEsperaSecretaria(MostrarDatos); break; case "REALIZADAS": conse.MostrarCitasRealizadasSecretaria(MostrarDatos); break; } }
//LOAD private void AñadirMascota_Load(object sender, EventArgs e) { ConsultasSecretaria conse = new ConsultasSecretaria(); conse.MostraDatosClientesSecretaria(MostrarDatos); CajaCategoriaMascota.Items.Add("ESCIÚRIDOS"); //Ardillas CajaCategoriaMascota.Items.Add("MÚRIDOS"); //Ratones, Ratas CajaCategoriaMascota.Items.Add("CRICÉTIDOS"); //hámsters CajaCategoriaMascota.Items.Add("FÉLIDOS"); //Gatos CajaCategoriaMascota.Items.Add("CÁNIDOS"); // Perros, zorros CajaCategoriaMascota.Items.Add("MUSTÉLIDOS"); // Comadreja, Tejón CajaCategoriaMascota.Items.Add("GALLINÁCEAS"); // Gallos CajaCategoriaMascota.Items.Add("TESTUDÍNIDOS"); // Tortuga CajaCategoriaMascota.Items.Add("TITÓNIDOS"); // Lechuzas }
//BOTON VER Y REGISTRAR EL NOMBRE DEL CLIENTE PARA LA CITA private void BotonInsertarCliente_Click(object sender, EventArgs e) { VerClientes vercli = new VerClientes(); if (vercli.ShowDialog() == DialogResult.OK) { IdCliente = vercli.IdCliente; //lee la propiedad IdMascota = vercli.IdMascota; //lee la propiedad //Obtengo los datos y recojo el nombre del cliente con las id obtenidos. ConsultasSecretaria conse = new ConsultasSecretaria(); ArrayList arreglin = new ArrayList(); arreglin = conse.ObtenerNombreMascotaCliente(IdMascota, IdCliente); CajaNombreCliente.Text = arreglin[0].ToString() + " " + arreglin[1].ToString(); } }
//BOTON CAMBIAR ESTADO DE UNA CITA A REALIZADA private void BotonCambiar_Click(object sender, EventArgs e) { if (CajaCambiarEstadoCita.Text == "") { MessageBox.Show("Ingrese una id para cambiar una cita."); } else { ConsultasSecretaria conse = new ConsultasSecretaria(); if (conse.ModificarEstadoCitaSecretaria(Convert.ToInt32(CajaCambiarEstadoCita.Text))) { MessageBox.Show("Estado de cita cambiado."); } else { MessageBox.Show("Ha ocurrido un error. Intente nuevamente."); } CajaCambiarEstadoCita.Text = ""; conse.MostrarCitasEnEsperaSecretaria(MostrarDatos); } }
//BOTON AÑADIR NUEVA MASCOTA CLIENTE private void BotonAñadirMascotaNuevacliente_Click(object sender, EventArgs e) { if (CajaIdCliente.Text == "" || CajaNombreMascota.Text == "" || CajaCategoriaMascota.Text == "") { MessageBox.Show("Rellene las casillas."); } else { ConsultasSecretaria conse = new ConsultasSecretaria(); if (conse.VerificarClienteMascotaSoloId(Convert.ToInt32(CajaIdCliente.Text))) { //Existe el cliente, solo basta crear la mascota con la id. Mascota masc = new Mascota(); masc.SetIdCliente(Convert.ToInt32(CajaIdCliente.Text)); masc.SetNombreMascota(CajaNombreMascota.Text); switch (CajaCategoriaMascota.Text) { case "ESCIÚRIDOS": masc.SetIdCategoriaMascota(1); break; case "MÚRIDOS": masc.SetIdCategoriaMascota(2); break; case "CRICÉTIDOS": masc.SetIdCategoriaMascota(3); break; case "FÉLIDOS": masc.SetIdCategoriaMascota(4); break; case "CÁNIDOS": masc.SetIdCategoriaMascota(5); break; case "MUSTÉLIDOS": masc.SetIdCategoriaMascota(6); break; case "GALLINÁCEAS": masc.SetIdCategoriaMascota(7); break; case "TESTUDÍNIDOS": masc.SetIdCategoriaMascota(8); break; case "TITÓNIDOS": masc.SetIdCategoriaMascota(9); break; } if (conse.RegistrarMascotaSecretaria(masc)) { MessageBox.Show("Se ha registrado con exito el cliente y su mascota."); this.Close(); } else { MessageBox.Show("Ha ocurrido un error. Intente nuevamente."); } } else { MessageBox.Show("El cliente no existe. Intente nuevamente."); } CajaIdCliente.Text = ""; CajaCategoriaMascota.ResetText(); CajaNombreMascota.Text = ""; } }
//LOAD private void VerClientes_Load(object sender, EventArgs e) { ConsultasSecretaria conse = new ConsultasSecretaria(); conse.MostraDatosClientesSecretaria(MostrarDatos); }
//BOTON CREAR NUEVO CLIENTE CON UNA MASCOTA private void BotonCrearClienteNuevo_Click(object sender, EventArgs e) { //Control casillas if (CajaNombreCliente.Text == "" || CajaRunCliente.Text == "" || CajaApellidosCliente.Text == "" || CajaCelularCliente.Text == "" || CajaDireccionCliente.Text == "" || CajaNombreMascota.Text == "") { MessageBox.Show("Rellene las casillas."); } else { //Creo un cliente en primera instancia Cliente cli = new Cliente(); cli.SetRutCliente(CajaRunCliente.Text); cli.SetNombreCliente(CajaNombreCliente.Text); cli.SetApellidosCliente(CajaApellidosCliente.Text); cli.SetFonoCliente(CajaFonoCliente.Text); cli.SetCelularCliente(CajaCelularCliente.Text); cli.SetDireccionCliente(CajaDireccionCliente.Text); ConsultasSecretaria conse = new ConsultasSecretaria(); if (conse.RegistrarClienteSecretaria(cli)) { //Creado el cliente, se debe crear la mascota al usuario //Por defecto, la mascota solo tendrá el nombre y la categoria correspondiente (), ya que los datos como estatura, edad y resto... se los agregará el //veterinario //Obtengo la id del cliente que se acaba de crer ArrayList ares = new ArrayList(); ares = conse.ObtenerIdClienteSecretaria(CajaRunCliente.Text); Mascota masc = new Mascota(); masc.SetIdCliente(Convert.ToInt32(ares[0])); masc.SetNombreMascota(CajaNombreMascota.Text); switch (CajaCategoriaMascota.Text) { case "ESCIÚRIDOS": masc.SetIdCategoriaMascota(1); break; case "MÚRIDOS": masc.SetIdCategoriaMascota(2); break; case "CRICÉTIDOS": masc.SetIdCategoriaMascota(3); break; case "FÉLIDOS": masc.SetIdCategoriaMascota(4); break; case "CÁNIDOS": masc.SetIdCategoriaMascota(5); break; case "MUSTÉLIDOS": masc.SetIdCategoriaMascota(6); break; case "GALLINÁCEAS": masc.SetIdCategoriaMascota(7); break; case "TESTUDÍNIDOS": masc.SetIdCategoriaMascota(8); break; case "TITÓNIDOS": masc.SetIdCategoriaMascota(9); break; } if (conse.RegistrarMascotaSecretaria(masc)) { MessageBox.Show("Se ha registrado con exito el cliente y su mascota."); this.Close(); } else { MessageBox.Show("Ha ocurrido un error. Intente nuevamente."); } } else { MessageBox.Show("Ha ocurrido un error. Intente nuevamente."); } } }