Time flies, blink of an eye in the past, over the beginning of the year eight teacher said to us back to school to help him do his project, now think about it, it is better to say that he wants to take advantage of this time to train us, because, from these days obviously, he gave us to do the analysis of the time has already finished these work.
This time the teacher from a city construction bureau of an online audit, assessment and application of the project online platform. The construction bureau is very strong, not only provides comfortable office conditions, but also provides a rich lunch. I really appreciate it. This project, because our teacher is engaged in. NET, so our project is mainly. NET to do. Because of the previous mainly Java learning, the. NET really understand not too much, so the first three days is almost a study.
Our project is to use asp.net the latest technology MVC3.0 to do, the following, according to my study these days, to sum up the mvc3.0:mvc3.0 mainly have model,view,controller three-layer structure, in the model is mainly the entity class and data cache container (own name, haha), sometimes in model also add some business processing logic. Even sometimes the model is layered three layers, view is mainly the display of the page and the layout of the page, and controller is mainly responsible for the page jump, generally do not do other work. A new view model Razor was added to the mvc3.0, which greatly reduced the programmer's Code volume. With a small amount of code to write more functions, there is a very important knowledge in this project is EntityFramework, Ado.net Entity Framework is the ado.net of Microsoft based on the object relationship (O/R Mapping) Solutions, early known as objectspace,,entityframework, are mainly divided into three ways to operate: Code-first,model--first,db-first,
1. These three ways, Code-first is mainly to write good entity classes, VS2010 can use the Code-first entityframework plug-ins automatically generate a database, but the disadvantage of this database is really bad control of the database, the later scalability is not good.
2.db-first, this approach is primarily to build the database, and then according to the database, add ado.net Entity Data Model, automatic generation of entity classes and data cache containers. There are also some data crud methods for some column operations.
3. The last one, Model-first is mainly to operate on the entity. edmx file, mainly in the graphical interface of the relationship between the entities to operate ... After designing the relationships between the entities, generate entity classes and databases based on this relationship
The main thing to do today a page of personal experience between the additions and deletions to check: Controller code:
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) {//dot? Click to add æ press the button ¥viewbag.editindex =-1;
list<workexperience> list = Expbll.select (personId);
Return View ("Index", list);
Public ActionResult edit (int workid) {//point?? Series-Press the button ¥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) {//DOT-clickDelete the button ¥expbll.delete (id) except Y.
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"); Code for View page: @model ienumerable<constructionmis.dll.entity.workexperience> <link HR ef= "@Url. Content (" ~/css/simple.css ")" rel= "stylesheet" type= "Text/css"/> <link "@Url. Content (" href= 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 () {$ (' #S
Tarttime '). DatePicker ();
$ (' #EndTime '). DatePicker ();
$ (' Table.grid tr:odd '). addclass (' odd '); });
$ (function) </script> <table class= "Grid" > <tr> <th colspan= "2" >
Ù for dysentery?
</th> <th> work ¤ for dysentery?
</th> <th> Professional service?
</th> <th> from the beginning of 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 ("compiled? Series-"," ", new {Id=inf. Id}) </td> <td> @Html. ActionLink ("delete") Except 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> Series-Detailed ê Love é</legend> Work ¤ for dysentery?: <input type= "text" id= "Company" value= "@m.company"/> duty?: <input Ty Pe= "text" id= "Duty" value= "@m.duty"/><br/> From the beginning of E?: <input type= "text" id= "StartTime" value
= "@m.starttime"/> to á<input type= "text" id= "Endtime" value= "@m.endtime"/><br/><br/> <input type= "Submit" value= "" style= "margin-left:100px"/> <input "reset" type=
E= "/> </fieldset>} </div>