Beispiel #1
0
    protected void botonguardar_Click(object sender, EventArgs e)
    {
        try
        {
            Error.Visible = false;

            int      doctor_id = Convert.ToInt32(doctoridhiddenfield.Value);
            Doctores obj       = new Doctores()
            {
                doctor_id    = doctor_id,
                nombre       = NombreDoctor.Text,
                especialidad = Especialidad.Text,
                telefono     = TelefonoTextbox.Text,
                usuario_id   = Convert.ToInt32(DropDownList1.SelectedValue)
            };
            if (doctor_id == 0)
            {
                DoctorBBL.insertar_doctor(obj);
            }
            else
            {
                DoctorBBL.actulizar_doctor(obj);
            }
        }
        catch (Exception ex)
        {
            Error.Visible = true;
            return;
        }
        Response.Redirect("~/Doctor.aspx");
    }
Beispiel #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            CargarLista();
        }

        if (IsPostBack)
        {
            return;
        }
        string stringid = Request.QueryString["id"];

        if (string.IsNullOrEmpty(stringid))
        {
            return;
        }
        try
        {
            int      doctor_id = Convert.ToInt32(stringid);
            Doctores obj       = DoctorBBL.GetDoctorById(doctor_id);
            NombreDoctor.Text    = obj.nombre;
            Especialidad.Text    = obj.especialidad;
            TelefonoTextbox.Text = obj.telefono;

            doctoridhiddenfield.Value = stringid;
        }
        catch (Exception ex)
        {
        }
    }
Beispiel #3
0
        public static int insertar_doctor(Doctores obj)
        {
            if (obj == null)
            {
                throw new ArgumentException("El objeto no puede ser nulo");
            }

            if (string.IsNullOrEmpty(obj.nombre))
            {
                throw new ArgumentException("El Nombre del Doctor no puede ser nulo");
            }
            if (string.IsNullOrEmpty(obj.especialidad))
            {
                throw new ArgumentException("La especialidad no puede ser nulo");
            }
            if (string.IsNullOrEmpty(obj.telefono))
            {
                throw new ArgumentException("El telefono no puede ser nulo");
            }
            if (string.IsNullOrEmpty(Convert.ToString(obj.usuario_id)))
            {
                throw new ArgumentException("El usuario no puede ser nulo");
            }
            int?id = 0;

            DoctordbTableAdapters.DoctorTableAdapter Adapter = new DoctordbTableAdapters.DoctorTableAdapter();
            Adapter.insertar_doctor(obj.nombre, obj.especialidad, obj.telefono, Convert.ToString(obj.usuario_id), ref id);
            if (id == null || id <= 0)
            {
                throw new Exception("la llave primaria no recorrio  bien");
            }
            return(id.Value);
        }
Beispiel #4
0
        public static void actulizar_doctor(Doctores obj)
        {
            if (obj == null)
            {
                throw new ArgumentException("El objeto no puede ser nulo");
            }
            if (obj.doctor_id <= 0)
            {
                throw new ArgumentException("El id del doctor no puede ser menor  o igual que a cero");
            }
            if (string.IsNullOrEmpty(obj.nombre))
            {
                throw new ArgumentException("El Nombre del Producto no puede ser nulo");
            }
            if (string.IsNullOrEmpty(obj.especialidad))
            {
                throw new ArgumentException("El especialidad no puede ser nulo");
            }
            if (string.IsNullOrEmpty(obj.telefono))
            {
                throw new ArgumentException("El telefono no puede ser nulo");
            }
            if (string.IsNullOrEmpty(Convert.ToString(obj.usuario_id)))
            {
                throw new ArgumentException("El usuario no puede ser nulo");
            }
            int?id = 0;

            DoctordbTableAdapters.DoctorTableAdapter Adapter = new DoctordbTableAdapters.DoctorTableAdapter();

            Adapter.actulizar_doctor(obj.nombre, obj.especialidad, obj.telefono, Convert.ToString(obj.usuario_id), obj.doctor_id);
        }
Beispiel #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            Doctores doctores = db.Doctores.Find(id);

            db.Doctores.Remove(doctores);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #6
