Exemple #1
0
        public static void ActualizarCita(Cita obj)
        {
            if (obj == null)
            {
                throw new ArgumentException("El objeto no puede ser nulo");
            }
            if (string.IsNullOrEmpty(obj.fechaHora))
            {
                throw new ArgumentException("El fecha no puede ser nulo o vacio");
            }

            if (string.IsNullOrEmpty(obj.observacion))
            {
                throw new ArgumentException("El observacion no puede ser nulo o vacio");
            }
            if (obj.pacienteid == null)
            {
                throw new ArgumentException("El paciente no puede ser nulo o vacio");
            }
            if (obj.usuarioId == null)
            {
                throw new ArgumentException("El usuario no puede ser nulo o vacio");
            }
            if (obj.doctorId == null)
            {
                throw new ArgumentException("El doctor no puede ser nulo o vacio");
            }

            CitaDSTableAdapters.CitaTableAdapter adapter = new CitaDSTableAdapters.CitaTableAdapter();
            adapter.ActualizarCita(obj.fechaHora, obj.observacion, obj.doctorId, obj.pacienteid, obj.usuarioId, obj.citaId);
        }
Exemple #2
0
 public static void EliminarCita(int citaId)
 {
     if (citaId <= 0)
     {
         throw new ArgumentException("El id de la Cita no puede ser menor o igual que cero");
     }
     CitaDSTableAdapters.CitaTableAdapter adapter = new CitaDSTableAdapters.CitaTableAdapter();
     adapter.EliminarCita(citaId);
 }
Exemple #3
0
        public static Cita GetCitaById(int citaId)
        {
            if (citaId <= 0)
            {
                throw new ArgumentException("El id de la Cita no puede ser menor o igual que cero");
            }

            CitaDSTableAdapters.CitaTableAdapter adapter = new CitaDSTableAdapters.CitaTableAdapter();
            CitaDS.CitaDataTable table = adapter.GetCitaById(citaId);
            Cita obj = getCitaFromRow(table[0]);

            return(obj);
        }
Exemple #4
0
        public static List <Cita> GetCita()
        {
            CitaDSTableAdapters.CitaTableAdapter adapter = new CitaDSTableAdapters.CitaTableAdapter();
            CitaDS.CitaDataTable table = adapter.GetCita();

            List <Cita> list = new List <Cita>();

            foreach (var row in table)
            {
                Cita obj = getCitaFromRow(row);
                list.Add(obj);
            }
            return(list);
        }
Exemple #5
0
        public static int InsertarCita(Cita obj)
        {
            if (obj == null)
            {
                throw new ArgumentException("El objeto no puede ser nulo");
            }

            if (string.IsNullOrEmpty(obj.fechaHora))
            {
                throw new ArgumentException("El fecha no puede ser nulo o vacio");
            }

            if (string.IsNullOrEmpty(obj.observacion))
            {
                throw new ArgumentException("El observacion no puede ser nulo o vacio");
            }
            if (obj.pacienteid == null)
            {
                throw new ArgumentException("El paciente no puede ser nulo o vacio");
            }
            if (obj.usuarioId == null)
            {
                throw new ArgumentException("El usuario no puede ser nulo o vacio");
            }
            if (obj.doctorId == null)
            {
                throw new ArgumentException("El doctor no puede ser nulo o vacio");
            }

            //string fecha1 = string.Format(obj.fecha);
            //string hora1 = string.Format(obj.hora);


            int?id = 0;

            CitaDSTableAdapters.CitaTableAdapter adapter = new CitaDSTableAdapters.CitaTableAdapter();

            adapter.InsertarCita(obj.fechaHora, obj.observacion, obj.doctorId, obj.pacienteid, obj.usuarioId, ref id);

            if (id == null || id <= 0)
            {
                throw new Exception("La llave primaria no se generó correctamente");
            }
            return(id.Value);
        }