}//obtener todas los vatihorimetros del sistemas.



        public bool actualizarHidrometro(Entity.Hidrometro hidrometro)
        {
            SqlCommand cmd = new SqlCommand("sp_actualizarHidrometro", connection);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@Numero_Hidrometro", hidrometro.Numero_Hidrometro);
            cmd.Parameters.AddWithValue("@Nombre_Hidrometro", hidrometro.Nombre_Hidrometro);
            cmd.Parameters.AddWithValue("@Id_Planta", hidrometro.Id_Planta);
            connection.Open();
            int i = cmd.ExecuteNonQuery();
            connection.Close();

            if (i >= 1)
                return true;
            else
                return false;
        }//actualizar los datos un planta
        }//constructor

        public bool crearHidrometro(Entity.Hidrometro hidrometro, int planta)
        {
            SqlCommand cmd = new SqlCommand("sp_crearHidrometro", connection);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@Numero_Hidrometro", hidrometro.Numero_Hidrometro);
            cmd.Parameters.AddWithValue("@Nombre_Hidrometro", hidrometro.Nombre_Hidrometro);
            cmd.Parameters.AddWithValue("@Id_Planta", planta);
            cmd.Parameters.AddWithValue("@EstadoBl", "A");


            connection.Open();
            int i = cmd.ExecuteNonQuery();
            connection.Close();
            if (i >= 1)
                return true;
            else
                return false;
        }//Añadir un vatihorimetro en el sistema
Esempio n. 3
0
 public ActionResult RegistrarHidrometroView(Entity.Hidrometro hidrometro, int plantas)
 {
         PlantaModel plantaModel = new PlantaModel();
         ViewData["plantas"] = new SelectList(plantaModel.obtenerPlantas(), "id", "nombre");
         if (ModelState.IsValid)
         {
         HidrometroModel sdb = new HidrometroModel();
             if (sdb.crearHidrometro(hidrometro, plantas))
             {
                 TempData["success"] = "true";
                 return RedirectToAction("RegistrarHidrometroView");
             }else
             {
                 TempData["success"] = "true";
                 return View();
             }
         }//end if
         return View();
 }//insertar