如何在一个详细信息页面中仅对所有查看选项卡进行读取视图?

发布于 2025-01-20 04:43:29 字数 17590 浏览 0 评论 0原文

我对此是全新的,我有一个网站,其中有一个项目控制器和三个视图,我想将所有视图页面详细信息显示到一个详细信息页面中,因此当尝试单击&查看项目的详细信息,该详细信息链接应包括所有其他视图页面详细信息作为只读视图,现在我只能看到属于项目控制器的一页的详细信息。如何将这些视图表数据详细信息导入到项目控制器详细信息页面中。我是否还需要为这两个视图创建详细信息页面?

ProjectController代码

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using SNAPAIS.Models;
using SNAPAIS.Utils;

namespace SNAPAIS.Controllers
{
    public class ProjectsController : BaseController
    {
        private AISEntities db = new AISEntities();

        // GET: Projects
        public ActionResult Index(int id)
        {
            var projects = db.Projects.Where(p => p.Contract.Id == id).Include(x=> x.Contract).ToList();
            ViewBag.ContractId = id;
            return View(projects);
        }

        // GET: Projects/Details/5
        public ActionResult Details(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            Project project = db.Projects.Where(x=> x.Id==id).SingleOrDefault();
            if (project == null)
            {
                return HttpNotFound();
            }
            return View(project);
        }

        // GET: Projects/Create
        public ActionResult Create(int contractId)
        {
            Project project = new Project();
            project.Id = 0;
            project.ContractId = contractId;
            return View(project);
        }

        // POST: Projects/Create
        // To protect from overposting attacks, enable the specific properties you want to bind to, for 
        // more details see https://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Create([Bind(Include = "Id,ContractId,ProjectName,ProjectManager,MODNumber,POP,CurrentYearOfPOP,AwardAmount,FundingBaseYear,OY1,OY2,OY3,OY4,CustomerName,CustomerAddress,CustOfficerName,CustSpeciAddress,CORName,CORAddress,TPOCName,TPOCAddress,IsWDC,IsIDIQ,InvoiceInfo,InvoicePeriod,Schedule,InvoiceSubNote")] Project project)
        {
            if (ModelState.IsValid)
            {
                project.CreatedDate = LoginInfo.CurrentDate();
                project.CreatedBy = LoginInfo.CurrentUser();

                db.Projects.Add(project);
                db.SaveChanges();

                return RedirectToAction("Accounting", new { projectId = project.Id });
            }

            return View(project);
        }
        
        public ActionResult Accounting(int projectId)
        {
            Accounting accounting = new Accounting();
            accounting.Id = 0;
            accounting.ProjectId = projectId;
            
            return View(accounting);
        }

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Accounting([Bind(Include = "Id,ProjectId,NewCPProjectNo,ChargeLevelTimesheet,PLCRate,BillingRate")] Accounting accounting)
        {
            if (ModelState.IsValid)
            {
                accounting.CreatedBy = LoginInfo.CurrentUser();
                accounting.CreatedDate = LoginInfo.CurrentDate();

                Project project = db.Projects.Where(x => x.Id == accounting.ProjectId).Single();

                db.Accountings.Add(accounting);
                db.SaveChanges();

                return RedirectToAction("HR", new { projectId = project.Id });               
            }           
            return View(accounting);
        }

        public ActionResult HR(int projectId)
        {
            HR hR = new HR();
            hR.Id = 0;
            hR.ProjectId = projectId;
            return View(hR);
        }

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult HR([Bind(Include = "Id,ProjectId,EmployeeName,EmployeeType,Position,LabourCategory,DOB,Address,StartDate,Organization,CPProjectCode,CSHS,PayRate,AcualRate,DUNS,UniqueId,BillingRate,ReportingManager,TimesheetApprover,EmailAddress")] HR hR)
        {
            if (ModelState.IsValid)
            {
                hR.CreatedBy = LoginInfo.CurrentUser();
                hR.CreatedDate = LoginInfo.CurrentDate();

                Project project = db.Projects.Where(x => x.Id == hR.ProjectId).Single();

                db.HRs.Add(hR);
                db.SaveChanges();

                return RedirectToAction("Index", new { id = project.ContractId });
            }
            return View(hR);
        }

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

