ASP.NET MVC企业级程序设计(增删,页面水平排列,字符串拼接,非空,添加框内默认提示)

目录

题目: 

实现过程 

控制器代码

DAL

 BLL

Index 

Deile


题目: 

 

实现过程 

控制器代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcApplication1.Models;

namespace MvcApplication1.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/

        public ActionResult Index()
        {
            ViewBag.Show = BLL.PropertyInfoManager.Show();
            return View();
        }
        [HttpPost]
        public ActionResult Index(string userName, string phone, string area)
        {
            PropertyInfo model = new PropertyInfo();
            model.userName = userName;
            model.phone = phone;
         
            model.idCard ="aewf4we5f6w4ef65aw46ef";
            model.area = decimal.Parse(area);
            BLL.PropertyInfoManager.Add(model);

            return RedirectToAction("Index");
        }
        public ActionResult Delect(int id)
        {
            BLL.PropertyInfoManager.Delect(id);
            return RedirectToAction("Index"); 
            
            }
    }
}

DAL

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MvcApplication1.Models;
namespace MvcApplication1.DAL
{
    public class PropertyInfoServices
    {
        public static List<PropertyInfo> Show() {
            PropertyDBEntities db = new PropertyDBEntities();
            return db.PropertyInfoes.ToList();
        }
        public static PropertyInfo FindModel(int id)
        {
            PropertyDBEntities db = new PropertyDBEntities();
            return db.PropertyInfoes.SingleOrDefault(x => x.Id == id);
        }
        public static bool Delect(int id)
        {
          PropertyInfo model=  FindModel(id);
            PropertyDBEntities db = new PropertyDBEntities();
            db.Entry(model).State = System.Data.EntityState.Deleted;
            return db.SaveChanges() > 0;
        }
        public static bool Add(PropertyInfo model) {
            PropertyDBEntities db = new PropertyDBEntities();
            db.Entry(model).State = System.Data.EntityState.Added;
           
            return db.SaveChanges() > 0;
        }
    }
}

 BLL

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MvcApplication1.Models;

namespace MvcApplication1.BLL
{
    public class PropertyInfoManager
    {
        
            public static List<PropertyInfo> Show()
            {
                return DAL.PropertyInfoServices.Show();
            }
           
            public static bool Delect(int id)
            {
                return DAL.PropertyInfoServices.Delect(id);
            }
            public static bool Add(PropertyInfo model)
            {
                return DAL.PropertyInfoServices.Add(model);
            }
        
    }
}

Index 

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
</head>
<body>
    <div>
        <form method="post" action="/Home/Index" >

        
        <label>用户名:</label><br />
            <input type="text" placeholder="请输入用户名" name="userName" required/><br />
             <label>手机号:</label><br />
            <input type="text" placeholder="请输入手机号" name="phone" required/><br />
             <label>住房面积(含公摊):</label><br />
            <input type="text" placeholder="请输入住房面积" name="area" required/><br />
            <input type="submit" value="添加用户数据"/>
            </form>
        <table border="1" style=" position:absolute;top:5%;right:70%">
            <tr>
                <th>编号</th>
            <th>用户名</th>
            <th>手机号</th>
            <th>物业卡</th>
            <th>住房面积(含公摊)</th>
            <th>操作</th>
            </tr>
            @foreach (var item in @ViewBag.Show as List<MvcApplication1.Models.PropertyInfo>)
            {
                <tr>
                    <td>@item.Id</td>
                     <td>@item.userName</td>
                     <td>@item.phone</td>
                     <td>@item.idCard</td>
                     <td>@item.area (m²)</td>
                     <td>@Html.ActionLink("删除", "Delect", new { id = @item.Id }, new {onclick="return confirm('确定删除吗?')" })</td>
                </tr>
            }
        </table>
    </div>
</body>
</html>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/725740.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

Tensorflow入门实战 T05-运动鞋识别

目录 一、完整代码 二、训练过程 &#xff08;1&#xff09;打印2行10列的数据。 &#xff08;2&#xff09;查看数据集中的一张图片 &#xff08;3&#xff09;训练过程&#xff08;训练50个epoch&#xff09; &#xff08;4&#xff09;训练结果的精确度 三、遇到的问…

Docker环境离线安装

Docker环境离线安装 下载下列.deb包 sudo *.deb

【PyQt5】python桌面级应用开发:PyQt5介绍,开发环境搭建快速入门

✨✨ 欢迎大家来到景天科技苑✨✨ &#x1f388;&#x1f388; 养成好习惯&#xff0c;先赞后看哦~&#x1f388;&#x1f388; &#x1f3c6; 作者简介&#xff1a;景天科技苑 &#x1f3c6;《头衔》&#xff1a;大厂架构师&#xff0c;华为云开发者社区专家博主&#xff0c;…

天津媒体邀约,及媒体名单?

传媒如春雨&#xff0c;润物细无声&#xff0c;大家好&#xff0c;我是51媒体网胡老师。 媒体宣传加速季&#xff0c;100万补贴享不停&#xff0c;一手媒体资源&#xff0c;全国100城线下落地执行。详情请联系胡老师。 天津作为中国北方的重要城市&#xff0c;拥有丰富的媒体资…

Jenkins+K8s实现持续集成(二)

部署前呢&#xff0c;要先把jenkins搭建好。 同时呢已经有了k8s的环境。 基于以上两步已经有了的情况&#xff0c;继续要实现jenkinsk8s持续集成&#xff0c;需要先准备四个文件&#xff1a; Dockerfile首先要准备好一个Dockerfile文件&#xff0c;用于构建Docker镜像的文本…

最新版本IntelliJ IDEA安装与“坤活”使用