0
        public static Doctores GetDoctorById(int doctor_id)
        {
            if (doctor_id <= 0)
            {
                throw new ArgumentException("El id del Doctor no puede ser menor o igual que cero");
            }
            DoctordbTableAdapters.DoctorTableAdapter adapter = new DoctordbTableAdapters.DoctorTableAdapter();
            Doctordb.DoctorDataTable table = adapter.GetDataBy3(doctor_id);
            Doctores obj = GetDoctorFromRow(table[0]);

            return(obj);
        }
Beispiel #7
0
 public ActionResult Edit([Bind(Include = "DoctoresID,EspecialidadID,HospitalID,NombreDoc,Descripcion,EstadoDoc")] Doctores doctores)
 {
     if (ModelState.IsValid)
     {
         db.Entry(doctores).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.EspecialidadID = new SelectList(db.Especialidads, "EspecialidadID", "NombreEsp", doctores.EspecialidadID);
     ViewBag.HospitalID     = new SelectList(db.Hospitals, "HospitalID", "NombreHosp", doctores.HospitalID);
     return(View(doctores));
 }
Beispiel #8
0
        public static List <Doctores> GetDoctor()
        {
            DoctordbTableAdapters.DoctorTableAdapter adapter = new DoctordbTableAdapters.DoctorTableAdapter();
            Doctordb.DoctorDataTable table = adapter.GetDoctor();
            List <Doctores>          list  = new List <Doctores>();

            foreach (var row in table)
            {
                Doctores obj = GetDoctorFromRow(row);
                list.Add(obj);
            }
            return(list);
        }
Beispiel #9
0
        public static Doctores GetDoctorFromRow(Doctordb.DoctorRow row)
        {
            Doctores obj = new Doctores()
            {
                doctor_id    = row.doctor_id,
                nombre       = row.nombre,
                especialidad = row.especialidad,
                telefono     = row.telefono,
                usuario_id   = Convert.ToInt32(row.usuario_id)
            };

            return(obj);
        }
Beispiel #10
0
 public ActionResult PostDoctores([FromBody] Doctores doctores)
 {
     try
     {
         context.Doctores.Add(doctores);
         context.SaveChanges();
         return(CreatedAtRoute("GetDoctores", new { id = doctores.IdDoctores }, doctores));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Beispiel #11
0
        // GET: Doctores/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Doctores doctores = db.Doctores.Find(id);

            if (doctores == null)
            {
                return(HttpNotFound());
            }
            return(View(doctores));
        }
 private static Result validarAtributos(Doctores registro)
 {
     if (registro.id == 0)
     {
         return(new Result {
             error = "Texto Validación", tipoAlerta = "warning"
         });
     }
     if (registro.idPersonas == 0)
     {
         return(new Result {
             error = "Texto Validación", tipoAlerta = "warning"
         });
     }
     if (registro.usuarioId == 0)
     {
         return(new Result {
             error = "Texto Validación", tipoAlerta = "warning"
         });
     }
     if (registro.telefonoCorporacion == 0)
     {
         return(new Result {
             error = "Texto Validación", tipoAlerta = "warning"
         });
     }
     if (registro.registroUnico == "")
     {
         return(new Result {
             error = "Texto Validación", tipoAlerta = "warning"
         });
     }
     if (registro.especialidad == "")
     {
         return(new Result {
             error = "Texto Validación", tipoAlerta = "warning"
         });
     }
     if (registro.direccionLaboral == "")
     {
         return(new Result {
             error = "Texto Validación", tipoAlerta = "warning"
         });
     }
     return(new Result()
     {
         error = ""
     });
 }
Beispiel #13
0
        // GET: Doctores/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Doctores doctores = db.Doctores.Find(id);

            if (doctores == null)
            {
                return(HttpNotFound());
            }
            ViewBag.EspecialidadID = new SelectList(db.Especialidads, "EspecialidadID", "NombreEsp", doctores.EspecialidadID);
            ViewBag.HospitalID     = new SelectList(db.Hospitals, "HospitalID", "NombreHosp", doctores.HospitalID);
            return(View(doctores));
        }
Beispiel #14
0
        public async Task <IActionResult> PutDoctores(int id, [FromBody] Doctores doctores)
        {
            try
            {
                if (id != doctores.IdDoctores)
                {
                    return(BadRequest());
                }

                context.Update(doctores);
                await context.SaveChangesAsync();

                return(Ok(new { message = " actualizado con exito!" }));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Beispiel #15
0
        public ResultadoEjecucion Post([FromBody] Doctores doctor)
        {
            ResultadoEjecucion resultado = new ResultadoEjecucion();

            try
            {
                context.Doctores.Add(doctor);
                context.SaveChanges();

                resultado.codigo      = 0;
                resultado.descripcion = "Paciente creado exitosamente";
                return(resultado);
            }
            catch (Exception ex)
            {
                resultado.codigo      = 100;
                resultado.descripcion = "Problema en la aplicacion, mensaje: " + ex.Message;
                return(resultado);
            }
        }
Beispiel #16
0
        public async Task <Doctores> SaveDoctores([FromBody] Doctores doctor)
        {
            if (!ModelState.IsValid)
            {
                throw new ApiException("Model binding failed.", 500);
            }

            if (!Repository.Validate(doctor))
            {
                throw new ApiException(Repository.ErrorMessage, 500, Repository.ValidationErrors);
            }

            var album = await Repository.SaveDoctores(doctor);

            if (album == null)
            {
                throw new ApiException(Repository.ErrorMessage, 500);
            }

            return(album);
        }
 public static Result eliminarDoctores(int doctoresId, int usuarioId)
 {
     using (MoldeEntities entity = new MoldeEntities())
     {
         if (existeRegistro(doctoresId))
         {
             Result result = new Result()
             {
                 error = ""
             };
             result = ValidateSession.validarOperacionesForm("Doctores", "Eliminar", usuarioId);
             if (result.error != null && result.error != "")
             {
                 return(result);
             }
             Doctores registroEliminar = entity.Doctores.Where(x => x.id == doctoresId).SingleOrDefault();
             entity.Doctores.Remove(registroEliminar);
             MoldeTrasabilidad.trasabilidadObject((registroEliminar as object), "Doctores", "Eliminado", usuarioId, "AplicacionMolde");
             try
             {
                 entity.SaveChanges();
                 return(new Result {
                     error = result.error, id = doctoresId
                 });
             }
             catch (Exception e)
             {
                 return(new Result {
                     error = e.Message, id = 0, tipoAlerta = "warning"
                 });
             }
         }
     }
     return(new Result {
         error = ""
     });
 }
        public static Result guardarDoctores(Doctores registro)
        {
            Result result = new Result()
            {
                error = ""
            };

            result = validarAtributos(registro);
            if (result.error != null && result.error != "")
            {
                return(result);
            }

            using (MoldeEntities entity = new MoldeEntities())
            {
                if (existeRegistro(registro.id))
                {
                    result = ValidateSession.validarOperacionesForm("Doctores", "Editar", registro.usuarioId);
                    if (result.error != null && result.error != "")
                    {
                        return(result);
                    }
                    int      doctoresId     = registro.id;
                    Doctores registroEditar = entity.Doctores.Where(x => x.id == doctoresId).SingleOrDefault();
                    entity.Entry(registroEditar).CurrentValues.SetValues(registro);
                    try
                    {
                        entity.SaveChanges();
                        return(new Result {
                            error = ""
                        });
                    }
                    catch (Exception e)
                    {
                        return(new Result {
                            error = e.Message, id = 0, tipoAlerta = "warning"
                        });
                    }
                }
                else
                {
                    result = ValidateSession.validarOperacionesForm("Doctores", "Nuevo", registro.usuarioId);
                    if (result.error != null && result.error != "")
                    {
                        return(result);
                    }
                    entity.Doctores.Add(registro);
                    try
                    {
                        entity.SaveChanges();
                        return(new Result {
                            error = result.error, id = registro.id
                        });
                    }
                    catch (Exception e)
                    {
                        return(new Result {
                            error = e.Message, id = 0, tipoAlerta = "warning"
                        });
                    }
                }
            }
        }
Beispiel #19
0
        public ActionResult Detalles(String doccod)
        {
            Doctores doc = modelo.BuscarDoctor(doccod);

            return(View(doc));
        }