        // POST: Projects/Edit/5
        // To protect from overposting attacks, enable the specific properties you want to bind to, for 
        // more details see https://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Edit([Bind(Include = "Id,ContractId,ProjectName,ProjectManager,MODNumber,POP,CurrentYearOfPOP,AwardAmount,FundingBaseYear,OY1,OY2,OY3,OY4,CustomerName,CustomerAddress,CustOfficerName,CustSpeciAddress,CORName,CORAddress,TPOCName,TPOCAddress,IsWDC,IsIDIQ,InvoiceInfo,InvoicePeriod,Schedule,InvoiceSubNote,CreatedBy,CreatedDate")] Project project)
        {
            if (ModelState.IsValid)
            {
                db.Entry(project).Entity.ModifiedBy = LoginInfo.CurrentUser();
                db.Entry(project).Entity.ModifiedDate = LoginInfo.CurrentDate();

                db.Entry(project).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("AccountingEdit", new { projectId = project.Id});
            }            
            return View(project);
        }

        // GET: Accounting/Edit/5
        public ActionResult AccountingEdit(int? projectId)
        {
            if (projectId == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            Accounting accounting = db.Accountings.Where(x =>x.ProjectId == projectId).SingleOrDefault();
            if (accounting == null)
            {
                return HttpNotFound();
            }
            return View(accounting);
        }

        // POST: Accounting/Edit/5
        // To protect from overposting attacks, enable the specific properties you want to bind to, for 
        // more details see https://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult AccountingEdit([Bind(Include = "Id,ProjectId,NewCPProjectNo,ChargeLevelTimesheet,PLCRate,BillingRate,CreatedBy,CreatedDate")] Accounting accounting)
        {
            if (ModelState.IsValid)
            {
                db.Entry(accounting).Entity.ModifiedBy = LoginInfo.CurrentUser();
                db.Entry(accounting).Entity.ModifiedDate = LoginInfo.CurrentDate();

                db.Entry(accounting).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("HREdit", new { projectId = accounting.ProjectId });
            }
            return View(accounting);
        }

        // GET: HR/Edit/5
        public ActionResult HREdit(int? projectId)
        {
            if (projectId == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            HR hR = db.HRs.Where(x=> x.ProjectId== projectId).SingleOrDefault();
            if (hR == null)
            {
                return HttpNotFound();
            }
            return View(hR);
        }

        // POST: HR/Edit/5
        // To protect from overposting attacks, enable the specific properties you want to bind to, for 
        // more details see https://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult HREdit([Bind(Include = "Id,ProjectId,EmployeeName,EmployeeType,Position,LabourCategory,DOB,Address,StartDate,Organization,CPProjectCode,CSHS,PayRate,AcualRate,DUNS,UniqueId,BillingRate,ReportingManager,TimesheetApprover,EmailAddress,CreatedBy,CreatedDate")] HR hR)
        {
            if (ModelState.IsValid)
            {
                db.Entry(hR).Entity.ModifiedBy = LoginInfo.CurrentUser();
                db.Entry(hR).Entity.ModifiedDate = LoginInfo.CurrentDate();


                db.Entry(hR).State = EntityState.Modified;
                db.SaveChanges();
                Project project = db.Projects.Find(hR.ProjectId);

                return RedirectToAction("Index", new { id = project.ContractId });
            }
            return View(hR);
        }

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

        // POST: Projects/Delete/5
        [HttpPost, ActionName("Delete")]
        [ValidateAntiForgeryToken]
        public ActionResult DeleteConfirmed(int id)
        {
            Project project = db.Projects.Find(id);
            db.Projects.Remove(project);
            db.SaveChanges();
            return RedirectToAction("Index", new { id = project.ContractId });
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                db.Dispose();
            }
            base.Dispose(disposing);
        }
    }
}

详情页代码

@model SNAPAIS.Models.Project

@{
    ViewBag.Title = "Details";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Details</h2>

<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">Project details</h3>
    </div>

    <div class="panel-body">
        <dl class="dl-horizontal">
            <dt>
                @Html.DisplayNameFor(model => model.Contract.ContractName)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.Contract.ContractName)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.ProjectName)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.ProjectName)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.ProjectManager)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.ProjectManager)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.MODNumber)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.MODNumber)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.POP)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.POP)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.CurrentYearOfPOP)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.CurrentYearOfPOP)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.AwardAmount)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.AwardAmount)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.FundingBaseYear)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.FundingBaseYear)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.OY1)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.OY1)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.OY2)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.OY2)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.OY3)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.OY3)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.OY4)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.OY4)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.CustomerName)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.CustomerName)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.CustomerAddress)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.CustomerAddress)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.CustOfficerName)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.CustOfficerName)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.CustSpeciAddress)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.CustSpeciAddress)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.CORName)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.CORName)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.CORAddress)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.CORAddress)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.TPOCName)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.TPOCName)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.TPOCAddress)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.TPOCAddress)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.IsWDC)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.IsWDC)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.IsIDIQ)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.IsIDIQ)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.InvoiceInfo)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.InvoiceInfo)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.InvoicePeriod)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.InvoicePeriod)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.Schedule)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.Schedule)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.InvoiceSubNote)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.InvoiceSubNote)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.CreatedDate)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.CreatedDate)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.CreatedBy)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.CreatedBy)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.ModifiedDate)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.ModifiedDate)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.ModifiedBy)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.ModifiedBy)
            </dd>

        </dl>
    </div>

    <div class="panel-footer">
        <p>
            @Html.ActionLink("Edit", "Edit", new { id = Model.Id }) |
            @Html.ActionLink("Back to List", "Index")
        </p>
    </div>
