Пример #1
0
 public ActionResult Edit([Bind(Include = "id,fecha,alerta_id,tratador_id")] tratamiento tratamiento)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tratamiento).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.tratador_id         = new SelectList(db.tratador, "id", "nombre", tratamiento.tratador_id);
     ViewBag.tipo_tratamiento_id = new SelectList(db.tipo_tratamiento, "id", "nombre", tratamiento.tipo_tratamiento_id);
     return(View(tratamiento));
 }
Пример #2
0
        // GET: Tratamiento/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tratamiento tratamiento = db.tratamiento.Find(id);

            if (tratamiento == null)
            {
                return(HttpNotFound());
            }
            return(View(tratamiento));
        }
Пример #3
0
        public ActionResult Create([Bind(Include = "id,fecha,tratador_id,tipo_tratamiento_id")] tratamiento tratamiento)
        {
            if (ModelState.IsValid)
            {
                db.tratamiento.Add(tratamiento);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }


            ViewBag.tratador_id         = new SelectList(db.tratador, "id", "nombre", tratamiento.tratador_id);
            ViewBag.tipo_tratamiento_id = new SelectList(db.tipo_tratamiento, "id", "nombre", tratamiento.tipo_tratamiento_id);
            return(View(tratamiento));
        }
Пример #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            tratamiento tratamiento = db.tratamiento.Find(id);

            try
            {
                db.tratamiento.Remove(tratamiento);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            catch
            {
                ViewBag.Error = "No se puede eliminar debido a que existen datos asociados";
            }
            return(View(tratamiento));
        }
Пример #5
0
        // GET: Tratamiento/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tratamiento tratamiento = db.tratamiento.Find(id);

            if (tratamiento == null)
            {
                return(HttpNotFound());
            }
            ViewBag.tratador_id         = new SelectList(db.tratador, "id", "nombre", tratamiento.tratador_id);
            ViewBag.tipo_tratamiento_id = new SelectList(db.tipo_tratamiento, "id", "nombre", tratamiento.tipo_tratamiento_id);
            return(View(tratamiento));
        }
Пример #6
0
        public static long update(ETratamiento tratamiento)
        {
            try
            {
                CapaDato.dbodontogramaEntity cn           = new dbodontogramaEntity();
                List <tratamiento>           tratamientos = new List <tratamiento>();
                tratamiento Obj = new tratamiento();

                tratamientos = (from d in cn.tratamiento
                                where d.nombre == tratamiento.nombre ||
                                d.color == tratamiento.color
                                select d).ToList();

                if (tratamientos.Count > 1)
                {
                    throw new Exception("Ingrese Otro Tratamiento, O Seleccione Otro Color");
                }


                Obj = (from d in cn.tratamiento
                       where d.tratamientoID == tratamiento.tratamientoID
                       select d).First();

                Obj.nombre = tratamiento.nombre;
                Obj.color  = tratamiento.color;
                Obj.tipo   = tratamiento.tipo;
                Obj.precio = tratamiento.precio;
                Obj.estado = 1;

                int result = cn.SaveChanges();
                if (result > 0)
                {
                    return(Obj.tratamientoID);
                }
                else
                {
                    throw new Exception("No Hubo Ningun Cambio al Editar");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Пример #7
0
        public static long save(ETratamiento tratamiento)
        {
            try
            {
                CapaDato.dbodontogramaEntity cn           = new dbodontogramaEntity();
                List <tratamiento>           tratamientos = new List <tratamiento>();
                tratamiento Obj = new tratamiento();

                tratamientos = (from d in cn.tratamiento
                                where d.nombre == tratamiento.nombre || d.color == tratamiento.color
                                select d).ToList();

                if (tratamientos.Count > 1)
                {
                    throw new Exception("Ingrese Otro Tratamiento o Seleccione Otro Color");
                }


                Obj.nombre = tratamiento.nombre;
                Obj.color  = tratamiento.color;
                if (Obj.nombre == string.Empty && Obj.color == string.Empty)
                {
                    throw new Exception("Ingrese Nombre y el Color");
                }

                Obj.tipo   = tratamiento.tipo;
                Obj.precio = tratamiento.precio;
                Obj.estado = 1;
                cn.tratamiento.Add(Obj);
                int result = cn.SaveChanges();
                if (result > 0)
                {
                    return(Obj.tratamientoID);
                }
                else
                {
                    throw new Exception("Error al guardar");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Пример #8
0
        public static string delete(ETratamiento tratamiento)
        {
            string rpta = "";

            try
            {
                CapaDato.dbodontogramaEntity cn = new dbodontogramaEntity();
                tratamiento Obj = new tratamiento();
                Obj        = cn.tratamiento.Find(tratamiento.tratamientoID);
                rpta       = Obj.estado == 1 ? "OK" : "No se Puede Eliminar el Registro";
                Obj.estado = 0;
                cn.SaveChanges();
            }
            catch (Exception ex)
            {
                rpta = (ex.Message);
            }
            return(rpta);
        }