建設局項目總結(一)

來源:互聯網
上載者:User

         時間飛逝,轉眼間暑假就過去了、過完年初八老師說要我們回學校幫他做他所接的項目,現在想想,真不如說他想趁這個時間培養我們,因為,從這幾天明顯的感覺到,他在給我們做分析的時間早已經把這些工作做完了。

            這次做的是老師從某市建設局的一個網上審核,評估和申請項目的網上平台。這個建設局倒是挺給力,不僅提供了舒適的辦公條件,還提供了豐富的午餐。真是心裡萬分感激。這次的項目,由於我們老師是搞.NET,所以我們這次的項目主要是.NET來做。由於以前主要是以java的學習為主,對.NET真正瞭解的也不算太多,所以前三天幾乎就是一個學習。

            我們這次項目是採用ASP.NET的最新技術MVC3.0來做,下面,根據我這幾天的學習,來總結一下MVC3.0:mvc3.0主要有model,view,controller三層結構組成,在model中主要是有實體類和資料緩衝容器(自己起的名字,哈哈),有時在model中也添加一些業務處理邏輯。。甚至有時候還對model進行分層三層,view主要是頁面的顯示和頁面的布局,而controller主要是負責頁面的跳轉,一般不做其他工作。在mvc3.0添加了新的視圖模型Razor,這個模型大大的減小了程式員的代碼量。用少量的代碼可以寫出更多的功能,還有一個這次項目中很重要的知識點就是EntityFramework ,ADO.NET Entity Framework 是微軟以 ADO.NET 為基礎所發展出來的對象關係對應 (O/R Mapping) 解決方案,早期被稱為 ObjectSpace,,EntityFramework主要分三種種方式進行操作:code-First,model——first,db—first,

1.這三種方式,code-first主要是寫好實體類,vs2010可以利用code-first EntityFrameWork外掛程式自動產生出資料庫,但是這樣產生資料庫的缺點是實在是不好控制資料庫,對以後的可擴充性不好。

2.db—first,這種方式主要是先建好資料庫,然後根據資料庫,添加ADO.NET實體資料模型,自動產生實體類和資料緩衝容器。還有一些資料CRUD一些列操作的方法。

3.最後一個,model-first主要是對實體.edmx檔案進行操作,主要是在圖形化介面中對實體之間的關係進行操作。。。設計好實體之間的關係之後,根據這個關係,產生實體類和資料庫

今天主要實現的事一個頁面之間的個人工作經驗的增刪改查:controller中的代碼:

using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Mvc;using ConstructionMis.Dll.Bll;using ConstructionMis.Dll.Entity;namespace ConstructionMis.Web.Controllers{    public class WorkExpController : Controller    {        //        // GET: /WorkExp/        WorkExpBll expBll = new WorkExpBll();        public ActionResult insert(int personId)        {//點?擊÷添?加ó按恪?鈕¥            ViewBag.editIndex = -1;            List<WorkExperience> list = expBll.select(personId);            return View("Index",list);        }        public ActionResult edit(int workId) {//點?擊÷編括?輯-按恪?鈕¥            int pId = expBll.getPId(workId);            ViewBag.personId = pId;            List<WorkExperience> list = expBll.select(pId);            ViewBag.editIndex = list.FindIndex(t => t.Id == workId);            return View("Index",list);        }        public ActionResult delete(int id)        {//點?擊÷刪?除y按恪?鈕¥            expBll.delete(id);            List<WorkExperience> list = expBll.select(id);            return View("Index",list);        }        public ActionResult Index(int id) {            List<WorkExperience> list = expBll.select(id);            return View(list);        }        public ActionResult Save(WorkExperience exp) {            int id = exp.Id;            if (id > 0)            {                expBll.update(exp);            }            else {                expBll.insert(exp);            }            return View("index");        }    }}View頁面的代碼:@model IEnumerable<ConstructionMis.Dll.Entity.WorkExperience>               <link href="@Url.Content("~/css/simple.css")" rel="stylesheet" type="text/css" />    <link href="@Url.Content("~/css/cupertino/jquery-ui-1.8.12.css")" rel="stylesheet" type="text/css" />    <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>    <script src="@Url.Content("~/Scripts/jquery-ui-1.8.11.min.js")"  type="text/javascript"></script>    <script src="@Url.Content("~/Scripts/jquery.ui.datepicker-zh-CN.js")" type="text/javascript"></script>    <script type="text/javascript">        $(function () {            $('#StartTime').datepicker();            $('#EndTime').datepicker();            $('table.grid tr:odd').addClass('odd');        });   //$(function )    </script><table class="grid">    <tr>        <th colspan="2">            操ù作痢?        </th>        <th>            工¤作痢?單蹋?位?        </th>        <th>            職°務?        </th>        <th>          起e始?時骸?間?        </th>    </tr>    @{ int i = 0; string css = "even"; }    @foreach (var inf in Model)    {        if (i % 2 == 0) { css = "even"; }        else { css = "odd"; }        <tr class='@css'>            <td>                @Html.ActionLink(" 編括? 輯- ", "", new { id=inf.Id })            </td>            <td>                @Html.ActionLink(" 刪?  除y ", "Delete", new { id = inf.Id })            </td>            <td>                @inf.Company            </td>            <td>                @inf.Duty            </td>            <td>@inf.StartTime.ToString().Substring(0, @inf.StartTime.ToString().IndexOf(" "))-@inf.EndTime.ToString().Substring(0, @inf.EndTime.ToString().IndexOf(" "))            </td>        </tr>    }</table>@{    string display = "none";    ConstructionMis.Dll.Entity. WorkExperience m=new ConstructionMis.Dll.Entity.WorkExperience();    if (ViewBag.editIndex != null)     {        display ="block";         if(ViewBag.editIndex>=0)        {            int i = ViewBag.editIndex;            m= Model[i];        }      }    }    <div id="editorInfo" style="display:@display">           @using (Html.BeginForm("",""))           {            <fieldset style="width:450px">                <legend>編括?輯-詳ê情é</legend>                工¤作痢?單蹋?位?:<input type="text" id="Company" value="@m.Company" />                職°務?:<input type="text" id="Duty" value="@m.Duty"/><br />                起e始?時骸?間?:<input type="text" id="StartTime" value="@m.StartTime" />  至á   <input type="text" id="EndTime" value="@m.EndTime" /><br /><br />                <input type="submit" value="提?交?" style="margin-left:100px;" />                <input type="reset" value="取?消?" />            </fieldset>           }    </div>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.