</div>

I am brand new to this I have a website in which I have a Projectcontroller an three views in it and I want to show all of the view pages details into one detail page so when try to click & see detail of project that detail link should include all other view page details as read only view right now I only see details for one page which belongs to project controller. How do I import those views table data details into the project controller detail page. Do I need to create detail pages for those two views as well?

ProjectController code

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using SNAPAIS.Models;
using SNAPAIS.Utils;

namespace SNAPAIS.Controllers
{
    public class ProjectsController : BaseController
    {
        private AISEntities db = new AISEntities();

        // GET: Projects
        public ActionResult Index(int id)
        {
            var projects = db.Projects.Where(p => p.Contract.Id == id).Include(x=> x.Contract).ToList();
            ViewBag.ContractId = id;
            return View(projects);
        }

        // GET: Projects/Details/5
        public ActionResult Details(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            Project project = db.Projects.Where(x=> x.Id==id).SingleOrDefault();
            if (project == null)
            {
                return HttpNotFound();
            }
            return View(project);
        }

        // GET: Projects/Create
        public ActionResult Create(int contractId)
        {
            Project project = new Project();
            project.Id = 0;
            project.ContractId = contractId;
            return View(project);
        }

        // POST: Projects/Create
        // To protect from overposting attacks, enable the specific properties you want to bind to, for 
        // more details see https://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Create([Bind(Include = "Id,ContractId,ProjectName,ProjectManager,MODNumber,POP,CurrentYearOfPOP,AwardAmount,FundingBaseYear,OY1,OY2,OY3,OY4,CustomerName,CustomerAddress,CustOfficerName,CustSpeciAddress,CORName,CORAddress,TPOCName,TPOCAddress,IsWDC,IsIDIQ,InvoiceInfo,InvoicePeriod,Schedule,InvoiceSubNote")] Project project)
        {
            if (ModelState.IsValid)
            {
                project.CreatedDate = LoginInfo.CurrentDate();
                project.CreatedBy = LoginInfo.CurrentUser();

                db.Projects.Add(project);
                db.SaveChanges();

                return RedirectToAction("Accounting", new { projectId = project.Id });
            }

            return View(project);
        }
        
