濮阳杆衣贸易有限公司

主頁 > 知識庫 > MVC4制作網(wǎng)站教程第三章 修改用戶組操作3.3

MVC4制作網(wǎng)站教程第三章 修改用戶組操作3.3

熱門標簽:400電話唐山辦理 漯河外呼調(diào)研線路 電銷專用外呼線路 旅游地圖標注線路 地圖標注位置怎么弄圖 廣西房產(chǎn)智能外呼系統(tǒng)推薦 電銷外呼系統(tǒng)是違法的嗎 威力最大的電銷機器人 電話機器人鑰匙扣

一、用戶 
二、用戶組
 
2.1瀏覽用戶組 
2.2添加用戶組 
2.3修改用戶組 
首先打開【UserGroupController】,修改[Edit(int Id)] Action 

/// summary>
 /// 修改用戶組
 /// /summary>
 /// param name="Id">用戶組Id/param>
 /// returns>/returns>
 [AdminAuthorize]
 public ActionResult Edit(int Id)
 {
 userGroupRsy = new UserGroupRepository();
 var _userGroup = userGroupRsy.Find(Id);
 return View(_userGroup);
 }

右鍵添加強類型視圖,并修改視圖代碼(與添加用戶組類似)

@model Ninesky.Models.UserGroup

@{
 ViewBag.Title = "修改用戶組";
 Layout = "~/Views/Layout/_Manage.cshtml";
}
div class="left">
 div class="top">/div>
 左側(cè)列表
/div>
div class="split">/div>
div class="workspace">
 div class="inside">
 div class="notebar">
 img alt="" src="~/Skins/Default/Manage/Images/UserGroup.gif" />修改用戶組資料
 /div>
 @using (Html.BeginForm("Eidt","UserGroup"))
 {
 @Html.ValidationSummary(true)
 fieldset>
 legend>用戶組資料/legend>

 @Html.HiddenFor(model => model.UserGroupId)
 ul>
  li>
  div class="editor-label">
  @Html.LabelFor(model => model.Type)
  /div>
  div class="editor-field">
  @Html.DisplayTextFor(model => model.Type)
  /div>
  /li>
  li>
  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>
  /li>
  li>
  div class="editor-label">
  @Html.LabelFor(model => model.Description)
  /div>
  div class="editor-field">
  @Html.EditorFor(model => model.Description)
  @Html.ValidationMessageFor(model => model.Description)
  /div>
  /li>
  li>
  div class="editor-label">
  /div>
  div class="editor-field">
  input type="submit" value="保存" />
  /div>
  /li>
 /ul>
 /fieldset>
 }
 /div>
/div>
div class="clear">/div>
@section Scripts {
 @Scripts.Render("~/bundles/jqueryval")
}

修改處理Action[Eidt(UserGroup userGroup)] 

[HttpPost]
 [AdminAuthorize]
 public ActionResult Eidt(UserGroup userGroup)
 {
 userGroupRsy = new UserGroupRepository();
 var _userGroup = userGroupRsy.Find(userGroup.UserGroupId);
 if (_userGroup == null)
 {
 Error _e = new Error { Title = "用戶組不存在", Details = "修改用戶時發(fā)生錯誤,修改的用戶組不存在。", Cause = "該用戶組已被其他管理員刪除", Solution = Server.UrlEncode("li>返回a href='" + Url.Action("List", "UserGroup") + "'>用戶組列表/a>/li>") };
 return RedirectToAction("ManageError", "Prompt", _e);
 }
 _userGroup.Name = userGroup.Name;
 _userGroup.Description = userGroup.Description;
 if (userGroupRsy.Update(_userGroup))
 {
 Notice _n = new Notice { Title = "修改成功", Details = "成功修改了用戶組信息", DwellTime = 3, NavigationName = "用戶組列表", NavigationUrl = Url.Action("List", "UserGroup") };
 return RedirectToAction("ManageNotice", "Prompt", _n);
 }
 else
 {
 Error _e = new Error { Title = "更新數(shù)據(jù)失敗", Details = "修改用戶組信息時修改的信息未能保存到數(shù)據(jù)庫。", Cause = Server.UrlEncode("li>您并未更改用戶組信息。/li>li>數(shù)據(jù)庫未知錯誤。/li>"), Solution = Server.UrlEncode("li>返回a href='" + Url.Action("List", "UserGroup") + "'>用戶組列表/a>/li>li>重新a href='" + Url.Action("Edit", "UserGroup", new { id = userGroup.UserGroupId }) + "'>修改用戶組/a>/li>") };
 return RedirectToAction("ManageError", "Prompt", _e);
 }
 }

瀏覽器中打開看一下

點保存

代碼打包地址:http://xiazai.jb51.net/201608/yuanma/Ninesky(jb51.net).rar

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

您可能感興趣的文章:
  • ASP.NET MVC5網(wǎng)站開發(fā)管理列表、回復及刪除(十三)
  • ASP.NET MVC5網(wǎng)站開發(fā)咨詢管理的架構(gòu)(十一)
  • ASP.NET MVC5網(wǎng)站開發(fā)顯示文章列表(九)
  • ASP.NET MVC5網(wǎng)站開發(fā)添加文章(八)
  • ASP.NET MVC5網(wǎng)站開發(fā)文章管理架構(gòu)(七)
  • ASP.NET MVC5網(wǎng)站開發(fā)用戶修改資料和密碼(六)
  • ASP.NET MVC5網(wǎng)站開發(fā)用戶登錄、注銷(五)
  • ASP.NET MVC5網(wǎng)站開發(fā)用戶注冊(四)
  • ASP.NET MVC5 網(wǎng)站開發(fā)框架模型、數(shù)據(jù)存儲、業(yè)務邏輯(三)
  • ASP.NET MVC5網(wǎng)站開發(fā)概述(一)

標簽:湘西 湖北 無錫 試駕邀約 焦作 銅陵 欽州 綏化

巨人網(wǎng)絡通訊聲明:本文標題《MVC4制作網(wǎng)站教程第三章 修改用戶組操作3.3》,本文關鍵詞  MVC4,制作,網(wǎng)站,教程,第三章,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權(quán)與本站無關。
  • 相關文章
  • 下面列出與本文章《MVC4制作網(wǎng)站教程第三章 修改用戶組操作3.3》相關的同類信息!
  • 本頁收集關于MVC4制作網(wǎng)站教程第三章 修改用戶組操作3.3的相關信息資訊供網(wǎng)民參考!
  • 推薦文章
    尉犁县| 盐亭县| 宜阳县| 富民县| 且末县| 陵水| 遵义县| 茂名市| 新竹市| 大方县| 尚志市| 安西县| 襄城县| 五原县| 阳朔县| 安宁市| 广灵县| 漯河市| 喜德县| 大城县| 浦城县| 遂平县| 社会| 教育| 噶尔县| 阜康市| 阿鲁科尔沁旗| 望江县| 山东省| 德兴市| 永康市| 五原县| 北安市| 澎湖县| 江西省| 华阴市| 渭南市| 左权县| 调兵山市| 龙陵县| 定州市|