zoukankan      html  css  js  c++  java
  • MVC系列博客之排球计分(七)具体实现

    前几篇已经讲了程序的大概实现,现在具体来实现

    打开Visual Studio2015,点击新建项目,命名VolleyBall

    点击确定

    然后添加一个CoachController和RefreeController,

    如下:

    添加两个模型类

    点击models,右键单击添加类,Score.cs和player

    代码如下:

    Players类:

     public class Players
        {
            public int ID { get; set; }
            [DisplayName("球员编号")]
            public string Name { get; set; }
            [DisplayName("球员姓名")]
            public string TeamName { get; set; }
            [DisplayName("队伍名称")]
            public string Status { get; set; }
            [DisplayName("球员定位")]



            public class pDBContext : DbContext
            {
                public DbSet<Players> player { get; set; }
            }
        }

    Score类:

    public class Score
        {

            public string ScorePlayer1 { get; set; }
            [DisplayName("中国队得分选手")]
            public int TotalScore1 { get; set; }
            [DisplayName("中国队总得分")]
            public string ScoreType1 { get; set; }
            [DisplayName("得分类型")]
            public string ScorePlayer2 { get; set; }
            [DisplayName("塞尔维亚队得分选手")]
            public int TotalScore2 { get; set; }
            [DisplayName("塞尔维亚队总得分")]
            public string ScoreType2 { get; set; }
            [DisplayName("得分类型")]


            public class gDBContext : DbContext
            {
                public DbSet<Score> Students { get; set; }
            }

        }

    CoachController的index视图界面代码:

    @model IEnumerable<VolleyBall.Models.Players>

    @{
        ViewBag.Title = "教练计分";
    }
    <style>

        div { 1000px;
              height:800px;
              margin:50px 20px;
             border:1px  red;
             background-color:#b6ff00;
            padding-left:100px;
            padding-top:80px;
        }
     
        .three {
            text-align:right;
        }
    </style>
    <html>
        <head>
    <title>
             排球计分
      </title>
        </head>
    <body>
        <div>
           
    <p>
        @Html.ActionLink("请开始编辑球员信息", "Create")
    </p>
    <table>
        <tr>
            <th>
                @Html.DisplayNameFor(model => model.ID)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Name)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.TeamName)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Status)
            </th>
            
            <th></th>
        </tr>

    @foreach (var item in Model) {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.TeamName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Status)
            </td>
        
            <td>
                @Html.ActionLink("编辑分数", "Edit", new { id=item.ID }) |
                @Html.ActionLink("分数详细", "Details", new { id=item.ID }) |
                @Html.ActionLink("删除记录", "Delete", new { id=item.ID })
            </td>
        </tr>
    }

    </table>
                 <p class="three">@Html.ActionLink("返回主界面","Index","Home")</p>
            
            </div>
        </body>
    </html>

    CoachController的增删改查视图界面代码:

    @model VolleyBall.Models.Players

    @{
        ViewBag.Title = "添加记录";
    }

    <style>

    .one { 700px;
              height:500px;
              margin:50px auto;
             border:1px solid red;
             background-color:#F1F1F1;
            padding-left:80px;
            padding-top:50px;
        }
    </style>
    <html>
        <head>
            <title></title>
        </head>
        <body>
    <div class="one">
    @using (Html.BeginForm()) {
        @Html.ValidationSummary(true)

        <fieldset>
            <legend>观众计分</legend>

            <div class="editor-label">
                @Html.LabelFor(model => model.ID)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.ID)
                @Html.ValidationMessageFor(model => model.ID)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.Name)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Name)
                @Html.ValidationMessageFor(model => model.Name)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.TeamName)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.TeamName)
                @Html.ValidationMessageFor(model => model.TeamName)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.Status)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Status)
                @Html.ValidationMessageFor(model => model.Status)
            </div>

          

            <p>
                <input type="submit" value="确定记录" />
            </p>
        </fieldset>
    }

    <div>
        @Html.ActionLink("Back to List", "Index")
    </div>

    @section Scripts {
        @Scripts.Render("~/bundles/jqueryval")
    }
        </div>
             </body>
        </html>
    。。。。。。。

    代码类似,省略了

    至此,程序基本完成。

  • 相关阅读:
    Java 单链表的倒置
    Android查询:模拟键盘鼠标事件(adb shell 实现)
    安卓 发送短信两种方式
    java tcp socket实例
    Java中读取某个目录下的所有文件和文件夹
    Android剖析和运行机制
    linux下搭建android NDK开发环境
    把log存起来
    判断Android系统net和wap接入点的开发实例
    android 4.0.4系统下实现apk的静默安装和启动
  • 原文地址:https://www.cnblogs.com/shiyufan/p/7073823.html
Copyright © 2011-2022 走看看