        public ActionResult Accounting(int projectId)
        {
            Accounting accounting = new Accounting();
            accounting.Id = 0;
            accounting.ProjectId = projectId;
            
            return View(accounting);
        }

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Accounting([Bind(Include = "Id,ProjectId,NewCPProjectNo,ChargeLevelTimesheet,PLCRate,BillingRate")] Accounting accounting)
        {
            if (ModelState.IsValid)
            {
                accounting.CreatedBy = LoginInfo.CurrentUser();
                accounting.CreatedDate = LoginInfo.CurrentDate();

                Project project = db.Projects.Where(x => x.Id == accounting.ProjectId).Single();

                db.Accountings.Add(accounting);
                db.SaveChanges();

                return RedirectToAction("HR", new { projectId = project.Id });               
            }           
            return View(accounting);
        }

        public ActionResult HR(int projectId)
        {
            HR hR = new HR();
            hR.Id = 0;
            hR.ProjectId = projectId;
            return View(hR);
        }

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult HR([Bind(Include = "Id,ProjectId,EmployeeName,EmployeeType,Position,LabourCategory,DOB,Address,StartDate,Organization,CPProjectCode,CSHS,PayRate,AcualRate,DUNS,UniqueId,BillingRate,ReportingManager,TimesheetApprover,EmailAddress")] HR hR)
        {
            if (ModelState.IsValid)
            {
                hR.CreatedBy = LoginInfo.CurrentUser();
                hR.CreatedDate = LoginInfo.CurrentDate();

                Project project = db.Projects.Where(x => x.Id == hR.ProjectId).Single();

                db.HRs.Add(hR);
                db.SaveChanges();

                return RedirectToAction("Index", new { id = project.ContractId });
            }
            return View(hR);
        }

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

        // POST: Projects/Edit/5
        // To protect from overposting attacks, enable the specific properties you want to bind to, for 
        // more details see https://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Edit([Bind(Include = "Id,ContractId,ProjectName,ProjectManager,MODNumber,POP,CurrentYearOfPOP,AwardAmount,FundingBaseYear,OY1,OY2,OY3,OY4,CustomerName,CustomerAddress,CustOfficerName,CustSpeciAddress,CORName,CORAddress,TPOCName,TPOCAddress,IsWDC,IsIDIQ,InvoiceInfo,InvoicePeriod,Schedule,InvoiceSubNote,CreatedBy,CreatedDate")] Project project)
        {
            if (ModelState.IsValid)
            {
                db.Entry(project).Entity.ModifiedBy = LoginInfo.CurrentUser();
                db.Entry(project).Entity.ModifiedDate = LoginInfo.CurrentDate();

                db.Entry(project).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("AccountingEdit", new { projectId = project.Id});
            }            
            return View(project);
        }

