コード例 #1
0
ファイル: WebService.aspx.cs プロジェクト: dchaves80/GDNN
        private void getTurnos(int idbox, string baseDate)
        {
            string[]            fecha             = baseDate.Split('/');
            DateTime            fechaBase         = new DateTime(int.Parse(fecha[2]), int.Parse(fecha[1]), int.Parse(fecha[0]));
            Struct_Box          auxBox            = Struct_Box.GetBoxById(idbox);
            List <Struct_Turno> turnosResponse    = Struct_Turno.ObtenerTurnosEntreDias(fechaBase, fechaBase.AddDays(5), auxBox.IdSucursal, idbox);
            List <coordenada>   coordenadasTurnos = new List <coordenada>();

            if (turnosResponse != null)
            {
                foreach (Struct_Turno turno in turnosResponse)
                {
                    TimeSpan TS  = turno.DiaReservacion - fechaBase;
                    DateTime aux = new DateTime(turno.DiaReservacion.Year, turno.DiaReservacion.Month,
                                                turno.DiaReservacion.Day, 6, 0, 0);
                    TimeSpan HR = turno.DiaReservacion - aux;

                    coordenada sesion = new coordenada();
                    sesion.coordfecha = TS.Days;
                    sesion.coordhora  = Convert.ToInt32(Math.Round(HR.TotalHours * 4));
                    sesion.idTurno    = turno.Id;
                    sesion.cliente    = turno.CLIENTE.RS;
                    coordenadasTurnos.Add(sesion);
                }
            }
            //devuelve coordenadas de turnos en la tabla
            if (coordenadasTurnos != null)
            {
                string jsonTurnos = new JavaScriptSerializer().Serialize(coordenadasTurnos);
                Response.Write(jsonTurnos);
            }
        }
コード例 #2
0
ファイル: WebService.aspx.cs プロジェクト: dchaves80/GDNN
        private void getInfoTurno(int identSesion)
        {
            Struct_Turno     aux        = Struct_Turno.ObtenerTurnoById(identSesion);
            Struct_Treatment auxTreat   = Struct_Treatment.GetTreatmentById(aux.SESION.IdTratamiento);
            tratasion        returnable = new tratasion();

            returnable.turno       = aux;
            returnable.tratamiento = auxTreat;
            string jsonTurno = new JavaScriptSerializer().Serialize(returnable);

            Response.Write(jsonTurno);
        }
コード例 #3
0
ファイル: WebService.aspx.cs プロジェクト: dchaves80/GDNN
        private void DeleteTurnos(string idturno)
        {
            Struct_Turno aux        = Struct_Turno.ObtenerTurnoById(int.Parse(idturno));
            string       IdentUnico = aux.IdUnico;
            bool         verify     = Struct_Turno.DeleteTurnos(IdentUnico);

            if (verify)
            {
                Response.Write("true");
            }
            else
            {
                Response.Write("false");
            }
        }
コード例 #4
0
ファイル: WebService.aspx.cs プロジェクト: dchaves80/GDNN
        private void UnassignTurnos(string idturno)
        {
            Struct_Turno aux = Struct_Turno.ObtenerTurnoById(int.Parse(idturno));

            aux.DiaReservacion = new DateTime(1753, 1, 1);
            aux.BOX            = new Struct_Box();
            aux.Estado         = "NoAsignado";
            bool verify = aux.ActualizarTurno();

            if (verify)
            {
                Response.Write("true");
            }
            else
            {
                Response.Write("false");
            }
        }
