示例#1
0
        public ActionResult Edit(ingresos ingresos)
        {
            ingresos oingresos = new ingresos();

            oingresos.Num_habitacion = System.Convert.ToInt32(ingresos.Num_habitacion);
            oingresos = ingresosData.Select_Record(ingresos);

            if (ModelState.IsValid)
            {
                bool bSucess = false;
                bSucess = ingresosData.Update(oingresos, ingresos);
                if (bSucess == true)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ModelState.AddModelError("", "Can Not Update");
                }
            }
            // ComboBox
            ViewData["id_cama"]     = new SelectList(ingresos_camasData.List(), "id_cama", "Num_cama", ingresos.id_cama);
            ViewData["id_historia"] = new SelectList(ingresos_historia_clinicaData.List(), "id_historia", "Cedula", ingresos.id_historia);

            return(View(ingresos));
        }
示例#2
0
        // GET: /ingresos/Edit/<id>
        public ActionResult Edit(
            Int32?Num_habitacion
            )
        {
            if (
                Num_habitacion == null
                )
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ingresos ingresos = new ingresos();

            ingresos.Num_habitacion = System.Convert.ToInt32(Num_habitacion);
            ingresos = ingresosData.Select_Record(ingresos);

            if (ingresos == null)
            {
                return(HttpNotFound());
            }
            // ComboBox
            ViewData["id_cama"]     = new SelectList(ingresos_camasData.List(), "id_cama", "Num_cama", ingresos.id_cama);
            ViewData["id_historia"] = new SelectList(ingresos_historia_clinicaData.List(), "id_historia", "Cedula", ingresos.id_historia);

            return(View(ingresos));
        }
示例#3
0
        public ActionResult Create([Bind(Include =
                                             "Comentario"
                                             + "," + "Fecha_ingreso"
                                             + "," + "Fecha_salida"
                                             + "," + "id_cama"
                                             + "," + "id_historia"
                                         )] ingresos ingresos)
        {
            if (ModelState.IsValid)
            {
                bool bSucess = false;
                bSucess = ingresosData.Add(ingresos);
                if (bSucess == true)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ModelState.AddModelError("", "Can Not Insert");
                }
            }
            // ComboBox
            ViewData["id_cama"]     = new SelectList(ingresos_camasData.List(), "id_cama", "Num_cama", ingresos.id_cama);
            ViewData["id_historia"] = new SelectList(ingresos_historia_clinicaData.List(), "id_historia", "Cedula", ingresos.id_historia);

            return(View(ingresos));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            ingresos ingresos = db.ingresos.Find(id);

            db.ingresos.Remove(ingresos);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "id,pacientes_ID,room_id,FechaInicio")] ingresos ingresos)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ingresos).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.pacientes_ID = new SelectList(db.Patients, "ID", "Cedula", ingresos.pacientes_ID);
     ViewBag.room_id      = new SelectList(db.rooms, "ID", "tipo", ingresos.room_id);
     return(View(ingresos));
 }
        // GET: ingresos/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ingresos ingresos = db.ingresos.Find(id);

            if (ingresos == null)
            {
                return(HttpNotFound());
            }
            return(View(ingresos));
        }
        // GET: ingresos/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ingresos ingresos = db.ingresos.Find(id);

            if (ingresos == null)
            {
                return(HttpNotFound());
            }
            ViewBag.pacientes_ID = new SelectList(db.Patients, "ID", "Cedula", ingresos.pacientes_ID);
            ViewBag.room_id      = new SelectList(db.rooms, "ID", "tipo", ingresos.room_id);
            return(View(ingresos));
        }
示例#8
0
        public static ingresos Select_Record(ingresos ingresosPara)
        {
            ingresos      ingresos        = new ingresos();
            SqlConnection connection      = hospitalData.GetConnection();
            string        selectProcedure = "[ingresosSelect]";
            SqlCommand    selectCommand   = new SqlCommand(selectProcedure, connection);

            selectCommand.CommandType = CommandType.StoredProcedure;
            selectCommand.Parameters.AddWithValue("@Num_habitacion", ingresosPara.Num_habitacion);
            try
            {
                connection.Open();
                SqlDataReader reader
                    = selectCommand.ExecuteReader(CommandBehavior.SingleRow);
                if (reader.Read())
                {
                    ingresos.Num_habitacion = System.Convert.ToInt32(reader["Num_habitacion"]);
                    ingresos.Comentario     = reader["Comentario"] is DBNull ? null : reader["Comentario"].ToString();
                    ingresos.Fecha_ingreso  = reader["Fecha_ingreso"] is DBNull ? null : (DateTime?)reader["Fecha_ingreso"];
                    ingresos.Fecha_salida   = reader["Fecha_salida"] is DBNull ? null : (DateTime?)reader["Fecha_salida"];
                    ingresos.id_cama        = reader["id_cama"] is DBNull ? null : (Int32?)reader["id_cama"];
                    ingresos.id_historia    = reader["id_historia"] is DBNull ? null : (Int32?)reader["id_historia"];
                }
                else
                {
                    ingresos = null;
                }
                reader.Close();
            }
            catch (SqlException)
            {
                return(ingresos);
            }
            finally
            {
                connection.Close();
            }
            return(ingresos);
        }