最新版本IntelliJ IDEA安装与“科学”使用 IntelliJ IDEA安装与坤活下载安装坤活idea1.将下面两个压缩文件解压到安装位置&#xff0c;注意路径不要包含中文空格等特殊符号2.双击 install-all-users.vbs &#xff0c;然后点击确定&#xff0c;等到出现 Done的弹窗3. 打开idea复…

函数依赖集等价、最小函数依赖集

一、函数依赖集等价 1、定义 假设F、G为一个关系模式上的两个函数依赖集&#xff0c;若&#xff0c;则称F和G是等价的&#xff0c;也可称F和G 互相覆盖。 2、判断 &#xff08;1&#xff09;引理3&#xff1a; 的充分必要条件是且 &#xff08;2&#xff09;两步走&…

密码学及其应用——为什么选择接近的质数因子对RSA加密算法不安全?

RSA加密算法是一种广泛使用的非对称加密算法&#xff0c;它的安全性依赖于大整数分解的难度。具体来说&#xff0c;RSA算法生成的公钥包含一个大整数N&#xff0c;这是两个大质数p和q的乘积。然而&#xff0c;如果这两个质数p和q太接近&#xff0c;则可以相对容易地对N进行因式…

Study--Oracle-04-SQL练习

一、SQL语句思维导图 二、SQL练习 -- 以employee_id 为排序&#xff0c;列出前5个人 -- FETCH select employee_id,first_name from employees order by employee_id FETCH FIRST 5 rows only; -- 以employee_id 为排序&#xff0c;从第6个人开始 到第10个人 -- offset …

计算机组成原理---Cache的基本工作原理习题

对应知识点&#xff1a; Cache的基本原理 1.某存储系统中&#xff0c;主存容量是Cache容量的4096倍&#xff0c;Cache 被分为 64 个块&#xff0c;当主存地址和Cache地址采用直接映射方式时&#xff0c;地址映射表的大小应为&#xff08;&#xff09;(假设不考虑一致维护和替…

【Redis】如何保证缓存和数据库的一致性

目录 背景问题思路 三个经典的缓存模式Cache-Aside读缓存写缓存为什么是删除旧缓存而不是更新旧缓存&#xff1f;为什么不先删除旧的缓存&#xff0c;然后再更新数据库&#xff1f; 延迟双删如何确保原子性 Read-Through/Write-ThroughRead-ThroughWrite-Through Write Behind …

Ubuntu22.04 下安装Curl库

1. apt 安装&#xff1a; sudo apt-get install curl 2. 官网压缩包&#xff1a; 下载地址&#xff1a;curl downloads wget https://curl.haxx.se/download/curl-7.78.0.tar.gz tar -xzvf curl-7.78.0.tar.gz cd curl-7.78.0 ./configure --with-openssl make sudo make i…

ubuntu系统上快速直接获取ip地址

文章目录 前言总结 前言 ubuntu系统上查看ip地址 $ hostname -I示例输出&#xff1a; 192.168.1.10总结 作者&#xff1a;加辣椒了吗&#xff1f; 简介&#xff1a;憨批大学生一枚&#xff0c;喜欢在博客上记录自己的学习心得&#xff0c;也希望能够帮助到你们&#xff01;

基于若依的ruoyi-nbcio流程管理系统增加所有任务功能(一)

更多ruoyi-nbcio功能请看演示系统 gitee源代码地址 前后端代码&#xff1a; https://gitee.com/nbacheng/ruoyi-nbcio 演示地址&#xff1a;RuoYi-Nbcio后台管理系统 http://218.75.87.38:9666/ 更多nbcio-boot功能请看演示系统 gitee源代码地址 后端代码&#xff1a; h…

CMake个人理解和使用

100编程书屋_孔夫子旧书网 前言 CMake是一个构建工具,通过它可以很容易创建跨平台的项目。通常使用它构建项目要分两步,通过源代码生成工程文件,通过工程文件构建目标产物(可能是动态库,静态库,也可能是可执行程序)。使用CMake的一个主要优势是在多平台或者多人协作的…

Python学习打卡:day10

day10 笔记来源于&#xff1a;黑马程序员python教程&#xff0c;8天python从入门到精通&#xff0c;学python看这套就够了 目录 day1073、文件的读取操作文件的操作步骤open()打开函数mode常用的三种基础访问模式读操作相关方法read()方法readlines()方法readline()方法for循…

Golang | Leetcode Golang题解之第168题Excel表列名称

题目&#xff1a; 题解&#xff1a; func convertToTitle(columnNumber int) string {ans : []byte{}for columnNumber > 0 {columnNumber--ans append(ans, Abyte(columnNumber%26))columnNumber / 26}for i, n : 0, len(ans); i < n/2; i {ans[i], ans[n-1-i] ans[n…

VSCode 安装NeoVim扩展(详细)

目录 1、安装NeoVim扩展 2、windows安装Neovim软件 3、优化操作相关的配置&#xff1a; 5、Neovim最好的兼容性配置 6、技巧和特点 6.1 故障排除 6.2、Neovim 插件组合键设置 6.3、跳转列表 1、安装NeoVim扩展 在扩展商店搜索NeoVim&#xff0c;安装扩展 2、windows安装…

吉时利Keithley2602B数字源表

吉时利Keithley2602B数字源表 2601B、2602B、2604B 系统 Sourcemeter SMU 仪器 2601B、2602B 和 2604B 系统 Sourcemeter SMU 仪器为 40W DC / 200W 脉冲 SMU&#xff0c;支持 10A 脉冲&#xff0c;3A 至 100fA 和 40V 至 100nV DC。它们将精密电源、实际电流源、6 位数字万用…