コード例 #5
0
ファイル: View.ascx.cs プロジェクト: dchaves80/GDNN
        protected void guardar_Click1(object sender, EventArgs e)
        {
            Struct_Cliente   clienteAux     = Session["cliente"] as Struct_Cliente;
            Struct_Treatment tratamientoAux = Session["tratamiento"] as Struct_Treatment;
            Guid             IdUnico        = Guid.NewGuid();
            bool             turnoOcupado   = false;
            bool             errorSaving    = false;
            string           tipoTurno      = "none";

            //  Formato del hiddenfield:
            //  Elementos de turno separados por comas y asteriscos:
            //
            //        "idTurno","idSesion","dia","hora","box"+"*"
            //
            //        Si IdTurno es 0, se crea un turno nuevo,
            //        si no es 0, se asigna el turno no asignado.
            //
            String[]        infoTurnos = turnosElegidos.Value.Split('*');
            String[]        elementoTurno;
            int             IdTurno;
            int             IdSesion;
            DateTime        FechayHora = new DateTime();
            Struct_Box      Box        = new Struct_Box();
            Struct_Turno    TurnoAux   = new Struct_Turno();
            Struct_Sesiones SesionAux  = new Struct_Sesiones();

            TurnoAux.CLIENTE = clienteAux;

            Log.ADD(turnosElegidos.Value, this);
            //  Se recorre el hiddenfield de turnos a guardar o asignar
            for (int i = 0; i < infoTurnos.Length - 1; i++)
            {
                //  Guardado de valores en variables auxilares
                elementoTurno = infoTurnos[i].Split(',');
                IdTurno       = int.Parse(elementoTurno[0]);
                IdSesion      = int.Parse(elementoTurno[1]);
                FechayHora    = DateTime.Parse(elementoTurno[2] + ' ' + elementoTurno[3]);
                Box           = Struct_Box.GetBoxById(int.Parse(elementoTurno[4]));

                //  Si el IdTurno es distinto de 0, se trata de un turno existente que no fue asignado:
                if (IdTurno != 0)
                {
                    TurnoAux = Struct_Turno.ObtenerTurnoById(IdTurno);
                    TurnoAux.DiaReservacion = FechayHora;
                    TurnoAux.BOX            = Box;
                    TurnoAux.Estado         = "Ingresado";
                    tipoTurno = "NoAsignado";
                }
                //  Si el IdTurno es igual a 0, se trata de un turno nuevo de un tratamiento nuevo:
                else
                {
                    SesionAux = Struct_Sesiones.GetSesionById(IdSesion);
                    TurnoAux  = new Struct_Turno(FechayHora, clienteAux, Conversion.ObtenerLocal(UserId), SesionAux, Box, IdUnico.ToString(), "Ingresado");
                    tipoTurno = "Nuevo";
                }

                //  Chequea si el turno ya existe
                List <Struct_Turno> turnosDeHoy = Struct_Turno.ObtenerTurnosDia(TurnoAux.DiaReservacion, Conversion.ObtenerLocal(UserId), Box.Id);
                if (turnosDeHoy != null)
                {
                    foreach (Struct_Turno turno in turnosDeHoy)
                    {
                        if (turno.DiaReservacion == TurnoAux.DiaReservacion)
                        {
                            turnoOcupado = true;
                        }
                    }
                    break;
                }


                //  Verificacion de turno ya ocupado en ese dia y hora
                if (turnoOcupado)
                {
                    string diaConflicto  = TurnoAux.DiaReservacion.ToShortDateString();
                    string horaConflicto = TurnoAux.DiaReservacion.ToShortTimeString();
                    string boxConflicto  = Box.Detalle;
                    errorSaving = true;
                    Response.Redirect(DotNetNuke.Common.Globals.NavigateURL() + "?addTurnoStatus=conflictingDate&fecha=" + diaConflicto + "&hora=" + horaConflicto + "&box=" + boxConflicto);
                }

                //  Si se trata de un turno no asignado, se actualiza el turno, de lo contrario se guarda el turno nuevo
                if (string.Equals(tipoTurno, "NoAsignado"))
                {
                    TurnoAux.ActualizarTurno();
                }
                if (string.Equals(tipoTurno, "Nuevo"))
                {
                    TurnoAux.GuardarTurno();
                }
            }

            //  Se recorren las sesiones del tratamiento para ver si quedo alguna sin asignar
            if (tratamientoAux != null)
            {
                //  Obtener turnos ya existentes relacionados al tratamiento nuevo
                List <Struct_Turno> asignados = Struct_Turno.ObtenerTurnosByIdUnico(IdUnico.ToString());

                foreach (Struct_Sesiones sesion in tratamientoAux.ListaSesiones)
                {
                    bool itExists = false;

                    //  Chequear si la sesion ya tiene un turno en la agenda (asignado o no asignado, no importa)
                    if (asignados != null)
                    {
                        foreach (Struct_Turno turno in asignados)
                        {
                            if (turno.IdSesion == sesion.Id)
                            {
                                itExists = true;
                                break;
                            }
                        }
                    }

                    //  Si la sesion no existe en "asignados", crear un turno nuevo y ponerlo como no asignado
                    if (!itExists)
                    {
                        TurnoAux.DiaReservacion = new DateTime(1753, 1, 1);
                        TurnoAux.IdSesion       = sesion.Id;
                        TurnoAux.SESION         = sesion;
                        Box             = new Struct_Box();
                        TurnoAux.Estado = "NoAsignado";
                        TurnoAux.GuardarTurno();
                    }
                }
            }

            //  Si no hay error en el guardado, se limpian todas las variables de sesion y los label
            if (!errorSaving)
            {
                Session.Remove("cliente");
                Session.Remove("tratamiento");
                labeldni.Text         = "";
                labelrs.Text          = "";
                labeltratamiento.Text = "";
                labelnumsesiones.Text = "";
                Response.Redirect(DotNetNuke.Common.Globals.NavigateURL() + "?addTurnoStatus=success");
            }
        }