示例#9
0
        public ActionResult DeleteConfirmed(
            Int32?Num_habitacion
            )
        {
            ingresos ingresos = new ingresos();

            ingresos.Num_habitacion = System.Convert.ToInt32(Num_habitacion);
            ingresos = ingresosData.Select_Record(ingresos);

            bool bSucess = false;

            bSucess = ingresosData.Delete(ingresos);
            if (bSucess == true)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                ModelState.AddModelError("", "Can Not Delete");
            }
            return(null);
        }
示例#10
0
        // GET: /ingresos/Delete/<id>
        public ActionResult Delete(
            Int32?Num_habitacion
            )
        {
            if (
                Num_habitacion == null
                )
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            A24dtcamas            = ingresos_camasData.SelectAll();
            A25dthistoria_clinica = ingresos_historia_clinicaData.SelectAll();

            ingresos ingresos = new ingresos();

            ingresos.Num_habitacion = System.Convert.ToInt32(Num_habitacion);
            ingresos       = ingresosData.Select_Record(ingresos);
            ingresos.camas = new camas()
            {
                id_cama    = (Int32)ingresos.id_cama
                , Num_cama = (from DataRow A24rowcamas in A24dtcamas.Rows
                              where ingresos.id_cama == (int)A24rowcamas["id_cama"]
                              select(Int32) A24rowcamas["Num_cama"]).FirstOrDefault()
            };
            ingresos.historia_clinica = new historia_clinica()
            {
                id_historia = (Int32)ingresos.id_historia
                , Cedula    = (from DataRow A25rowhistoria_clinica in A25dthistoria_clinica.Rows
                               where ingresos.id_historia == (int)A25rowhistoria_clinica["id_historia"]
                               select(String) A25rowhistoria_clinica["Cedula"]).FirstOrDefault()
            };

            if (ingresos == null)
            {
                return(HttpNotFound());
            }
            return(View(ingresos));
        }
示例#11
0
        public static bool Delete(ingresos ingresos)
        {
            SqlConnection connection      = hospitalData.GetConnection();
            string        deleteProcedure = "[ingresosDelete]";
            SqlCommand    deleteCommand   = new SqlCommand(deleteProcedure, connection);

            deleteCommand.CommandType = CommandType.StoredProcedure;
            deleteCommand.Parameters.AddWithValue("@OldNum_habitacion", ingresos.Num_habitacion);
            if (ingresos.Comentario != null)
            {
                deleteCommand.Parameters.AddWithValue("@OldComentario", ingresos.Comentario);
            }
            else
            {
                deleteCommand.Parameters.AddWithValue("@OldComentario", DBNull.Value);
            }
            if (ingresos.Fecha_ingreso.HasValue == true)
            {
                deleteCommand.Parameters.AddWithValue("@OldFecha_ingreso", ingresos.Fecha_ingreso);
            }
            else
            {
                deleteCommand.Parameters.AddWithValue("@OldFecha_ingreso", DBNull.Value);
            }
            if (ingresos.Fecha_salida.HasValue == true)
            {
                deleteCommand.Parameters.AddWithValue("@OldFecha_salida", ingresos.Fecha_salida);
            }
            else
            {
                deleteCommand.Parameters.AddWithValue("@OldFecha_salida", DBNull.Value);
            }
            if (ingresos.id_cama.HasValue == true)
            {
                deleteCommand.Parameters.AddWithValue("@Oldid_cama", ingresos.id_cama);
            }
            else
            {
                deleteCommand.Parameters.AddWithValue("@Oldid_cama", DBNull.Value);
            }
            if (ingresos.id_historia.HasValue == true)
            {
                deleteCommand.Parameters.AddWithValue("@Oldid_historia", ingresos.id_historia);
            }
            else
            {
                deleteCommand.Parameters.AddWithValue("@Oldid_historia", DBNull.Value);
            }
            deleteCommand.Parameters.Add("@ReturnValue", System.Data.SqlDbType.Int);
            deleteCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.Output;
            try
            {
                connection.Open();
                deleteCommand.ExecuteNonQuery();
                int count = System.Convert.ToInt32(deleteCommand.Parameters["@ReturnValue"].Value);
                if (count > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (SqlException)
            {
                return(false);
            }
            finally
            {
                connection.Close();
            }
        }