Beispiel #1
0
        public ActionResult mapa(long?id)
        {
            if (id == null)
            {
                //RedirectToAction("locales", "Home");
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ModelClinica local  = new ModelClinica();
            String       codigo = id.ToString();

            var datos = (from x in local.Clinicas where x.cod_cli == codigo select x).First();

            if (datos.Equals(null))
            {
                ViewBag.Message = "No se encuentra Datos";
                return(View());
            }
            ViewBag.Lat     = datos.Lat_cli;
            ViewBag.Log     = datos.Log_cli;
            ViewBag.descrip = datos.des_cli;
            ViewBag.nom_cli = datos.nom_cli;
            ViewBag.tel_cli = datos.tel_cli;
            ViewBag.dir_cli = datos.dir_cli;
            return(View(datos));
        }
        public ActionResult ListaClinicas(int?page, string searchString)
        {
            if (TempData["mensaje"] != null)
            {
                ViewBag.mensaje     = TempData["mensaje"];
                TempData["mensaje"] = null;
            }
            string       currentFilter = null;
            ModelClinica local         = new ModelClinica();
            //var datos = (from x in local.Clinicas where x.Est_cli == "1" orderby x.cod_cli select x);
            var datos = (from x in local.Clinicas where x.Est_cli == "1" select x);

            if (!String.IsNullOrEmpty(searchString))
            {
                datos = datos.Where(s => s.nom_cli.Contains(searchString.ToString()));
            }

            datos = datos.OrderByDescending(x => x.cod_cli);
            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewBag.CurrentFilter = searchString;


            int pageSize   = 8;
            int pageNumber = (page ?? 1);

            return(View(datos.ToPagedList(pageNumber, pageSize)));
        }
        //[Bind(Include = "nom_cont,emi_cont")]
        public ActionResult CreateClinica(Clinicas dbcont)
        {
            try
            {
                // this.ConnectionString = ConfigurationManager.ConnectionStrings["Movies"].ConnectionString;
                string       Conexion  = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
                ModelClinica DBClinica = new ModelClinica();
                using (var con = new SqlConnection(@Conexion))
                {
                    //result = Dapper.SqlMapper.Query<int>(Conexion,"SP_INSERTACLINICA",System.Data.CommandType.StoredProcedure);
                    con.Open();
                    var parameter = new DynamicParameters();
                    parameter.Add("@nom_cli", dbcont.nom_cli);
                    parameter.Add("@des_cli", dbcont.des_cli);
                    parameter.Add("@dir_cli", dbcont.dir_cli);
                    parameter.Add("@tel_cli", dbcont.tel_cli);
                    parameter.Add("@Lat_cli", dbcont.Lat_cli);
                    parameter.Add("@Log_cli", dbcont.Log_cli);

                    Dapper.SqlMapper.Execute(con, "SP_INSERTACLINICA", parameter, commandType: CommandType.StoredProcedure);
                    con.Close();
                }

                TempData["mensaje"] = ("<div class='exito'>Su Mensaje Fue Registrado con Exito</div>");
                return(RedirectToAction("CreateClinica"));
            }
            catch (Exception ex)
            {
                string mimsg = ex.Message;
                //ViewBag.mensaje = ("<div class='alerta'>Error al Registra Valores > " +ex.Message+" </div>");
                ViewBag.mensaje = ("<div class='alerta'>Error al Registra Valores   </div>");
                return(View());
            }
        }
        public ActionResult EditClinicas(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            string       codigo = id.ToString();
            ModelClinica local  = new ModelClinica();
            Clinicas     datos  = (from x in local.Clinicas where x.cod_cli == codigo select x).First();

            //Clinicas datos = DbClinica.Clinicas.Find(id);
            if (datos == null)
            {
                return(HttpNotFound());
            }
            if (TempData["mensaje"] != null)
            {
                ViewBag.mensaje     = TempData["mensaje"];
                TempData["mensaje"] = null;
            }
            return(View(datos));
        }
Beispiel #5
0
        public ActionResult locales(int?page, string searchString)
        {
            string       currentFilter = null;
            ModelClinica local         = new ModelClinica();
            //var datos = (from x in local.Clinicas where x.Est_cli == "1" orderby x.cod_cli select x);
            var datos = (from x in local.Clinicas where x.Est_cli == "1" select x);

            if (!String.IsNullOrEmpty(searchString))
            {
                datos = datos.Where(s => s.nom_cli.Contains(searchString.ToString()));

                /*
                 * datos = datos.Where(s => s.des_cli.Contains(searchString)
                 || s.FirstMidName.Contains(searchString));
                 */
            }

            datos = datos.OrderBy(x => x.cod_cli);
            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewBag.CurrentFilter = searchString;


            //var datos = ( from x in  local.Clinicas where x.Est_cli=="1" orderby x.cod_cli select x );


            int pageSize   = 8;
            int pageNumber = (page ?? 1);

            return(View(datos.ToPagedList(pageNumber, pageSize)));
        }