        // GET: Accounting/Edit/5
        public ActionResult AccountingEdit(int? projectId)
        {
            if (projectId == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            Accounting accounting = db.Accountings.Where(x =>x.ProjectId == projectId).SingleOrDefault();
            if (accounting == null)
            {
                return HttpNotFound();
            }
            return View(accounting);
        }

        // POST: Accounting/Edit/5
        // To protect from overposting attacks, enable the specific properties you want to bind to, for 
        // more details see https://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult AccountingEdit([Bind(Include = "Id,ProjectId,NewCPProjectNo,ChargeLevelTimesheet,PLCRate,BillingRate,CreatedBy,CreatedDate")] Accounting accounting)
        {
            if (ModelState.IsValid)
            {
                db.Entry(accounting).Entity.ModifiedBy = LoginInfo.CurrentUser();
                db.Entry(accounting).Entity.ModifiedDate = LoginInfo.CurrentDate();

                db.Entry(accounting).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("HREdit", new { projectId = accounting.ProjectId });
            }
            return View(accounting);
        }

        // GET: HR/Edit/5
        public ActionResult HREdit(int? projectId)
        {
            if (projectId == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            HR hR = db.HRs.Where(x=> x.ProjectId== projectId).SingleOrDefault();
            if (hR == null)
            {
                return HttpNotFound();
            }
            return View(hR);
        }

        // POST: HR/Edit/5
        // To protect from overposting attacks, enable the specific properties you want to bind to, for 
        // more details see https://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult HREdit([Bind(Include = "Id,ProjectId,EmployeeName,EmployeeType,Position,LabourCategory,DOB,Address,StartDate,Organization,CPProjectCode,CSHS,PayRate,AcualRate,DUNS,UniqueId,BillingRate,ReportingManager,TimesheetApprover,EmailAddress,CreatedBy,CreatedDate")] HR hR)
        {
            if (ModelState.IsValid)
            {
                db.Entry(hR).Entity.ModifiedBy = LoginInfo.CurrentUser();
                db.Entry(hR).Entity.ModifiedDate = LoginInfo.CurrentDate();


                db.Entry(hR).State = EntityState.Modified;
                db.SaveChanges();
                Project project = db.Projects.Find(hR.ProjectId);

                return RedirectToAction("Index", new { id = project.ContractId });
            }
            return View(hR);
        }

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

        // POST: Projects/Delete/5
        [HttpPost, ActionName("Delete")]
        [ValidateAntiForgeryToken]
        public ActionResult DeleteConfirmed(int id)
        {
            Project project = db.Projects.Find(id);
            db.Projects.Remove(project);
            db.SaveChanges();
            return RedirectToAction("Index", new { id = project.ContractId });
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                db.Dispose();
            }
            base.Dispose(disposing);
        }
    }
}

Detail page code

@model SNAPAIS.Models.Project

@{
    ViewBag.Title = "Details";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Details</h2>

<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">Project details</h3>
    </div>

    <div class="panel-body">
        <dl class="dl-horizontal">
            <dt>
                @Html.DisplayNameFor(model => model.Contract.ContractName)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.Contract.ContractName)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.ProjectName)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.ProjectName)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.ProjectManager)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.ProjectManager)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.MODNumber)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.MODNumber)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.POP)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.POP)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.CurrentYearOfPOP)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.CurrentYearOfPOP)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.AwardAmount)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.AwardAmount)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.FundingBaseYear)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.FundingBaseYear)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.OY1)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.OY1)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.OY2)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.OY2)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.OY3)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.OY3)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.OY4)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.OY4)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.CustomerName)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.CustomerName)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.CustomerAddress)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.CustomerAddress)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.CustOfficerName)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.CustOfficerName)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.CustSpeciAddress)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.CustSpeciAddress)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.CORName)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.CORName)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.CORAddress)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.CORAddress)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.TPOCName)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.TPOCName)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.TPOCAddress)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.TPOCAddress)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.IsWDC)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.IsWDC)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.IsIDIQ)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.IsIDIQ)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.InvoiceInfo)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.InvoiceInfo)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.InvoicePeriod)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.InvoicePeriod)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.Schedule)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.Schedule)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.InvoiceSubNote)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.InvoiceSubNote)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.CreatedDate)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.CreatedDate)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.CreatedBy)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.CreatedBy)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.ModifiedDate)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.ModifiedDate)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.ModifiedBy)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.ModifiedBy)
            </dd>

        </dl>
    </div>

    <div class="panel-footer">
        <p>
            @Html.ActionLink("Edit", "Edit", new { id = Model.Id }) |
            @Html.ActionLink("Back to List", "Index")
        </p>
    </div>
</div>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凉世弥音 2025-01-27 04:43:29

您可以创建另一个模型,其中包含每个现有模型作为属性。

public class AnotherModel
{
  public Accounting Accounting {get; set;}
  public Project Project {get; set;}
}

然后,您必须从数据源获取数据,并将它们放在另一个具有模型 @model SNAPAIS.Models.AnotherModel 的视图中。

You can create another model that contains every existing models as properties.

public class AnotherModel
{
  public Accounting Accounting {get; set;}
  public Project Project {get; set;}
}

Then you have to get data from your data sources and put them together in another View with model @model SNAPAIS.Models.AnotherModel.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文