Beispiel #1
0
        private void mbtnAgendar_Click(object sender, EventArgs e)
        {
            /**try
            {*/
                //se obtiene el ID del Servicio con el reglon seleccionado///
                DataGridViewRow reglonServicio = dgvServicios.SelectedRows[0];
                int servicioID = (int)reglonServicio.Cells[0].Value;

                //se obtiene el ID del Empleado con el reglon seleccionado///
                DataGridViewRow reglonEmpleado = dgvEmpleado.SelectedRows[0];
                int empleadoID = (int)reglonEmpleado.Cells[0].Value;

                TACitas taCitas = new TACitas();
                TAVistaCitas taVistaCitas = new TAVistaCitas();
                string fechaHora = ((dtpFechaCita.Value.ToString("MM/dd/yyyy hh:mm:ss tt")).Replace("a.m.","am")).Replace("p.m.", "pm");
                int cuartoID = (int)cbCuartos.SelectedValue;
                //string fechaHora = dtpFechaCita.Value.ToString();

            //Se busca si hay citas que hacen conflicto con la que se esta agendando
            VistaCitas vistaCitasConflictivas = taVistaCitas.GetDataByCitasConflictivas(clienteID, fechaHora, empleadoID, servicioID,cuartoID);
            //VistaCitas vistaCitasConflictivas = taVistaCitas.GetDataByCitasConflictivas2(clienteID, dtpFechaCita.Value, empleadoID, servicioID, cuartoID);
            if (vistaCitasConflictivas.Rows.Count == 0)
                {//Si no hay citas conflictivas
                    if (ModooVentana == "Modificar")
                    {
                        taCitas.UpdateQueryCitaID(clienteID, empleadoID, servicioID, dtpFechaCita.Value, null, null, false, citaID);
                        MessageBox.Show("Cita modificada satisfactoriamente.", "Modificado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                    else
                    {
                        //Se insertan los datos de la cita a la base de datos//
                        taCitas.Insert(clienteID, empleadoID, servicioID, dtpFechaCita.Value, null, null, false, (int)cbCuartos.SelectedValue, false);
                        MessageBox.Show("Guardado satisfactoriamente.", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                    //Se actualiza la lista de registro de citas//
                    inicioActuaCita.actualizarRegistroCita();
                }
                else
                {
                    if (chbDosPersonas.Checked==false)
                    {
                        //Hay citas conflictivas, asi que se le muestran al usuario en una leyenda.
                        FrmMostrarCitasConflictivas frmCitasConflictivas = new FrmMostrarCitasConflictivas(vistaCitasConflictivas);
                        frmCitasConflictivas.ShowDialog();
                    }
                    else
                    {
                        DialogResult dr = MessageBox.Show("¿Esta seguro que desea agendar dos citas en el mismo cuarto al mismo tiempo?",
                        "Agendar citas", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                            if (dr == DialogResult.Yes)
                            {
                                taCitas.Insert(clienteID, empleadoID, servicioID, dtpFechaCita.Value, null, null, false, (int)cbCuartos.SelectedValue, false);
                                MessageBox.Show("Guardado satisfactoriamente.", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                this.Close();
                            }
                    }
                }
            //}
            /*catch
            {
                MessageBox.Show("Error al realizar la cita. No hay un Servicio o Empleado selecionado", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();

            }*/
        }
Beispiel #2
0
        private void frmCitas_Load(object sender, EventArgs e)
        {
            // TODO: esta línea de código carga datos en la tabla 'lucySpaDB.Cuarto' Puede moverla o quitarla según sea necesario.
            this.cuartoTableAdapter.Fill(this.lucySpaDB.Cuarto);
            // TODO: This line of code loads data into the 'lucySpaDB.Servicio' table. You can move, or remove it, as needed.
            //this.servicioTableAdapter.Fill(this.lucySpaDB.Servicio);
            // TODO: This line of code loads data into the 'lucySpaDB.vistaEmpleado' table. You can move, or remove it, as needed.
            this.vistaEmpleadoTableAdapter.Fill(this.lucySpaDB.vistaEmpleado);
            // TODO: This line of code loads data into the 'lucySpaDB.vistaCLiente' table. You can move, or remove it, as needed.
            this.vistaCLienteTableAdapter.Fill(this.lucySpaDB.vistaCLiente);
            //Cargar por primera vez el datagridview de servicios del cuarto uno que es el que esta por default en el combobox
            this.servicioTableAdapter.FillByCuartoID(this.lucySpaDB.Servicio, 1);

            //Tomar nombre de cliente
            TAClientes taClientes = new TAClientes();

            RowCliente rowCliente = taClientes.GetDataByClienteID(clienteID)[0];
            String nombreCompleto = rowCliente.Nombre + " " + rowCliente.Apellido;
            tbNombreCliente.Text = nombreCompleto + " (" + clienteID + ")";
            if (ModooVentana == "Modificar")
            {
                // Se crea table adapter para obtener los datos de la cita que se quiere modificar//
                TACitas tacitas = new TACitas();
                rowCitas Fila = tacitas.GetDataByCitaID(citaID)[0];
                int servicioID = Fila.ServicioID;
                int empleadoID = Fila.EmpleadoID;
                clienteID = Fila.ClienteID;
                try
                {
                    Realizado = Fila.Realizado;
                }
                catch { }
                // Se obtiene el tamaño del arreglo de la vista Servicio//
                int tamdgvCitas = dgvServicios.RowCount - 1;

                for (int c = 0; c < tamdgvCitas; c++)
                {
                    int fila = (int)dgvServicios.Rows[c].Cells[0].Value;
                    if (fila == servicioID)
                    {
                        dgvServicios.Rows[c].Selected = true;
                    }

                }
                // Se obtiene el tamaño del arreglo de la vista Servicio//
                int tamdgvEmpleado = dgvEmpleado.RowCount - 1;
                for (int c = 0; c < tamdgvEmpleado; c++)
                {
                    int fila = (int)dgvEmpleado.Rows[c].Cells[0].Value;
                    if (fila == empleadoID)
                    {
                        dgvEmpleado.Rows[c].Selected = true;
                    }
                }
                dtpFechaCita.Text = Fila.Fecha.ToString();

            }
        }